Browse code

- Retry-After parser missing files (from older commit)

Andrei Pelinescu-Onciul authored on 30/07/2007 20:19:31
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,74 @@
0
+/* 
1
+ * $Id$ 
2
+ *
3
+ * Expires Header Field Name Parsing Macros
4
+ *
5
+ * Copyright (C) 2007 iptelorg GmbH
6
+ *
7
+ * This file is part of ser, a free SIP server.
8
+ *
9
+ * ser is free software; you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation; either version 2 of the License, or
12
+ * (at your option) any later version
13
+ *
14
+ * For a license to use the ser software under conditions
15
+ * other than those described here, or to purchase support for this
16
+ * software, please contact iptel.org by e-mail at the following addresses:
17
+ *    info@iptel.org
18
+ *
19
+ * ser is distributed in the hope that it will be useful,
20
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
+ * GNU General Public License for more details.
23
+ *
24
+ * You should have received a copy of the GNU General Public License 
25
+ * along with this program; if not, write to the Free Software 
26
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
+ *
28
+ * History:
29
+ * ---------
30
+ *  2007-07-27  created by andrei
31
+ */
32
+
33
+
34
+#ifndef CASE_RETR_H
35
+#define CASE_RETR_H
36
+
37
+#include "../comp_defs.h"
38
+#include "keys.h"
39
+
40
+#define RETR_TER_CASE				\
41
+	switch(LOWER_DWORD(val)){	\
42
+		case _ter1_:				\
43
+			hdr->type = HDR_RETRY_AFTER_T;	\
44
+			hdr->name.len = 11;				\
45
+			return (p + 4);					\
46
+		\
47
+		case _ter2_:                     \
48
+			hdr->type = HDR_RETRY_AFTER_T;	\
49
+			p += 4;							\
50
+			goto dc_end;					\
51
+	}
52
+
53
+
54
+
55
+#define RETR_Y_AF_CASE				\
56
+	if (LOWER_DWORD(val)==_y_af_){	\
57
+		p+=4;						\
58
+		val=READ(p);				\
59
+		RETR_TER_CASE;				\
60
+		goto other;					\
61
+	}
62
+
63
+
64
+
65
+
66
+#define retr_CASE		\
67
+	p+=4;			\
68
+	val=READ(p);	\
69
+	RETR_Y_AF_CASE;	\
70
+	goto other;
71
+
72
+
73
+#endif /* CASE_RETR_H */
0 74
new file mode 100644
... ...
@@ -0,0 +1,95 @@
0
+/* 
1
+ * $Id$ 
2
+ *
3
+ * Copyright (C) 2007 iptelorg GmbH
4
+ *
5
+ * This file is part of ser, a free SIP server.
6
+ *
7
+ * ser is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 2 of the License, or
10
+ * (at your option) any later version
11
+ *
12
+ * For a license to use the ser software under conditions
13
+ * other than those described here, or to purchase support for this
14
+ * software, please contact iptel.org by e-mail at the following addresses:
15
+ *    info@iptel.org
16
+ *
17
+ * ser is distributed in the hope that it will be useful,
18
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+ * GNU General Public License for more details.
21
+ *
22
+ * You should have received a copy of the GNU General Public License 
23
+ * along with this program; if not, write to the Free Software 
24
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
+ * 
26
+ * History:
27
+ * --------
28
+ *  2007-07-27  created by andrei
29
+ */
30
+
31
+
32
+#include "../comp_defs.h"
33
+#include "parse_retry_after.h"
34
+#include "parser_f.h"  /* eat_space_end and so on */
35
+#include "parse_def.h"
36
+#include "../dprint.h"
37
+#include "../mem/mem.h"
38
+
39
+/* Parse the Retry-after header field */
40
+char* parse_retry_after(char *buf, char* end, unsigned* after, int* err)
41
+{
42
+	char *t;
43
+	int i;
44
+	unsigned val;
45
+	
46
+	val=0;
47
+	t=buf;
48
+	
49
+	t=eat_lws_end(t, end);
50
+	if (t>=end) goto error;
51
+	for (i=0; t<end; i++,t++){
52
+		if ((*t >= '0') && (*t <= '9')){
53
+			val=val*10+(*t-'0');
54
+		}else{
55
+			switch(*t){
56
+				/* for now we don't care about retry-after params or comment*/
57
+				case ' ':
58
+				case '\t':
59
+				case ';':
60
+				case '\r':
61
+				case '\n':
62
+					goto found;
63
+				default:
64
+					/* invalid char */
65
+					goto error;
66
+			}
67
+		}
68
+	}
69
+	goto error_nocrlf; /* end reached without encountering cr or lf */
70
+found:
71
+	if (i>10 || i==0) /* too many  or too few digits */
72
+		goto error;
73
+	*after=val;
74
+	/* find the end of header */
75
+	for (; t<end; t++){
76
+		if (*t=='\n'){
77
+			if (((t+1)<end) && (*(t+1)=='\r'))
78
+				t++;
79
+			if (((t+1)<end) && (*(t+1)==' ' || *(t+1)=='\t')){
80
+				t++;
81
+				continue; /* line folding ... */
82
+			}
83
+			*err=0;
84
+			return t+1;
85
+		}
86
+	}
87
+error_nocrlf:
88
+	LOG(L_ERR, "ERROR: parse_retry_after: strange EoHF\n");
89
+	goto error;
90
+error:
91
+	LOG(L_ERR, "ERROR: parse_retry_after: bad Retry-After header \n");
92
+	*err=1;
93
+	return t;
94
+}
0 95
new file mode 100644
... ...
@@ -0,0 +1,41 @@
0
+/*
1
+ * $Id$
2
+ *
3
+ * Copyright (C) 2007 iptelorg GmbH
4
+ *
5
+ * This file is part of ser, a free SIP server.
6
+ *
7
+ * ser is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 2 of the License, or
10
+ * (at your option) any later version
11
+ *
12
+ * For a license to use the ser software under conditions
13
+ * other than those described here, or to purchase support for this
14
+ * software, please contact iptel.org by e-mail at the following addresses:
15
+ *    info@iptel.org
16
+ *
17
+ * ser is distributed in the hope that it will be useful,
18
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+ * GNU General Public License for more details.
21
+ *
22
+ * You should have received a copy of the GNU General Public License 
23
+ * along with this program; if not, write to the Free Software 
24
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
+ */
26
+
27
+
28
+#ifndef _parse_retry_after_h
29
+#define _parse_retry_after_h
30
+
31
+#include "../str.h"
32
+
33
+
34
+/* Parse Retry-After header field */
35
+char* parse_retry_after(char *buf, char* end, unsigned* after, int* err);
36
+
37
+
38
+
39
+
40
+#endif