MT#55283 emulate legacy direction=... parsing

... using from-interface and to-interface keys. Add tests to that
effect.

Change-Id: I03c6c3e5effadb1be9a8e875a1ec0daa20055209
pull/1848/head
Richard Fuchs 1 year ago
parent 5f78fbfa02
commit d90b7cda8c

@ -189,6 +189,17 @@ static bool parse_str_flag(str * key, str * val, const char * name,
}
#endif
static void rtpp_direction_flag(ng_parser_ctx_t *ctx, bencode_buffer_t *buf, unsigned int *flagnum, str *val) {
static const str keys[2] = {STR_CONST("from-interface"), STR_CONST("to-interface")};
if (*flagnum >= G_N_ELEMENTS(keys)) {
ilog(LOG_WARN, "Too many 'direction=...' flags encountered");
return;
}
str key = keys[(*flagnum)++];
call_ng_main_flags(ctx, &key, bencode_str(buf, val), NULL);
}
/**
* Parse flags from bencode string into given bencode dictionary.
*
@ -199,7 +210,7 @@ static bool parse_str_flag(str * key, str * val, const char * name,
void parse_rtpp_flags(const str * rtpp_flags, ng_parser_ctx_t *ctx)
{
str remainder, key, val;
bencode_item_t * direction;
unsigned int direction_flag = 0;
unsigned int transport = 0;
bencode_buffer_t *buf = &ctx->ngbuf->buffer;
@ -208,8 +219,6 @@ void parse_rtpp_flags(const str * rtpp_flags, ng_parser_ctx_t *ctx)
remainder = *rtpp_flags;
direction = bencode_list(buf);
while (remainder.len)
{
/* skip spaces */
@ -277,7 +286,7 @@ void parse_rtpp_flags(const str * rtpp_flags, ng_parser_ctx_t *ctx)
}
/* direction */
else if (str_eq(&key, "internal") || str_eq(&key, "external"))
bencode_list_add_str(direction, &key);
rtpp_direction_flag(ctx, buf, &direction_flag, &key);
/* other non-defined flags */
else
goto generic;
@ -289,7 +298,7 @@ void parse_rtpp_flags(const str * rtpp_flags, ng_parser_ctx_t *ctx)
transport = 0x103;
/* direction */
else if (str_eq(&key, "direction"))
bencode_list_add_str(direction, &val);
rtpp_direction_flag(ctx, buf, &direction_flag, &val);
else
goto generic;
goto next;
@ -326,8 +335,4 @@ next:;
/* define transport */
if (transport)
parse_transports(ctx, buf, transport);
/* add directions to the root dict */
if (direction && direction->child)
call_ng_direction_flag(ctx, direction);
}

@ -10,6 +10,7 @@ use NGCP::Rtpclient::ICE;
use POSIX;
autotest_start(qw(--config-file=none -t -1 -i 203.0.113.1 -i 2001:db8:4321::1
-i foo/203.0.113.7 -i bar/203.0.113.8
-n 2223 -c 12345 -f -L 7 -E -u 2222 --silence-detect=1 --log-level-internals=7))
or die;
@ -301,5 +302,89 @@ a=sendrecv
a=rtcp:PORT
SDP
new_call;
offer('direction', { 'rtpp-flags' => 'direction=foo direction=bar' }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 2000 RTP/AVP 0
c=IN IP4 198.51.100.1
a=sendrecv
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.8
a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
SDP
answer('direction', { }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.3
s=tester
t=0 0
m=audio 2002 RTP/AVP 0
c=IN IP4 198.51.100.3
a=sendrecv
--------------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.3
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.7
a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
SDP
new_call;
offer('int/ext', { 'rtpp-flags' => 'internal external' }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 2000 RTP/AVP 0
c=IN IP4 198.51.100.1
a=sendrecv
----------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP6 2001:db8:4321::1
a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
SDP
answer('direction', { }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.3
s=tester
t=0 0
m=audio 2002 RTP/AVP 0
c=IN IP6 2001:db8:4321::7
a=sendrecv
--------------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.3
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
SDP
#done_testing;NGCP::Rtpengine::AutoTest::terminate('f00');exit;
done_testing();
done_testing();

Loading…
Cancel
Save