Browse Source

- reverted the msg_start/first_line line memeber addition: almost the same
effect can be obtained without adding another structure member which eats more
memory,
- added the SIP_MSG_START(msg) macro which has the same functions as the now
removed msg->first_line.line.s

(this commit should also fix SER-248)

Andrei Pelinescu-Onciul 19 years ago
parent
commit
2c99a29dbe
4 changed files with 12 additions and 7 deletions
  1. 4 0
      parser/msg_parser.h
  2. 0 2
      parser/parse_fline.c
  3. 3 3
      parser/parse_fline.h
  4. 5 2
      select_core.c

+ 4 - 0
parser/msg_parser.h

@@ -42,6 +42,7 @@
  *  2006-11-10  check_transaction_quadruple inlined (andrei)
  *  2006-11-10  check_transaction_quadruple inlined (andrei)
  *  2007-01-26  added date, identity, identity_info header fields
  *  2007-01-26  added date, identity, identity_info header fields
  *		to sip_msg (gergo)
  *		to sip_msg (gergo)
+ *  2007-03-14  added SIP_MSG_START(msg) macro
  */
  */
 
 
 
 
@@ -74,6 +75,9 @@
 #define REPLY_STATUS first_line.u.reply.statuscode
 #define REPLY_STATUS first_line.u.reply.statuscode
 #define REPLY_CLASS(_reply) ((_reply)->REPLY_STATUS/100)
 #define REPLY_CLASS(_reply) ((_reply)->REPLY_STATUS/100)
 
 
+/* start of "actual" sip msg (start of first line) */
+#define SIP_MSG_START(m)	((m)->first_line.u.request.method.s)
+
 /* number methods as power of two to allow bitmap matching */
 /* 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_BYE=8, METHOD_INFO=16, METHOD_REGISTER=32, METHOD_SUBSCRIBE=64,

+ 0 - 2
parser/parse_fline.c

@@ -92,7 +92,6 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
 		LOG(L_INFO, "ERROR: parse_first_line: message too short: %d\n", len);
 		LOG(L_INFO, "ERROR: parse_first_line: message too short: %d\n", len);
 		goto error1;
 		goto error1;
 	}
 	}
-	fl->line.s = buffer;
 	tmp=buffer;
 	tmp=buffer;
   	/* is it perhaps a reply, ie does it start with "SIP...." ? */
   	/* is it perhaps a reply, ie does it start with "SIP...." ? */
 	if ( 	(*tmp=='S' || *tmp=='s') && 
 	if ( 	(*tmp=='S' || *tmp=='s') && 
@@ -212,7 +211,6 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
 		}
 		}
 		offset+=tmp-third;
 		offset+=tmp-third;
 	}
 	}
-	fl->line.len = tmp-fl->line.s;
 	nl=eat_line(tmp,len-offset);
 	nl=eat_line(tmp,len-offset);
 	if (nl>=end){ /* no crlf in packet or only 1 line > invalid */
 	if (nl>=end){ /* no crlf in packet or only 1 line > invalid */
 		goto error;
 		goto error;

+ 3 - 3
parser/parse_fline.h

@@ -60,9 +60,8 @@
 #define NOTIFY_LEN 6
 #define NOTIFY_LEN 6
 
 
 struct msg_start {
 struct msg_start {
-	int type;                         /* Type of the Message - Request/Response */
-	str line;                         /* len does not include CRLF, correct way how to point at second line is line.s+len */
-	int len; 						/* length including delimiter */
+	int type;					/* Type of the Message - Request/Response */
+	int len; 					/* length including delimiter */
 	union {
 	union {
 		struct {
 		struct {
 			str method;       /* Method string */
 			str method;       /* Method string */
@@ -80,6 +79,7 @@ struct msg_start {
 };
 };
 
 
 
 
+
 char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl);
 char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl);
 
 
 char* parse_fline(char* buffer, char* end, struct msg_start* fl);
 char* parse_fline(char* buffer, char* end, struct msg_start* fl);

+ 5 - 2
select_core.c

@@ -459,7 +459,10 @@ int select_msg(str* res, select_t* s, struct sip_msg* msg)
 
 
 int select_msg_first_line(str* res, select_t* s, struct sip_msg* msg) 
 int select_msg_first_line(str* res, select_t* s, struct sip_msg* msg) 
 {
 {
-	RETURN0_res(msg->first_line.line);
+	res->s=SIP_MSG_START(msg);
+	res->len=msg->first_line.len;
+	trim_trailing(res);
+	return 0;
 }
 }
 
 
 int select_msg_type(str* res, select_t* s, struct sip_msg* msg) {
 int select_msg_type(str* res, select_t* s, struct sip_msg* msg) {
@@ -493,7 +496,7 @@ int select_msg_header(str* res, select_t* s, struct sip_msg* msg)
 {
 {
 	/* get all headers */
 	/* get all headers */
 	char *c;
 	char *c;
-	res->s = msg->first_line.line.s + msg->first_line.len; 
+	res->s = SIP_MSG_START(msg) + msg->first_line.len; 
 	c = get_body(msg);
 	c = get_body(msg);
 	res->len = c - res->s;
 	res->len = c - res->s;
 	return 0;
 	return 0;