Merge "res_pjsip_outbound_registration: Subscribe to network change events"
authorJoshua Colp <jcolp@digium.com>
Wed, 1 Mar 2017 01:25:04 +0000 (19:25 -0600)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Wed, 1 Mar 2017 01:25:04 +0000 (19:25 -0600)
Makefile
bridges/bridge_native_rtp.c
configs/samples/pjsip.conf.sample
include/asterisk/bridge_technology.h
main/Makefile
res/res_pjsip.c
res/res_pjsip/pjsip_options.c
res/res_pjsip_outbound_publish.c
res/res_pjsip_outbound_registration.c
res/res_pjsip_pubsub.c

index 80845d5..2c7f925 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -652,6 +652,37 @@ ifneq ($(LDCONFIG),)
        fi
 endif
 
+ifeq ($(and $(findstring 64,$(HOST_CPU)),$(findstring lib64,$(DESTDIR)$(ASTLIBDIR))),lib64)
+_oldlibdir = $(subst lib64,lib,$(DESTDIR)$(ASTLIBDIR))
+
+check-old-libdir:
+       @oldfiles=`find "$(_oldlibdir)" -name libasterisk* -print -quit -o \( -path *asterisk/modules/* -a -name *.so \) -print -quit` ;\
+       if [ "x$$oldfiles" != "x" ] ; then \
+               echo " WARNING WARNING WARNING" ;\
+               echo "" ;\
+               echo " Installation is to: " ;\
+               echo "   $(DESTDIR)$(ASTLIBDIR)" ;\
+               echo " but there are asterisk shared libraries in: " ;\
+               echo "   $(_oldlibdir)" ;\
+               echo " or" ;\
+               echo "   $(_oldlibdir)/asterisk/modules" ;\
+               echo "" ;\
+               echo " It is unlikely that asterisk will start." ;\
+               echo "" ;\
+               echo " You should do one of the following..." ;\
+               echo "  * Run 'make uninstall' to remove the incorrect libraries" ;\
+               echo "    then run 'make install' again." ;\
+               echo "  * Manually remove the libraries from" ;\
+               echo "   $(_oldlibdir)" ;\
+               echo "   and run 'ldconfig' to rebuild the linker cache." ;\
+               echo "" ;\
+               echo " WARNING WARNING WARNING" ;\
+       fi
+else
+check-old-libdir:
+
+endif
+
 badshell:
 ifneq ($(filter ~%,$(DESTDIR)),)
        @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
@@ -691,6 +722,7 @@ install: badshell bininstall datafiles
        @echo " +-------------------------------------------+"
        @$(MAKE) -s oldmodcheck
        @$(MAKE) -s ld-cache-update
+       @$(MAKE) -s check-old-libdir
 
 isntall: install
 
@@ -911,6 +943,7 @@ main-binuninstall:
 
 _uninstall: $(SUBDIRS_UNINSTALL) main-binuninstall
        rm -f "$(DESTDIR)$(ASTMODDIR)/"*
+       rm -f "$(subst lib64,lib,$(DESTDIR)$(ASTMODDIR))/"*
        rm -f "$(DESTDIR)$(ASTSBINDIR)/astgenkey"
        rm -f "$(DESTDIR)$(ASTSBINDIR)/autosupport"
        rm -rf "$(DESTDIR)$(ASTHEADERDIR)"
@@ -943,6 +976,7 @@ uninstall: _uninstall
 
 uninstall-all: _uninstall
        rm -rf "$(DESTDIR)$(ASTMODDIR)"
+       rm -rf "$(subst lib64,lib,$(DESTDIR)$(ASTMODDIR))"
        rm -rf "$(DESTDIR)$(ASTVARLIBDIR)"
        rm -rf "$(DESTDIR)$(ASTDATADIR)"
        rm -rf "$(DESTDIR)$(ASTSPOOLDIR)"
@@ -1057,6 +1091,7 @@ check-alembic: makeopts
 .PHONY: basic-pbx
 .PHONY: check-alembic
 .PHONY: ld-cache-update
+.PHONY: check-old-libdir
 .PHONY: $(SUBDIRS_INSTALL)
 .PHONY: $(SUBDIRS_DIST_CLEAN)
 .PHONY: $(SUBDIRS_CLEAN)
index e011f50..77e321f 100644 (file)
@@ -129,7 +129,7 @@ static void native_rtp_bridge_start(struct ast_bridge *bridge, struct ast_channe
 {
        struct ast_bridge_channel *bc0 = AST_LIST_FIRST(&bridge->channels);
        struct ast_bridge_channel *bc1 = AST_LIST_LAST(&bridge->channels);
-       enum ast_rtp_glue_result native_type;
+       enum ast_rtp_glue_result native_type = AST_RTP_GLUE_RESULT_FORBID;
        struct ast_rtp_glue *glue0, *glue1;
        RAII_VAR(struct ast_rtp_instance *, instance0, NULL, ao2_cleanup);
        RAII_VAR(struct ast_rtp_instance *, instance1, NULL, ao2_cleanup);
@@ -145,7 +145,9 @@ static void native_rtp_bridge_start(struct ast_bridge *bridge, struct ast_channe
        }
 
        ast_channel_lock_both(bc0->chan, bc1->chan);
-       native_type = native_rtp_bridge_get(bc0->chan, bc1->chan, &glue0, &glue1, &instance0, &instance1, &vinstance0, &vinstance1);
+       if (!bc0->suspended && !bc1->suspended) {
+               native_type = native_rtp_bridge_get(bc0->chan, bc1->chan, &glue0, &glue1, &instance0, &instance1, &vinstance0, &vinstance1);
+       }
 
        switch (native_type) {
        case AST_RTP_GLUE_RESULT_LOCAL:
index 323100b..b18fdb2 100644 (file)
                         ; when placing on hold and sendrecv when taking off hold
 ;outbound_auth= ; Authentication object used for outbound requests (default:
                 ; "")
-;outbound_proxy=        ; Proxy through which to send requests a full SIP URI
+;outbound_proxy=        ; Proxy through which to send requests, a full SIP URI
                         ; must be provided (default: "")
 ;rewrite_contact=no     ; Allow Contact header to be rewritten with the source
                         ; IP address port (default: "no")
 ;qualify_timeout=3.0      ; Qualify timeout in fractional seconds (default: "3.0")
 ;authenticate_qualify=no        ; Authenticates a qualify request if needed
                                 ; (default: "no")
-;outbound_proxy=        ; Outbound proxy used when sending OPTIONS request
-                        ; (default: "")
+;outbound_proxy=        ; Proxy through which to send OPTIONS requests, a full SIP URI
+                        ; must be provided (default: "")
 
 
 ;==========================SYSTEM SECTION OPTIONS=========================
 ;max_forwards=70        ; Value used in Max Forwards header for SIP requests
                         ; (default: "70")
 ;type=  ; Must be of type global (default: "")
-;user_agent=Asterisk PBX SVN-branch-12-r404375  ; Value used in User Agent
-                                                ; header for SIP requests and
-                                                ; Server header for SIP
-                                                ; responses (default: "Asterisk
-                                                ; PBX SVN-branch-12-r404375")
+;user_agent=Asterisk PBX        ; Allows you to change the user agent string
+                                ; The default user agent string also contains
+                                ; the Asterisk version. If you don't want to
+                                ; expose this, change the user_agent string.
 ;default_outbound_endpoint=default_outbound_endpoint    ; Endpoint to use when
                                                         ; sending an outbound
                                                         ; request to a URI
 ;max_retries=10 ; Maximum number of registration attempts (default: "10")
 ;outbound_auth= ; Authentication object to be used for outbound registrations
                 ; (default: "")
-;outbound_proxy=        ; Outbound Proxy used to send registrations (default:
-                        ; "")
+;outbound_proxy=        ; Proxy through which to send registrations, a full SIP URI
+                        ; must be provided (default: "")
 ;retry_interval=60      ; Interval in seconds between retries if outbound
                         ; registration is unsuccessful (default: "60")
 ;forbidden_retry_interval=0     ; Interval used when receiving a 403 Forbidden
index 8df19d9..843d93c 100644 (file)
@@ -110,6 +110,9 @@ struct ast_bridge_technology {
         *
         * \note The bridge technology must tollerate a failed to join channel
         * until it can be kicked from the bridge.
+        *
+        * \note A channel may be in a suspended state already when joining a bridge
+        * technology. The technology must handle this case.
         */
        int (*join)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
        /*!
index d3463f7..cf38f5f 100644 (file)
@@ -359,16 +359,8 @@ endif
 binuninstall:
        rm -f "$(DESTDIR)$(ASTSBINDIR)/$(MAIN_TGT)"
        rm -f "$(DESTDIR)$(ASTSBINDIR)/rasterisk"
-ifneq ($(ASTSSL_LIB).$(ASTSSL_SO_VERSION),.)
-#   ASTSSL_SO_VERSION may not exist on Darwin
-       rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTSSL_LIB).$(ASTSSL_SO_VERSION)" || :
-       rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTSSL_LIB)"
-endif
-ifneq ($(ASTPJ_LIB).$(ASTPJ_SO_VERSION),.)
-#   ASTSSL_SO_VERSION may not exist on Darwin
-       rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTPJ_LIB).$(ASTPJ_SO_VERSION)" || :
-       rm -f "$(DESTDIR)$(ASTLIBDIR)/$(ASTPJ_LIB)"
-endif
+       rm -f "$(DESTDIR)$(ASTLIBDIR)/libasterisk"* || :
+       rm -f "$(subst lib64,lib,$(DESTDIR)$(ASTLIBDIR))/libasterisk"* || :
 
 clean::
        rm -f asterisk libasteriskssl.o
index 9782cc9..810b6d3 100644 (file)
                                        </description>
                                </configOption>
                                <configOption name="outbound_proxy">
-                                       <synopsis>Proxy through which to send requests, a full SIP URI must be provided</synopsis>
+                                       <synopsis>Full SIP URI of the outbound proxy used to send requests</synopsis>
                                </configOption>
                                <configOption name="rewrite_contact">
                                        <synopsis>Allow Contact header to be rewritten with the source IP address-port</synopsis>
index 6fd3c25..662166c 100644 (file)
@@ -1250,8 +1250,8 @@ int ast_sip_format_contact_ami(void *obj, void *arg, int flags)
        if (!ast_strlen_zero(contact->call_id)) {
                ast_str_append(&buf, 0, "CallID: %s\r\n", contact->call_id);
        }
-       ast_str_append(&buf, 0, "Status: %s\r\n", ast_sip_get_contact_status_label(status->status));
-       if (status->status == UNKNOWN) {
+       ast_str_append(&buf, 0, "Status: %s\r\n", ast_sip_get_contact_status_label(status ? status->status : UNKNOWN));
+       if (!status || status->status == UNKNOWN) {
                ast_str_append(&buf, 0, "RoundtripUsec: N/A\r\n");
        } else {
                ast_str_append(&buf, 0, "RoundtripUsec: %" PRId64 "\r\n", status->rtt);
index 53eb6ac..a19a9bb 100644 (file)
@@ -69,7 +69,7 @@
                                        </description>
                                </configOption>
                                <configOption name="outbound_proxy" default="">
-                                       <synopsis>SIP URI of the outbound proxy used to send publishes</synopsis>
+                                       <synopsis>Full SIP URI of the outbound proxy used to send publishes</synopsis>
                                </configOption>
                                <configOption name="server_uri">
                                        <synopsis>SIP URI of the server and entity to publish to</synopsis>
index 683642f..538967e 100644 (file)
@@ -96,7 +96,7 @@
                                        </description>
                                </configOption>
                                <configOption name="outbound_proxy" default="">
-                                       <synopsis>Outbound Proxy used to send registrations</synopsis>
+                                       <synopsis>Full SIP URI of the outbound proxy used to send registrations</synopsis>
                                </configOption>
                                <configOption name="retry_interval" default="60">
                                        <synopsis>Interval in seconds between retries if outbound registration is unsuccessful</synopsis>
@@ -1211,6 +1211,17 @@ static int sip_outbound_registration_regc_alloc(void *data)
                return -1;
        }
 
+       if (!ast_strlen_zero(registration->outbound_proxy)) {
+               pj_strdup2_with_null(pool, &tmp, registration->outbound_proxy);
+               uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0);
+               if (!uri) {
+                       ast_log(LOG_ERROR, "Invalid outbound proxy URI '%s' specified on outbound registration '%s'\n",
+                               registration->outbound_proxy, ast_sorcery_object_get_id(registration));
+                       pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
+                       return -1;
+               }
+       }
+
        pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
 
 
index 709dc66..e905024 100644 (file)
@@ -1456,7 +1456,6 @@ static int sub_persistence_recreate(void *obj)
                ast_log(LOG_WARNING, "Failed recreating '%s' subscription: The endpoint was not found\n",
                        persistence->endpoint);
                ast_sorcery_delete(ast_sip_get_sorcery(), persistence);
-               ao2_ref(endpoint, -1);
                return 0;
        }