Module: kamailio Branch: master Commit: 91e9835dc751403440b1b8c3d03004b3434fdd45 URL: https://github.com/kamailio/kamailio/commit/91e9835dc751403440b1b8c3d03004b3...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2020-02-24T09:31:39+01:00
kemix: exported get_conid() function to retrieve tcp connection id
- returns -1 if not available
---
Modified: src/modules/kemix/kemix_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/91e9835dc751403440b1b8c3d03004b3... Patch: https://github.com/kamailio/kamailio/commit/91e9835dc751403440b1b8c3d03004b3...
---
diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c index d261766f85..81e433c9e3 100644 --- a/src/modules/kemix/kemix_mod.c +++ b/src/modules/kemix/kemix_mod.c @@ -32,6 +32,7 @@ #include "../../core/parser/parse_from.h" #include "../../core/parser/parse_to.h" #include "../../core/parser/digest/digest.h" +#include "../../core/tcp_conn.h"
MODULE_VERSION
@@ -822,6 +823,25 @@ static sr_kemi_xval_t* ki_kx_get_callid(sip_msg_t *msg) return &_sr_kemi_kx_xval; }
+/** + * + */ +static int ki_kx_get_conid(sip_msg_t *msg) +{ + tcp_connection_t *con; + int conid; + + if (msg == NULL) + return -1; + + if ((con = tcpconn_get(msg->rcv.proto_reserved1, 0, 0, 0, 0)) == NULL) + return -1; + + conid = con->id; + tcpconn_put(con); + + return conid; +}
/** * @@ -1058,6 +1078,11 @@ static sr_kemi_t sr_kemi_kx_exports[] = { { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } }, + { str_init("kx"), str_init("get_conid"), + SR_KEMIP_INT, ki_kx_get_conid, + { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + },
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } } };