From aee3e683d8d7b0227748711f73cc384475a9fb16 Mon Sep 17 00:00:00 2001 From: Razvan Crainea Date: Tue, 23 Nov 2021 17:35:25 +0200 Subject: [PATCH] siprec: specify socket through the $siprec variable --- modules/siprec/doc/siprec_admin.xml | 4 ++++ modules/siprec/siprec.c | 2 +- modules/siprec/siprec_var.c | 19 +++++++++++++++++++ modules/siprec/siprec_var.h | 2 ++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/siprec/doc/siprec_admin.xml b/modules/siprec/doc/siprec_admin.xml index dc5b249fa5c..2f1f3e459fe 100644 --- a/modules/siprec/doc/siprec_admin.xml +++ b/modules/siprec/doc/siprec_admin.xml @@ -457,6 +457,10 @@ modparam("siprec", "skip_failover_codes", "[34][0-9][0-9]") NOTE: headers must be separated by \r\n and must end with \r\n. + + socket - listening socket that the outgoing + request towards SRS should be used. + diff --git a/modules/siprec/siprec.c b/modules/siprec/siprec.c index 6780dd74b4f..87cf8a0a1f8 100644 --- a/modules/siprec/siprec.c +++ b/modules/siprec/siprec.c @@ -223,7 +223,7 @@ static int siprec_start_rec(struct sip_msg *msg, str *srs, str *rtp) (var && var->media.len?&var->media:NULL), (var && var->group.len?&var->group:NULL), (var && var->headers.len?&var->headers:NULL), - msg->force_send_socket))) { + (var?var->si:NULL)))) { LM_ERR("cannot create siprec session!\n"); return -2; } diff --git a/modules/siprec/siprec_var.c b/modules/siprec/siprec_var.c index 84475921228..7c5b0383494 100644 --- a/modules/siprec/siprec_var.c +++ b/modules/siprec/siprec_var.c @@ -28,6 +28,7 @@ #define SIPREC_VAR_CALLEE_ID (1 << 2) #define SIPREC_VAR_HEADERS_ID (1 << 3) #define SIPREC_VAR_MEDIA_ID (1 << 4) +#define SIPREC_VAR_SOCKET_ID (1 << 5) struct { const char *name; @@ -38,6 +39,7 @@ struct { {"callee", SIPREC_VAR_CALLEE_ID}, {"media_ip", SIPREC_VAR_MEDIA_ID}, {"headers", SIPREC_VAR_HEADERS_ID}, + {"socket", SIPREC_VAR_SOCKET_ID}, }; static int srec_msg_idx; @@ -177,6 +179,11 @@ int pv_get_siprec(struct sip_msg *msg, pv_param_t *param, case SIPREC_VAR_HEADERS_ID: field = &sv->headers; break; + case SIPREC_VAR_SOCKET_ID: + if (!sv->si) + return pv_get_null(msg, param, val); + field = get_socket_real_name(sv->si); + break; default: LM_BUG("unknown field!\n"); case SIPREC_VAR_INVAID_ID: @@ -221,6 +228,18 @@ int pv_set_siprec(struct sip_msg* msg, pv_param_t *param, case SIPREC_VAR_HEADERS_ID: field = &sv->headers; break; + case SIPREC_VAR_SOCKET_ID: + if (!(val->flags & PV_VAL_STR)) { + LM_ERR("invalid socket type!\n"); + return -1; + } + sv->si = parse_sock_info(&val->rs); + if (!sv->si) { + LM_ERR("socket info not existing %.*s\n", + val->rs.len, val->rs.s); + return -1; + } + return 1; default: LM_BUG("unknown field %d!\n", pv_parse_siprec_get_name(msg, param)); case SIPREC_VAR_INVAID_ID: diff --git a/modules/siprec/siprec_var.h b/modules/siprec/siprec_var.h index bc29ff8ebf0..e808cc5ac16 100644 --- a/modules/siprec/siprec_var.h +++ b/modules/siprec/siprec_var.h @@ -23,9 +23,11 @@ #include "../../str.h" #include "../../pvar.h" +#include "../../socket_info.h" struct srec_var { str group, caller, callee, media, headers; + struct socket_info *si; }; int init_srec_var(void);