diff --git a/daemon/control_ng_flags_parser.c b/daemon/control_ng_flags_parser.c index 488063c58..765a6d100 100644 --- a/daemon/control_ng_flags_parser.c +++ b/daemon/control_ng_flags_parser.c @@ -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); } diff --git a/t/auto-daemon-tests-rtpp-flags.pl b/t/auto-daemon-tests-rtpp-flags.pl index 694f5907f..965735bb7 100644 --- a/t/auto-daemon-tests-rtpp-flags.pl +++ b/t/auto-daemon-tests-rtpp-flags.pl @@ -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' }, < 'internal external' }, <