Skip to content

Commit

Permalink
rtpengine: add in-iface and out-iface params
Browse files Browse the repository at this point in the history
These new params can be used to specify rtpengine interface in bridge
mode
  • Loading branch information
razvancrainea committed Nov 22, 2017
1 parent cd6d003 commit c2f8c02
Show file tree
Hide file tree
Showing 4 changed files with 2,113 additions and 29 deletions.
30 changes: 15 additions & 15 deletions modules/rtpengine/README
Expand Up @@ -318,21 +318,21 @@ rtpengine_offer();
SDP when corresponding session already exists in the
RTP proxy. By default is on when the session is to be
completed.
+ internal, external - these flags specify the direction
of the SIP message. These flags only make sense when
the RTP proxy is running in bridge mode. "internal"
corresponds to the proxy's first interface, "external"
corresponds to the RTP proxy's second interface. You
always have to specify two flags to define the
incoming network and the outgoing network. For
example, "internal external" should be used for SIP
message received from the local interface and sent out
on the external interface, and "external internal"
vice versa. Other options are "internal internal" and
"external external". So, for example if a SIP requests
is processed with "internal external" flags, the
corresponding response must be processed with
"internal external" flags.
+ in-iface=..., out-iface=... - these flags specify the
direction the SIP message. These flags only make sense
when the RTP proxy is running in bridge mode.
"in-iface" should indicate the proxy's inbound
interface, and "out-iface" corresponds to the RTP
proxy's outbound interface. You always have to specify
two flags to define the incoming network and the
outgoing network. For example, "in-iface=internal
out-iface=external" should be used for SIP message
received from the local interface and sent out on the
external interface.
+ internal, external - these the old flags used to
specify the direction of call. They are now obsolate,
being replaced by the "in-iface=internal
out-iface=external" configuration.
+ auto-bridge - this flag an alternative to the
"internal" and "external" flags in order to do
automatic bridging between IPv4 on the "internal
Expand Down
24 changes: 12 additions & 12 deletions modules/rtpengine/doc/rtpengine_admin.xml
Expand Up @@ -310,20 +310,20 @@ rtpengine_offer();
completed.
</para></listitem>
<listitem><para>
<emphasis>internal, external</emphasis> - these flags specify the direction of
<emphasis>in-iface=..., out-iface=...</emphasis> - these flags specify the direction
the SIP message. These flags only make sense when the &rtp; proxy is running
in bridge mode. <quote>internal</quote> corresponds to the proxy's first
interface, <quote>external</quote> corresponds to the &rtp; proxy's
second interface. You always have to specify two flags to define
the incoming network and the outgoing network. For example, <quote>internal
external</quote> should be
in bridge mode. <quote>in-iface</quote> should indicate the proxy's inbound
interface, and <quote>out-iface</quote> corresponds to the &rtp; proxy's
outbound interface. You always have to specify two flags to define
the incoming network and the outgoing network. For example,
<quote>in-iface=internal out-iface=external</quote> should be
used for SIP message received from the local interface and sent out on the
external interface, and <quote>external internal</quote> vice versa. Other
options are <quote>internal internal</quote> and <quote>external
external</quote>.
So, for example if a SIP requests is processed with <quote>internal
external</quote> flags, the corresponding
response must be processed with <quote>internal external</quote> flags.
external interface.
</para></listitem>
<listitem><para>
<emphasis>internal, external</emphasis> - these the old flags used to
specify the direction of call. They are now obsolate, being replaced by the
<quote>in-iface=internal out-iface=external</quote> configuration.
</para></listitem>
<listitem><para>
<emphasis>auto-bridge</emphasis> - this flag an alternative to the
Expand Down
32 changes: 30 additions & 2 deletions modules/rtpengine/rtpengine.c
Expand Up @@ -1029,10 +1029,13 @@ static int parse_flags(struct ng_flags_parse *ng_flags, struct sip_msg *msg,
str key, val;
int delete_delay;
bencode_item_t *bitem;
str iniface, outiface;

if (!flags_str)
return 0;

iniface.len = outiface.len = 0;

while (1) {
while (*flags_str == ' ')
flags_str++;
Expand Down Expand Up @@ -1108,20 +1111,24 @@ static int parse_flags(struct ng_flags_parse *ng_flags, struct sip_msg *msg,

case 8:
if (str_eq(&key, "internal"))
bencode_list_add_string(ng_flags->direction, "internal");
iniface = key;
else if (str_eq(&key, "external"))
bencode_list_add_string(ng_flags->direction, "external");
outiface = key;
else if (str_eq(&key, "RTP/AVPF"))
ng_flags->transport = 0x102;
else if (str_eq(&key, "RTP/SAVP"))
ng_flags->transport = 0x101;
else if (str_eq(&key, "in-iface"))
iniface = val;
else
break;
continue;

case 9:
if (str_eq(&key, "RTP/SAVPF"))
ng_flags->transport = 0x103;
else if (str_eq(&key, "out-iface"))
outiface = val;
else
break;
continue;
Expand Down Expand Up @@ -1262,6 +1269,27 @@ static int parse_flags(struct ng_flags_parse *ng_flags, struct sip_msg *msg,
}
}

if (iniface.len != 0 && outiface.len != 0) {
bitem = bencode_str(bencode_item_buffer(ng_flags->direction), &iniface);
if (!bitem) {
err = "no more memory";
goto error;
}
BCHECK(bencode_list_add(ng_flags->direction, bitem));
bitem = bencode_str(bencode_item_buffer(ng_flags->direction), &outiface);
if (!bitem) {
err = "no more memory";
goto error;
}
BCHECK(bencode_list_add(ng_flags->direction, bitem));
} else if (iniface.len) {
LM_ERR("in-iface value without out-iface\n");
return -1;
} else if (outiface.len) {
LM_ERR("out-iface value without in-iface\n");
return -1;
}

return 0;

error:
Expand Down

0 comments on commit c2f8c02

Please sign in to comment.