Module: kamailio Branch: master Commit: c3d753885b3cd1bc0cb9f46986e5798dfb5f6552 URL: https://github.com/kamailio/kamailio/commit/c3d753885b3cd1bc0cb9f46986e5798d...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2024-02-27T09:50:05+01:00
tcpops: if connection not found, return attributes from sip msg rcv
---
Modified: src/modules/tcpops/tcpops_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/c3d753885b3cd1bc0cb9f46986e5798d... Patch: https://github.com/kamailio/kamailio/commit/c3d753885b3cd1bc0cb9f46986e5798d...
---
diff --git a/src/modules/tcpops/tcpops_mod.c b/src/modules/tcpops/tcpops_mod.c index 15e39993d64..aad29665d72 100644 --- a/src/modules/tcpops/tcpops_mod.c +++ b/src/modules/tcpops/tcpops_mod.c @@ -762,41 +762,50 @@ static int pv_get_tcp(sip_msg_t *msg, pv_param_t *param, pv_value_t *res) return -1; }
+ con = tcpconn_get(msg->rcv.proto_reserved1, 0, 0, 0, 0);
switch(param->pvn.u.isname.name.n) { - case 1: - sval.s = ip_addr2a(&msg->rcv.src_ip); + case 1: /* c_si */ + if(con == NULL) { + sval.s = ip_addr2a(&msg->rcv.src_ip); + sval.len = strlen(sval.s); + return pv_get_strval(msg, param, res, &sval); + } + sval.s = ip_addr2a(&con->cinfo.src_ip); + tcpconn_put(con); sval.len = strlen(sval.s); return pv_get_strval(msg, param, res, &sval); - case 2: - ival = msg->rcv.src_port; + case 2: /* c_sp */ + if(con == NULL) { + ival = msg->rcv.src_port; + return pv_get_sintval(msg, param, res, ival); + } + ival = con->cinfo.src_port; + tcpconn_put(con); return pv_get_sintval(msg, param, res, ival); - case 3: - if((con = tcpconn_get(msg->rcv.proto_reserved1, 0, 0, 0, 0)) - == NULL) { + case 3: /* ac_si */ + if(con == NULL) { return pv_get_null(msg, param, res); } sval.s = ip_addr2a(&con->cinfo.src_ip); tcpconn_put(con); sval.len = strlen(sval.s); return pv_get_strval(msg, param, res, &sval); - case 4: - if((con = tcpconn_get(msg->rcv.proto_reserved1, 0, 0, 0, 0)) - == NULL) { + case 4: /* ac_sp */ + if(con == NULL) { return pv_get_null(msg, param, res); } ival = con->cinfo.src_port; tcpconn_put(con); return pv_get_sintval(msg, param, res, ival); - case 5: - if((con = tcpconn_get(msg->rcv.proto_reserved1, 0, 0, 0, 0)) - == NULL) { + case 5: /* aconid */ + if(con == NULL) { return pv_get_null(msg, param, res); } ival = con->id; tcpconn_put(con); return pv_get_sintval(msg, param, res, ival); - default: + default: /* conid */ return pv_get_sintval(msg, param, res, msg->rcv.proto_reserved1); } }