Browse code

- 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 authored on 14/03/2007 17:28:04
Showing 4 changed files
... ...
@@ -42,6 +42,7 @@
42 42
  *  2006-11-10  check_transaction_quadruple inlined (andrei)
43 43
  *  2007-01-26  added date, identity, identity_info header fields
44 44
  *		to sip_msg (gergo)
45
+ *  2007-03-14  added SIP_MSG_START(msg) macro
45 46
  */
46 47
 
47 48
 
... ...
@@ -74,6 +75,9 @@
74 75
 #define REPLY_STATUS first_line.u.reply.statuscode
75 76
 #define REPLY_CLASS(_reply) ((_reply)->REPLY_STATUS/100)
76 77
 
78
+/* start of "actual" sip msg (start of first line) */
79
+#define SIP_MSG_START(m)	((m)->first_line.u.request.method.s)
80
+
77 81
 /* number methods as power of two to allow bitmap matching */
78 82
 enum request_method { METHOD_UNDEF=0, METHOD_INVITE=1, METHOD_CANCEL=2, METHOD_ACK=4,
79 83
 	METHOD_BYE=8, METHOD_INFO=16, METHOD_REGISTER=32, METHOD_SUBSCRIBE=64,
... ...
@@ -92,7 +92,6 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
92 92
 		LOG(L_INFO, "ERROR: parse_first_line: message too short: %d\n", len);
93 93
 		goto error1;
94 94
 	}
95
-	fl->line.s = buffer;
96 95
 	tmp=buffer;
97 96
   	/* is it perhaps a reply, ie does it start with "SIP...." ? */
98 97
 	if ( 	(*tmp=='S' || *tmp=='s') && 
... ...
@@ -212,7 +211,6 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
212 211
 		}
213 212
 		offset+=tmp-third;
214 213
 	}
215
-	fl->line.len = tmp-fl->line.s;
216 214
 	nl=eat_line(tmp,len-offset);
217 215
 	if (nl>=end){ /* no crlf in packet or only 1 line > invalid */
218 216
 		goto error;
... ...
@@ -60,9 +60,8 @@
60 60
 #define NOTIFY_LEN 6
61 61
 
62 62
 struct msg_start {
63
-	int type;                         /* Type of the Message - Request/Response */
64
-	str line;                         /* len does not include CRLF, correct way how to point at second line is line.s+len */
65
-	int len; 						/* length including delimiter */
63
+	int type;					/* Type of the Message - Request/Response */
64
+	int len; 					/* length including delimiter */
66 65
 	union {
67 66
 		struct {
68 67
 			str method;       /* Method string */
... ...
@@ -80,6 +79,7 @@ struct msg_start {
80 79
 };
81 80
 
82 81
 
82
+
83 83
 char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl);
84 84
 
85 85
 char* parse_fline(char* buffer, char* end, struct msg_start* fl);
... ...
@@ -459,7 +459,10 @@ int select_msg(str* res, select_t* s, struct sip_msg* msg)
459 459
 
460 460
 int select_msg_first_line(str* res, select_t* s, struct sip_msg* msg) 
461 461
 {
462
-	RETURN0_res(msg->first_line.line);
462
+	res->s=SIP_MSG_START(msg);
463
+	res->len=msg->first_line.len;
464
+	trim_trailing(res);
465
+	return 0;
463 466
 }
464 467
 
465 468
 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)
493 496
 {
494 497
 	/* get all headers */
495 498
 	char *c;
496
-	res->s = msg->first_line.line.s + msg->first_line.len; 
499
+	res->s = SIP_MSG_START(msg) + msg->first_line.len; 
497 500
 	c = get_body(msg);
498 501
 	res->len = c - res->s;
499 502
 	return 0;