Merge "configure: Don't use the progress bar with curl when downloading to stdout"
authorJoshua Colp <jcolp@digium.com>
Wed, 15 Mar 2017 18:01:16 +0000 (13:01 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Wed, 15 Mar 2017 18:01:16 +0000 (13:01 -0500)
configs/samples/hep.conf.sample
main/stasis_cache.c
res/res_pjsip.c
res/res_pjsip_endpoint_identifier_ip.c
res/res_pjsip_outbound_registration.c
res/res_pjsip_transport_websocket.c
third-party/pjproject/patches/0014-Add-pjsip-transport-register-type-ipv6.patch [new file with mode: 0644]

index e1cd52e..3d1e741 100644 (file)
@@ -2,6 +2,15 @@
 ; res_hep Module configuration for Asterisk
 ;
 
+;
+; Note that this configuration file is consumed by res_hep, which is responsible
+; for the HEPv3 protocol manipulation and managing the connection to the Homer
+; capture server. Additional modules provide specific messages to be sent to
+; the Homer server:
+;  - res_hep_pjsip: Send SIP messages transmitted/received by the PJSIP stack
+;  - res_hep_rtcp: Send RTCP information (all channels)
+;
+
 ; All settings are currently set in the general section.
 [general]
 enabled = no                       ; Enable/disable forwarding of packets to a
@@ -17,4 +26,3 @@ uuid_type = call-id                ; Specify the preferred source for the Homer
                                    ; correlation UUID. Valid options are:
                                    ; - 'call-id' for the PJSIP SIP Call-ID
                                    ; - 'channel' for the Asterisk channel name
-
index e632a21..ce4e023 100644 (file)
@@ -840,7 +840,7 @@ static void caching_topic_exec(void *data, struct stasis_subscription *sub,
                        }
                        ao2_cleanup(update);
                } else {
-                       ast_log(LOG_ERROR,
+                       ast_debug(1,
                                "Attempting to remove an item from the %s cache that isn't there: %s %s\n",
                                stasis_topic_name(caching_topic->topic),
                                stasis_message_type_name(msg_type), msg_id);
index 810b6d3..e1800e2 100644 (file)
@@ -2757,7 +2757,7 @@ static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *u
        pj_str_t tmp, local_addr;
        pjsip_uri *uri;
        pjsip_sip_uri *sip_uri;
-       pjsip_transport_type_e type = PJSIP_TRANSPORT_UNSPECIFIED;
+       pjsip_transport_type_e type;
        int local_port;
        char default_user[PJSIP_MAX_URL_SIZE];
 
@@ -2777,21 +2777,21 @@ static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *u
        sip_uri = pjsip_uri_get_uri(uri);
 
        /* Determine the transport type to use */
+       type = pjsip_transport_get_type_from_name(&sip_uri->transport_param);
        if (PJSIP_URI_SCHEME_IS_SIPS(sip_uri)) {
-               type = PJSIP_TRANSPORT_TLS;
+               if (type == PJSIP_TRANSPORT_UNSPECIFIED
+                       || !(pjsip_transport_get_flag_from_type(type) & PJSIP_TRANSPORT_SECURE)) {
+                       type = PJSIP_TRANSPORT_TLS;
+               }
        } else if (!sip_uri->transport_param.slen) {
                type = PJSIP_TRANSPORT_UDP;
-       } else {
-               type = pjsip_transport_get_type_from_name(&sip_uri->transport_param);
-       }
-
-       if (type == PJSIP_TRANSPORT_UNSPECIFIED) {
+       } else if (type == PJSIP_TRANSPORT_UNSPECIFIED) {
                return -1;
        }
 
        /* If the host is IPv6 turn the transport into an IPv6 version */
-       if (pj_strchr(&sip_uri->host, ':') && type < PJSIP_TRANSPORT_START_OTHER) {
-               type = (pjsip_transport_type_e)(((int)type) + PJSIP_TRANSPORT_IPV6);
+       if (pj_strchr(&sip_uri->host, ':')) {
+               type |= PJSIP_TRANSPORT_IPV6;
        }
 
        if (!ast_strlen_zero(domain)) {
@@ -2815,8 +2815,8 @@ static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *u
        }
 
        /* If IPv6 was specified in the transport, set the proper type */
-       if (pj_strchr(&local_addr, ':') && type < PJSIP_TRANSPORT_START_OTHER) {
-               type = (pjsip_transport_type_e)(((int)type) + PJSIP_TRANSPORT_IPV6);
+       if (pj_strchr(&local_addr, ':')) {
+               type |= PJSIP_TRANSPORT_IPV6;
        }
 
        from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
index 86a5afb..a732384 100644 (file)
@@ -57,7 +57,7 @@
                                        perform SRV lookups for _sip._udp, _sip._tcp, and _sips._tcp of the given
                                        hostnames to determine additional addresses that traffic may originate from.
                                        </para></description>
-                                </configOption>
+                               </configOption>
                                <configOption name="type">
                                        <synopsis>Must be of type 'identify'.</synopsis>
                                </configOption>
index 538967e..704239b 100644 (file)
@@ -1086,7 +1086,7 @@ static int sip_dialog_create_contact(pj_pool_t *pool, pj_str_t *contact, const c
        pj_str_t tmp, local_addr;
        pjsip_uri *uri;
        pjsip_sip_uri *sip_uri;
-       pjsip_transport_type_e type = PJSIP_TRANSPORT_UNSPECIFIED;
+       pjsip_transport_type_e type;
        int local_port;
 
        pj_strdup_with_null(pool, &tmp, target);
@@ -1098,20 +1098,20 @@ static int sip_dialog_create_contact(pj_pool_t *pool, pj_str_t *contact, const c
 
        sip_uri = pjsip_uri_get_uri(uri);
 
+       type = pjsip_transport_get_type_from_name(&sip_uri->transport_param);
        if (PJSIP_URI_SCHEME_IS_SIPS(sip_uri)) {
-               type = PJSIP_TRANSPORT_TLS;
+               if (type == PJSIP_TRANSPORT_UNSPECIFIED
+                       || !(pjsip_transport_get_flag_from_type(type) & PJSIP_TRANSPORT_SECURE)) {
+                       type = PJSIP_TRANSPORT_TLS;
+               }
        } else if (!sip_uri->transport_param.slen) {
                type = PJSIP_TRANSPORT_UDP;
-       } else {
-               type = pjsip_transport_get_type_from_name(&sip_uri->transport_param);
-       }
-
-       if (type == PJSIP_TRANSPORT_UNSPECIFIED) {
+       } else if (type == PJSIP_TRANSPORT_UNSPECIFIED) {
                return -1;
        }
 
        if (pj_strchr(&sip_uri->host, ':')) {
-               type = (pjsip_transport_type_e)(((int)type) + PJSIP_TRANSPORT_IPV6);
+               type |= PJSIP_TRANSPORT_IPV6;
        }
 
        if (pjsip_tpmgr_find_local_addr(pjsip_endpt_get_tpmgr(ast_sip_get_pjsip_endpoint()),
@@ -1120,7 +1120,7 @@ static int sip_dialog_create_contact(pj_pool_t *pool, pj_str_t *contact, const c
        }
 
        if (!pj_strchr(&sip_uri->host, ':') && pj_strchr(&local_addr, ':')) {
-               type = (pjsip_transport_type_e)(((int)type) + PJSIP_TRANSPORT_IPV6);
+               type |= PJSIP_TRANSPORT_IPV6;
        }
 
        contact->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
index a52b42d..b3e63fc 100644 (file)
@@ -39,6 +39,7 @@
 #include "asterisk/taskprocessor.h"
 
 static int transport_type_wss;
+static int transport_type_wss_ipv6;
 
 /*!
  * \brief Wrapper for pjsip_transport, for storing the WebSocket session
@@ -198,15 +199,20 @@ static int transport_create(void *data)
                newtransport->transport.type_name, ws_addr_str);
 
        pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&buf, ws_addr_str), &newtransport->transport.key.rem_addr);
-       newtransport->transport.key.rem_addr.addr.sa_family = pj_AF_INET();
-       newtransport->transport.key.type = transport_type_wss;
+       if (newtransport->transport.key.rem_addr.addr.sa_family == pj_AF_INET6()) {
+               newtransport->transport.key.type = transport_type_wss_ipv6;
+               newtransport->transport.local_name.host.ptr = (char *)pj_pool_alloc(pool, PJ_INET6_ADDRSTRLEN);
+               pj_sockaddr_print(&newtransport->transport.key.rem_addr, newtransport->transport.local_name.host.ptr, PJ_INET6_ADDRSTRLEN, 0);
+       } else {
+               newtransport->transport.key.type = transport_type_wss;
+               newtransport->transport.local_name.host.ptr = (char *)pj_pool_alloc(pool, PJ_INET_ADDRSTRLEN);
+               pj_sockaddr_print(&newtransport->transport.key.rem_addr, newtransport->transport.local_name.host.ptr, PJ_INET_ADDRSTRLEN, 0);
+       }
 
        newtransport->transport.addr_len = pj_sockaddr_get_len(&newtransport->transport.key.rem_addr);
 
        pj_sockaddr_cp(&newtransport->transport.local_addr, &newtransport->transport.key.rem_addr);
 
-       newtransport->transport.local_name.host.ptr = (char *)pj_pool_alloc(pool, newtransport->transport.addr_len+4);
-       pj_sockaddr_print(&newtransport->transport.key.rem_addr, newtransport->transport.local_name.host.ptr, newtransport->transport.addr_len+4, 0);
        newtransport->transport.local_name.host.slen = pj_ansi_strlen(newtransport->transport.local_name.host.ptr);
        newtransport->transport.local_name.port = pj_sockaddr_get_port(&newtransport->transport.key.rem_addr);
 
@@ -271,8 +277,6 @@ static int transport_read(void *data)
        rdata->pkt_info.zero = 0;
 
        pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&buf, ast_sockaddr_stringify(ast_websocket_remote_address(session))), &rdata->pkt_info.src_addr);
-       rdata->pkt_info.src_addr.addr.sa_family = pj_AF_INET();
-
        rdata->pkt_info.src_addr_len = sizeof(rdata->pkt_info.src_addr);
 
        pj_ansi_strcpy(rdata->pkt_info.src_name, ast_sockaddr_stringify_host(ast_websocket_remote_address(session)));
@@ -395,7 +399,7 @@ static pj_bool_t websocket_on_rx_msg(pjsip_rx_data *rdata)
 
        long type = rdata->tp_info.transport->key.type;
 
-       if (type != (long) transport_type_wss) {
+       if (type != (long) transport_type_wss && type != (long) transport_type_wss_ipv6) {
                return PJ_FALSE;
        }
 
@@ -451,15 +455,17 @@ static int load_module(void)
        CHECK_PJSIP_MODULE_LOADED();
 
        /*
-        * We only need one transport type defined.  Firefox and Chrome
-        * do not support anything other than secure websockets anymore.
+        * We only need one transport type name (ws) defined.  Firefox
+        * and Chrome do not support anything other than secure websockets
+        * anymore.
         *
         * Also we really cannot have two transports with the same name
-        * because it would be ambiguous.  Outgoing requests may try to
-        * find the transport by name and pjproject only finds the first
-        * one registered.
+        * and address family because it would be ambiguous.  Outgoing
+        * requests may try to find the transport by name and pjproject
+        * only finds the first one registered.
         */
        pjsip_transport_register_type(PJSIP_TRANSPORT_RELIABLE | PJSIP_TRANSPORT_SECURE, "ws", 5060, &transport_type_wss);
+       pjsip_transport_register_type(PJSIP_TRANSPORT_RELIABLE | PJSIP_TRANSPORT_SECURE | PJSIP_TRANSPORT_IPV6, "ws", 5060, &transport_type_wss_ipv6);
 
        if (ast_sip_register_service(&websocket_module) != PJ_SUCCESS) {
                return AST_MODULE_LOAD_DECLINE;
diff --git a/third-party/pjproject/patches/0014-Add-pjsip-transport-register-type-ipv6.patch b/third-party/pjproject/patches/0014-Add-pjsip-transport-register-type-ipv6.patch
new file mode 100644 (file)
index 0000000..796473a
--- /dev/null
@@ -0,0 +1,62 @@
+From daeb0956524606b597704a90b54d81340e10b3e4 Mon Sep 17 00:00:00 2001
+From: Joshua Colp <jcolp@digium.com>
+Date: Tue, 7 Mar 2017 12:32:49 +0000
+Subject: [PATCH] Add support for registering IPv6 transport type.
+
+This change allows an IPv6 transport type to be registered
+and used. The IPv4 transport is found (if available) and the
+IPv4 flag added to its type to match how the finding of
+IPv6 transport types works.
+---
+ pjsip/src/pjsip/sip_transport.c | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c
+index 7df6138..ce72814 100644
+--- a/pjsip/src/pjsip/sip_transport.c
++++ b/pjsip/src/pjsip/sip_transport.c
+@@ -236,6 +236,7 @@ PJ_DEF(pj_status_t) pjsip_transport_register_type( unsigned tp_flag,
+                                                  int *p_tp_type)
+ {
+     unsigned i;
++    pjsip_transport_type_e parent = 0;
+     PJ_ASSERT_RETURN(tp_flag && tp_name && def_port, PJ_EINVAL);
+     PJ_ASSERT_RETURN(pj_ansi_strlen(tp_name) <
+@@ -243,6 +244,11 @@ PJ_DEF(pj_status_t) pjsip_transport_register_type( unsigned tp_flag,
+                    PJ_ENAMETOOLONG);
+     for (i=1; i<PJ_ARRAY_SIZE(transport_names); ++i) {
++        if (tp_flag & PJSIP_TRANSPORT_IPV6 &&
++            pj_stricmp2(&transport_names[i].name, tp_name) == 0)
++        {
++          parent = transport_names[i].type;
++        }
+       if (transport_names[i].type == 0)
+           break;
+     }
+@@ -250,14 +256,19 @@ PJ_DEF(pj_status_t) pjsip_transport_register_type( unsigned tp_flag,
+     if (i == PJ_ARRAY_SIZE(transport_names))
+       return PJ_ETOOMANY;
+-    transport_names[i].type = (pjsip_transport_type_e)i;
++    if (tp_flag & PJSIP_TRANSPORT_IPV6 && parent) {
++        transport_names[i].type = parent | PJSIP_TRANSPORT_IPV6;
++    } else {
++        transport_names[i].type = (pjsip_transport_type_e)i;
++    }
++
+     transport_names[i].port = (pj_uint16_t)def_port;
+     pj_ansi_strcpy(transport_names[i].name_buf, tp_name);
+     transport_names[i].name = pj_str(transport_names[i].name_buf);
+     transport_names[i].flag = tp_flag;
+     if (p_tp_type)
+-      *p_tp_type = i;
++      *p_tp_type = transport_names[i].type;
+     return PJ_SUCCESS;
+ }
+-- 
+2.7.4
+