Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,293 +0,0 @@
1
-/*
2
- * Fast 32-bit Header Field Name Parser
3
- *
4
- * Copyright (C) 2001-2003 FhG Fokus
5
- *
6
- * This file is part of Kamailio, a free SIP server.
7
- *
8
- * Kamailio is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version
12
- *
13
- * Kamailio is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program; if not, write to the Free Software
20
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21
- *
22
- */
23
-
24
-/** Parser :: Fast 32-bit Header Field Name Parser.
25
- * @file
26
- * @ingroup parser
27
- */
28
-
29
-#include "../comp_defs.h"
30
-#include "parse_hname2.h"
31
-#include "keys.h"
32
-#include "../ut.h"  /* q_memchr */
33
-
34
-#define LOWER_BYTE(b) ((b) | 0x20)
35
-#define LOWER_DWORD(d) ((d) | 0x20202020)
36
-
37
-/** Skip all white-chars and return position of the first non-white char.
38
- */
39
-static inline char* skip_ws(char* p, unsigned int size)
40
-{
41
-	char* end;
42
-
43
-	end = p + size;
44
-	for(; p < end; p++) {
45
-		if ((*p != ' ') && (*p != '\t')) return p;
46
-	}
47
-	return p;
48
-}
49
-
50
-/*! \name 
51
- * Parser macros
52
- */
53
-/*@{ */
54
-#include "case_via.h"      /* Via */
55
-#include "case_from.h"     /* From */
56
-#include "case_to.h"       /* To */
57
-#include "case_cseq.h"     /* CSeq */
58
-#include "case_call.h"     /* Call-ID */
59
-#include "case_cont.h"     /* Contact, Content-Type, Content-Length, Content-Purpose,
60
-			    * Content-Action, Content-Disposition */
61
-#include "case_rout.h"     /* Route */
62
-#include "case_max.h"      /* Max-Forwards */
63
-#include "case_reco.h"     /* Record-Route */
64
-#include "case_auth.h"     /* Authorization */
65
-#include "case_expi.h"     /* Expires */
66
-#include "case_prox.h"     /* Proxy-Authorization, Proxy-Require */
67
-#include "case_allo.h"     /* Allow */
68
-#include "case_unsu.h"     /* Unsupported */
69
-#include "case_even.h"     /* Event */
70
-#include "case_sip.h"      /* Sip-If-Match */
71
-#include "case_acce.h"     /* Accept, Accept-Language */
72
-#include "case_orga.h"     /* Organization */
73
-#include "case_prio.h"     /* Priority */
74
-#include "case_subj.h"     /* Subject */
75
-#include "case_user.h"     /* User-Agent */
76
-#include "case_serv.h"     /* Server */
77
-#include "case_supp.h"     /* Supported */
78
-#include "case_dive.h"     /* Diversion */
79
-#include "case_remo.h"     /* Remote-Party-ID */
80
-#include "case_refe.h"     /* Refer-To */
81
-#include "case_sess.h"     /* Session-Expires */
82
-#include "case_reje.h"     /* Reject-Contact */
83
-#include "case_min.h"      /* Min-SE */
84
-#include "case_subs.h"     /* Subscription-State */
85
-#include "case_requ.h"     /* Require */
86
-#include "case_www.h"      /* WWW-Authenticate */
87
-#include "case_date.h"     /* Date */
88
-#include "case_iden.h"     /* Identity, Identity-info */
89
-#include "case_retr.h"     /* Retry-After */
90
-#include "case_path.h"     /* Path */
91
-#include "case_priv.h"
92
-#include "case_reas.h"     /* Reason */
93
-#include "case_p_as.h"     /* P-Asserted-Identity */
94
-#include "case_p_pr.h"     /* P-Preferred-Identity */
95
-
96
-/*@} */
97
-
98
-#define SAFE_READ(val, len) \
99
-((len) == 1 ? READ1(val) : ((len) == 2 ? READ2(val) : ((len) == 3 ? READ3(val) : ((len) > 3 ? READ4(val) : READ0(val)))))
100
-
101
-#define READ(val) \
102
-READ4(val)
103
-
104
-#define READ4(val) \
105
-(*((val) + 0) + (*((val) + 1) << 8) + (*((val) + 2) << 16) + (*((val) + 3) << 24))
106
-
107
-#define READ3(val) \
108
-(*((val) + 0) + (*((val) + 1) << 8) + (*((val) + 2) << 16))
109
-
110
-#define READ2(val) \
111
-(*((val) + 0) + (*((val) + 1) << 8))
112
-
113
-#define READ1(val) \
114
-(*((val) + 0))
115
-
116
-#define READ0(val) \
117
-(0)
118
-
119
-#define FIRST_QUATERNIONS       \
120
-        case _via1_: via1_CASE; \
121
-	case _from_: from_CASE; \
122
-	case _to12_: to12_CASE; \
123
-	case _cseq_: cseq_CASE; \
124
-	case _call_: call_CASE; \
125
-	case _cont_: cont_CASE; \
126
-	case _rout_: rout_CASE; \
127
-	case _max__: max_CASE;  \
128
-	case _reco_: reco_CASE; \
129
-	case _via2_: via2_CASE; \
130
-	case _auth_: auth_CASE; \
131
-	case _supp_: supp_CASE; \
132
-	case _expi_: expi_CASE; \
133
-	case _prox_: prox_CASE; \
134
-	case _allo_: allo_CASE; \
135
-	case _unsu_: unsu_CASE; \
136
-        case _even_: even_CASE; \
137
-        case _sip_ : sip_CASE;  \
138
-        case _acce_: acce_CASE; \
139
-        case _orga_: orga_CASE; \
140
-        case _prio_: prio_CASE; \
141
-        case _subj_: subj_CASE; \
142
-        case _subs_: subs_CASE; \
143
-        case _user_: user_CASE; \
144
-        case _serv_: serv_CASE; \
145
-        case _dive_: dive_CASE; \
146
-        case _remo_: remo_CASE; \
147
-        case _refe_: refe_CASE; \
148
-	case _sess_: sess_CASE; \
149
-	case _reje_: reje_CASE; \
150
-	case _min__: min_CASE;  \
151
-	case _requ_: requ_CASE;  \
152
-	case _www__: www_CASE; \
153
-	case _date_: date_CASE; \
154
-	case _iden_: iden_CASE; \
155
-	case _retr_: retr_CASE; \
156
-	case _path_: path_CASE; \
157
-	case _priv_: priv_CASE; \
158
-	case _reas_: reas_CASE; \
159
-	case _p_as_: p_as_CASE; \
160
-	case _p_pr_: p_pr_CASE;
161
-
162
-
163
-#define PARSE_COMPACT(id)          \
164
-        switch(*(p + 1)) {         \
165
-        case ' ':                  \
166
-	        hdr->type = id;    \
167
-	        p += 2;            \
168
-	        goto dc_end;       \
169
-	                           \
170
-        case ':':                  \
171
-	        hdr->type = id;    \
172
-	        hdr->name.len = 1; \
173
-	        return (p + 2);    \
174
-        }
175
-
176
-char* parse_hname2(char* const begin, const char* const end, struct hdr_field* const hdr)
177
-{
178
-	register char* p;
179
-	register unsigned int val;
180
-
181
-	if ((end - begin) < 4) {
182
-		hdr->type = HDR_ERROR_T;
183
-		return begin;
184
-	}
185
-
186
-	p = begin;
187
-
188
-	val = LOWER_DWORD(READ(p));
189
-	hdr->name.s = begin;
190
-
191
-	switch(val) {
192
-	FIRST_QUATERNIONS;
193
-
194
-	default:
195
-		switch(LOWER_BYTE(*p)) {
196
-		case 't':
197
-			switch(LOWER_BYTE(*(p + 1))) {
198
-			case 'o':
199
-			case ' ':
200
-				hdr->type = HDR_TO_T;
201
-				p += 2;
202
-				goto dc_end;
203
-
204
-			case ':':
205
-				hdr->type = HDR_TO_T;
206
-				hdr->name.len = 1;
207
-				return (p + 2);
208
-			}
209
-			break;
210
-
211
-		case 'v': PARSE_COMPACT(HDR_VIA_T);           break;
212
-		case 'f': PARSE_COMPACT(HDR_FROM_T);          break;
213
-		case 'i': PARSE_COMPACT(HDR_CALLID_T);        break;
214
-		case 'm': PARSE_COMPACT(HDR_CONTACT_T);       break;
215
-		case 'l': PARSE_COMPACT(HDR_CONTENTLENGTH_T); break;
216
-		case 'k': PARSE_COMPACT(HDR_SUPPORTED_T);     break;
217
-		case 'c': PARSE_COMPACT(HDR_CONTENTTYPE_T);   break;
218
-		case 'o': PARSE_COMPACT(HDR_EVENT_T);         break;
219
-		case 'x': PARSE_COMPACT(HDR_SESSIONEXPIRES_T);break;
220
-		case 'a': PARSE_COMPACT(HDR_ACCEPTCONTACT_T); break;
221
-		case 'u': PARSE_COMPACT(HDR_ALLOWEVENTS_T);   break;
222
-		case 'e': PARSE_COMPACT(HDR_CONTENTENCODING_T); break;
223
-		case 'b': PARSE_COMPACT(HDR_REFERREDBY_T);    break;
224
-		case 'j': PARSE_COMPACT(HDR_REJECTCONTACT_T); break;
225
-		case 'd': PARSE_COMPACT(HDR_REQUESTDISPOSITION_T); break;
226
-		case 's': PARSE_COMPACT(HDR_SUBJECT_T);       break;
227
-		case 'r': PARSE_COMPACT(HDR_REFER_TO_T);      break;
228
-		case 'y': PARSE_COMPACT(HDR_IDENTITY_T);      break;
229
-		case 'n': PARSE_COMPACT(HDR_IDENTITY_INFO_T); break;
230
-		}
231
-		goto other;
232
-        }
233
-
234
-	     /* Double colon hasn't been found yet */
235
- dc_end:
236
-       	p = skip_ws(p, end - p);
237
-	if (*p != ':') {
238
-	        goto other;
239
-	} else {
240
-		hdr->name.len = p - hdr->name.s;
241
-		return (p + 1);
242
-	}
243
-
244
-	     /* Unknown header type */
245
- other:
246
-	p = q_memchr(p, ':', end - p);
247
-	if (!p) {        /* No double colon found, error.. */
248
-		hdr->type = HDR_ERROR_T;
249
-		hdr->name.s = 0;
250
-		hdr->name.len = 0;
251
-		return 0;
252
-	} else {
253
-		hdr->type = HDR_OTHER_T;
254
-		hdr->name.len = p - hdr->name.s;
255
-		/*hdr_update_type(hdr);*/
256
-		return (p + 1);
257
-	}
258
-}
259
-
260
-/**
261
- * parse_hname2_short() - safer version to parse header name stored in short buffers
262
- *   - parse_hanem2() reads 4 bytes at once, expecting to walk through a buffer
263
- *   that contains more than the header name (e.g., sip msg buf, full header buf
264
- *   with name and body)
265
- */
266
-char* parse_hname2_short(char* const begin, const char* const end, struct hdr_field* const hdr)
267
-{
268
-#define HBUF_MAX_SIZE 256
269
-	char hbuf[HBUF_MAX_SIZE];
270
-	char *p;
271
-
272
-	if(end-begin>=HBUF_MAX_SIZE-4) {
273
-		p = q_memchr(begin, ':', end - begin);
274
-		if(p && p-4> begin) {
275
-			/* header name termination char found and enough space in buffer after it */
276
-			return parse_hname2(begin, end, hdr);
277
-		}
278
-		/* not enough space */
279
-		LM_ERR("not enough space to parse the header name in [%.*s] (%d)\n",
280
-				(int)(end-begin), begin, (int)(end-begin));
281
-		return NULL;
282
-	}
283
-	/* pad with whitespace - tipycal char after the ':' of the header name */
284
-	memset(hbuf, ' ', HBUF_MAX_SIZE);
285
-	memcpy(hbuf, begin, end-begin);
286
-	p = parse_hname2(hbuf, hbuf + 4 + (end-begin), hdr);
287
-	if(!p) {
288
-		LM_ERR("failed to parse the header name in [%.*s] (%d)\n",
289
-				(int)(end-begin), begin, (int)(end-begin));
290
-		return NULL;
291
-	}
292
-	return begin + (p-hbuf);
293
-}
Browse code

parse: more log messages in case of errors in parse_hname2_short()

Daniel-Constantin Mierla authored on 15/09/2015 11:08:53
Showing 1 changed files
... ...
@@ -276,12 +276,18 @@ char* parse_hname2_short(char* const begin, const char* const end, struct hdr_fi
276 276
 			return parse_hname2(begin, end, hdr);
277 277
 		}
278 278
 		/* not enough space */
279
+		LM_ERR("not enough space to parse the header name in [%.*s] (%d)\n",
280
+				(int)(end-begin), begin, (int)(end-begin));
279 281
 		return NULL;
280 282
 	}
281 283
 	/* pad with whitespace - tipycal char after the ':' of the header name */
282 284
 	memset(hbuf, ' ', HBUF_MAX_SIZE);
283 285
 	memcpy(hbuf, begin, end-begin);
284 286
 	p = parse_hname2(hbuf, hbuf + 4 + (end-begin), hdr);
285
-	if(!p) return NULL;
287
+	if(!p) {
288
+		LM_ERR("failed to parse the header name in [%.*s] (%d)\n",
289
+				(int)(end-begin), begin, (int)(end-begin));
290
+		return NULL;
291
+	}
286 292
 	return begin + (p-hbuf);
287 293
 }
Browse code

parser: fix start of search for long header names

- in parse_hname2_short(), used only for mod fixups, in the case header
name given as function param was greater than 250 chars

Daniel-Constantin Mierla authored on 08/09/2015 15:28:40
Showing 1 changed files
... ...
@@ -270,7 +270,7 @@ char* parse_hname2_short(char* const begin, const char* const end, struct hdr_fi
270 270
 	char *p;
271 271
 
272 272
 	if(end-begin>=HBUF_MAX_SIZE-4) {
273
-		p = q_memchr(p, ':', end - begin);
273
+		p = q_memchr(begin, ':', end - begin);
274 274
 		if(p && p-4> begin) {
275 275
 			/* header name termination char found and enough space in buffer after it */
276 276
 			return parse_hname2(begin, end, hdr);
Browse code

parser: fix overflow access when parsing Reason header stored in short buffer

- it can happen for fixup functions from textops module having header
name as a parameter, with critical impact when using system malloc,
the internal pkg malloc does a roundup of the allocated space
- the issue is caused by the word (4 bytes) read step performed by
parse_hname2() - second 4-byte read in buffer "Reason:" exceeds the
size by 1
- added a safe read macro that reads 1, 2 or 3 bytes if the size of the
buffer is not big enough for a 4 bytes read

Chris Double authored on 02/09/2015 11:15:37 • Daniel-Constantin Mierla committed on 02/09/2015 11:15:37
Showing 1 changed files
... ...
@@ -95,11 +95,26 @@ static inline char* skip_ws(char* p, unsigned int size)
95 95
 
96 96
 /*@} */
97 97
 
98
+#define SAFE_READ(val, len) \
99
+((len) == 1 ? READ1(val) : ((len) == 2 ? READ2(val) : ((len) == 3 ? READ3(val) : ((len) > 3 ? READ4(val) : READ0(val)))))
100
+
98 101
 #define READ(val) \
99
-(*(val + 0) + (*(val + 1) << 8) + (*(val + 2) << 16) + (*(val + 3) << 24))
102
+READ4(val)
103
+
104
+#define READ4(val) \
105
+(*((val) + 0) + (*((val) + 1) << 8) + (*((val) + 2) << 16) + (*((val) + 3) << 24))
100 106
 
101 107
 #define READ3(val) \
102
-(*(val + 0) + (*(val + 1) << 8) + (*(val + 2) << 16))
108
+(*((val) + 0) + (*((val) + 1) << 8) + (*((val) + 2) << 16))
109
+
110
+#define READ2(val) \
111
+(*((val) + 0) + (*((val) + 1) << 8))
112
+
113
+#define READ1(val) \
114
+(*((val) + 0))
115
+
116
+#define READ0(val) \
117
+(0)
103 118
 
104 119
 #define FIRST_QUATERNIONS       \
105 120
         case _via1_: via1_CASE; \
Browse code

parser: safer function to parse header name stored in short buffer

Daniel-Constantin Mierla authored on 02/09/2015 11:07:45
Showing 1 changed files
... ...
@@ -242,3 +242,31 @@ char* parse_hname2(char* const begin, const char* const end, struct hdr_field* c
242 242
 	}
243 243
 }
244 244
 
245
+/**
246
+ * parse_hname2_short() - safer version to parse header name stored in short buffers
247
+ *   - parse_hanem2() reads 4 bytes at once, expecting to walk through a buffer
248
+ *   that contains more than the header name (e.g., sip msg buf, full header buf
249
+ *   with name and body)
250
+ */
251
+char* parse_hname2_short(char* const begin, const char* const end, struct hdr_field* const hdr)
252
+{
253
+#define HBUF_MAX_SIZE 256
254
+	char hbuf[HBUF_MAX_SIZE];
255
+	char *p;
256
+
257
+	if(end-begin>=HBUF_MAX_SIZE-4) {
258
+		p = q_memchr(p, ':', end - begin);
259
+		if(p && p-4> begin) {
260
+			/* header name termination char found and enough space in buffer after it */
261
+			return parse_hname2(begin, end, hdr);
262
+		}
263
+		/* not enough space */
264
+		return NULL;
265
+	}
266
+	/* pad with whitespace - tipycal char after the ':' of the header name */
267
+	memset(hbuf, ' ', HBUF_MAX_SIZE);
268
+	memcpy(hbuf, begin, end-begin);
269
+	p = parse_hname2(hbuf, hbuf + 4 + (end-begin), hdr);
270
+	if(!p) return NULL;
271
+	return begin + (p-hbuf);
272
+}
Browse code

core parser - remove svn ID, remove history, change "ser" => "Kamailio"

Olle E. Johansson authored on 18/01/2015 19:36:18
Showing 1 changed files
... ...
@@ -3,19 +3,14 @@
3 3
  *
4 4
  * Copyright (C) 2001-2003 FhG Fokus
5 5
  *
6
- * This file is part of ser, a free SIP server.
6
+ * This file is part of Kamailio, a free SIP server.
7 7
  *
8
- * ser is free software; you can redistribute it and/or modify
8
+ * Kamailio is free software; you can redistribute it and/or modify
9 9
  * it under the terms of the GNU General Public License as published by
10 10
  * the Free Software Foundation; either version 2 of the License, or
11 11
  * (at your option) any later version
12 12
  *
13
- * For a license to use the ser software under conditions
14
- * other than those described here, or to purchase support for this
15
- * software, please contact iptel.org by e-mail at the following addresses:
16
- *    info@iptel.org
17
- *
18
- * ser is distributed in the hope that it will be useful,
13
+ * Kamailio is distributed in the hope that it will be useful,
19 14
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 16
  * GNU General Public License for more details.
... ...
@@ -24,13 +19,6 @@
24 19
  * along with this program; if not, write to the Free Software
25 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
26 21
  *
27
- * History:
28
- * --------
29
- * 2003-02-28 scratchpad compatibility abandoned (jiri)
30
- * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
31
- * 2003-05-01 added support for Accept HF (janakj)
32
- * 2007-01-26 Date, Identity, Identity_info HF support added (gergo)
33
- * 2007-07-27 added support for Retry-After (andrei)
34 22
  */
35 23
 
36 24
 /** Parser :: Fast 32-bit Header Field Name Parser.
Browse code

all: updated FSF address in GPL text

Anthony Messina authored on 04/07/2014 09:36:37 • Daniel-Constantin Mierla committed on 04/07/2014 09:37:36
Showing 1 changed files
... ...
@@ -22,7 +22,7 @@
22 22
  *
23 23
  * You should have received a copy of the GNU General Public License
24 24
  * along with this program; if not, write to the Free Software
25
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
26 26
  *
27 27
  * History:
28 28
  * --------
Browse code

parser: remove old $Id$ docs header from subversion times, not usable anymore

Henning Westerholt authored on 05/07/2012 21:39:51
Showing 1 changed files
... ...
@@ -1,6 +1,4 @@
1 1
 /*
2
- * $Id$
3
- *
4 2
  * Fast 32-bit Header Field Name Parser
5 3
  *
6 4
  * Copyright (C) 2001-2003 FhG Fokus
Browse code

parser: remove two blocks of old code, commented some years ago

Henning Westerholt authored on 05/07/2012 20:40:45
Showing 1 changed files
... ...
@@ -172,26 +172,6 @@ static inline char* skip_ws(char* p, unsigned int size)
172 172
 	        return (p + 2);    \
173 173
         }
174 174
 
175
-#if 0
176
-int hdr_update_type(struct hdr_field* hdr)
177
-{
178
-	if(hdr==0 || hdr->name.s==0)
179
-		return -1;
180
-	switch(hdr->name.len) {
181
-		case 19:
182
-			if(strncasecmp(hdr->name.s, "P-Asserted-Identity", 19)==0)
183
-				hdr->type = HDR_PAI_T;
184
-		break;
185
-		case 20:
186
-			if(strncasecmp(hdr->name.s, "P-Preferred-Identity", 20)==0)
187
-				hdr->type = HDR_PPI_T;
188
-		break;
189
-	}
190
-
191
-	return 0;
192
-}
193
-#endif
194
-
195 175
 char* parse_hname2(char* const begin, const char* const end, struct hdr_field* const hdr)
196 176
 {
197 177
 	register char* p;
Browse code

parser: make get_hdr_field(..) and necessary called functions const-correct

Henning Westerholt authored on 05/07/2012 20:35:22
Showing 1 changed files
... ...
@@ -192,7 +192,7 @@ int hdr_update_type(struct hdr_field* hdr)
192 192
 }
193 193
 #endif
194 194
 
195
-char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
195
+char* parse_hname2(char* const begin, const char* const end, struct hdr_field* const hdr)
196 196
 {
197 197
 	register char* p;
198 198
 	register unsigned int val;
Browse code

core: PAI & PPI header names parser fixes

Changed to the usual "case" construct. This also fixes the case
when spaces were present between the header name and ':'
(e.g. "P-Preferred-Identity : ..." was not recognized).

Andrei Pelinescu-Onciul authored on 19/02/2010 10:55:44
Showing 1 changed files
... ...
@@ -103,7 +103,9 @@ static inline char* skip_ws(char* p, unsigned int size)
103 103
 #include "case_retr.h"     /* Retry-After */
104 104
 #include "case_path.h"     /* Path */
105 105
 #include "case_priv.h"
106
-#include "case_reas.h"
106
+#include "case_reas.h"     /* Reason */
107
+#include "case_p_as.h"     /* P-Asserted-Identity */
108
+#include "case_p_pr.h"     /* P-Preferred-Identity */
107 109
 
108 110
 /*@} */
109 111
 
... ...
@@ -152,7 +154,9 @@ static inline char* skip_ws(char* p, unsigned int size)
152 154
 	case _retr_: retr_CASE; \
153 155
 	case _path_: path_CASE; \
154 156
 	case _priv_: priv_CASE; \
155
-	case _reas_: reas_CASE;
157
+	case _reas_: reas_CASE; \
158
+	case _p_as_: p_as_CASE; \
159
+	case _p_pr_: p_pr_CASE;
156 160
 
157 161
 
158 162
 #define PARSE_COMPACT(id)          \
... ...
@@ -168,7 +172,7 @@ static inline char* skip_ws(char* p, unsigned int size)
168 172
 	        return (p + 2);    \
169 173
         }
170 174
 
171
-
175
+#if 0
172 176
 int hdr_update_type(struct hdr_field* hdr)
173 177
 {
174 178
 	if(hdr==0 || hdr->name.s==0)
... ...
@@ -186,6 +190,7 @@ int hdr_update_type(struct hdr_field* hdr)
186 190
 
187 191
 	return 0;
188 192
 }
193
+#endif
189 194
 
190 195
 char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
191 196
 {
... ...
@@ -266,7 +271,7 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
266 271
 	} else {
267 272
 		hdr->type = HDR_OTHER_T;
268 273
 		hdr->name.len = p - hdr->name.s;
269
-		hdr_update_type(hdr);
274
+		/*hdr_update_type(hdr);*/
270 275
 		return (p + 1);
271 276
 	}
272 277
 }
Browse code

core: support for parsing the Reason header

Andrei Pelinescu-Onciul authored on 18/02/2010 20:20:07
Showing 1 changed files
... ...
@@ -35,10 +35,9 @@
35 35
  * 2007-07-27 added support for Retry-After (andrei)
36 36
  */
37 37
 
38
-/*! \file
39
- * \brief Parser :: Fast 32-bit Header Field Name Parser
40
- *
41
- * \ingroup parser
38
+/** Parser :: Fast 32-bit Header Field Name Parser.
39
+ * @file
40
+ * @ingroup parser
42 41
  */
43 42
 
44 43
 #include "../comp_defs.h"
... ...
@@ -49,9 +48,7 @@
49 48
 #define LOWER_BYTE(b) ((b) | 0x20)
50 49
 #define LOWER_DWORD(d) ((d) | 0x20202020)
51 50
 
52
-/*! \brief
53
- * Skip all white-chars and return position of the first
54
- * non-white char
51
+/** Skip all white-chars and return position of the first non-white char.
55 52
  */
56 53
 static inline char* skip_ws(char* p, unsigned int size)
57 54
 {
... ...
@@ -106,6 +103,7 @@ static inline char* skip_ws(char* p, unsigned int size)
106 103
 #include "case_retr.h"     /* Retry-After */
107 104
 #include "case_path.h"     /* Path */
108 105
 #include "case_priv.h"
106
+#include "case_reas.h"
109 107
 
110 108
 /*@} */
111 109
 
... ...
@@ -152,8 +150,9 @@ static inline char* skip_ws(char* p, unsigned int size)
152 150
 	case _date_: date_CASE; \
153 151
 	case _iden_: iden_CASE; \
154 152
 	case _retr_: retr_CASE; \
155
-    case _path_: path_CASE; \
156
-	case _priv_: priv_CASE;
153
+	case _path_: path_CASE; \
154
+	case _priv_: priv_CASE; \
155
+	case _reas_: reas_CASE;
157 156
 
158 157
 
159 158
 #define PARSE_COMPACT(id)          \
Browse code

Merge remote branch 'origin/sr_3.0'

latest sr_3.0 fixes.

* origin/sr_3.0: (36 commits)
core: added id to every field of gw table schema
tcp: use the forced socket ip as source
tmx: pv_t_copy_msg: copy also the send flags
textops(k): msg_apply_changes: preserve the send flags
seas: use set_force_socket()
rr(k): use set_force_socket()
registrar(k): use set_force_socket()
pv: use set_force_socket()
kex: use set_force_socket()
domainpolicy: use set_force_socket()
rr(s): use set_force_socket()
registrar(s): use set_force_socket()
tm: use set_force_socket() instead of msg->force_send_socket
tm: preserve forced sockets and send flags during dns failover
core: extra flag when forcing a socket
core: kamailio mode config parser fix
core: PAI and PPI parsing support fixed
core: dset minor cleanups
core: append_branch() sets also the send_socket, path & flags
remove extra backslash in make modules-doc action
...

Andrei Pelinescu-Onciul authored on 06/11/2009 07:56:40
Showing 0 changed files
Browse code

core: PAI and PPI parsing support fixed

- use a new function to identify hdr type instead of 'case' construct
- reported by Juha Heinanen
(cherry picked from commit 78f069c3726085902101a55d3bb98f0be7549b60)

Daniel-Constantin Mierla authored on 01/11/2009 13:06:04 • Juha Heinanen committed on 01/11/2009 12:50:42
Showing 1 changed files
... ...
@@ -163,6 +163,24 @@ static inline char* skip_ws(char* p, unsigned int size)
163 163
         }
164 164
 
165 165
 
166
+int hdr_update_type(struct hdr_field* hdr)
167
+{
168
+	if(hdr==0 || hdr->name.s==0)
169
+		return -1;
170
+	switch(hdr->name.len) {
171
+		case 19:
172
+			if(strncasecmp(hdr->name.s, "P-Asserted-Identity", 19)==0)
173
+				hdr->type = HDR_PAI_T;
174
+		break;
175
+		case 20:
176
+			if(strncasecmp(hdr->name.s, "P-Preferred-Identity", 20)==0)
177
+				hdr->type = HDR_PPI_T;
178
+		break;
179
+	}
180
+
181
+	return 0;
182
+}
183
+
166 184
 char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
167 185
 {
168 186
 	register char* p;
... ...
@@ -242,6 +260,8 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
242 260
 	} else {
243 261
 		hdr->type = HDR_OTHER_T;
244 262
 		hdr->name.len = p - hdr->name.s;
263
+		hdr_update_type(hdr);
245 264
 		return (p + 1);
246 265
 	}
247 266
 }
267
+
Browse code

Fix bad doxygen formatting of groups

oej authored on 25/10/2009 18:31:44
Showing 1 changed files
... ...
@@ -67,7 +67,7 @@ static inline char* skip_ws(char* p, unsigned int size)
67 67
 /*! \name 
68 68
  * Parser macros
69 69
  */
70
-/*! { */
70
+/*@{ */
71 71
 #include "case_via.h"      /* Via */
72 72
 #include "case_from.h"     /* From */
73 73
 #include "case_to.h"       /* To */
... ...
@@ -107,7 +107,7 @@ static inline char* skip_ws(char* p, unsigned int size)
107 107
 #include "case_path.h"     /* Path */
108 108
 #include "case_priv.h"
109 109
 
110
-/*! } */
110
+/*@} */
111 111
 
112 112
 #define READ(val) \
113 113
 (*(val + 0) + (*(val + 1) << 8) + (*(val + 2) << 16) + (*(val + 3) << 24))
Browse code

Doxygen changes

oej authored on 25/10/2009 18:30:31
Showing 1 changed files
... ...
@@ -35,6 +35,11 @@
35 35
  * 2007-07-27 added support for Retry-After (andrei)
36 36
  */
37 37
 
38
+/*! \file
39
+ * \brief Parser :: Fast 32-bit Header Field Name Parser
40
+ *
41
+ * \ingroup parser
42
+ */
38 43
 
39 44
 #include "../comp_defs.h"
40 45
 #include "parse_hname2.h"
... ...
@@ -44,7 +49,7 @@
44 49
 #define LOWER_BYTE(b) ((b) | 0x20)
45 50
 #define LOWER_DWORD(d) ((d) | 0x20202020)
46 51
 
47
-/*
52
+/*! \brief
48 53
  * Skip all white-chars and return position of the first
49 54
  * non-white char
50 55
  */
... ...
@@ -59,9 +64,10 @@ static inline char* skip_ws(char* p, unsigned int size)
59 64
 	return p;
60 65
 }
61 66
 
62
-/*
67
+/*! \name 
63 68
  * Parser macros
64 69
  */
70
+/*! { */
65 71
 #include "case_via.h"      /* Via */
66 72
 #include "case_from.h"     /* From */
67 73
 #include "case_to.h"       /* To */
... ...
@@ -101,6 +107,7 @@ static inline char* skip_ws(char* p, unsigned int size)
101 107
 #include "case_path.h"     /* Path */
102 108
 #include "case_priv.h"
103 109
 
110
+/*! } */
104 111
 
105 112
 #define READ(val) \
106 113
 (*(val + 0) + (*(val + 1) << 8) + (*(val + 2) << 16) + (*(val + 3) << 24))
Browse code

Kamailio compatibility: Privacy header field name parser

This patch adds support for the Privacy header field name parser.

Jan Janak authored on 27/03/2009 07:59:37
Showing 1 changed files
... ...
@@ -99,6 +99,7 @@ static inline char* skip_ws(char* p, unsigned int size)
99 99
 #include "case_iden.h"     /* Identity, Identity-info */
100 100
 #include "case_retr.h"     /* Retry-After */
101 101
 #include "case_path.h"     /* Path */
102
+#include "case_priv.h"
102 103
 
103 104
 
104 105
 #define READ(val) \
... ...
@@ -144,8 +145,8 @@ static inline char* skip_ws(char* p, unsigned int size)
144 145
 	case _date_: date_CASE; \
145 146
 	case _iden_: iden_CASE; \
146 147
 	case _retr_: retr_CASE; \
147
-    case _path_: path_CASE;
148
-
148
+    case _path_: path_CASE; \
149
+	case _priv_: priv_CASE;
149 150
 
150 151
 
151 152
 #define PARSE_COMPACT(id)          \
Browse code

Teach sip-router how to recognized Path header field name.

Jan Janak authored on 16/03/2009 17:49:27
Showing 1 changed files
... ...
@@ -98,6 +98,7 @@ static inline char* skip_ws(char* p, unsigned int size)
98 98
 #include "case_date.h"     /* Date */
99 99
 #include "case_iden.h"     /* Identity, Identity-info */
100 100
 #include "case_retr.h"     /* Retry-After */
101
+#include "case_path.h"     /* Path */
101 102
 
102 103
 
103 104
 #define READ(val) \
... ...
@@ -143,6 +144,7 @@ static inline char* skip_ws(char* p, unsigned int size)
143 144
 	case _date_: date_CASE; \
144 145
 	case _iden_: iden_CASE; \
145 146
 	case _retr_: retr_CASE; \
147
+    case _path_: path_CASE;
146 148
 
147 149
 
148 150
 
Browse code

- added support for parsing the Retry-After header

Andrei Pelinescu-Onciul authored on 30/07/2007 19:49:09
Showing 1 changed files
... ...
@@ -32,6 +32,7 @@
32 32
  * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
33 33
  * 2003-05-01 added support for Accept HF (janakj)
34 34
  * 2007-01-26 Date, Identity, Identity_info HF support added (gergo)
35
+ * 2007-07-27 added support for Retry-After (andrei)
35 36
  */
36 37
 
37 38
 
... ...
@@ -96,6 +97,7 @@ static inline char* skip_ws(char* p, unsigned int size)
96 97
 #include "case_www.h"      /* WWW-Authenticate */
97 98
 #include "case_date.h"     /* Date */
98 99
 #include "case_iden.h"     /* Identity, Identity-info */
100
+#include "case_retr.h"     /* Retry-After */
99 101
 
100 102
 
101 103
 #define READ(val) \
... ...
@@ -140,6 +142,7 @@ static inline char* skip_ws(char* p, unsigned int size)
140 142
 	case _www__: www_CASE; \
141 143
 	case _date_: date_CASE; \
142 144
 	case _iden_: iden_CASE; \
145
+	case _retr_: retr_CASE; \
143 146
 
144 147
 
145 148
 
Browse code

Hook up Server header field support.

Maxim Sobolev authored on 01/05/2007 21:25:53
Showing 1 changed files
... ...
@@ -83,6 +83,7 @@ static inline char* skip_ws(char* p, unsigned int size)
83 83
 #include "case_prio.h"     /* Priority */
84 84
 #include "case_subj.h"     /* Subject */
85 85
 #include "case_user.h"     /* User-Agent */
86
+#include "case_serv.h"     /* Server */
86 87
 #include "case_supp.h"     /* Supported */
87 88
 #include "case_dive.h"     /* Diversion */
88 89
 #include "case_remo.h"     /* Remote-Party-ID */
... ...
@@ -128,6 +129,7 @@ static inline char* skip_ws(char* p, unsigned int size)
128 129
         case _subj_: subj_CASE; \
129 130
         case _subs_: subs_CASE; \
130 131
         case _user_: user_CASE; \
132
+        case _serv_: serv_CASE; \
131 133
         case _dive_: dive_CASE; \
132 134
         case _remo_: remo_CASE; \
133 135
         case _refe_: refe_CASE; \
Browse code

Date, Identity, Identity-info HF support added

Gergely Kovacs authored on 08/03/2007 14:56:10
Showing 1 changed files
... ...
@@ -31,6 +31,7 @@
31 31
  * 2003-02-28 scratchpad compatibility abandoned (jiri)
32 32
  * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
33 33
  * 2003-05-01 added support for Accept HF (janakj)
34
+ * 2007-01-26 Date, Identity, Identity_info HF support added (gergo)
34 35
  */
35 36
 
36 37
 
... ...
@@ -92,6 +93,8 @@ static inline char* skip_ws(char* p, unsigned int size)
92 93
 #include "case_subs.h"     /* Subscription-State */
93 94
 #include "case_requ.h"     /* Require */
94 95
 #include "case_www.h"      /* WWW-Authenticate */
96
+#include "case_date.h"     /* Date */
97
+#include "case_iden.h"     /* Identity, Identity-info */
95 98
 
96 99
 
97 100
 #define READ(val) \
... ...
@@ -133,6 +136,8 @@ static inline char* skip_ws(char* p, unsigned int size)
133 136
 	case _min__: min_CASE;  \
134 137
 	case _requ_: requ_CASE;  \
135 138
 	case _www__: www_CASE; \
139
+	case _date_: date_CASE; \
140
+	case _iden_: iden_CASE; \
136 141
 
137 142
 
138 143
 
... ...
@@ -202,6 +207,8 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
202 207
 		case 'd': PARSE_COMPACT(HDR_REQUESTDISPOSITION_T); break;
203 208
 		case 's': PARSE_COMPACT(HDR_SUBJECT_T);       break;
204 209
 		case 'r': PARSE_COMPACT(HDR_REFER_TO_T);      break;
210
+		case 'y': PARSE_COMPACT(HDR_IDENTITY_T);      break;
211
+		case 'n': PARSE_COMPACT(HDR_IDENTITY_INFO_T); break;
205 212
 		}
206 213
 		goto other;
207 214
         }
Browse code

- tm: aggregate challenges (WWW/Proxy-Authenticate) from all the 401 & 407 if the final reply is a 401/407 (required by rfc3261). To turn this off and fall back to the old behaviour set tm aggregate_challenges parameter to 0 (see tm docs for more details) - core: header parse support for WWW-Authenticate and Proxy-Authenticate

Andrei Pelinescu-Onciul authored on 16/10/2006 18:44:01
Showing 1 changed files
... ...
@@ -91,11 +91,14 @@ static inline char* skip_ws(char* p, unsigned int size)
91 91
 #include "case_min.h"      /* Min-SE */
92 92
 #include "case_subs.h"     /* Subscription-State */
93 93
 #include "case_requ.h"     /* Require */
94
+#include "case_www.h"      /* WWW-Authenticate */
94 95
 
95 96
 
96 97
 #define READ(val) \
97 98
 (*(val + 0) + (*(val + 1) << 8) + (*(val + 2) << 16) + (*(val + 3) << 24))
98 99
 
100
+#define READ3(val) \
101
+(*(val + 0) + (*(val + 1) << 8) + (*(val + 2) << 16))
99 102
 
100 103
 #define FIRST_QUATERNIONS       \
101 104
         case _via1_: via1_CASE; \
... ...
@@ -129,6 +132,7 @@ static inline char* skip_ws(char* p, unsigned int size)
129 132
 	case _reje_: reje_CASE; \
130 133
 	case _min__: min_CASE;  \
131 134
 	case _requ_: requ_CASE;  \
135
+	case _www__: www_CASE; \
132 136
 
133 137
 
134 138
 
Browse code

added parsing of Require header field

Vaclav Kubart authored on 23/06/2006 08:51:37
Showing 1 changed files
... ...
@@ -90,6 +90,7 @@ static inline char* skip_ws(char* p, unsigned int size)
90 90
 #include "case_reje.h"     /* Reject-Contact */
91 91
 #include "case_min.h"      /* Min-SE */
92 92
 #include "case_subs.h"     /* Subscription-State */
93
+#include "case_requ.h"     /* Require */
93 94
 
94 95
 
95 96
 #define READ(val) \
... ...
@@ -127,6 +128,7 @@ static inline char* skip_ws(char* p, unsigned int size)
127 128
 	case _sess_: sess_CASE; \
128 129
 	case _reje_: reje_CASE; \
129 130
 	case _min__: min_CASE;  \
131
+	case _requ_: requ_CASE;  \
130 132
 
131 133
 
132 134
 
Browse code

added Subscription-State header field parsing (only needed parts)

Vaclav Kubart authored on 21/06/2006 13:33:01
Showing 1 changed files
... ...
@@ -89,6 +89,7 @@ static inline char* skip_ws(char* p, unsigned int size)
89 89
 #include "case_sess.h"     /* Session-Expires */
90 90
 #include "case_reje.h"     /* Reject-Contact */
91 91
 #include "case_min.h"      /* Min-SE */
92
+#include "case_subs.h"     /* Subscription-State */
92 93
 
93 94
 
94 95
 #define READ(val) \
... ...
@@ -118,6 +119,7 @@ static inline char* skip_ws(char* p, unsigned int size)
118 119
         case _orga_: orga_CASE; \
119 120
         case _prio_: prio_CASE; \
120 121
         case _subj_: subj_CASE; \
122
+        case _subs_: subs_CASE; \
121 123
         case _user_: user_CASE; \
122 124
         case _dive_: dive_CASE; \
123 125
         case _remo_: remo_CASE; \
Browse code

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

Tomas Mandys authored on 21/06/2006 08:18:53
Showing 1 changed files
... ...
@@ -88,6 +88,7 @@ static inline char* skip_ws(char* p, unsigned int size)
88 88
 #include "case_refe.h"     /* Refer-To */
89 89
 #include "case_sess.h"     /* Session-Expires */
90 90
 #include "case_reje.h"     /* Reject-Contact */
91
+#include "case_min.h"      /* Min-SE */
91 92
 
92 93
 
93 94
 #define READ(val) \
... ...
@@ -123,6 +124,7 @@ static inline char* skip_ws(char* p, unsigned int size)
123 124
         case _refe_: refe_CASE; \
124 125
 	case _sess_: sess_CASE; \
125 126
 	case _reje_: reje_CASE; \
127
+	case _min__: min_CASE;  \
126 128
 
127 129
 
128 130
 
Browse code

- adjusted compact headers. There were missing compact equivalents for Subject, Refer-To and completely missing Session-Expires, Accept-Contact, etc. support. Currently I've implemented both compact header and case switches to assign enumeration type. No next parsing is processed, but probably will be done, good candidate e.g. Session-Expires.

Now e.g. textops hf_value correctly recognizes "Session-Expires" and "x" as equal headers.

Tomas Mandys authored on 18/06/2006 23:15:22
Showing 1 changed files
... ...
@@ -1,5 +1,5 @@
1
-/* 
2
- * $Id$ 
1
+/*
2
+ * $Id$
3 3
  *
4 4
  * Fast 32-bit Header Field Name Parser
5 5
  *
... ...
@@ -22,8 +22,8 @@
22 22
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 23
  * GNU General Public License for more details.
24 24
  *
25
- * You should have received a copy of the GNU General Public License 
26
- * along with this program; if not, write to the Free Software 
25
+ * You should have received a copy of the GNU General Public License
26
+ * along with this program; if not, write to the Free Software
27 27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28 28
  *
29 29
  * History:
... ...
@@ -49,14 +49,14 @@
49 49
 static inline char* skip_ws(char* p, unsigned int size)
50 50
 {
51 51
 	char* end;
52
-	
52
+
53 53
 	end = p + size;
54 54
 	for(; p < end; p++) {
55 55
 		if ((*p != ' ') && (*p != '\t')) return p;
56 56
 	}
57 57
 	return p;
58 58
 }
59
-	
59
+
60 60
 /*
61 61
  * Parser macros
62 62
  */
... ...
@@ -65,7 +65,7 @@ static inline char* skip_ws(char* p, unsigned int size)
65 65
 #include "case_to.h"       /* To */
66 66
 #include "case_cseq.h"     /* CSeq */
67 67
 #include "case_call.h"     /* Call-ID */
68
-#include "case_cont.h"     /* Contact, Content-Type, Content-Length, Content-Purpose, 
68
+#include "case_cont.h"     /* Contact, Content-Type, Content-Length, Content-Purpose,
69 69
 			    * Content-Action, Content-Disposition */
70 70
 #include "case_rout.h"     /* Route */
71 71
 #include "case_max.h"      /* Max-Forwards */
... ...
@@ -86,6 +86,8 @@ static inline char* skip_ws(char* p, unsigned int size)
86 86
 #include "case_dive.h"     /* Diversion */
87 87
 #include "case_remo.h"     /* Remote-Party-ID */