Skip to content

Commit

Permalink
tm: KEMI expose t_relay_to_xxx protocol functions
Browse files Browse the repository at this point in the history
In KEMI let's expose
    t_relay_to_tcp
    t_relay_to_udp
    t_relay_to_tls
to force the transport.
  • Loading branch information
aalba6675 committed Nov 26, 2020
1 parent fb878ee commit 6520ee4
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/modules/tm/tm.c
Expand Up @@ -2897,6 +2897,29 @@ static int ki_t_relay(sip_msg_t *msg)
return _w_t_relay_to(msg, (struct proxy_l *)0, PROTO_NONE);
}

/**
*
*/
static int ki_t_relay_to_proto(sip_msg_t *msg, str *sproto)
{

int proto = PROTO_NONE;

if (sproto != NULL && sproto->s != NULL && sproto->len == 3) {
if (strncasecmp(sproto->s, "UDP", 3) == 0) {
proto = PROTO_UDP;
} else if (strncasecmp(sproto->s, "TCP", 3) == 0) {
proto = PROTO_TCP;
} else if (strncasecmp(sproto->s, "TLS", 3)) {
proto = PROTO_TLS;
} else {
LM_ERR("t_relay_to_proto failed, bad protocol specified <%s>\n", sproto->s);
return E_UNSPEC;
}
}
return _w_t_relay_to(msg, (struct proxy_l *)0, proto);
}

/**
*
*/
Expand Down Expand Up @@ -3226,6 +3249,11 @@ static sr_kemi_t tm_kemi_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
{ str_init("tm"), str_init("t_relay_to_proto"),
SR_KEMIP_INT, ki_t_relay_to_proto,
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
{ str_init("tm"), str_init("t_get_status_code"),
SR_KEMIP_INT, ki_t_get_status_code,
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
Expand Down

0 comments on commit 6520ee4

Please sign in to comment.