Ethereal-dev: [Ethereal-dev] Patch for packet-mulitpart to allow short names

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Ruud Linders <moztest@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 19 Jan 2005 16:38:11 +0100

Hi,

Cleaning up my private ethereal tree patches.

For some SIP-T decoding this patch is needed to allow also decoding
when short names are used in the multipart header.

Would be nice if this could be included.

Regards,
	Ruud Linders

--- packet-multipart.c.ORIG	Tue Dec 14 20:52:56 2004
+++ packet-multipart.c	Fri Dec 17 20:17:04 2004
@@ -89,13 +89,18 @@
  * the structure from SIP dissector, all the content- is also from SIP */
 
 
-static const char *multipart_headers[] = {
-	"Unknown-header",		/* Pad so that the real headers start at index 1 */
-	"Content-Disposition",
-	"Content-Encoding",
-	"Content-Language",
-	"Content-Length",
-	"Content-Type",
+typedef struct {
+        char *name;
+        char *compact_name;
+} multipart_header_t;
+
+static const multipart_header_t multipart_headers[] = {
+	{ "Unknown-header", NULL },		/* Pad so that the real headers start at index 1 */
+	{ "Content-Disposition", NULL },
+	{ "Content-Encoding", "e" },
+	{ "Content-Language", NULL },
+	{ "Content-Length", "l" },
+	{ "Content-Type", "c" },
 };
 
 #define POS_CONTENT_DISPOSITION		1
@@ -777,10 +782,14 @@
 	guint i;
 
 	for (i = 1; i < array_length(multipart_headers); i++) {
-		if (len == strlen(multipart_headers[i]) &&
-			strncasecmp(header_str, multipart_headers[i], len) == 0) {
+		if (len == strlen(multipart_headers[i].name) &&
+			strncasecmp(header_str, multipart_headers[i].name, len) == 0)
 			return i;
-		}
+		if ( multipart_headers[i].compact_name != NULL &&
+                        len == strlen(multipart_headers[i].compact_name) &&
+			strncasecmp(header_str, multipart_headers[i].compact_name, len) == 0)
+			return i;
+		
 	}
 
 	return -1;