From c3d753885b3cd1bc0cb9f46986e5798dfb5f6552 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Tue, 27 Feb 2024 09:50:05 +0100 Subject: [PATCH] tcpops: if connection not found, return attributes from sip msg rcv --- src/modules/tcpops/tcpops_mod.c | 37 ++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-) 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); } }