瀏覽代碼

- parsing of Content-Purpose and Content-Action removed
- parsing of Accept-Disposition added.

Jan Janak 22 年之前
父節點
當前提交
6a2b0decb0
共有 8 個文件被更改,包括 166 次插入87 次删除
  1. 52 11
      modules/tm/sip_msg.c
  2. 39 2
      parser/case_acce.h
  3. 2 41
      parser/case_cont.h
  4. 59 13
      parser/hf.c
  5. 3 4
      parser/hf.h
  6. 5 4
      parser/keys.h
  7. 5 10
      parser/msg_parser.c
  8. 1 2
      parser/msg_parser.h

+ 52 - 11
modules/tm/sip_msg.c

@@ -272,9 +272,16 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
 		len += ROUND4(sizeof( struct hdr_field));
 		switch (hdr->type)
 		{
-			case HDR_CSEQ:
-				len+=ROUND4(sizeof(struct cseq_body));
+			case HDR_VIA:
+				for (via=(struct via_body*)hdr->parsed;via;via=via->next)
+				{
+					len+=ROUND4(sizeof(struct via_body));
+					/*via param*/
+					for(prm=via->param_lst;prm;prm=prm->next)
+						len+=ROUND4(sizeof(struct via_param ));
+				}
 				break;
+
 		        case HDR_TO:
 		        case HDR_FROM:
 				     /* From header might be unparsed */
@@ -286,16 +293,12 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
 						len+=ROUND4(sizeof(struct to_param ));
 				}
 				break;				
-			case HDR_VIA:
-				for (via=(struct via_body*)hdr->parsed;via;via=via->next)
-				{
-					len+=ROUND4(sizeof(struct via_body));
-					/*via param*/
-					for(prm=via->param_lst;prm;prm=prm->next)
-						len+=ROUND4(sizeof(struct via_param ));
-				}
+
+			case HDR_CSEQ:
+				len+=ROUND4(sizeof(struct cseq_body));
 				break;
 
+
 		        case HDR_AUTHORIZATION:
 		        case HDR_PROXYAUTH:
 				if (hdr->parsed) {
@@ -310,9 +313,20 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
 			case HDR_RECORDROUTE:
 			case HDR_CONTENTTYPE:
 			case HDR_CONTENTLENGTH:
+		        case HDR_EXPIRES:
+		        case HDR_SUPPORTED:
 			case HDR_PROXYREQUIRE:
 			case HDR_UNSUPPORTED:
 			case HDR_ALLOW:
+		        case HDR_EVENT:
+		        case HDR_ACCEPT:
+		        case HDR_ACCEPTLANGUAGE:
+		        case HDR_ORGANIZATION:
+		        case HDR_PRIORITY:
+		        case HDR_SUBJECT:
+		        case HDR_USERAGENT:
+		        case HDR_ACCEPTDISPOSITION:
+		        case HDR_CONTENTDISPOSITION:
 				/* we ignore them for now even if they have something parsed*/
 				break;
 
@@ -573,8 +587,35 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
 				new_msg->unsupported = new_hdr;
 				break;
 			case HDR_ALLOW :
-				new_msg->unsupported = new_hdr;	
+				new_msg->allow = new_hdr;	
+				break;
+		        case HDR_EVENT:
+				new_msg->event = new_hdr;
+				break;
+		        case HDR_ACCEPT:
+				new_msg->accept = new_hdr;
+				break;
+		        case HDR_ACCEPTLANGUAGE:
+				new_msg->accept_language = new_hdr;
+				break;
+		        case HDR_ORGANIZATION:
+				new_msg->organization = new_hdr;
 				break;
+		        case HDR_PRIORITY:
+			        new_msg->priority = new_hdr;
+			        break;
+		        case HDR_SUBJECT:
+			        new_msg->subject = new_hdr;
+			        break;
+		        case HDR_USERAGENT:
+			        new_msg->user_agent = new_hdr;
+			        break;
+		        case HDR_ACCEPTDISPOSITION:
+			        new_msg->accept_disposition = new_hdr;
+			        break;
+		        case HDR_CONTENTDISPOSITION:
+		 	        new_msg->content_disposition = new_hdr;
+			        break;
 		}/*switch*/
 
 		if ( last_hdr )

+ 39 - 2
parser/case_acce.h

@@ -55,20 +55,57 @@
 	}
 
 
-#define ptl_CASE                   \
+#define on_CASE                                            \
+        if (LOWER_BYTE(*p) == 'o') {                       \
+                p++;                                       \
+                if (LOWER_BYTE(*p) == 'n') {               \
+                        hdr->type = HDR_ACCEPTDISPOSITION; \
+                        p++;                               \
+                        goto dc_end;                       \
+                }                                          \
+        }
+
+
+#define siti_CASE                  \
+        switch(LOWER_DWORD(val)) { \
+        case _siti_:               \
+                p += 4;            \
+                val = READ(p);     \
+                on_CASE;           \
+                goto other;        \
+        }
+
+
+#define ispo_CASE                  \
+        switch(LOWER_DWORD(val)) { \
+        case _ispo_:               \
+                p += 4;            \
+                val = READ(p);     \
+                siti_CASE;         \
+                goto other;        \
+        }
+
+
+#define ptld_CASE                  \
         switch(LOWER_DWORD(val)) { \
         case _pt_l_:               \
 		p += 4;            \
 		val = READ(p);     \
 		angu_CASE;         \
 		goto other;        \
+                                   \
+        case _pt_d_:               \
+                p += 4;            \
+                val = READ(p);     \
+                ispo_CASE;         \
+                goto other;        \
 	}
 
 
 #define acce_CASE                           \
     p += 4;                                 \
     val = READ(p);                          \
-    ptl_CASE;                               \
+    ptld_CASE;                              \
                                             \
     if (LOWER_BYTE(*p) == 'p') {            \
             p++;                            \

+ 2 - 41
parser/case_cont.h

@@ -1,8 +1,8 @@
 /* 
  * $Id$ 
  *
- * Contact, Content-Type, Content-Length, Content-Purpose,
- * Content-Action, Content-Disposition  Header Field Name Parsing Macros
+ * Contact, Content-Type, Content-Length, Content-Disposition
+ * Header Field Name Parsing Macros
  *
  * Copyright (C) 2001-2003 Fhg Fokus
  *
@@ -57,33 +57,6 @@
         }
 
 
-#define PURP_CASE                               \
-        switch(LOWER_DWORD(val)) {              \
-        case _ose1_:                            \
-	        hdr->type = HDR_CONTENTPURPOSE; \
-	        hdr->name.len = 15;             \
-	        return (p + 4);                 \
-                                                \
-        case _ose2_:                            \
-                hdr->type = HDR_CONTENTPURPOSE; \
-                p += 4;                         \
-	        goto dc_end;                    \
-        }
-
-
-#define ACTION_CASE                                \
-    p += 4;                                        \
-    if (LOWER_BYTE(*p) == 'o') {                   \
-            p++;                                   \
-            if (LOWER_BYTE(*p) == 'n') {           \
-                    hdr->type = HDR_CONTENTACTION; \
-                    p++;                           \
-                    goto dc_end;                   \
-            }                                      \
-    }                                              \
-    goto other;
-
-
 #define ion_CASE                                    \
         switch(LOWER_DWORD(val)) {                  \
         case _ion1_:                                \
@@ -121,18 +94,6 @@
                 p += 4;                      \
                 goto dc_end;                 \
                                              \
-        case _purp_:                         \
-		p += 4;                      \
-		val = READ(p);               \
-		PURP_CASE;                   \
-		goto other;                  \
-                                             \
-        case _acti_:                         \
-                p += 4;                      \
-                val = READ(p);               \
-                ACTION_CASE;                 \
-                goto other;                  \
-                                             \
         case _disp_:                         \
                 p += 4;                      \
 		val = READ(p);               \

+ 59 - 13
parser/hf.c

@@ -63,42 +63,88 @@ void clean_hdr_field(struct hdr_field* hf)
 			free_to(hf->parsed);
 			break;
 
+		case HDR_FROM:
+			free_to(hf->parsed);
+			break;
+
 		case HDR_CSEQ:
 			free_cseq(hf->parsed);
 			break;
 
+		case HDR_CALLID:
+			break;
+
+		case HDR_CONTACT:
+			free_contact((contact_body_t**)(&(hf->parsed)));
+			break;
+
+		case HDR_MAXFORWARDS:
+			break;
+
+		case HDR_ROUTE:
+			free_rr((rr_t**)(&hf->parsed));
+			break;
+
+		case HDR_RECORDROUTE:
+			free_rr((rr_t**)(&hf->parsed));
+			break;
+
+		case HDR_CONTENTTYPE:
+			break;
+
+		case HDR_CONTENTLENGTH:
+			break;
+
 		case HDR_AUTHORIZATION:
+			break;
+
+		case HDR_EXPIRES:
+			free_expires((exp_body_t**)(&(hf->parsed)));
+			break;
+
 		case HDR_PROXYAUTH:
 			free_credentials((auth_body_t**)(&(hf->parsed)));
 			break;
 
-		case HDR_FROM:
-			free_to(hf->parsed);
+		case HDR_SUPPORTED:
+			break;
+
+		case HDR_PROXYREQUIRE:
+			break;
+
+		case HDR_UNSUPPORTED:
+			break;
+
+		case HDR_ALLOW:
 			break;
 
 		case HDR_EVENT:
 			free_event((event_t**)(&(hf->parsed)));
 			break;
 
-		case HDR_EXPIRES:
-			free_expires((exp_body_t**)(&(hf->parsed)));
+		case HDR_ACCEPT:
+			pkg_free(hf->parsed);
 			break;
 
-		case HDR_CONTACT:
-			free_contact((contact_body_t**)(&(hf->parsed)));
+		case HDR_ACCEPTLANGUAGE:
+			break;
+			
+		case HDR_ORGANIZATION:
+			break;
+			
+		case HDR_PRIORITY:
 			break;
 
-		case HDR_ROUTE:
-		case HDR_RECORDROUTE:
-			free_rr((rr_t**)(&hf->parsed));
+		case HDR_SUBJECT:
 			break;
 
-		case HDR_CONTENTLENGTH:
-		case HDR_CONTENTTYPE:
+		case HDR_USERAGENT:
 			break;
 
-		case HDR_ACCEPT:
-			pkg_free(hf->parsed);
+		case HDR_ACCEPTDISPOSITION:
+			break;
+
+		case HDR_CONTENTDISPOSITION:
 			break;
 
 		default:

+ 3 - 4
parser/hf.h

@@ -69,10 +69,9 @@
 #define HDR_PRIORITY           (1 << 23)  /* Priority header field */
 #define HDR_SUBJECT            (1 << 24)  /* Subject header field */
 #define HDR_USERAGENT          (1 << 25)  /* User-Agent header field */
-#define HDR_CONTENTPURPOSE     (1 << 26)  /* Content-Purpose header field */
-#define HDR_CONTENTACTION      (1 << 27)  /* Content-Action header field */
-#define HDR_CONTENTDISPOSITION (1 << 28)  /* Content-Disposition header field */
-#define HDR_OTHER              (1 << 29)  /* Some other header field */
+#define HDR_ACCEPTDISPOSITION  (1 << 26)  /* Accept-Disposition header field */
+#define HDR_CONTENTDISPOSITION (1 << 27)  /* Content-Disposition header field */
+#define HDR_OTHER              (1 << 28)  /* Some other header field */
 
 
 /* 

+ 5 - 4
parser/keys.h

@@ -29,6 +29,7 @@
  * History:
  * --------
  * 2003-05-01 _acce_ macro added (janakj)
+ * 2003-05-01 Macros for Accept-Disposition added (janakj)
  */
 
 #ifndef KEYS_H
@@ -105,13 +106,13 @@
 #define _ect1_ 0x3a746365   /* "ect:" */
 #define _user_ 0x72657375   /* "user" */
 #define __age_ 0x6567612d   /* "-age" */
-#define _purp_ 0x70727570   /* "purp" */
-#define _ose2_ 0x2065736f   /* "ose " */
-#define _ose1_ 0x3a65736f   /* "ose:" */
-#define _acti_ 0x69746361   /* "acti" */
 #define _disp_ 0x70736964   /* "disp" */
 #define _osit_ 0x7469736f   /* "osit" */
 #define _ion2_ 0x206e6f69   /* "ion " */
 #define _ion1_ 0x3a6e6f69   /* "ion:" */
 
+#define _pt_d_ 0x64617470   /* "pt-d" */
+#define _ispo_ 0x6f707369   /* "ispo" */
+#define _siti_ 0x69746973   /* "siti" */
+
 #endif /* KEYS_H */

+ 5 - 10
parser/msg_parser.c

@@ -200,9 +200,8 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 	        case HDR_PRIORITY:
 	        case HDR_SUBJECT:
 	        case HDR_USERAGENT:
-	        case HDR_CONTENTPURPOSE:
-	        case HDR_CONTENTACTION:
 	        case HDR_CONTENTDISPOSITION:
+	        case HDR_ACCEPTDISPOSITION:
 		case HDR_OTHER:
 			/* just skip over it */
 			hdr->body.s=tmp;
@@ -390,18 +389,14 @@ int parse_headers(struct sip_msg* msg, int flags, int next)
 				if (msg->user_agent==0) msg->user_agent = hf;
 				msg->parsed_flag|=HDR_USERAGENT;
 				break;
-		        case HDR_CONTENTPURPOSE:
-				if (msg->content_purpose==0) msg->content_purpose = hf;
-				msg->parsed_flag|=HDR_CONTENTPURPOSE;
-				break;
-		        case HDR_CONTENTACTION:
-				if (msg->content_action==0) msg->content_action = hf;
-				msg->parsed_flag|=HDR_CONTENTACTION;
-				break;
 		        case HDR_CONTENTDISPOSITION:
 				if (msg->content_disposition==0) msg->content_disposition = hf;
 				msg->parsed_flag|=HDR_CONTENTDISPOSITION;
 				break;
+		        case HDR_ACCEPTDISPOSITION:
+				if (msg->accept_disposition==0) msg->accept_disposition = hf;
+				msg->parsed_flag|=HDR_ACCEPTDISPOSITION;
+				break;
 			case HDR_VIA:
 				msg->parsed_flag|=HDR_VIA;
 				DBG("parse_headers: Via found, flags=%d\n", flags);

+ 1 - 2
parser/msg_parser.h

@@ -184,9 +184,8 @@ struct sip_msg {
 	struct hdr_field* priority;
 	struct hdr_field* subject;
 	struct hdr_field* user_agent;
-	struct hdr_field* content_purpose;
-	struct hdr_field* content_action;
 	struct hdr_field* content_disposition;
+	struct hdr_field* accept_disposition;
 
 	char* eoh;        /* pointer to the end of header (if found) or null */
 	char* unparsed;   /* here we stopped parsing*/