Module: sip-router Branch: master Commit: 399dd84d28da82d751e40488cda604a4e03fcbf3 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=399dd84d...
Author: Peter Dunkley peter.dunkley@crocodile-rcs.com Committer: Peter Dunkley peter.dunkley@crocodile-rcs.com Date: Fri May 10 20:02:51 2013 +0100
modules/pv: added new $conid PV
- Returns the TCP connection ID that the current message arrived on (for TCP/TLS/WS/WSS) or $null (for UDP/SCTP)
---
modules/pv/pv.c | 3 +++ modules/pv/pv_core.c | 15 +++++++++++++++ modules/pv/pv_core.h | 3 +++ 3 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/modules/pv/pv.c b/modules/pv/pv.c index 4ea5cc6..2c4d544 100644 --- a/modules/pv/pv.c +++ b/modules/pv/pv.c @@ -143,6 +143,9 @@ static pv_export_t mod_pvs[] = { {{"cnt", sizeof("cnt")-1}, PVT_OTHER, pv_get_cnt, 0, pv_parse_cnt_name, 0, 0, 0 }, + {{"conid", (sizeof("conid")-1)}, /* */ + PVT_OTHER, pv_get_tcpconn_id, 0, + 0, 0, 0, 0}, {{"cs", (sizeof("cs")-1)}, /* */ PVT_OTHER, pv_get_cseq, 0, 0, 0, 0, 0}, diff --git a/modules/pv/pv_core.c b/modules/pv/pv_core.c index 66ab63e..3dda6a2 100644 --- a/modules/pv/pv_core.c +++ b/modules/pv/pv_core.c @@ -32,6 +32,7 @@ #include "../../socket_info.h" #include "../../data_lump.h" #include "../../lib/kcore/cmpapi.h" +#include "../../tcp_conn.h"
#include "../../parser/parse_from.h" #include "../../parser/parse_uri.h" @@ -1822,6 +1823,20 @@ int pv_get_ruid(struct sip_msg *msg, pv_param_t *param, return pv_get_strval(msg, param, res, &msg->ruid); }
+int pv_get_tcpconn_id(struct sip_msg *msg, pv_param_t *param, + pv_value_t *res) +{ + struct tcp_connection *con; + + if (msg == NULL) + return -1; + + if ((con = tcpconn_get(msg->rcv.proto_reserved1, 0, 0, 0, 0)) == NULL) + return pv_get_null(msg, param, res); + + return pv_get_sintval(msg, param, res, con->id); +} +
/********* end PV get functions *********/
diff --git a/modules/pv/pv_core.h b/modules/pv/pv_core.h index a51349f..9b62d41 100644 --- a/modules/pv/pv_core.h +++ b/modules/pv/pv_core.h @@ -217,6 +217,9 @@ int pv_get_cnt(struct sip_msg *msg, pv_param_t *param, int pv_get_ruid(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
+int pv_get_tcpconn_id(struct sip_msg *msg, pv_param_t *param, + pv_value_t *res); + /********* end PV get functions *********/
/********* start PV set functions *********/