Skip to content

Commit

Permalink
siprec: specify socket through the $siprec variable
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Nov 23, 2021
1 parent 153256c commit aee3e68
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions modules/siprec/doc/siprec_admin.xml
Expand Up @@ -457,6 +457,10 @@ modparam("siprec", "skip_failover_codes", "[34][0-9][0-9]")
<emphasis>NOTE:</emphasis> headers must be separated by
<emphasis>\r\n</emphasis> and must end with <emphasis>\r\n</emphasis>.
</para></listitem>
<listitem><para>
<emphasis>socket</emphasis> - listening socket that the outgoing
request towards SRS should be used.
</para></listitem>
</itemizedlist>
</section>

Expand Down
2 changes: 1 addition & 1 deletion modules/siprec/siprec.c
Expand Up @@ -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;
}
Expand Down
19 changes: 19 additions & 0 deletions modules/siprec/siprec_var.c
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions modules/siprec/siprec_var.h
Expand Up @@ -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);
Expand Down

0 comments on commit aee3e68

Please sign in to comment.