Module: kamailio Branch: master Commit: 57ed2639259f7116795f6214ca505cc86bb7ccb5 URL: https://github.com/kamailio/kamailio/commit/57ed2639259f7116795f6214ca505cc86bb7ccb5
Author: Daniel-Constantin Mierla <mico...@gmail.com> Committer: Daniel-Constantin Mierla <mico...@gmail.com> Date: 2023-11-22T10:09:16+01:00 ims_ipsec_pcscf: do not change msg r-uri with ipsec_destroy() param - only changing r-uri shortcut inside sip msg field can have side effects, avoid it by providing the parameter to fill_contact() - use core fixup function for handling config parameter for aor --- Modified: src/modules/ims_ipsec_pcscf/cmd.c Modified: src/modules/ims_ipsec_pcscf/ims_ipsec_pcscf_mod.c --- Diff: https://github.com/kamailio/kamailio/commit/57ed2639259f7116795f6214ca505cc86bb7ccb5.diff Patch: https://github.com/kamailio/kamailio/commit/57ed2639259f7116795f6214ca505cc86bb7ccb5.patch --- diff --git a/src/modules/ims_ipsec_pcscf/cmd.c b/src/modules/ims_ipsec_pcscf/cmd.c index aa905b09a9b..69d1fccc502 100644 --- a/src/modules/ims_ipsec_pcscf/cmd.c +++ b/src/modules/ims_ipsec_pcscf/cmd.c @@ -162,7 +162,7 @@ static str get_www_auth_param(const char *param_name, str www_auth) } static int fill_contact( - pcontact_info_t *ci, sip_msg_t *m, tm_cell_t *t, int sflags) + pcontact_info_t *ci, sip_msg_t *m, tm_cell_t *t, str *ruri, int sflags) { contact_body_t *cb = NULL; struct via_body *vb = NULL; @@ -183,8 +183,13 @@ static int fill_contact( memset(&uri, 0, sizeof(struct sip_uri)); - if((sflags & IPSEC_DSTADDR_SEARCH) && m->dst_uri.s != NULL - && m->dst_uri.len > 0) { + if(ruri != NULL && ruri->len > 0) { + suri.s = ruri->s; + suri.len = ruri->len; + LM_DBG("using param r-uri for contact filling: %.*s\n", suri.len, + suri.s); + } else if((sflags & IPSEC_DSTADDR_SEARCH) && m->dst_uri.s != NULL + && m->dst_uri.len > 0) { suri = m->dst_uri; LM_DBG("using dst uri for contact filling: %.*s\n", suri.len, suri.s); @@ -702,7 +707,7 @@ int ipsec_create(struct sip_msg *m, udomain_t *d, int _cflags) t = tmb.t_gett(); } // Find the contact - if(fill_contact(&ci, m, t, _cflags) != 0) { + if(fill_contact(&ci, m, t, NULL, _cflags) != 0) { LM_ERR("Error filling in contact data\n"); return ret; } @@ -860,7 +865,7 @@ int ipsec_forward(struct sip_msg *m, udomain_t *d, int _cflags) // // Find the contact // - if(fill_contact(&ci, m, t, _cflags) != 0) { + if(fill_contact(&ci, m, t, NULL, _cflags) != 0) { LM_ERR("Error filling in contact data\n"); return ret; } @@ -1052,14 +1057,8 @@ int ipsec_destroy(struct sip_msg *m, udomain_t *d, str *uri) t = tmb.t_gett(); } - // Insert URI in SIP message - if(uri != NULL) { - m->first_line.u.request.uri.s = uri->s; - m->first_line.u.request.uri.len = uri->len; - } - // Find the contact - if(fill_contact(&ci, m, t, 0) != 0) { + if(fill_contact(&ci, m, t, uri, 0) != 0) { LM_ERR("Error filling in contact data\n"); return ret; } diff --git a/src/modules/ims_ipsec_pcscf/ims_ipsec_pcscf_mod.c b/src/modules/ims_ipsec_pcscf/ims_ipsec_pcscf_mod.c index 3709a78c610..1e25650e1bc 100644 --- a/src/modules/ims_ipsec_pcscf/ims_ipsec_pcscf_mod.c +++ b/src/modules/ims_ipsec_pcscf/ims_ipsec_pcscf_mod.c @@ -23,6 +23,7 @@ */ #include "../../core/sr_module.h" +#include "../../core/mod_fix.h" #include "../../modules/tm/tm_load.h" #include "../ims_usrloc_pcscf/usrloc.h" @@ -459,24 +460,7 @@ static int unregister_fixup(void **param, int param_no) if(param_no == 1) { return domain_fixup(param, param_no); } else { - pv_elem_t *model = NULL; - str s; - - /* convert to str */ - s.s = (char *)*param; - s.len = strlen(s.s); - - model = NULL; - if(s.len == 0) { - LM_ERR("no param!\n"); - return E_CFG; - } - if(pv_parse_format(&s, &model) < 0 || model == NULL) { - LM_ERR("wrong format [%s]!\n", s.s); - return E_CFG; - } - *param = (void *)model; - return 0; + return fixup_spve_all(param, param_no); } return E_CFG; } @@ -503,13 +487,11 @@ static int w_forward(struct sip_msg *_m, char *_d, char *_cflags) static int w_destroy(struct sip_msg *_m, char *_d, char *_aor) { - pv_elem_t *model; str aor; if(_aor) { - model = (pv_elem_t *)_aor; - if(pv_printf_s(_m, model, &aor) < 0) { - LM_ERR("error - cannot print the format\n"); + if(fixup_get_svalue(_m, (gparam_t *)_aor, &aor) < 0) { + LM_ERR("failed to get aor parameter\n"); return -1; } LM_DBG("URI: %.*s\n", aor.len, aor.s); _______________________________________________ Kamailio (SER) - Development Mailing List To unsubscribe send an email to sr-dev-le...@lists.kamailio.org