Module: kamailio Branch: master Commit: ac2572b880c5373864a55ebe1b9e538dd9337e63 URL: https://github.com/kamailio/kamailio/commit/ac2572b880c5373864a55ebe1b9e538d...
Author: Juha Heinanen jh@tutpro.com Committer: Juha Heinanen jh@tutpro.com Date: 2017-04-08T15:22:54+03:00
modules/registrar: apply method_filtering only on initial requests w/o to-tag
---
Modified: src/modules/registrar/README Modified: src/modules/registrar/doc/registrar_admin.xml Modified: src/modules/registrar/lookup.c
---
Diff: https://github.com/kamailio/kamailio/commit/ac2572b880c5373864a55ebe1b9e538d... Patch: https://github.com/kamailio/kamailio/commit/ac2572b880c5373864a55ebe1b9e538d...
---
diff --git a/src/modules/registrar/README b/src/modules/registrar/README index 220e2a8..0b80869 100644 --- a/src/modules/registrar/README +++ b/src/modules/registrar/README @@ -568,9 +568,10 @@ modparam("registrar", "sock_hdr_name", "Sock-Info") 3.17. method_filtering (integer)
Tells if the contact filtering based on supported methods should be - performed during lookup. It's enabled only if it has a non zero value. - Supported methods are listed in the “Allow:” header in the REGISTER - message and stored in the location database. + performed during lookup on initial requests without to-tag. It's + enabled only if it has a non zero value. Supported methods are listed + in the “Allow:” header in the REGISTER message and stored in the + location database.
Default value is 0 (disabled).
@@ -882,9 +883,9 @@ save("location", "0x00", "sip:test@kamailio.org"); value and optionally the rest will be appended to the message (depending on append_branches parameter value).
- If the method_filtering option is enabled, the lookup function will - return only the contacts that support the method of the processed - request. + If the method_filtering option is enabled and request is initial + request without to-tag, the lookup function will return only the + contacts that support the method of the processed request.
Meaning of the parameters is as follows: * domain - Name of table that should be used for the lookup. diff --git a/src/modules/registrar/doc/registrar_admin.xml b/src/modules/registrar/doc/registrar_admin.xml index 0a81b8b..7e98b05 100644 --- a/src/modules/registrar/doc/registrar_admin.xml +++ b/src/modules/registrar/doc/registrar_admin.xml @@ -515,7 +515,8 @@ modparam("registrar", "sock_hdr_name", "Sock-Info") <title><varname>method_filtering</varname> (integer)</title> <para> Tells if the contact filtering based on supported methods should be - performed during lookup. It's enabled only if it has a non zero + performed during lookup on initial requests without to-tag. + It's enabled only if it has a non zero value. Supported methods are listed in the <quote>Allow:</quote> header in the REGISTER message and stored in the location database. </para> @@ -1077,8 +1078,9 @@ save("location", "0x00", "sip:test@kamailio.org"); the message (depending on append_branches parameter value). </para> <para> - If the <varname>method_filtering</varname> option is enabled, - the <function>lookup</function> function + If the <varname>method_filtering</varname> option is enabled and + request is initial request without to-tag, the + <function>lookup</function> function will return only the contacts that support the method of the processed request. </para> diff --git a/src/modules/registrar/lookup.c b/src/modules/registrar/lookup.c index c9853a6..27d040b 100644 --- a/src/modules/registrar/lookup.c +++ b/src/modules/registrar/lookup.c @@ -45,9 +45,16 @@ #include "lookup.h" #include "config.h"
-#define allowed_method(_msg, _c) \ - ( !method_filtering || ((_msg)->REQ_METHOD)&((_c)->methods) ) +static int has_to_tag(struct sip_msg* msg) +{
+ if (parse_to_header(msg) < 0) return 0; + return (get_to(msg)->tag_value.len > 0) ? 1 : 0; +} + +#define allowed_method(_msg, _c) \ + ( !method_filtering || ((_msg)->REQ_METHOD)&((_c)->methods) || \ + has_to_tag(_msg) )
/** * compare two instances, by skipping '<' & '>'