... | ... |
@@ -92,8 +92,7 @@ int supports_extension(struct sip_msg *m, str *extension) |
92 | 92 |
struct hdr_field *h; |
93 | 93 |
int res; |
94 | 94 |
|
95 |
- /* we need all Supported headers, Min-SE, |
|
96 |
- * Session-Expires */ |
|
95 |
+ /* we need all Supported headers */ |
|
97 | 96 |
res = parse_headers(m, HDR_EOH_F, 0); |
98 | 97 |
if (res == -1) { |
99 | 98 |
ERR("Error while parsing headers (%d)\n", res); |
... | ... |
@@ -110,5 +109,27 @@ int supports_extension(struct sip_msg *m, str *extension) |
110 | 109 |
return 0; |
111 | 110 |
} |
112 | 111 |
|
112 |
+int requires_extension(struct sip_msg *m, str *extension) |
|
113 |
+{ |
|
114 |
+ /* walk through all Require headers */ |
|
115 |
+ struct hdr_field *h; |
|
116 |
+ int res; |
|
117 |
+ |
|
118 |
+ /* we need all Require headers */ |
|
119 |
+ res = parse_headers(m, HDR_EOH_F, 0); |
|
120 |
+ if (res == -1) { |
|
121 |
+ ERR("Error while parsing headers (%d)\n", res); |
|
122 |
+ return 0; /* what to return here ? */ |
|
123 |
+ } |
|
124 |
+ |
|
125 |
+ h = m->require; |
|
126 |
+ while (h) { |
|
127 |
+ if (h->type == HDR_REQUIRE_T) { |
|
128 |
+ if (contains_extension_support(h, extension)) return 1; |
|
129 |
+ } |
|
130 |
+ h = h->next; |
|
131 |
+ } |
|
132 |
+ return 0; |
|
133 |
+} |
|
113 | 134 |
|
114 | 135 |
#endif |
... | ... |
@@ -16,6 +16,10 @@ int is_terminating_notify(struct sip_msg *m); |
16 | 16 |
* 0 if not or an error occured while parsing */ |
17 | 17 |
int supports_extension(struct sip_msg *m, str *extension); |
18 | 18 |
|
19 |
+/* returns 1 if given extension is in Require headers, |
|
20 |
+ * 0 if not or an error occured while parsing */ |
|
21 |
+int requires_extension(struct sip_msg *m, str *extension); |
|
22 |
+ |
|
19 | 23 |
#endif |
20 | 24 |
|
21 | 25 |
#endif |
... | ... |
@@ -71,6 +71,7 @@ enum _hdr_types_t { |
71 | 71 |
HDR_EXPIRES_T /* Expires header field */, |
72 | 72 |
HDR_PROXYAUTH_T /* Proxy-Authorization hdr field */, |
73 | 73 |
HDR_SUPPORTED_T /* Supported header field */, |
74 |
+ HDR_REQUIRE_T /* Require header */, |
|
74 | 75 |
HDR_PROXYREQUIRE_T /* Proxy-Require header field */, |
75 | 76 |
HDR_UNSUPPORTED_T /* Unsupported header field */, |
76 | 77 |
HDR_ALLOW_T /* Allow header field */, |
... | ... |
@@ -131,6 +132,7 @@ typedef unsigned long long hdr_flags_t; |
131 | 132 |
#define HDR_EXPIRES_F HDR_F_DEF(EXPIRES) |
132 | 133 |
#define HDR_PROXYAUTH_F HDR_F_DEF(PROXYAUTH) |
133 | 134 |
#define HDR_SUPPORTED_F HDR_F_DEF(SUPPORTED) |
135 |
+#define HDR_REQUIRE_F HDR_F_DEF(REQUIRE) |
|
134 | 136 |
#define HDR_PROXYREQUIRE_F HDR_F_DEF(PROXYREQUIRE) |
135 | 137 |
#define HDR_UNSUPPORTED_F HDR_F_DEF(UNSUPPORTED) |
136 | 138 |
#define HDR_ALLOW_F HDR_F_DEF(ALLOW) |
... | ... |
@@ -182,6 +182,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr) |
182 | 182 |
(int)(long)hdr->parsed); |
183 | 183 |
break; |
184 | 184 |
case HDR_SUPPORTED_T: |
185 |
+ case HDR_REQUIRE_T: |
|
185 | 186 |
case HDR_CONTENTTYPE_T: |
186 | 187 |
case HDR_FROM_T: |
187 | 188 |
case HDR_CALLID_T: |
... | ... |
@@ -381,6 +382,10 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next) |
381 | 382 |
if (msg->supported==0) msg->supported=hf; |
382 | 383 |
msg->parsed_flag|=HDR_SUPPORTED_F; |
383 | 384 |
break; |
385 |
+ case HDR_REQUIRE_T: |
|
386 |
+ if (msg->require==0) msg->require=hf; |
|
387 |
+ msg->parsed_flag|=HDR_REQUIRE_F; |
|
388 |
+ break; |
|
384 | 389 |
case HDR_UNSUPPORTED_T: |
385 | 390 |
if (msg->unsupported==0) msg->unsupported=hf; |
386 | 391 |
msg->parsed_flag|=HDR_UNSUPPORTED_F; |
... | ... |
@@ -193,6 +193,7 @@ struct sip_msg { |
193 | 193 |
struct hdr_field* expires; |
194 | 194 |
struct hdr_field* proxy_auth; |
195 | 195 |
struct hdr_field* supported; |
196 |
+ struct hdr_field* require; |
|
196 | 197 |
struct hdr_field* proxy_require; |
197 | 198 |
struct hdr_field* unsupported; |
198 | 199 |
struct hdr_field* allow; |
... | ... |
@@ -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 |
|