Browse code

TM callbacks, acc, flags

Jiri Kuthan authored on 13/05/2002 01:15:40
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,277 +0,0 @@
1
-/*
2
- * $Id$
3
- */
4
-
5
-#ifndef msg_parser_h
6
-#define msg_parser_h
7
-
8
-#include "str.h"
9
-#include "data_lump.h"
10
-
11
-#define SIP_REQUEST 1
12
-#define SIP_REPLY   2
13
-#define SIP_INVALID 0
14
-
15
-
16
-
17
-/*header types and flags*/
18
-#define HDR_EOH           -1
19
-#define HDR_ERROR          0
20
-#define HDR_VIA            1
21
-#define HDR_VIA1           1
22
-#define HDR_VIA2           2  /*only used as flag*/
23
-#define HDR_TO             4
24
-#define HDR_FROM           8
25
-#define HDR_CSEQ          16
26
-#define HDR_CALLID        32
27
-#define HDR_CONTACT       64
28
-#define HDR_MAXFORWARDS  128
29
-#define HDR_ROUTE        256
30
-#define HDR_RECORDROUTE  512
31
-#define HDR_OTHER       65536 /*unknown header type*/
32
-
33
-
34
-/* maximum length of values appended to Via-branch parameter */
35
-#ifdef USE_SYNONIM
36
-#define MAX_BRANCH_PARAM_LEN  22
37
-#else
38
-#define MAX_BRANCH_PARAM_LEN  48
39
-#endif
40
-/* via param types
41
- * WARNING: keep in sync w/ FIN_*, GEN_PARAM and PARAM_ERROR from via_parse.c*/
42
-enum{
43
-		PARAM_HIDDEN=230, PARAM_TTL, PARAM_BRANCH, PARAM_MADDR, PARAM_RECEIVED,
44
-		GEN_PARAM,
45
-		PARAM_ERROR
46
-};
47
-
48
-enum{
49
-		TAG_PARAM=400, GENERAL_PARAM
50
-};
51
-
52
-/* casting macro for accessing CSEQ body */
53
-#define get_cseq( p_msg)  ((struct cseq_body*)(p_msg)->cseq->parsed)
54
-#define get_to( p_msg)      ((struct to_body*)(p_msg)->to->parsed)
55
-
56
-#ifdef NEW_HNAME
57
-#	define parse_hname(_b,_e,_h) parse_hname2((_b),(_e),(_h))
58
-	void init_htable(void);
59
-#else
60
-#	define parse_hname(_b,_e,_h) parse_hname1((_b),(_e),(_h))
61
-#endif
62
-
63
-
64
-#define INVITE_LEN	6
65
-#define ACK_LEN		3
66
-#define CANCEL_LEN	6
67
-#define BYE_LEN		3
68
-enum { METHOD_OTHER, METHOD_INVITE, METHOD_CANCEL, METHOD_ACK, METHOD_BYE };
69
-
70
-#define IFISMETHOD(methodname,firstchar)                                  \
71
-if (  (*tmp==(firstchar) || *tmp==((firstchar) | 32)) &&                  \
72
-        strncasecmp( tmp+1, #methodname +1, methodname##_LEN-1)==0 &&     \
73
-        *(tmp+methodname##_LEN)==' ') {                                   \
74
-                fl->type=SIP_REQUEST;                                     \
75
-                fl->u.request.method.len=methodname##_LEN;                \
76
-                fl->u.request.method_value=METHOD_##methodname;           \
77
-                tmp=buffer+methodname##_LEN;                              \
78
-}
79
-
80
-
81
-#define VIA_PARSE_OK	1
82
-#define VIA_PARSE_ERROR -1
83
-#define PARSE_ERROR -1
84
-#define PARSE_OK 1
85
-
86
-#define SIP_VERSION	"SIP/2.0"
87
-#define SIP_VERSION_LEN 7
88
-
89
-
90
-struct msg_start{
91
-	int type;
92
-	union {
93
-		struct {
94
-			str method;
95
-			str uri;
96
-			str version;
97
-			int method_value;
98
-		}request;
99
-		struct {
100
-			str version;
101
-			str status;
102
-			str reason;
103
-			unsigned int /* statusclass,*/ statuscode;
104
-		}reply;
105
-	}u;
106
-};
107
-
108
-struct hdr_field{   /* format: name':' body */
109
-	int type;
110
-	str name;
111
-	str body;
112
-	void* parsed;
113
-	struct hdr_field* next;
114
-};
115
-
116
-
117
-
118
-struct via_param{
119
-	int type;
120
-	str name;
121
-	str value;
122
-	int size; /* total size*/
123
-	struct via_param* next;
124
-};
125
-
126
-struct via_body{  /* format: name/version/transport host:port;params comment */
127
-	int error;
128
-	str hdr;   /* contains "Via" or "v" */
129
-	str name;
130
-	str version;
131
-	str transport;
132
-	str host;
133
-	int port;
134
-	str port_str;
135
-	str params;
136
-	str comment;
137
-	int bsize;    /* body size, not including hdr */
138
-	struct via_param* param_lst; /* list of parameters*/
139
-	struct via_param* last_param; /*last via parameter, internal use*/
140
-	/* shortcuts to "important" params*/
141
-	struct via_param* branch;
142
-
143
-	struct via_body* next; /* pointer to next via body string if
144
-         compact via or null */
145
-};
146
-
147
-
148
-
149
-struct to_param{
150
-	int type;
151
-	str name;
152
-	str value;
153
-	struct to_param* next;
154
-};
155
-
156
-struct to_body{
157
-	int error;
158
-	str body;
159
-	str uri;
160
-	str tag_value;
161
-	struct to_param *param_lst;
162
-	struct to_param *last_param;
163
-};
164
-
165
-
166
-struct cseq_body{
167
-	int error;
168
-	str number;
169
-	str method;
170
-};
171
-
172
-
173
-
174
-struct sip_msg{
175
-	unsigned int id; /* message id, unique/process*/
176
-	struct msg_start first_line;
177
-	struct via_body* via1;
178
-	struct via_body* via2;
179
-	struct hdr_field* headers; /* all the parsed headers*/
180
-	struct hdr_field* last_header; /* pointer to the last parsed header*/
181
-	int parsed_flag;
182
-	/* via, to, cseq, call-id, from, end of header*/
183
-	/* first occurance of it; subsequent occurances saved in 'headers' */
184
-	struct hdr_field* h_via1;
185
-	struct hdr_field* h_via2;
186
-	struct hdr_field* callid;
187
-	struct hdr_field* to;
188
-	struct hdr_field* cseq;
189
-	struct hdr_field* from;
190
-	struct hdr_field* contact;
191
-	struct hdr_field* maxforwards;
192
-	struct hdr_field* route;
193
-	struct hdr_field* record_route;
194
-	char* eoh; /* pointer to the end of header (if found) or null */
195
-	char* unparsed; /* here we stopped parsing*/
196
-
197
-	unsigned int src_ip;
198
-	unsigned int dst_ip;
199
-	char* orig; /* original message copy */
200
-	char* buf;  /* scratch pad, holds a modfied message,
201
-				   via, etc. point into it */
202
-				   
203
-	unsigned int len; /* message len (orig) */
204
-
205
-	/* modifications */
206
-	str new_uri; /* changed first line uri*/
207
-
208
-	struct lump* add_rm;      /* used for all the forwarded messages */
209
-	struct lump* repl_add_rm; /* only for localy generated replies !!!*/
210
-	struct lump_rpl *reply_lump;
211
-
212
-	/* str add_to_branch; */ /* whatever whoever want to append to branch comes here */
213
-	char add_to_branch_s[MAX_BRANCH_PARAM_LEN];
214
-	int add_to_branch_len;
215
-
216
-	/* index to TM hash table; stored in core to avoid unnecessary calcs */
217
-	unsigned int  hash_index;
218
-
219
-	
220
-};
221
-
222
-
223
-struct sip_uri{
224
-	str user;
225
-	str passwd;
226
-	str host;
227
-	str port;
228
-	str params;
229
-	str headers;
230
-};
231
-
232
-
233
-char* parse_fline(char* buffer, char* end, struct msg_start* fl);
234
-char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl);
235
-char* parse_hostport(char* buf, str* host, short int* port);
236
-
237
-int parse_msg(char* buf, unsigned int len, struct sip_msg* msg);
238
-int parse_uri(char *buf, int len, struct sip_uri* uri);
239
-int parse_headers(struct sip_msg* msg, int flags);
240
-
241
-void free_uri(struct sip_uri* u);
242
-
243
-
244
-/* char* parse_hname(char* buf, char* end, struct hdr_field* hdr); */
245
-char* parse_hname1(char* buf, char* end, struct hdr_field* hdr);
246
-char* parse_hname2(char* buf, char* end, struct hdr_field* hdr);
247
-
248
-char* parse_via(char* buffer, char* end, struct via_body *vb);
249
-char* parse_to(char* buffer, char* end, struct to_body *to_b);
250
-char* parse_cseq(char* buffer, char* end, struct cseq_body *cb);
251
-
252
-void free_via_param_list(struct via_param *vp);
253
-void free_via_list(struct via_body *vb);
254
-void clean_hdr_field(struct hdr_field* hf);
255
-void free_hdr_field_lst(struct hdr_field* hf);
256
-void free_sip_msg(struct sip_msg* msg);
257
-
258
-/* make sure all HFs needed for transaction identification have been
259
-   parsed; return 0 if those HFs can't be found
260
- */
261
-
262
-#define check_transaction_quadruple(msg ) \
263
-	(parse_headers((msg), HDR_FROM|HDR_TO|HDR_CALLID|HDR_CSEQ)!=-1 && \
264
-	(msg)->from && (msg)->to && (msg)->callid && (msg)->cseq)
265
-
266
-/* restored to the original double-check and put macro params
267
-   in parenthesses  -jiri */
268
-/* re-reverted to the shorter version -andrei 
269
-#define check_transaction_quadruple(msg ) \
270
-   ( ((msg)->from || (parse_headers( (msg), HDR_FROM)!=-1 && (msg)->from)) && 	\
271
-   ((msg)->to|| (parse_headers( (msg), HDR_TO)!=-1 && (msg)->to)) &&		\
272
-   ((msg)->callid|| (parse_headers( (msg), HDR_CALLID)!=-1 && (msg)->callid)) &&\
273
-   ((msg)->cseq|| (parse_headers( (msg), HDR_CSEQ)!=-1 && (msg)->cseq)) && \
274
-   ((msg)->via1|| (parse_headers( (msg), HDR_VIA)!=-1 && (msg)->via1)) ) 
275
-*/
276
-	
277
-#endif
Browse code

*** empty log message ***

Bogdan-Andrei Iancu authored on 01/03/2002 15:00:14
Showing 1 changed files
... ...
@@ -156,6 +156,7 @@ struct to_param{
156 156
 struct to_body{
157 157
 	int error;
158 158
 	str body;
159
+	str uri;
159 160
 	str tag_value;
160 161
 	struct to_param *param_lst;
161 162
 	struct to_param *last_param;
Browse code

added WAIT protection, NEW_HNAME, memory command-line option, first version of SRL

Jiri Kuthan authored on 26/02/2002 00:04:05
Showing 1 changed files
... ...
@@ -30,6 +30,7 @@
30 30
 #define HDR_RECORDROUTE  512
31 31
 #define HDR_OTHER       65536 /*unknown header type*/
32 32
 
33
+
33 34
 /* maximum length of values appended to Via-branch parameter */
34 35
 #ifdef USE_SYNONIM
35 36
 #define MAX_BRANCH_PARAM_LEN  22
... ...
@@ -52,6 +53,12 @@ enum{
52 53
 #define get_cseq( p_msg)  ((struct cseq_body*)(p_msg)->cseq->parsed)
53 54
 #define get_to( p_msg)      ((struct to_body*)(p_msg)->to->parsed)
54 55
 
56
+#ifdef NEW_HNAME
57
+#	define parse_hname(_b,_e,_h) parse_hname2((_b),(_e),(_h))
58
+	void init_htable(void);
59
+#else
60
+#	define parse_hname(_b,_e,_h) parse_hname1((_b),(_e),(_h))
61
+#endif
55 62
 
56 63
 
57 64
 #define INVITE_LEN	6
... ...
@@ -233,7 +240,10 @@ int parse_headers(struct sip_msg* msg, int flags);
233 240
 void free_uri(struct sip_uri* u);
234 241
 
235 242
 
236
-char* parse_hname(char* buf, char* end, struct hdr_field* hdr);
243
+/* char* parse_hname(char* buf, char* end, struct hdr_field* hdr); */
244
+char* parse_hname1(char* buf, char* end, struct hdr_field* hdr);
245
+char* parse_hname2(char* buf, char* end, struct hdr_field* hdr);
246
+
237 247
 char* parse_via(char* buffer, char* end, struct via_body *vb);
238 248
 char* parse_to(char* buffer, char* end, struct to_body *to_b);
239 249
 char* parse_cseq(char* buffer, char* end, struct cseq_body *cb);
Browse code

*** empty log message ***

Bogdan-Andrei Iancu authored on 13/02/2002 21:37:17
Showing 1 changed files
... ...
@@ -199,6 +199,7 @@ struct sip_msg{
199 199
 
200 200
 	struct lump* add_rm;      /* used for all the forwarded messages */
201 201
 	struct lump* repl_add_rm; /* only for localy generated replies !!!*/
202
+	struct lump_rpl *reply_lump;
202 203
 
203 204
 	/* str add_to_branch; */ /* whatever whoever want to append to branch comes here */
204 205
 	char add_to_branch_s[MAX_BRANCH_PARAM_LEN];
Browse code

To parsing and tag used in ACK matching

Bogdan-Andrei Iancu authored on 07/02/2002 16:02:45
Showing 1 changed files
... ...
@@ -44,8 +44,13 @@ enum{
44 44
 		PARAM_ERROR
45 45
 };
46 46
 
47
+enum{
48
+		TAG_PARAM=400, GENERAL_PARAM
49
+};
50
+
47 51
 /* casting macro for accessing CSEQ body */
48
-#define get_cseq( p_msg)    ((struct cseq_body*)(p_msg)->cseq->parsed)
52
+#define get_cseq( p_msg)  ((struct cseq_body*)(p_msg)->cseq->parsed)
53
+#define get_to( p_msg)      ((struct to_body*)(p_msg)->to->parsed)
49 54
 
50 55
 
51 56
 
... ...
@@ -127,13 +132,27 @@ struct via_body{  /* format: name/version/transport host:port;params comment */
127 132
 	struct via_param* last_param; /*last via parameter, internal use*/
128 133
 	/* shortcuts to "important" params*/
129 134
 	struct via_param* branch;
130
-	
135
+
131 136
 	struct via_body* next; /* pointer to next via body string if
132
-							  compact via or null */
137
+         compact via or null */
133 138
 };
134 139
 
135 140
 
136 141
 
142
+struct to_param{
143
+	int type;
144
+	str name;
145
+	str value;
146
+	struct to_param* next;
147
+};
148
+
149
+struct to_body{
150
+	int error;
151
+	str body;
152
+	str tag_value;
153
+	struct to_param *param_lst;
154
+	struct to_param *last_param;
155
+};
137 156
 
138 157
 
139 158
 struct cseq_body{
... ...
@@ -165,7 +184,6 @@ struct sip_msg{
165 184
 	struct hdr_field* route;
166 185
 	struct hdr_field* record_route;
167 186
 	char* eoh; /* pointer to the end of header (if found) or null */
168
-
169 187
 	char* unparsed; /* here we stopped parsing*/
170 188
 
171 189
 	unsigned int src_ip;
... ...
@@ -216,6 +234,7 @@ void free_uri(struct sip_uri* u);
216 234
 
217 235
 char* parse_hname(char* buf, char* end, struct hdr_field* hdr);
218 236
 char* parse_via(char* buffer, char* end, struct via_body *vb);
237
+char* parse_to(char* buffer, char* end, struct to_body *to_b);
219 238
 char* parse_cseq(char* buffer, char* end, struct cseq_body *cb);
220 239
 
221 240
 void free_via_param_list(struct via_param *vp);
Browse code

MD5 matching for reply

Bogdan-Andrei Iancu authored on 31/01/2002 19:16:36
Showing 1 changed files
... ...
@@ -31,8 +31,11 @@
31 31
 #define HDR_OTHER       65536 /*unknown header type*/
32 32
 
33 33
 /* maximum length of values appended to Via-branch parameter */
34
-#define	MAX_BRANCH_PARAM_LEN	32
35
-
34
+#ifdef USE_SYNONIM
35
+#define MAX_BRANCH_PARAM_LEN  22
36
+#else
37
+#define MAX_BRANCH_PARAM_LEN  48
38
+#endif
36 39
 /* via param types
37 40
  * WARNING: keep in sync w/ FIN_*, GEN_PARAM and PARAM_ERROR from via_parse.c*/
38 41
 enum{
Browse code

memory access syncing protection added

Jiri Kuthan authored on 28/01/2002 23:30:56
Showing 1 changed files
... ...
@@ -183,6 +183,9 @@ struct sip_msg{
183 183
 	char add_to_branch_s[MAX_BRANCH_PARAM_LEN];
184 184
 	int add_to_branch_len;
185 185
 
186
+	/* index to TM hash table; stored in core to avoid unnecessary calcs */
187
+	unsigned int  hash_index;
188
+
186 189
 	
187 190
 };
188 191
 
Browse code

Extended parser automaton, Record-Route is now parsed.

Jan Janak authored on 28/01/2002 18:45:42
Showing 1 changed files
... ...
@@ -27,6 +27,7 @@
27 27
 #define HDR_CONTACT       64
28 28
 #define HDR_MAXFORWARDS  128
29 29
 #define HDR_ROUTE        256
30
+#define HDR_RECORDROUTE  512
30 31
 #define HDR_OTHER       65536 /*unknown header type*/
31 32
 
32 33
 /* maximum length of values appended to Via-branch parameter */
... ...
@@ -159,6 +160,7 @@ struct sip_msg{
159 160
 	struct hdr_field* contact;
160 161
 	struct hdr_field* maxforwards;
161 162
 	struct hdr_field* route;
163
+	struct hdr_field* record_route;
162 164
 	char* eoh; /* pointer to the end of header (if found) or null */
163 165
 
164 166
 	char* unparsed; /* here we stopped parsing*/
Browse code

- added maxforwards support to sip_msg & parse_headers.

Andrei Pelinescu-Onciul authored on 22/01/2002 16:27:50
Showing 1 changed files
... ...
@@ -157,7 +157,8 @@ struct sip_msg{
157 157
 	struct hdr_field* cseq;
158 158
 	struct hdr_field* from;
159 159
 	struct hdr_field* contact;
160
-	struct hdr_field* route;    /* janakj, was missing here */
160
+	struct hdr_field* maxforwards;
161
+	struct hdr_field* route;
161 162
 	char* eoh; /* pointer to the end of header (if found) or null */
162 163
 
163 164
 	char* unparsed; /* here we stopped parsing*/
Browse code

Added missing parts for Route HF.

Jan Janak authored on 16/01/2002 10:57:02
Showing 1 changed files
... ...
@@ -157,6 +157,7 @@ struct sip_msg{
157 157
 	struct hdr_field* cseq;
158 158
 	struct hdr_field* from;
159 159
 	struct hdr_field* contact;
160
+	struct hdr_field* route;    /* janakj, was missing here */
160 161
 	char* eoh; /* pointer to the end of header (if found) or null */
161 162
 
162 163
 	char* unparsed; /* here we stopped parsing*/
Browse code

*** empty log message ***

Andrei Pelinescu-Onciul authored on 15/01/2002 21:29:27
Showing 1 changed files
... ...
@@ -78,13 +78,13 @@ struct msg_start{
78 78
 			str method;
79 79
 			str uri;
80 80
 			str version;
81
-			short method_value;
81
+			int method_value;
82 82
 		}request;
83 83
 		struct {
84 84
 			str version;
85 85
 			str status;
86 86
 			str reason;
87
-			unsigned short /* statusclass,*/ statuscode;
87
+			unsigned int /* statusclass,*/ statuscode;
88 88
 		}reply;
89 89
 	}u;
90 90
 };
Browse code

performance and bug fixes

Jiri Kuthan authored on 07/01/2002 04:39:49
Showing 1 changed files
... ...
@@ -84,7 +84,7 @@ struct msg_start{
84 84
 			str version;
85 85
 			str status;
86 86
 			str reason;
87
-			unsigned short statusclass, statuscode;
87
+			unsigned short /* statusclass,*/ statuscode;
88 88
 		}reply;
89 89
 	}u;
90 90
 };
Browse code

- fixed macros ("(",")", do{}while(0)). - small Makefile changes

Andrei Pelinescu-Onciul authored on 08/12/2001 14:20:09
Showing 1 changed files
... ...
@@ -41,7 +41,7 @@ enum{
41 41
 };
42 42
 
43 43
 /* casting macro for accessing CSEQ body */
44
-#define get_cseq( p_msg)    ((struct cseq_body*)p_msg->cseq->parsed)
44
+#define get_cseq( p_msg)    ((struct cseq_body*)(p_msg)->cseq->parsed)
45 45
 
46 46
 
47 47
 
Browse code

#define clean-up

Jiri Kuthan authored on 05/12/2001 23:00:08
Showing 1 changed files
... ...
@@ -195,15 +195,8 @@ struct sip_uri{
195 195
 
196 196
 char* parse_fline(char* buffer, char* end, struct msg_start* fl);
197 197
 char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl);
198
-#ifdef OLD_PARSER 
199
-char* get_hdr_field(char *buffer, unsigned int len, struct hdr_field*  hdr_f);
200
-int field_name(char *s, int len);
201
-#endif
202 198
 char* parse_hostport(char* buf, str* host, short int* port);
203 199
 
204
-#ifdef OLD_PARSER 
205
-char* parse_via_body(char* buffer,unsigned int len, struct via_body * vb);
206
-#endif
207 200
 int parse_msg(char* buf, unsigned int len, struct sip_msg* msg);
208 201
 int parse_uri(char *buf, int len, struct sip_uri* uri);
209 202
 int parse_headers(struct sip_msg* msg, int flags);
... ...
@@ -211,11 +204,9 @@ int parse_headers(struct sip_msg* msg, int flags);
211 204
 void free_uri(struct sip_uri* u);
212 205
 
213 206
 
214
-#ifndef OLD_PARSER
215 207
 char* parse_hname(char* buf, char* end, struct hdr_field* hdr);
216 208
 char* parse_via(char* buffer, char* end, struct via_body *vb);
217 209
 char* parse_cseq(char* buffer, char* end, struct cseq_body *cb);
218
-#endif
219 210
 
220 211
 void free_via_param_list(struct via_param *vp);
221 212
 void free_via_list(struct via_body *vb);
Browse code

- small fixes/cosmetic changes

Andrei Pelinescu-Onciul authored on 03/12/2001 16:25:38
Showing 1 changed files
... ...
@@ -227,20 +227,19 @@ void free_sip_msg(struct sip_msg* msg);
227 227
    parsed; return 0 if those HFs can't be found
228 228
  */
229 229
 
230
-/*
231 230
 #define check_transaction_quadruple(msg ) \
232
-	(parse_headers(msg, HDR_FROM|HDR_TO|HDR_CALLID|HDR_CSEQ)!=-1 && \
233
-	 msg->from && msg->to && msg->callid && msg->cseq)
234
-*/
231
+	(parse_headers((msg), HDR_FROM|HDR_TO|HDR_CALLID|HDR_CSEQ)!=-1 && \
232
+	(msg)->from && (msg)->to && (msg)->callid && (msg)->cseq)
235 233
 
236 234
 /* restored to the original double-check and put macro params
237 235
    in parenthesses  -jiri */
238
-
236
+/* re-reverted to the shorter version -andrei 
239 237
 #define check_transaction_quadruple(msg ) \
240 238
    ( ((msg)->from || (parse_headers( (msg), HDR_FROM)!=-1 && (msg)->from)) && 	\
241 239
    ((msg)->to|| (parse_headers( (msg), HDR_TO)!=-1 && (msg)->to)) &&		\
242 240
    ((msg)->callid|| (parse_headers( (msg), HDR_CALLID)!=-1 && (msg)->callid)) &&\
243 241
    ((msg)->cseq|| (parse_headers( (msg), HDR_CSEQ)!=-1 && (msg)->cseq)) && \
244 242
    ((msg)->via1|| (parse_headers( (msg), HDR_VIA)!=-1 && (msg)->via1)) ) 
245
-
243
+*/
244
+	
246 245
 #endif
Browse code

T-management hugely refurbished, fat bugs fixed; alas, the timer routing in T-mgmt core dumps now

Jiri Kuthan authored on 03/12/2001 13:07:13
Showing 1 changed files
... ...
@@ -240,8 +240,7 @@ void free_sip_msg(struct sip_msg* msg);
240 240
    ( ((msg)->from || (parse_headers( (msg), HDR_FROM)!=-1 && (msg)->from)) && 	\
241 241
    ((msg)->to|| (parse_headers( (msg), HDR_TO)!=-1 && (msg)->to)) &&		\
242 242
    ((msg)->callid|| (parse_headers( (msg), HDR_CALLID)!=-1 && (msg)->callid)) &&\
243
-   ((msg)->cseq|| (parse_headers( (msg), HDR_CSEQ)!=-1 && (msg)->cseq)) ) 
244
-
245
-
243
+   ((msg)->cseq|| (parse_headers( (msg), HDR_CSEQ)!=-1 && (msg)->cseq)) && \
244
+   ((msg)->via1|| (parse_headers( (msg), HDR_VIA)!=-1 && (msg)->via1)) ) 
246 245
 
247 246
 #endif
Browse code

very noisy debugging for branch

Jiri Kuthan authored on 02/12/2001 19:21:49
Showing 1 changed files
... ...
@@ -177,7 +177,7 @@ struct sip_msg{
177 177
 
178 178
 	/* str add_to_branch; */ /* whatever whoever want to append to branch comes here */
179 179
 	char add_to_branch_s[MAX_BRANCH_PARAM_LEN];
180
-	short add_to_branch_len;
180
+	int add_to_branch_len;
181 181
 
182 182
 	
183 183
 };
Browse code

branch fixes

Jiri Kuthan authored on 02/12/2001 18:28:24
Showing 1 changed files
... ...
@@ -226,9 +226,22 @@ void free_sip_msg(struct sip_msg* msg);
226 226
 /* make sure all HFs needed for transaction identification have been
227 227
    parsed; return 0 if those HFs can't be found
228 228
  */
229
+
230
+/*
229 231
 #define check_transaction_quadruple(msg ) \
230 232
 	(parse_headers(msg, HDR_FROM|HDR_TO|HDR_CALLID|HDR_CSEQ)!=-1 && \
231 233
 	 msg->from && msg->to && msg->callid && msg->cseq)
234
+*/
235
+
236
+/* restored to the original double-check and put macro params
237
+   in parenthesses  -jiri */
238
+
239
+#define check_transaction_quadruple(msg ) \
240
+   ( ((msg)->from || (parse_headers( (msg), HDR_FROM)!=-1 && (msg)->from)) && 	\
241
+   ((msg)->to|| (parse_headers( (msg), HDR_TO)!=-1 && (msg)->to)) &&		\
242
+   ((msg)->callid|| (parse_headers( (msg), HDR_CALLID)!=-1 && (msg)->callid)) &&\
243
+   ((msg)->cseq|| (parse_headers( (msg), HDR_CSEQ)!=-1 && (msg)->cseq)) ) 
244
+
232 245
 
233 246
 
234 247
 #endif
Browse code

minor fix: printing branch

Jiri Kuthan authored on 02/12/2001 16:01:46
Showing 1 changed files
... ...
@@ -175,7 +175,7 @@ struct sip_msg{
175 175
 	struct lump* add_rm;      /* used for all the forwarded messages */
176 176
 	struct lump* repl_add_rm; /* only for localy generated replies !!!*/
177 177
 
178
-	str add_to_branch; /* whatever whoever want to append to branch comes here */
178
+	/* str add_to_branch; */ /* whatever whoever want to append to branch comes here */
179 179
 	char add_to_branch_s[MAX_BRANCH_PARAM_LEN];
180 180
 	short add_to_branch_len;
181 181
 
Browse code

newly added

Jiri Kuthan authored on 01/12/2001 00:40:04
Showing 1 changed files
... ...
@@ -149,6 +149,7 @@ struct sip_msg{
149 149
 	struct hdr_field* last_header; /* pointer to the last parsed header*/
150 150
 	int parsed_flag;
151 151
 	/* via, to, cseq, call-id, from, end of header*/
152
+	/* first occurance of it; subsequent occurances saved in 'headers' */
152 153
 	struct hdr_field* h_via1;
153 154
 	struct hdr_field* h_via2;
154 155
 	struct hdr_field* callid;
Browse code

- small but essential fixes

Andrei Pelinescu-Onciul authored on 30/11/2001 01:03:02
Showing 1 changed files
... ...
@@ -222,7 +222,12 @@ void clean_hdr_field(struct hdr_field* hf);
222 222
 void free_hdr_field_lst(struct hdr_field* hf);
223 223
 void free_sip_msg(struct sip_msg* msg);
224 224
 
225
-int check_transaction_quadruple( struct sip_msg* msg );
225
+/* make sure all HFs needed for transaction identification have been
226
+   parsed; return 0 if those HFs can't be found
227
+ */
228
+#define check_transaction_quadruple(msg ) \
229
+	(parse_headers(msg, HDR_FROM|HDR_TO|HDR_CALLID|HDR_CSEQ)!=-1 && \
230
+	 msg->from && msg->to && msg->callid && msg->cseq)
226 231
 
227 232
 
228 233
 #endif
Browse code

branch transaction labels added

Jiri Kuthan authored on 29/11/2001 19:27:45
Showing 1 changed files
... ...
@@ -29,6 +29,9 @@
29 29
 #define HDR_ROUTE        256
30 30
 #define HDR_OTHER       65536 /*unknown header type*/
31 31
 
32
+/* maximum length of values appended to Via-branch parameter */
33
+#define	MAX_BRANCH_PARAM_LEN	32
34
+
32 35
 /* via param types
33 36
  * WARNING: keep in sync w/ FIN_*, GEN_PARAM and PARAM_ERROR from via_parse.c*/
34 37
 enum{
... ...
@@ -37,6 +40,9 @@ enum{
37 40
 		PARAM_ERROR
38 41
 };
39 42
 
43
+/* casting macro for accessing CSEQ body */
44
+#define get_cseq( p_msg)    ((struct cseq_body*)p_msg->cseq->parsed)
45
+
40 46
 
41 47
 
42 48
 #define INVITE_LEN	6
... ...
@@ -169,6 +175,9 @@ struct sip_msg{
169 175
 	struct lump* repl_add_rm; /* only for localy generated replies !!!*/
170 176
 
171 177
 	str add_to_branch; /* whatever whoever want to append to branch comes here */
178
+	char add_to_branch_s[MAX_BRANCH_PARAM_LEN];
179
+	short add_to_branch_len;
180
+
172 181
 	
173 182
 };
174 183
 
... ...
@@ -213,5 +222,7 @@ void clean_hdr_field(struct hdr_field* hf);
213 222
 void free_hdr_field_lst(struct hdr_field* hf);
214 223
 void free_sip_msg(struct sip_msg* msg);
215 224
 
225
+int check_transaction_quadruple( struct sip_msg* msg );
226
+
216 227
 
217 228
 #endif
Browse code

dded support for appending branch parameters

Jiri Kuthan authored on 29/11/2001 12:49:49
Showing 1 changed files
... ...
@@ -167,6 +167,8 @@ struct sip_msg{
167 167
 
168 168
 	struct lump* add_rm;      /* used for all the forwarded messages */
169 169
 	struct lump* repl_add_rm; /* only for localy generated replies !!!*/
170
+
171
+	str add_to_branch; /* whatever whoever want to append to branch comes here */
170 172
 	
171 173
 };
172 174
 
Browse code

- added branch meber to via_body - added free_via_param_list

Andrei Pelinescu-Onciul authored on 26/11/2001 19:32:07
Showing 1 changed files
... ...
@@ -112,9 +112,12 @@ struct via_body{  /* format: name/version/transport host:port;params comment */
112 112
 	str port_str;
113 113
 	str params;
114 114
 	str comment;
115
+	int bsize;    /* body size, not including hdr */
115 116
 	struct via_param* param_lst; /* list of parameters*/
116 117
 	struct via_param* last_param; /*last via parameter, internal use*/
117
-	int bsize;    /* body size, not including hdr */
118
+	/* shortcuts to "important" params*/
119
+	struct via_param* branch;
120
+	
118 121
 	struct via_body* next; /* pointer to next via body string if
119 122
 							  compact via or null */
120 123
 };
... ...
@@ -202,6 +205,7 @@ char* parse_via(char* buffer, char* end, struct via_body *vb);
202 205
 char* parse_cseq(char* buffer, char* end, struct cseq_body *cb);
203 206
 #endif
204 207
 
208
+void free_via_param_list(struct via_param *vp);
205 209
 void free_via_list(struct via_body *vb);
206 210
 void clean_hdr_field(struct hdr_field* hf);
207 211
 void free_hdr_field_lst(struct hdr_field* hf);
Browse code

- added via_param list to via_body

Andrei Pelinescu-Onciul authored on 26/11/2001 19:13:23
Showing 1 changed files
... ...
@@ -29,6 +29,16 @@
29 29
 #define HDR_ROUTE        256
30 30
 #define HDR_OTHER       65536 /*unknown header type*/
31 31
 
32
+/* via param types
33
+ * WARNING: keep in sync w/ FIN_*, GEN_PARAM and PARAM_ERROR from via_parse.c*/
34
+enum{
35
+		PARAM_HIDDEN=230, PARAM_TTL, PARAM_BRANCH, PARAM_MADDR, PARAM_RECEIVED,
36
+		GEN_PARAM,
37
+		PARAM_ERROR
38
+};
39
+
40
+
41
+
32 42
 #define INVITE_LEN	6
33 43
 #define ACK_LEN		3
34 44
 #define CANCEL_LEN	6
... ...
@@ -81,6 +91,16 @@ struct hdr_field{   /* format: name':' body */
81 91
 	struct hdr_field* next;
82 92
 };
83 93
 
94
+
95
+
96
+struct via_param{
97
+	int type;
98
+	str name;
99
+	str value;
100
+	int size; /* total size*/
101
+	struct via_param* next;
102
+};
103
+
84 104
 struct via_body{  /* format: name/version/transport host:port;params comment */
85 105
 	int error;
86 106
 	str hdr;   /* contains "Via" or "v" */
... ...
@@ -92,6 +112,8 @@ struct via_body{  /* format: name/version/transport host:port;params comment */
92 112
 	str port_str;
93 113
 	str params;
94 114
 	str comment;
115
+	struct via_param* param_lst; /* list of parameters*/
116
+	struct via_param* last_param; /*last via parameter, internal use*/
95 117
 	int bsize;    /* body size, not including hdr */
96 118
 	struct via_body* next; /* pointer to next via body string if
97 119
 							  compact via or null */
... ...
@@ -99,6 +121,8 @@ struct via_body{  /* format: name/version/transport host:port;params comment */
99 121
 
100 122
 
101 123
 
124
+
125
+
102 126
 struct cseq_body{
103 127
 	int error;
104 128
 	str number;
Browse code

- added another first line parser (test only) - default= use new malloc - removed some debugging options

Andrei Pelinescu-Onciul authored on 23/11/2001 18:06:20
Showing 1 changed files
... ...
@@ -154,7 +154,7 @@ struct sip_uri{
154 154
 };
155 155
 
156 156
 
157
-
157
+char* parse_fline(char* buffer, char* end, struct msg_start* fl);
158 158
 char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl);
159 159
 #ifdef OLD_PARSER 
160 160
 char* get_hdr_field(char *buffer, unsigned int len, struct hdr_field*  hdr_f);
Browse code

*** empty log message ***

Andrei Pelinescu-Onciul authored on 23/11/2001 09:15:13
Showing 1 changed files
... ...
@@ -181,6 +181,7 @@ char* parse_cseq(char* buffer, char* end, struct cseq_body *cb);
181 181
 void free_via_list(struct via_body *vb);
182 182
 void clean_hdr_field(struct hdr_field* hf);
183 183
 void free_hdr_field_lst(struct hdr_field* hf);
184
+void free_sip_msg(struct sip_msg* msg);
184 185
 
185 186
 
186 187
 #endif
Browse code

- added cseq_body and prototype cseq parser - fixed some missing #ifdef STATS

Andrei Pelinescu-Onciul authored on 23/11/2001 00:47:19
Showing 1 changed files
... ...
@@ -48,6 +48,8 @@ if (  (*tmp==(firstchar) || *tmp==((firstchar) | 32)) &&                  \
48 48
 
49 49
 #define VIA_PARSE_OK	1
50 50
 #define VIA_PARSE_ERROR -1
51
+#define PARSE_ERROR -1
52
+#define PARSE_OK 1
51 53
 
52 54
 #define SIP_VERSION	"SIP/2.0"
53 55
 #define SIP_VERSION_LEN 7
... ...
@@ -95,6 +97,16 @@ struct via_body{  /* format: name/version/transport host:port;params comment */
95 97
 							  compact via or null */
96 98
 };
97 99
 
100
+
101
+
102
+struct cseq_body{
103
+	int error;
104
+	str number;
105
+	str method;
106
+};
107
+
108
+
109
+
98 110
 struct sip_msg{
99 111
 	unsigned int id; /* message id, unique/process*/
100 112
 	struct msg_start first_line;
... ...
@@ -155,12 +167,15 @@ char* parse_via_body(char* buffer,unsigned int len, struct via_body * vb);
155 167
 #endif
156 168
 int parse_msg(char* buf, unsigned int len, struct sip_msg* msg);
157 169
 int parse_uri(char *buf, int len, struct sip_uri* uri);
170
+int parse_headers(struct sip_msg* msg, int flags);
171
+
158 172
 void free_uri(struct sip_uri* u);
159 173
 
160 174
 
161 175
 #ifndef OLD_PARSER
162 176
 char* parse_hname(char* buf, char* end, struct hdr_field* hdr);
163 177
 char* parse_via(char* buffer, char* end, struct via_body *vb);
178
+char* parse_cseq(char* buffer, char* end, struct cseq_body *cb);
164 179
 #endif
165 180
 
166 181
 void free_via_list(struct via_body *vb);
Browse code

- switched to new via & header parsing - lots of new members added to sip_msg - all headers are parsed - merged with cvs version => compilation errors in receive.c

Andrei Pelinescu-Onciul authored on 22/11/2001 22:32:38
Showing 1 changed files
... ...
@@ -13,10 +13,21 @@
13 13
 #define SIP_INVALID 0
14 14
 
15 15
 
16
-enum {	HDR_EOH=-1, HDR_ERROR=0, HDR_OTHER,
17
-		HDR_VIA, HDR_TO, HDR_FROM, HDR_CSEQ, HDR_CALLID, HDR_CONTACT,
18
-		HDR_MAXFORWARDS, HDR_ROUTE
19
-	};
16
+
17
+/*header types and flags*/
18
+#define HDR_EOH           -1
19
+#define HDR_ERROR          0
20
+#define HDR_VIA            1
21
+#define HDR_VIA1           1
22
+#define HDR_VIA2           2  /*only used as flag*/
23
+#define HDR_TO             4
24
+#define HDR_FROM           8
25
+#define HDR_CSEQ          16
26
+#define HDR_CALLID        32
27
+#define HDR_CONTACT       64
28
+#define HDR_MAXFORWARDS  128
29
+#define HDR_ROUTE        256
30
+#define HDR_OTHER       65536 /*unknown header type*/
20 31
 
21 32
 #define INVITE_LEN	6
22 33
 #define ACK_LEN		3
... ...
@@ -65,6 +76,7 @@ struct hdr_field{   /* format: name':' body */
65 76
 	str name;
66 77
 	str body;
67 78
 	void* parsed;
79
+	struct hdr_field* next;
68 80
 };
69 81
 
70 82
 struct via_body{  /* format: name/version/transport host:port;params comment */
... ...
@@ -78,14 +90,30 @@ struct via_body{  /* format: name/version/transport host:port;params comment */
78 90
 	str port_str;
79 91
 	str params;
80 92
 	str comment;
81
-	int size;    /* full size, including hdr */
82
-	char* next; /* pointer to next via body string if compact via or null */
93
+	int bsize;    /* body size, not including hdr */
94
+	struct via_body* next; /* pointer to next via body string if
95
+							  compact via or null */
83 96
 };
84 97
 
85 98
 struct sip_msg{
99
+	unsigned int id; /* message id, unique/process*/
86 100
 	struct msg_start first_line;
87
-	struct via_body via1;
88
-	struct via_body via2;
101
+	struct via_body* via1;
102
+	struct via_body* via2;
103
+	struct hdr_field* headers; /* all the parsed headers*/
104
+	struct hdr_field* last_header; /* pointer to the last parsed header*/
105
+	int parsed_flag;
106
+	/* via, to, cseq, call-id, from, end of header*/
107
+	struct hdr_field* h_via1;
108
+	struct hdr_field* h_via2;
109
+	struct hdr_field* callid;
110
+	struct hdr_field* to;
111
+	struct hdr_field* cseq;
112
+	struct hdr_field* from;
113
+	struct hdr_field* contact;
114
+	char* eoh; /* pointer to the end of header (if found) or null */
115
+
116
+	char* unparsed; /* here we stopped parsing*/
89 117
 
90 118
 	unsigned int src_ip;
91 119
 	unsigned int dst_ip;
... ...
@@ -135,5 +163,9 @@ char* parse_hname(char* buf, char* end, struct hdr_field* hdr);
135 163
 char* parse_via(char* buffer, char* end, struct via_body *vb);
136 164
 #endif
137 165
 
166
+void free_via_list(struct via_body *vb);
167
+void clean_hdr_field(struct hdr_field* hf);
168
+void free_hdr_field_lst(struct hdr_field* hf);
169
+
138 170
 
139 171
 #endif
Browse code

port numbers different now for remote and local

Jiri Kuthan authored on 20/11/2001 06:26:49
Showing 1 changed files
... ...
@@ -18,7 +18,21 @@ enum {	HDR_EOH=-1, HDR_ERROR=0, HDR_OTHER,
18 18
 		HDR_MAXFORWARDS, HDR_ROUTE
19 19
 	};
20 20
 
21
-
21
+#define INVITE_LEN	6
22
+#define ACK_LEN		3
23
+#define CANCEL_LEN	6
24
+#define BYE_LEN		3
25
+enum { METHOD_OTHER, METHOD_INVITE, METHOD_CANCEL, METHOD_ACK, METHOD_BYE };
26
+
27
+#define IFISMETHOD(methodname,firstchar)                                  \
28
+if (  (*tmp==(firstchar) || *tmp==((firstchar) | 32)) &&                  \
29
+        strncasecmp( tmp+1, #methodname +1, methodname##_LEN-1)==0 &&     \
30
+        *(tmp+methodname##_LEN)==' ') {                                   \
31
+                fl->type=SIP_REQUEST;                                     \
32
+                fl->u.request.method.len=methodname##_LEN;                \
33
+                fl->u.request.method_value=METHOD_##methodname;           \