diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 92ef5d3aa3..818dd442ac 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -1945,3 +1945,13 @@ int call_interfaces_init() { return 0; } + + +void format_network_address(str* o, struct packet_stream *ps, struct sdp_ng_flags *flags, int keep_unspec) { + if (!is_addr_unspecified(&flags->parsed_media_address)) + o->len = sprintf(o->s, "%s %s", + flags->parsed_media_address.family->rfc_name, + sockaddr_print_buf(&flags->parsed_media_address)); + else + call_stream_address46(o->s, ps, SAF_NG, &o->len, NULL, keep_unspec); +} diff --git a/daemon/sdp.c b/daemon/sdp.c index 00fa92e98f..acace8ac48 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -1571,7 +1571,7 @@ static int replace_network_address(struct sdp_chopper *chop, struct network_addr struct packet_stream *ps, struct sdp_ng_flags *flags, int keep_unspec) { char buf[64]; - int len; + str res = { buf, 0 }; struct packet_stream *sink = packet_stream_sink(ps); if (is_addr_unspecified(&address->parsed) @@ -1583,14 +1583,9 @@ static int replace_network_address(struct sdp_chopper *chop, struct network_addr if (flags->media_address.s && is_addr_unspecified(&flags->parsed_media_address)) __parse_address(&flags->parsed_media_address, NULL, NULL, &flags->media_address); - - if (!is_addr_unspecified(&flags->parsed_media_address)) - len = sprintf(buf, "%s %s", - flags->parsed_media_address.family->rfc_name, - sockaddr_print_buf(&flags->parsed_media_address)); - else - call_stream_address46(buf, ps, SAF_NG, &len, NULL, keep_unspec); - chopper_append(chop, buf, len); + + format_network_address(&res, ps, flags, keep_unspec); + chopper_append(chop, res.s, res.len); if (skip_over(chop, &address->address)) return -1; diff --git a/include/call_interfaces.h b/include/call_interfaces.h index f225e7450f..2b81797eb8 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -124,5 +124,6 @@ void ng_call_stats(struct call *call, const str *fromtag, const str *totag, benc int call_interfaces_init(void); +void format_network_address(str* o, struct packet_stream *ps, struct sdp_ng_flags *flags, int keep_unspec); #endif