Skip to content

Commit

Permalink
registrar: adding tcpconn_id to xavp_cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
jchavanton authored and miconda committed May 9, 2023
1 parent 43ac6b2 commit 404ccb0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/modules/registrar/doc/registrar_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/modules/registrar/regpv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down
24 changes: 24 additions & 0 deletions src/modules/registrar/save.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(&reg_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
Expand Down Expand Up @@ -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 &&
Expand Down

0 comments on commit 404ccb0

Please sign in to comment.