Browse code

- added support for parsing the Retry-After header

Andrei Pelinescu-Onciul authored on 30/07/2007 19:49:09
Showing 8 changed files
... ...
@@ -76,7 +76,7 @@ MAIN_NAME=ser
76 76
 VERSION = 2
77 77
 PATCHLEVEL = 1
78 78
 SUBLEVEL =  0
79
-EXTRAVERSION = -dev9-dns
79
+EXTRAVERSION = -dev10
80 80
 
81 81
 SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
82 82
 			$(SUBLEVEL) )
... ...
@@ -361,6 +361,7 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
361 361
 		case HDR_RECORDROUTE_T:
362 362
 		case HDR_CONTENTTYPE_T:
363 363
 		case HDR_CONTENTLENGTH_T:
364
+		case HDR_RETRY_AFTER_T:
364 365
 		case HDR_EXPIRES_T:
365 366
 		case HDR_SUPPORTED_T:
366 367
 		case HDR_REQUIRE_T:
... ...
@@ -538,6 +539,7 @@ do { \
538 539
 		case HDR_DATE_T:
539 540
 		case HDR_IDENTITY_T:
540 541
 		case HDR_IDENTITY_INFO_T:
542
+		case HDR_RETRY_AFTER_T:
541 543
 			break;
542 544
 
543 545
 		case HDR_VIA_T:
... ...
@@ -30,6 +30,7 @@
30 30
  * 2003-04-26 ZSW (jiri)
31 31
  * 2003-08-05 free the parsed part of Accept header (bogdan)
32 32
  * 2007-01-26 HDR_DATE_T, HDR_IDENTITY_T, HDR_IDENTITY_INFO_T added (gergo)
33
+ * 2007-07-27 added HDR_RETRY_AFTER_T (andrei)
33 34
  */
34 35
 
35 36
 
... ...
@@ -107,6 +108,9 @@ void clean_hdr_field(struct hdr_field* hf)
107 108
 		case HDR_CONTENTLENGTH_T:
108 109
 			break;
109 110
 
111
+		case HDR_RETRY_AFTER_T:
112
+			break;
113
+
110 114
 		case HDR_AUTHORIZATION_T:
111 115
 			free_credentials((auth_body_t**)h_parsed);
112 116
 			break;
... ...
@@ -32,6 +32,7 @@
32 32
  * 2005-02-14 hdr_flags_t && hdr_flags_f defined, split HDR_xxx into
33 33
  *             HDR_xxx_F & HDR_xxx_T [WARNING: don't mix them!] (andrei)
34 34
  * 2007-01-26 HDR_DATE_T, HDR_IDENTITY_T, HDR_IDENTITY_INFO_T added (gergo)
35
+ * 2007-07-27 HDR_RETRY_AFTER_[TF] added (andrei)
35 36
  */
36 37
 
37 38
 
... ...
@@ -105,6 +106,7 @@ enum _hdr_types_t {
105 106
 	HDR_DATE_T			       /* Date header field */,
106 107
 	HDR_IDENTITY_T			       /* Identity header field */,
107 108
 	HDR_IDENTITY_INFO_T		       /* Identity-info header field */,
109
+	HDR_RETRY_AFTER_T		           /* Retry-After header field */,
108 110
 
109 111
 	HDR_EOH_T					       /* End of message header */
110 112
 };
... ...
@@ -172,6 +174,7 @@ typedef unsigned long long hdr_flags_t;
172 174
 #define HDR_DATE_F			HDR_F_DEF(DATE)
173 175
 #define HDR_IDENTITY_F			HDR_F_DEF(IDENTITY)
174 176
 #define HDR_IDENTITY_INFO_F		HDR_F_DEF(IDENTITY_INFO)
177
+#define HDR_RETRY_AFTER_F			HDR_F_DEF(RETRY_AFTER)
175 178
 
176 179
 #define HDR_OTHER_F					HDR_F_DEF(OTHER)
177 180
 
... ...
@@ -174,4 +174,10 @@
174 174
 
175 175
 #define _min__ 0x2d6e696d   /* "min-" */
176 176
 
177
+
178
+#define _retr_ 0x72746572   /* "retr" */
179
+#define _y_af_ 0x66612d79   /* "y-af" */
180
+#define _ter1_ 0x3a726574   /* "ter:" */
181
+#define _ter2_ 0x20726574   /* "ter " */
182
+
177 183
 #endif /* KEYS_H */
... ...
@@ -58,6 +58,7 @@
58 58
 #include "parse_hname2.h"
59 59
 #include "parse_uri.h"
60 60
 #include "parse_content.h"
61
+#include "../compiler_opt.h"
61 62
 
62 63
 #ifdef DEBUG_DMALLOC
63 64
 #include <mem/dmalloc.h>
... ...
@@ -82,7 +83,8 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
82 83
 	struct date_body* date_b;
83 84
 	struct identity_body* identity_b;
84 85
 	struct identityinfo_body* identityinfo_b;
85
-	int integer;
86
+	int integer, err;
87
+	unsigned uval;
86 88
 
87 89
 	if ((*buf)=='\n' || (*buf)=='\r'){
88 90
 		/* double crlf or lflf or crcr */
... ...
@@ -186,6 +188,18 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
186 188
 			DBG("DEBUG: get_hdr_body : content_length=%d\n",
187 189
 					(int)(long)hdr->parsed);
188 190
 			break;
191
+		case HDR_RETRY_AFTER_T:
192
+			hdr->body.s=tmp;
193
+			tmp=parse_retry_after(tmp,end, &uval, &err);
194
+			if (err){
195
+				LOG(L_ERR, "ERROR:get_hdr_field: bad retry_after header\n");
196
+				goto error;
197
+			}
198
+			hdr->parsed=(void*)(unsigned long)uval;
199
+			hdr->body.len=tmp-hdr->body.s;
200
+			DBG("DEBUG: get_hdr_body : retry_after=%d\n",
201
+					(unsigned)(long)hdr->parsed);
202
+			break;
189 203
 		case HDR_DATE_T:
190 204
 			date_b=pkg_malloc(sizeof(*date_b));
191 205
 			if (date_b==0){
... ...
@@ -351,8 +365,9 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
351 365
 
352 366
 	DBG("parse_headers: flags=%llx\n", (unsigned long long)flags);
353 367
 	while( tmp<end && (flags & msg->parsed_flag) != flags){
368
+		prefetch_loc_r(tmp+64, 1);
354 369
 		hf=pkg_malloc(sizeof(struct hdr_field));
355
-		if (hf==0){
370
+		if (unlikely(hf==0)){
356 371
 			ser_error=E_OUT_OF_MEM;
357 372
 			LOG(L_ERR, "ERROR:parse_headers: memory allocation error\n");
358 373
 			goto error;
... ...
@@ -377,6 +392,7 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
377 392
 			case HDR_REQUESTDISPOSITION_T:
378 393
 			case HDR_WWW_AUTHENTICATE_T:
379 394
 			case HDR_PROXY_AUTHENTICATE_T:
395
+			case HDR_RETRY_AFTER_T:
380 396
 			case HDR_OTHER_T: /*do nothing*/
381 397
 				break;
382 398
 			case HDR_CALLID_T:
... ...
@@ -65,6 +65,7 @@
65 65
 #include "parse_to.h"
66 66
 #include "parse_via.h"
67 67
 #include "parse_fline.h"
68
+#include "parse_retry_after.h"
68 69
 #include "hf.h"
69 70
 #include "../error.h"
70 71
 
... ...
@@ -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