diff --git a/mms-dump/mms-dump.c b/mms-dump/mms-dump.c index 5fe9a43..dd85da6 100644 --- a/mms-dump/mms-dump.c +++ b/mms-dump/mms-dump.c @@ -847,7 +847,7 @@ mms_part_decode_headers( static gboolean -mms_decode_attachments( +mms_decode_multipart( struct wsp_header_iter* iter, unsigned int flags) { @@ -890,6 +890,37 @@ mms_decode_attachments( return FALSE; } +static +gboolean +mms_decode_attachment( + struct wsp_header_iter* iter, + unsigned int flags) +{ + const unsigned char* pdu = iter->pdu + iter->pos + 1; + unsigned int len = iter->max - iter->pos - 1; + unsigned int consumed, parlen; + const void *type = NULL; + if (wsp_decode_content_type(pdu, len, &type, &consumed, &parlen)) { + unsigned int total = consumed + parlen; + unsigned int off = iter->pos + 1 + total; + len -= total; + printf("Attachment:\n"); + if (flags & MMS_DUMP_FLAG_VERBOSE) { + printf("Offset: %u (0x%x)\n", off, off); + printf("Length: %u (0x%x)\n", len, len); + } else { + printf("Offset: %u\n", off); + printf("Length: %u\n", len); + } + printf(" Content-Type: %s", (char*)type); + mms_value_decode_wsp_params(pdu + consumed, parlen); + mms_value_verbose_dump(iter->pdu + iter->pos, total+1, flags); + printf("\n"); + return TRUE; + } + return FALSE; +} + static int mms_decode_data( @@ -926,13 +957,20 @@ mms_decode_data( WSP_HEADER_ITER_FLAG_DETECT_MMS_MULTIPART); if (mms_message_decode_headers(&iter, " ", flags) && (wsp_header_iter_at_end(&iter) || - (wsp_header_iter_is_multipart(&iter) && - mms_decode_attachments(&iter, flags) && - wsp_header_iter_at_end(&iter)))) { - return RET_OK; - } else { - printf("Decoding FAILED\n"); + wsp_header_iter_is_content_type(&iter))) { + + if (wsp_header_iter_is_multipart(&iter)) { + if (mms_decode_multipart(&iter, flags) && + wsp_header_iter_at_end(&iter)) { + return RET_OK; + } + } else { + if (mms_decode_attachment(&iter, flags)) { + return RET_OK; + } + } } + printf("Decoding FAILED\n"); return RET_ERR_DECODE; }