From: Joshua Colp Date: Wed, 26 Oct 2016 11:32:04 +0000 (+0000) Subject: res_pjsip_sdp_rtp: Fix address family of explicit media_address. X-Git-Tag: 14.2.0-rc1~66^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=110c18f413292b976debcf257880e953e44e8a0d;p=thirdparty%2Fasterisk.git res_pjsip_sdp_rtp: Fix address family of explicit media_address. When an explicit media_address is provided the address family in the SDP needs to be set to reflect it. ASTERISK-26309 Change-Id: Ib9350cc91c120eb2f96f0623d3907d12af67eb79 --- diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c index 7937972c7b..0b65fee0d3 100644 --- a/res/res_pjsip_sdp_rtp.c +++ b/res/res_pjsip_sdp_rtp.c @@ -1047,6 +1047,7 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as pj_pool_t *pool = session->inv_session->pool_prov; static const pj_str_t STR_IN = { "IN", 2 }; static const pj_str_t STR_IP4 = { "IP4", 3}; + static const pj_str_t STR_IP6 = { "IP6", 3}; static const pj_str_t STR_SENDRECV = { "sendrecv", 8 }; static const pj_str_t STR_SENDONLY = { "sendonly", 8 }; pjmedia_sdp_media *media; @@ -1111,9 +1112,19 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as } media->conn->net_type = STR_IN; - /* Connection information will be updated by the multihomed module */ + /* Assume that the connection will use IPv4 until proven otherwise */ media->conn->addr_type = STR_IP4; pj_strdup2(pool, &media->conn->addr, hostip); + + if (!ast_strlen_zero(session->endpoint->media.address)) { + pj_sockaddr ip; + + if ((pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &media->conn->addr, &ip) == PJ_SUCCESS) && + (ip.addr.sa_family == pj_AF_INET6())) { + media->conn->addr_type = STR_IP6; + } + } + ast_rtp_instance_get_local_address(session_media->rtp, &addr); media->desc.port = direct_media_enabled ? ast_sockaddr_port(&session_media->direct_media_addr) : (pj_uint16_t) ast_sockaddr_port(&addr); media->desc.port_count = 1;