Module: kamailio Branch: master Commit: 404ccb00ad294b39da58132772881143bc15fa04 URL: https://github.com/kamailio/kamailio/commit/404ccb00ad294b39da58132772881143bc15fa04
Author: Julien Chavanton <jchavan...@gmail.com> Committer: Daniel-Constantin Mierla <mico...@gmail.com> Date: 2023-05-09T20:23:16+02:00 registrar: adding tcpconn_id to xavp_cfg --- Modified: src/modules/registrar/doc/registrar_admin.xml Modified: src/modules/registrar/regpv.c Modified: src/modules/registrar/save.c --- Diff: https://github.com/kamailio/kamailio/commit/404ccb00ad294b39da58132772881143bc15fa04.diff Patch: https://github.com/kamailio/kamailio/commit/404ccb00ad294b39da58132772881143bc15fa04.patch --- diff --git a/src/modules/registrar/doc/registrar_admin.xml b/src/modules/registrar/doc/registrar_admin.xml index 58647f42e4e..c38c8921f4e 100644 --- a/src/modules/registrar/doc/registrar_admin.xml +++ b/src/modules/registrar/doc/registrar_admin.xml @@ -798,6 +798,13 @@ modparam("registrar", "reg_callid_avp", "$avp(s:avp)") Used in save(). </para> </listitem> + <listitem> + <para> + <emphasis>tcpconn_id</emphasis> This can be set with $conid, the TCP connection ID of the connection the current message. + This is useful when calling save() on a reply route to set the connecion of the original request. + Used in save(). + </para> + </listitem> </itemizedlist> <para> For example. if this parameter is set to 'reg', then the number diff --git a/src/modules/registrar/regpv.c b/src/modules/registrar/regpv.c index 1c764ea96c5..66121608bb4 100644 --- a/src/modules/registrar/regpv.c +++ b/src/modules/registrar/regpv.c @@ -275,6 +275,8 @@ int pv_get_ulc(struct sip_msg *msg, pv_param_t *param, return pv_get_strval(msg, param, res, &c->instance); break; case 21: /* conid */ + if (c->tcpconn_id > 0) + return pv_get_sintval(msg, param, res, c->tcpconn_id); if (c->sock && (c->sock->proto == PROTO_TCP || c->sock->proto == PROTO_TLS || c->sock->proto == PROTO_WS || c->sock->proto == PROTO_WSS)) return pv_get_sintval(msg, param, res, c->tcpconn_id); break; @@ -664,6 +666,10 @@ int pv_fetch_contacts_helper(sip_msg_t* msg, udomain_t* dt, str* uri, { c0->tcpconn_id = ptr->tcpconn_id; } + if (ptr->tcpconn_id > 0) { + LM_DBG("preset tcpconn_id : %d\n", ptr->tcpconn_id); + c0->tcpconn_id = ptr->tcpconn_id; + } if(ptr0==NULL) { diff --git a/src/modules/registrar/save.c b/src/modules/registrar/save.c index 74d118fd277..5ccc499787a 100644 --- a/src/modules/registrar/save.c +++ b/src/modules/registrar/save.c @@ -71,6 +71,27 @@ extern sruid_t _reg_sruid; static int q_override_msg_id; static qvalue_t q_override_value; +int reg_get_cfg_tcpconnid(void) +{ + int n; + sr_xavp_t *vavp=NULL; + str vname = {"tcpconn_id", 10}; + + n = 0; + + if(reg_xavp_cfg.s!=NULL) + { + vavp = xavp_get_child_with_ival(®_xavp_cfg, &vname); + if(vavp!=NULL) + { + n = vavp->val.v.i; + LM_DBG("using tcpconn_id value from xavp: %d\n", n); + } + } + + return n; +} + /*! \brief * Process request that contained a star (*) as a contact, in that case, * we will remove all bindings with the given username @@ -277,6 +298,9 @@ static inline ucontact_info_t* pack_ci( struct sip_msg* _m, contact_t* _c, } else { ci.tcpconn_id = -1; } + /* if a tcp connectionid is set, use it */ + if (reg_get_cfg_tcpconnid()) + ci.tcpconn_id = reg_get_cfg_tcpconnid(); /* additional info from message */ if (parse_headers(_m, HDR_USERAGENT_F, 0) != -1 && _m->user_agent && _______________________________________________ Kamailio (SER) - Development Mailing List To unsubscribe send an email to sr-dev-le...@lists.kamailio.org