From 824c31c22d32987384b4d72eb45f4e4cbc82c54d Mon Sep 17 00:00:00 2001 From: Camille Oudot Date: Wed, 4 Mar 2015 19:38:33 +0100 Subject: [PATCH] registrar: make connection id available in $ulc() if an UA is registered using TCP (or TLS or WS(S)), make the internal connection id avalilable in the $ulc(xxx=>conid) pv --- modules/registrar/README | 1 + modules/registrar/doc/registrar_admin.xml | 4 ++++ modules/registrar/regpv.c | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/modules/registrar/README b/modules/registrar/README index a35aa622114..f305a69a211 100644 --- a/modules/registrar/README +++ b/modules/registrar/README @@ -1068,6 +1068,7 @@ event_route[usrloc:contact-expired] { * ruid - record unique ID * reg-id - reg-id value * instance - instance value + * conid - TCP socket internal connection ID ($null if UDP) The pseudo-variable accepts positive index value to access a specific contact record. diff --git a/modules/registrar/doc/registrar_admin.xml b/modules/registrar/doc/registrar_admin.xml index f1c9dc51a47..53693ef9e98 100644 --- a/modules/registrar/doc/registrar_admin.xml +++ b/modules/registrar/doc/registrar_admin.xml @@ -1455,6 +1455,10 @@ event_route[usrloc:contact-expired] { instance - instance value + + conid - TCP socket internal connection ID ($null if UDP) + + The pseudo-variable accepts positive index value to access diff --git a/modules/registrar/regpv.c b/modules/registrar/regpv.c index 719bec3ff0c..d891b4d743d 100644 --- a/modules/registrar/regpv.c +++ b/modules/registrar/regpv.c @@ -269,6 +269,10 @@ int pv_get_ulc(struct sip_msg *msg, pv_param_t *param, if(c->instance.len>0) return pv_get_strval(msg, param, res, &c->instance); break; + case 21: /* conid */ + 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; } return pv_get_null(msg, param, res); @@ -363,6 +367,8 @@ int pv_parse_ulc_name(pv_spec_p sp, str *in) rp->attr = 17; else if(strncmp(pa.s, "regid", 5)==0) rp->attr = 19; + else if(strncmp(pa.s, "conid", 5)==0) + rp->attr = 21; else goto error; break; case 6: @@ -538,6 +544,10 @@ int pv_fetch_contacts(struct sip_msg* msg, char* table, char* uri, c0->instance.len = ptr->instance.len; p += c0->instance.len; } + if (ptr->sock->proto == PROTO_TCP || ptr->sock->proto == PROTO_TLS || ptr->sock->proto == PROTO_WS || ptr->sock->proto == PROTO_WSS) + { + c0->tcpconn_id = ptr->tcpconn_id; + } if(ptr0==NULL) {