1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,46 @@ |
1 |
+/* |
|
2 |
+ * Refer-To Header Field Name Parsing Macros |
|
3 |
+ * |
|
4 |
+ * Copyright (C) 2005 Juha Heinanen |
|
5 |
+ * |
|
6 |
+ * This file is part of ser, a free SIP server. |
|
7 |
+ * |
|
8 |
+ * ser 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 |
+ * 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, |
|
19 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
+ * GNU General Public License for more details. |
|
22 |
+ * |
|
23 |
+ * You should have received a copy of the GNU General Public License |
|
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 |
|
26 |
+ */ |
|
27 |
+ |
|
28 |
+#ifndef CASE_REFE_H |
|
29 |
+#define CASE_REFE_H |
|
30 |
+ |
|
31 |
+#define r_to_CASE \ |
|
32 |
+ if (LOWER_DWORD(val) == _r_to_) { \ |
|
33 |
+ hdr->type = HDR_REFER_TO; \ |
|
34 |
+ p += 4; \ |
|
35 |
+ goto dc_end; \ |
|
36 |
+ } |
|
37 |
+ |
|
38 |
+ |
|
39 |
+#define refe_CASE \ |
|
40 |
+ p += 4; \ |
|
41 |
+ val = READ(p); \ |
|
42 |
+ r_to_CASE; \ |
|
43 |
+ goto other; |
|
44 |
+ |
|
45 |
+ |
|
46 |
+#endif /* CASE_REFE_H */ |
... | ... |
@@ -158,6 +158,10 @@ void clean_hdr_field(struct hdr_field* hf) |
158 | 158 |
free_to(hf->parsed); |
159 | 159 |
break; |
160 | 160 |
|
161 |
+ case HDR_REFER_TO: |
|
162 |
+ free_to(hf->parsed); |
|
163 |
+ break; |
|
164 |
+ |
|
161 | 165 |
default: |
162 | 166 |
LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n", |
163 | 167 |
hf->type); |
... | ... |
@@ -73,14 +73,15 @@ |
73 | 73 |
#define HDR_CONTENTDISPOSITION (1 << 27) /* Content-Disposition hdr field */ |
74 | 74 |
#define HDR_DIVERSION (1 << 28) /* Diversion header field */ |
75 | 75 |
#define HDR_RPID (1 << 29) /* Remote-Party-ID header field */ |
76 |
-#define HDR_OTHER (1 << 30) /* Some other header field */ |
|
76 |
+#define HDR_REFER_TO (1 << 30) /* Remote-Party-ID header field */ |
|
77 |
+#define HDR_OTHER (1 << 31) /* Some other header field */ |
|
77 | 78 |
|
78 | 79 |
|
79 | 80 |
/* returns true if the header links allocated memory on parse field */ |
80 | 81 |
#define hdr_allocs_parse( _hdr ) \ |
81 | 82 |
(((_hdr)->type)&(HDR_VIA|HDR_TO|HDR_FROM|HDR_CONTACT|HDR_ROUTE|\ |
82 | 83 |
HDR_RECORDROUTE|HDR_AUTHORIZATION|HDR_EXPIRES|HDR_PROXYAUTH|\ |
83 |
- HDR_EVENT|HDR_ACCEPT|HDR_CONTENTDISPOSITION|HDR_DIVERSION|HDR_RPID)) |
|
84 |
+ HDR_EVENT|HDR_ACCEPT|HDR_CONTENTDISPOSITION|HDR_DIVERSION|HDR_RPID|HDR_REFER_TO)) |
|
84 | 85 |
|
85 | 86 |
|
86 | 87 |
|
... | ... |
@@ -204,6 +204,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr) |
204 | 204 |
case HDR_ACCEPTDISPOSITION: |
205 | 205 |
case HDR_DIVERSION: |
206 | 206 |
case HDR_RPID: |
207 |
+ case HDR_REFER_TO: |
|
207 | 208 |
case HDR_OTHER: |
208 | 209 |
/* just skip over it */ |
209 | 210 |
hdr->body.s=tmp; |
... | ... |
@@ -407,6 +408,10 @@ int parse_headers(struct sip_msg* msg, int flags, int next) |
407 | 408 |
if (msg->rpid==0) msg->rpid = hf; |
408 | 409 |
msg->parsed_flag|=HDR_RPID; |
409 | 410 |
break; |
411 |
+ case HDR_REFER_TO: |
|
412 |
+ if (msg->refer_to==0) msg->refer_to = hf; |
|
413 |
+ msg->parsed_flag|=HDR_REFER_TO; |
|
414 |
+ break; |
|
410 | 415 |
case HDR_VIA: |
411 | 416 |
msg->parsed_flag|=HDR_VIA; |
412 | 417 |
DBG("parse_headers: Via found, flags=%d\n", flags); |
... | ... |
@@ -194,6 +194,7 @@ struct sip_msg { |
194 | 194 |
struct hdr_field* accept_disposition; |
195 | 195 |
struct hdr_field* diversion; |
196 | 196 |
struct hdr_field* rpid; |
197 |
+ struct hdr_field* refer_to; |
|
197 | 198 |
|
198 | 199 |
char* eoh; /* pointer to the end of header (if found) or null */ |
199 | 200 |
char* unparsed; /* here we stopped parsing*/ |
... | ... |
@@ -84,6 +84,7 @@ static inline char* skip_ws(char* p, unsigned int size) |
84 | 84 |
#include "case_supp.h" /* Supported */ |
85 | 85 |
#include "case_dive.h" /* Diversion */ |
86 | 86 |
#include "case_remo.h" /* Remote-Party-ID */ |
87 |
+#include "case_refe.h" /* Refer-To */ |
|
87 | 88 |
|
88 | 89 |
|
89 | 90 |
#define READ(val) \ |
... | ... |
@@ -114,7 +115,8 @@ static inline char* skip_ws(char* p, unsigned int size) |
114 | 115 |
case _subj_: subj_CASE; \ |
115 | 116 |
case _user_: user_CASE; \ |
116 | 117 |
case _dive_: dive_CASE; \ |
117 |
- case _remo_: remo_CASE; |
|
118 |
+ case _remo_: remo_CASE; \ |
|
119 |
+ case _refe_: refe_CASE; |
|
118 | 120 |
|
119 | 121 |
|
120 | 122 |
#define PARSE_COMPACT(id) \ |
121 | 123 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,79 @@ |
1 |
+/* |
|
2 |
+ * Copyright (C) 2005 Juha Heinanen |
|
3 |
+ * |
|
4 |
+ * This file is part of ser, a free SIP server. |
|
5 |
+ * |
|
6 |
+ * ser is free software; you can redistribute it and/or modify |
|
7 |
+ * it under the terms of the GNU General Public License as published by |
|
8 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
9 |
+ * (at your option) any later version |
|
10 |
+ * |
|
11 |
+ * For a license to use the ser software under conditions |
|
12 |
+ * other than those described here, or to purchase support for this |
|
13 |
+ * software, please contact iptel.org by e-mail at the following addresses: |
|
14 |
+ * info@iptel.org |
|
15 |
+ * |
|
16 |
+ * ser is distributed in the hope that it will be useful, |
|
17 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
+ * GNU General Public License for more details. |
|
20 |
+ * |
|
21 |
+ * You should have received a copy of the GNU General Public License |
|
22 |
+ * along with this program; if not, write to the Free Software |
|
23 |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
+ */ |
|
25 |
+ |
|
26 |
+#include "parse_from.h" |
|
27 |
+#include "parse_to.h" |
|
28 |
+#include <stdlib.h> |
|
29 |
+#include <string.h> |
|
30 |
+#include "../dprint.h" |
|
31 |
+#include "msg_parser.h" |
|
32 |
+#include "../ut.h" |
|
33 |
+#include "../mem/mem.h" |
|
34 |
+ |
|
35 |
+ |
|
36 |
+/* |
|
37 |
+ * This method is used to parse Refer-To header. |
|
38 |
+ * |
|
39 |
+ * params: msg : sip msg |
|
40 |
+ * returns 0 on success, |
|
41 |
+ * -1 on failure. |
|
42 |
+ */ |
|
43 |
+int parse_refer_to_header( struct sip_msg *msg ) |
|
44 |
+{ |
|
45 |
+ struct to_body* refer_to_b; |
|
46 |
+ |
|
47 |
+ if ( !msg->refer_to && |
|
48 |
+ (parse_headers(msg, HDR_REFER_TO,0)==-1 || !msg->refer_to)) { |
|
49 |
+ goto error; |
|
50 |
+ } |
|
51 |
+ |
|
52 |
+ /* maybe the header is already parsed! */ |
|
53 |
+ if (msg->refer_to->parsed) |
|
54 |
+ return 0; |
|
55 |
+ |
|
56 |
+ /* bad luck! :-( - we have to parse it */ |
|
57 |
+ /* first, get some memory */ |
|
58 |
+ refer_to_b = pkg_malloc(sizeof(struct to_body)); |
|
59 |
+ if (refer_to_b == 0) { |
|
60 |
+ LOG(L_ERR, "ERROR:parse_refer_to_header: out of pkg_memory\n"); |
|
61 |
+ goto error; |
|
62 |
+ } |
|
63 |
+ |
|
64 |
+ /* now parse it!! */ |
|
65 |
+ memset(refer_to_b, 0, sizeof(struct to_body)); |
|
66 |
+ parse_to(msg->refer_to->body.s, |
|
67 |
+ msg->refer_to->body.s + msg->refer_to->body.len+1, |
|
68 |
+ refer_to_b); |
|
69 |
+ if (refer_to_b->error == PARSE_ERROR) { |
|
70 |
+ LOG(L_ERR, "ERROR:parse_refer_to_header: bad Refer-To header\n"); |
|
71 |
+ pkg_free(refer_to_b); |
|
72 |
+ goto error; |
|
73 |
+ } |
|
74 |
+ msg->refer_to->parsed = refer_to_b; |
|
75 |
+ |
|
76 |
+ return 0; |
|
77 |
+ error: |
|
78 |
+ return -1; |
|
79 |
+} |
0 | 80 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,42 @@ |
1 |
+/* |
|
2 |
+ * Copyright (C) 2005 Juha Heinanen |
|
3 |
+ * |
|
4 |
+ * This file is part of ser, a free SIP server. |
|
5 |
+ * |
|
6 |
+ * ser is free software; you can redistribute it and/or modify |
|
7 |
+ * it under the terms of the GNU General Public License as published by |
|
8 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
9 |
+ * (at your option) any later version |
|
10 |
+ * |
|
11 |
+ * For a license to use the ser software under conditions |
|
12 |
+ * other than those described here, or to purchase support for this |
|
13 |
+ * software, please contact iptel.org by e-mail at the following addresses: |
|
14 |
+ * info@iptel.org |
|
15 |
+ * |
|
16 |
+ * ser is distributed in the hope that it will be useful, |
|
17 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
+ * GNU General Public License for more details. |
|
20 |
+ * |
|
21 |
+ * You should have received a copy of the GNU General Public License |
|
22 |
+ * along with this program; if not, write to the Free Software |
|
23 |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
+ */ |
|
25 |
+ |
|
26 |
+ |
|
27 |
+#ifndef PARSE_REFER_TO_H |
|
28 |
+#define PARSE_REFER_TO_H |
|
29 |
+ |
|
30 |
+#include "msg_parser.h" |
|
31 |
+ |
|
32 |
+ |
|
33 |
+/* casting macro for accessing Refer-To body */ |
|
34 |
+#define get_refer_to(p_msg) ((struct to_body*)(p_msg)->refer_to->parsed) |
|
35 |
+ |
|
36 |
+ |
|
37 |
+/* |
|
38 |
+ * Refer-To header field parser |
|
39 |
+ */ |
|
40 |
+int parse_refer_to_header( struct sip_msg *msg); |
|
41 |
+ |
|
42 |
+#endif /* PARSE_REFER_TO_H */ |