Browse Source

- added parsing of Min-SE (related to Session-Expires)
- added msg->session_expires, msg->min_se fields

Tomas Mandys 19 years ago
parent
commit
8a4f3a740b
8 changed files with 125 additions and 31 deletions
  1. 30 6
      modules/tm/sip_msg.c
  2. 53 0
      parser/case_min.h
  3. 1 0
      parser/hf.c
  4. 9 7
      parser/hf.h
  5. 3 1
      parser/keys.h
  6. 9 1
      parser/msg_parser.c
  7. 18 16
      parser/msg_parser.h
  8. 2 0
      parser/parse_hname2.c

+ 30 - 6
modules/tm/sip_msg.c

@@ -155,7 +155,7 @@ inline struct via_body* via_body_cloner( char* new_buf,
 					case PARAM_ALIAS:
 							new_via->alias = new_vp;
 							break;
-							
+
 #ifdef USE_COMP
 					case PARAM_COMP:
 							new_via->comp = new_vp;
@@ -318,7 +318,7 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
 		case HDR_VIA2_T:
 		case HDR_EOH_T:
 			break;
-			
+
 		case HDR_VIA_T:
 			for (via=(struct via_body*)hdr->parsed;via;via=via->next) {
 				len+=ROUND4(sizeof(struct via_body));
@@ -327,7 +327,7 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
 					len+=ROUND4(sizeof(struct via_param ));
 			}
 			break;
-			
+
 		case HDR_TO_T:
 		case HDR_FROM_T:
 			     /* From header might be unparsed */
@@ -343,7 +343,7 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
 		case HDR_CSEQ_T:
 			len+=ROUND4(sizeof(struct cseq_body));
 			break;
-			
+
 
 		case HDR_AUTHORIZATION_T:
 		case HDR_PROXYAUTH_T:
@@ -377,7 +377,15 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
 		case HDR_RPID_T:
 		case HDR_REFER_TO_T:
 		case HDR_SIPIFMATCH_T:
-			     /* we ignore them for now even if they have something parsed*/
+		case HDR_SESSIONEXPIRES_T:
+		case HDR_MIN_SE_T:
+		case HDR_ACCEPTCONTACT_T:
+		case HDR_ALLOWEVENTS_T:
+		case HDR_CONTENTENCODING_T:
+		case HDR_REFERREDBY_T:
+		case HDR_REJECTCONTACT_T:
+		case HDR_REQUESTDISPOSITION_T:
+/* we ignore them for now even if they have something parsed*/
 			break;
 		}/*switch*/
 	}/*for all headers*/
@@ -509,6 +517,12 @@ do { \
 		case HDR_OTHER_T:
 		case HDR_VIA2_T:
 		case HDR_EOH_T:
+		case HDR_ACCEPTCONTACT_T:
+		case HDR_ALLOWEVENTS_T:
+		case HDR_CONTENTENCODING_T:
+		case HDR_REFERREDBY_T:
+		case HDR_REJECTCONTACT_T:
+		case HDR_REQUESTDISPOSITION_T:
 			break;
 
 		case HDR_VIA_T:
@@ -561,7 +575,7 @@ do { \
 			((struct to_body*)new_hdr->parsed)->body.s =
 				translate_pointer( new_msg->buf , org_msg->buf ,
 						   ((struct to_body*)hdr->parsed)->body.s );
-			((struct to_body*)new_hdr->parsed)->display.s = 
+			((struct to_body*)new_hdr->parsed)->display.s =
 				translate_pointer( new_msg->buf, org_msg->buf,
 						   ((struct to_body*)hdr->parsed)->display.s);
 			((struct to_body*)new_hdr->parsed)->uri.s =
@@ -735,6 +749,16 @@ do { \
 				new_msg->refer_to = new_hdr;
 			}
 			break;
+		case HDR_SESSIONEXPIRES_T:
+			if (!HOOK_SET(session_expires)) {
+				new_msg->session_expires = new_hdr;
+			}
+			break;
+		case HDR_MIN_SE_T:
+			if (!HOOK_SET(min_se)) {
+				new_msg->min_se = new_hdr;
+			}
+			break;
 		case HDR_SIPIFMATCH_T:
 			if (!HOOK_SET(sipifmatch)) {
 				new_msg->sipifmatch = new_hdr;

+ 53 - 0
parser/case_min.h

@@ -0,0 +1,53 @@
+/*
+ * $Id$
+ *
+ * Min-SE 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_MIN_H
+#define CASE_MIN_H
+
+
+#define min_se_CASE                  \
+        if (LOWER_BYTE(*p) == 's') {                       \
+                p++;                                       \
+                if (LOWER_BYTE(*p) == 'e') {               \
+                        hdr->type = HDR_MIN_SE_T;          \
+                        p++;                               \
+                        goto dc_end;                       \
+                }                                          \
+        }
+
+
+#define min_CASE       \
+     p += 4;           \
+     val = READ(p);    \
+     min_se_CASE;      \
+     goto other;       \
+
+
+#endif /* CASE_MIN_H */

+ 1 - 0
parser/hf.c

@@ -168,6 +168,7 @@ void clean_hdr_field(struct hdr_field* hf)
 			break;
 
 		case HDR_SESSIONEXPIRES_T:
+		case HDR_MIN_SE_T:
 		case HDR_ACCEPTCONTACT_T:
 		case HDR_ALLOWEVENTS_T:
 		case HDR_CONTENTENCODING_T:

+ 9 - 7
parser/hf.h

@@ -1,5 +1,5 @@
-/* 
- * $Id$ 
+/*
+ * $Id$
  *
  * Copyright (C) 2001-2003 FhG Fokus
  *
@@ -20,8 +20,8 @@
  * 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 
+ * 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
  *
  * History:
@@ -88,6 +88,7 @@ enum _hdr_types_t {
 	HDR_REFER_TO_T				       /* Refer-To header fiels */,
 	HDR_SIPIFMATCH_T                   /* SIP-If-Match header field */,
 	HDR_SESSIONEXPIRES_T                           /* Session-Expires header */,
+	HDR_MIN_SE_T                                   /* Min-SE */,
 	HDR_ACCEPTCONTACT_T                            /* Accept-Contact header */,
 	HDR_ALLOWEVENTS_T                              /* Allow-Events header */,
 	HDR_CONTENTENCODING_T                          /* Content-Encoding header */,
@@ -146,6 +147,7 @@ typedef unsigned long long hdr_flags_t;
 #define HDR_REFER_TO_F				HDR_F_DEF(REFER_TO)
 #define HDR_SIPIFMATCH_F			HDR_F_DEF(SIPIFMATCH)
 #define HDR_SESSIONEXPIRES_F			HDR_F_DEF(SESSIONEXPIRES)
+#define HDR_MIN_SE_F				HDR_F_DEF(MIN_SE)
 #define HDR_ACCEPTCONTACT_F			HDR_F_DEF(HDR_ACCEPTCONTACT_T)
 #define HDR_ALLOWEVENTS_F			HDR_F_DEF(HDR_ALLOWEVENTS_T)
 #define HDR_CONTENTENCODING_F			HDR_F_DEF(HDR_CONTENTENCODING_T)
@@ -157,10 +159,10 @@ typedef unsigned long long hdr_flags_t;
 
 typedef enum _hdr_types_t hdr_types_t;
 
-/* 
- * Format: name':' body 
+/*
+ * Format: name':' body
  */
-struct hdr_field {   
+struct hdr_field {
 	hdr_types_t type;       /* Header field type */
 	str name;               /* Header field name */
 	str body;               /* Header field body (may not include CRLF) */

+ 3 - 1
parser/keys.h

@@ -41,7 +41,7 @@
  * 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 3a 20  2d
  *
  * Test manually/visually if dword is intended string using:
- * awk '/^#define/ {printf("%s \"%x%x%x%x\" ... %s \n",  $3,strtonum("0x" substr($3,9,2)),strtonum("0x" substr($3,7,2)),strtonum("0x" substr($3,5,2)),strtonum("0x" substr($3,3,2)),$5)}' keys.h
+ * awk '/^#define/ {printf("%s \"%c%c%c%c\" ... %s \n",  $3,strtonum("0x" substr($3,9,2)),strtonum("0x" substr($3,7,2)),strtonum("0x" substr($3,5,2)),strtonum("0x" substr($3,3,2)),$5)}' keys.h
  *
  */
 
@@ -158,4 +158,6 @@
 
 #define _est__ 0x2d747365   /* "est-" */
 
+#define _min__ 0x2d6e696d   /* "min-" */
+
 #endif /* KEYS_H */

+ 9 - 1
parser/msg_parser.c

@@ -209,6 +209,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 		case HDR_SIPIFMATCH_T:
 		case HDR_REFER_TO_T:
 		case HDR_SESSIONEXPIRES_T:
+		case HDR_MIN_SE_T:
 		case HDR_ACCEPTCONTACT_T:
 		case HDR_ALLOWEVENTS_T:
 		case HDR_CONTENTENCODING_T:
@@ -307,7 +308,6 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
 				msg->parsed_flag|=HDR_EOH_F;
 				pkg_free(hf);
 				goto skip;
-			case HDR_SESSIONEXPIRES_T:
 			case HDR_ACCEPTCONTACT_T:
 			case HDR_ALLOWEVENTS_T:
 			case HDR_CONTENTENCODING_T:
@@ -436,6 +436,14 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
 				if (msg->refer_to==0) msg->refer_to = hf;
 				msg->parsed_flag|=HDR_REFER_TO_F;
 				break;
+			case HDR_SESSIONEXPIRES_T:
+				if (msg->session_expires==0) msg->session_expires = hf;
+				msg->parsed_flag|=HDR_SESSIONEXPIRES_F;
+				break;
+			case HDR_MIN_SE_T:
+				if (msg->min_se==0) msg->min_se = hf;
+				msg->parsed_flag|=HDR_MIN_SE_F;
+				break;
 			case HDR_VIA_T:
 				msg->parsed_flag|=HDR_VIA_F;
 				DBG("parse_headers: Via found, flags=%llx\n",

+ 18 - 16
parser/msg_parser.h

@@ -20,8 +20,8 @@
  * 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 
+ * 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
  *
  * History
@@ -67,7 +67,7 @@
 #define REPLY_CLASS(_reply) ((_reply)->REPLY_STATUS/100)
 
 /* number methods as power of two to allow bitmap matching */
-enum request_method { METHOD_UNDEF=0, METHOD_INVITE=1, METHOD_CANCEL=2, METHOD_ACK=4, 
+enum request_method { METHOD_UNDEF=0, METHOD_INVITE=1, METHOD_CANCEL=2, METHOD_ACK=4,
 	METHOD_BYE=8, METHOD_INFO=16, METHOD_REGISTER=32, METHOD_SUBSCRIBE=64,
         METHOD_NOTIFY=128, METHOD_OTHER=256 };
 
@@ -123,7 +123,7 @@ struct sip_uri {
 	str host;     /* Host name */
 	str port;     /* Port number */
 	str params;   /* Parameters */
-	str headers;  
+	str headers;
 	unsigned short port_no;
 };
 #endif
@@ -137,7 +137,7 @@ struct sip_uri {
 	str host;     /* Host name */
 	str port;     /* Port number */
 	str params;   /* Parameters */
-	str headers;  
+	str headers;
 	unsigned short port_no;
 	unsigned short proto; /* from transport */
 	uri_type type; /* uri scheme */
@@ -207,12 +207,14 @@ struct sip_msg {
 	struct hdr_field* accept_disposition;
 	struct hdr_field* diversion;
 	struct hdr_field* rpid;
-        struct hdr_field* refer_to;
+	struct hdr_field* refer_to;
+	struct hdr_field* session_expires;
+	struct hdr_field* min_se;
 	struct hdr_field* sipifmatch;
 
 	char* eoh;        /* pointer to the end of header (if found) or null */
 	char* unparsed;   /* here we stopped parsing*/
-	
+
 	struct receive_info rcv; /* source & dest ip, ports, proto a.s.o*/
 
 	char* buf;        /* scratch pad, holds a modified message,
@@ -220,7 +222,7 @@ struct sip_msg {
 	unsigned int len; /* message len (orig) */
 
 	     /* modifications */
-	
+
 	str new_uri; /* changed first line uri, when you change this
 	                don't forget to set parsed_uri_ok to 0*/
 
@@ -233,25 +235,25 @@ struct sip_msg {
 	/* the same for original uri */
 	int parsed_orig_ruri_ok;
 	struct sip_uri parsed_orig_ruri;
-	
+
 	struct lump* add_rm;       /* used for all the forwarded requests/replies */
 	struct lump* body_lumps;     /* Lumps that update Content-Length */
 	struct lump_rpl *reply_lump; /* only for localy generated replies !!!*/
 
-	/* str add_to_branch; 
-	   whatever whoever want to append to branch comes here 
+	/* str add_to_branch;
+	   whatever whoever want to append to branch comes here
 	*/
 	char add_to_branch_s[MAX_BRANCH_PARAM_LEN];
 	int add_to_branch_len;
-	
+
 	     /* index to TM hash table; stored in core to avoid unnecessary calculations */
 	unsigned int  hash_index;
 	unsigned int msg_flags; /* flags used by core */
-	     /* allows to set various flags on the message; may be used for 
+	     /* allows to set various flags on the message; may be used for
 	      *	simple inter-module communication or remembering processing state
-	      * reached 
+	      * reached
 	      */
-	flag_t flags;	
+	flag_t flags;
 	str set_global_address;
 	str set_global_port;
 	struct socket_info* force_send_socket; /* force sending on this socket,
@@ -300,7 +302,7 @@ inline static int char_msg_val( struct sip_msg *msg, char *cv )
 	src[2]= msg->callid->body;
 	src[3]= msg->first_line.u.request.uri;
 	src[4]= get_cseq( msg )->number;
-	
+
 	/* topmost Via is part of transaction key as well ! */
 	src[5]= msg->via1->host;
 	src[6]= msg->via1->port_str;

+ 2 - 0
parser/parse_hname2.c

@@ -88,6 +88,7 @@ static inline char* skip_ws(char* p, unsigned int size)
 #include "case_refe.h"     /* Refer-To */
 #include "case_sess.h"     /* Session-Expires */
 #include "case_reje.h"     /* Reject-Contact */
+#include "case_min.h"      /* Min-SE */
 
 
 #define READ(val) \
@@ -123,6 +124,7 @@ static inline char* skip_ws(char* p, unsigned int size)
         case _refe_: refe_CASE; \
 	case _sess_: sess_CASE; \
 	case _reje_: reje_CASE; \
+	case _min__: min_CASE;  \