Browse Source

Add support for Server header field, since it is necessary in one place
(mediaproxy module) already and will also be used in another new module.

Submitted by: Valentin Nechaev <[email protected]>

Maxim Sobolev 21 years ago
parent
commit
fe70e4fbea
7 changed files with 63 additions and 4 deletions
  1. 45 0
      parser/case_serv.h
  2. 5 2
      parser/hf.c
  3. 2 1
      parser/hf.h
  4. 2 0
      parser/keys.h
  5. 5 0
      parser/msg_parser.c
  6. 1 0
      parser/msg_parser.h
  7. 3 1
      parser/parse_hname2.c

+ 45 - 0
parser/case_serv.h

@@ -0,0 +1,45 @@
+/*
+ * $Id$
+ *
+ * Subject Header Field Name Parsing Macros
+ *
+ * Copyright (C) 2001-2003 Fhg Fokus
+ *
+ * This file is part of ser, a free SIP server.
+ *
+ * ser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * For a license to use the ser software under conditions
+ * other than those described here, or to purchase support for this
+ * software, please contact iptel.org by e-mail at the following addresses:
+ *    [email protected]
+ *
+ * ser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#ifndef CASE_SERV_H
+#define CASE_SERV_H
+
+
+#define serv_CASE                   \
+    p += 4;                         \
+    if (LOWER_BYTE(*p) == 'e' && LOWER_BYTE(p[1]) == 'r') {   \
+            hdr->type = HDR_SERVER; \
+            p+= 2;                  \
+	    goto dc_end;            \
+    }                               \
+    goto other;
+
+
+#endif /* CASE_SERV_H */

+ 5 - 2
parser/hf.c

@@ -130,10 +130,10 @@ void clean_hdr_field(struct hdr_field* hf)
 
 		case HDR_ACCEPTLANGUAGE:
 			break;
-			
+
 		case HDR_ORGANIZATION:
 			break;
-			
+
 		case HDR_PRIORITY:
 			break;
 
@@ -158,6 +158,9 @@ void clean_hdr_field(struct hdr_field* hf)
 			free_to(hf->parsed);
 			break;
 
+		case HDR_SERVER:
+			break;
+
 		default:
 			LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n",
 			    hf->type);

+ 2 - 1
parser/hf.h

@@ -73,7 +73,8 @@
 #define HDR_CONTENTDISPOSITION (1 << 27)  /* Content-Disposition hdr field */
 #define HDR_DIVERSION          (1 << 28)  /* Diversion header field */
 #define HDR_RPID               (1 << 29)  /* Remote-Party-ID header field */
-#define HDR_OTHER              (1 << 30)  /* Some other header field */
+#define HDR_SERVER             (1 << 30)  /* Server header field */
+#define HDR_OTHER              (1 << 31)  /* Some other header field */
 
 
 /* returns true if the header links allocated memory on parse field */

+ 2 - 0
parser/keys.h

@@ -116,6 +116,8 @@
 #define _ispo_ 0x6f707369   /* "ispo" */
 #define _siti_ 0x69746973   /* "siti" */
 
+#define _serv_ 0x76726573   /* "serv" */
+
 #define _dive_ 0x65766964   /* "dive" */
 #define _rsio_ 0x6f697372   /* "rsio" */
 

+ 5 - 0
parser/msg_parser.c

@@ -204,6 +204,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 	        case HDR_ACCEPTDISPOSITION:
 	        case HDR_DIVERSION:
 	        case HDR_RPID:
+	        case HDR_SERVER:
 		case HDR_OTHER:
 			/* just skip over it */
 			hdr->body.s=tmp;
@@ -407,6 +408,10 @@ int parse_headers(struct sip_msg* msg, int flags, int next)
 				if (msg->rpid==0) msg->rpid = hf;
 				msg->parsed_flag|=HDR_RPID;
 				break;
+		        case HDR_SERVER:
+				if (msg->server==0) msg->server = hf;
+				msg->parsed_flag|=HDR_SERVER;
+				break;
 			case HDR_VIA:
 				msg->parsed_flag|=HDR_VIA;
 				DBG("parse_headers: Via found, flags=%d\n", flags);

+ 1 - 0
parser/msg_parser.h

@@ -193,6 +193,7 @@ struct sip_msg {
 	struct hdr_field* accept_disposition;
 	struct hdr_field* diversion;
 	struct hdr_field* rpid;
+	struct hdr_field* server;
 
 	char* eoh;        /* pointer to the end of header (if found) or null */
 	char* unparsed;   /* here we stopped parsing*/

+ 3 - 1
parser/parse_hname2.c

@@ -84,6 +84,7 @@ static inline char* skip_ws(char* p, unsigned int size)
 #include "case_supp.h"     /* Supported */
 #include "case_dive.h"     /* Diversion */
 #include "case_remo.h"     /* Remote-Party-ID */
+#include "case_serv.h"     /* Server */
 
 
 #define READ(val) \
@@ -114,7 +115,8 @@ static inline char* skip_ws(char* p, unsigned int size)
         case _subj_: subj_CASE; \
         case _user_: user_CASE; \
         case _dive_: dive_CASE; \
-        case _remo_: remo_CASE;
+        case _remo_: remo_CASE; \
+        case _serv_: serv_CASE;
 
 
 #define PARSE_COMPACT(id)          \