Author: mmichelson Date: Thu Aug 21 16:43:45 2014 New Revision: 421798 URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=421798 Log: Switch from hostname to an IP address in the SDP origin line.
Using the hostname in the SDP origin line may not satisfy the requirement of RFC 4566 that we use a FQDN or IP address. This change has us use the same information from the SDP connection line if possible. If not possible, we'll use the configured media address. And if that's not possible, we use the result of a PJLIB call to get the IP address of ourself. ASTERISK-23994 #close Reported by Private Name Review: https://reviewboard.asterisk.org/r/3925 ........ Merged revisions 421796 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 421797 from http://svn.asterisk.org/svn/asterisk/branches/13 Modified: trunk/ (props changed) trunk/res/res_pjsip_session.c Propchange: trunk/ ------------------------------------------------------------------------------ Binary property 'branch-13-merged' - no diff available. Modified: trunk/res/res_pjsip_session.c URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_session.c?view=diff&rev=421798&r1=421797&r2=421798 ============================================================================== --- trunk/res/res_pjsip_session.c (original) +++ trunk/res/res_pjsip_session.c Thu Aug 21 16:43:45 2014 @@ -50,9 +50,6 @@ #define MOD_DATA_ON_RESPONSE "on_response" #define MOD_DATA_NAT_HOOK "nat_hook" - -/* Hostname used for origin line within SDP */ -static const pj_str_t *hostname; /* Some forward declarations */ static void handle_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata, pjsip_event_id_e type); @@ -2094,9 +2091,6 @@ } pj_strdup2(inv->pool, &local->origin.user, session->endpoint->media.sdpowner); - local->origin.net_type = STR_IN; - local->origin.addr_type = session->endpoint->media.rtp.ipv6 ? STR_IP6 : STR_IP4; - local->origin.addr = *hostname; pj_strdup2(inv->pool, &local->name, session->endpoint->media.sdpsession); /* Now let the handlers add streams of various types, pjmedia will automatically reorder the media streams for us */ @@ -2109,6 +2103,23 @@ /* Use the connection details of the first media stream if possible for SDP level */ if (local->media_count) { local->conn = local->media[0]->conn; + pj_strassign(&local->origin.net_type, &local->conn->net_type); + pj_strassign(&local->origin.addr_type, &local->conn->addr_type); + pj_strassign(&local->origin.addr, &local->conn->addr); + } else { + local->origin.net_type = STR_IN; + local->origin.addr_type = session->endpoint->media.rtp.ipv6 ? STR_IP6 : STR_IP4; + + if (!ast_strlen_zero(session->endpoint->media.address)) { + pj_strdup2(inv->pool, &local->origin.addr, session->endpoint->media.address); + } else { + pj_sockaddr localaddr; + char our_ip[PJ_INET6_ADDRSTRLEN]; + + pj_gethostip(session->endpoint->media.rtp.ipv6 ? pj_AF_INET6() : pj_AF_INET(), &localaddr); + pj_sockaddr_print(&localaddr, our_ip, sizeof(our_ip), 0); + pj_strdup2(inv->pool, &local->origin.addr, our_ip); + } } return local; @@ -2258,6 +2269,7 @@ static int load_module(void) { pjsip_endpoint *endpt; + if (!ast_sip_get_sorcery() || !ast_sip_get_pjsip_endpoint()) { return AST_MODULE_LOAD_DECLINE; } @@ -2275,7 +2287,6 @@ pjsip_inv_usage_init(endpt, &inv_callback); pjsip_100rel_init_module(endpt); pjsip_timer_init_module(endpt); - hostname = pj_gethostname(); if (ast_sip_register_service(&session_module)) { return AST_MODULE_LOAD_DECLINE; } -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- svn-commits mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/svn-commits