Module: sip-router Branch: master Commit: 21f1a3783ca167ece11658ee148108636b434e27 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=21f1a378...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Fri Apr 13 19:28:37 2012 +0200
registrar(k): added new parameter gruu_enabled
- makes possible to turn off GRUU handling for REGISTER
---
modules_k/registrar/README | 47 +++++++++++++++++++-------- modules_k/registrar/doc/registrar_admin.xml | 27 +++++++++++++++ modules_k/registrar/reg_mod.c | 3 ++ modules_k/registrar/reg_mod.h | 1 + modules_k/registrar/save.c | 3 +- 5 files changed, 66 insertions(+), 15 deletions(-)
diff --git a/modules_k/registrar/README b/modules_k/registrar/README index ede93b0..7ea05cc 100644 --- a/modules_k/registrar/README +++ b/modules_k/registrar/README @@ -56,6 +56,7 @@ Bogdan-Andre Iancu 3.19. path_use_received (integer) 3.20. reg_callid_avp (string) 3.21. xavp_cfg (string) + 3.22. gruu_enabled (integer)
4. Functions
@@ -103,14 +104,15 @@ Bogdan-Andre Iancu 1.18. Set path_use_received parameter 1.19. Set reg_callid_avp parameter 1.20. Set xavp_cfg parameter - 1.21. save usage - 1.22. lookup usage - 1.23. registered usage - 1.24. add_sock_hdr usage - 1.25. registered usage + 1.21. Set gruu_enabled parameter + 1.22. save usage + 1.23. lookup usage + 1.24. registered usage + 1.25. add_sock_hdr usage 1.26. registered usage 1.27. registered usage - 1.28. $ulc(name) usage + 1.28. registered usage + 1.29. $ulc(name) usage
Chapter 1. Admin Guide
@@ -149,6 +151,7 @@ Chapter 1. Admin Guide 3.19. path_use_received (integer) 3.20. reg_callid_avp (string) 3.21. xavp_cfg (string) + 3.22. gruu_enabled (integer)
4. Functions
@@ -258,6 +261,7 @@ Chapter 1. Admin Guide 3.19. path_use_received (integer) 3.20. reg_callid_avp (string) 3.21. xavp_cfg (string) + 3.22. gruu_enabled (integer)
3.1. default_expires (integer)
@@ -578,6 +582,21 @@ modparam("registrar", "reg_callid_avp", "$avp(s:avp)") modparam("registrar", "xavp_cfg", "reg") ...
+3.22. gruu_enabled (integer) + + If set to 1 and GRUU "+sip.instance" parameter to Contact header of + REGISTER is present, then the value of the parameter is saved to + location and pub-gruu and temp-gruu addresses are generated. + + Set it to 0 if you want to ignore GRUU extensions in REGISTER. + + Default value is 1 (enabled). + + Example 1.21. Set gruu_enabled parameter +... +modparam("registrar", "gruu_enabled", 0) +... + 4. Functions
4.1. save(domain, [, flags [, uri]]) @@ -625,7 +644,7 @@ modparam("registrar", "xavp_cfg", "reg")
This function can be used from REQUEST_ROUTE and REPLY_ROUTE.
- Example 1.21. save usage + Example 1.22. save usage ... save("location"); save("location", "0x01"); @@ -658,7 +677,7 @@ save("location", "0x00", "sip:test@kamailio.org");
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
- Example 1.22. lookup usage + Example 1.23. lookup usage ... lookup("location"); switch ($retcode) { @@ -686,7 +705,7 @@ switch ($retcode) {
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
- Example 1.23. registered usage + Example 1.24. registered usage ... if (registered("location")) { sl_send_reply("100", "Trying"); @@ -706,7 +725,7 @@ if (registered("location")) {
This function can be used from REQUEST_ROUTE.
- Example 1.24. add_sock_hdr usage + Example 1.25. add_sock_hdr usage ... add_sock_hdr("Sock-Info"); ... @@ -724,7 +743,7 @@ add_sock_hdr("Sock-Info");
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
- Example 1.25. registered usage + Example 1.26. registered usage ... unregister("location", "$ru"); unregister("location", "sip:user@kamailio.org"); @@ -746,7 +765,7 @@ unregister("location", "sip:user@kamailio.org");
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
- Example 1.26. registered usage + Example 1.27. registered usage ... reg_fetch_contacts("location", "$ru", "callee"); reg_fetch_contacts("location", "sip:user@kamailio.org", "caller"); @@ -765,7 +784,7 @@ reg_fetch_contacts("location", "sip:user@kamailio.org", "caller");
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
- Example 1.27. registered usage + Example 1.28. registered usage ... reg_free_contacts("callee"); ... @@ -831,7 +850,7 @@ reg_free_contacts("callee"); The pseudo-variable accepts positive index value to access a specific contact record.
- Example 1.28. $ulc(name) usage + Example 1.29. $ulc(name) usage ... if(reg_fetch_contacts("location", "$fu", "caller")) { diff --git a/modules_k/registrar/doc/registrar_admin.xml b/modules_k/registrar/doc/registrar_admin.xml index 13f59bb..a4bec36 100644 --- a/modules_k/registrar/doc/registrar_admin.xml +++ b/modules_k/registrar/doc/registrar_admin.xml @@ -658,6 +658,33 @@ modparam("registrar", "xavp_cfg", "reg") </programlisting> </example> </section> + + <section> + <title><varname>gruu_enabled</varname> (integer)</title> + <para> + If set to 1 and GRUU <quote>+sip.instance</quote> parameter to + Contact header of REGISTER is present, then the value of the + parameter is saved to location and pub-gruu and temp-gruu addresses + are generated. + </para> + <para> + Set it to 0 if you want to ignore GRUU extensions in REGISTER. + </para> + <para> + <emphasis> + Default value is 1 (enabled). + </emphasis> + </para> + <example> + <title>Set <varname>gruu_enabled</varname> parameter</title> + <programlisting format="linespecific"> +... +modparam("registrar", "gruu_enabled", 0) +... + </programlisting> + </example> + </section> + </section>
diff --git a/modules_k/registrar/reg_mod.c b/modules_k/registrar/reg_mod.c index 0cff0ae..3501efd 100644 --- a/modules_k/registrar/reg_mod.c +++ b/modules_k/registrar/reg_mod.c @@ -117,6 +117,8 @@ int path_use_params = 0; /*!< if the received- and nat-parameters of last Path /* sruid to get internal uid */ sruid_t _reg_sruid;
+int reg_gruu_enabled = 1; + /* Populate this AVP if testing for specific registration instance. */ char *reg_callid_avp_param = 0; unsigned short reg_callid_avp_type = 0; @@ -214,6 +216,7 @@ static param_export_t params[] = { {"path_mode", INT_PARAM, &path_mode }, {"path_use_received", INT_PARAM, &path_use_params }, {"xavp_cfg", STR_PARAM, ®_xavp_cfg.s }, + {"gruu_enabled", INT_PARAM, ®_gruu_enabled }, {0, 0, 0} };
diff --git a/modules_k/registrar/reg_mod.h b/modules_k/registrar/reg_mod.h index f39ce46..a32f043 100644 --- a/modules_k/registrar/reg_mod.h +++ b/modules_k/registrar/reg_mod.h @@ -83,6 +83,7 @@ extern int method_filtering; extern int path_enabled; extern int path_mode; extern int path_use_params; +extern int reg_gruu_enabled;
extern str sock_hdr_name; extern int sock_flag; diff --git a/modules_k/registrar/save.c b/modules_k/registrar/save.c index 14b93ef..36bff89 100644 --- a/modules_k/registrar/save.c +++ b/modules_k/registrar/save.c @@ -357,7 +357,8 @@ static inline ucontact_info_t* pack_ci( struct sip_msg* _m, contact_t* _c, ci.received = received; } } - if(_c->instance) + if(reg_gruu_enabled==1 && _c->instance!=NULL + && _c->instance->body.len>0) ci.instance = _c->instance->body; if(sruid_next(&_reg_sruid)<0) goto error;