diff options
-rw-r--r-- | CHANGES | 8 | ||||
-rw-r--r-- | Makefile | 35 | ||||
-rw-r--r-- | bridges/bridge_native_rtp.c | 6 | ||||
-rw-r--r-- | configs/samples/pjsip.conf.sample | 19 | ||||
-rw-r--r-- | include/asterisk/bridge_technology.h | 3 | ||||
-rw-r--r-- | main/Makefile | 12 | ||||
-rw-r--r-- | res/res_config_pgsql.c | 4 | ||||
-rw-r--r-- | res/res_pjsip.c | 2 | ||||
-rw-r--r-- | res/res_pjsip/pjsip_options.c | 4 | ||||
-rw-r--r-- | res/res_pjsip_outbound_publish.c | 2 | ||||
-rw-r--r-- | res/res_pjsip_outbound_registration.c | 108 | ||||
-rw-r--r-- | res/res_pjsip_pubsub.c | 1 |
12 files changed, 160 insertions, 44 deletions
@@ -17,6 +17,14 @@ app_record * Added new 'u' option to Record() application which prevents Asterisk from truncating silence from the end of recorded files. +res_pjsip_outbound_registration +------------------ + * Outbound registrations are now refreshed when res_stun_monitor detects + a network change event has happened. + The 'pjsip send (un)register' CLI commands were updated to accept '*all' + as an argument to operate on all registrations. + The 'PJSIP(Un)Register' AMI commands were updated to also accept '*all'. + app_voicemail ------------------ * The 'Comedian Mail' prompts can now be overriden using the 'vm-login' and @@ -653,6 +653,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\")." @@ -692,6 +723,7 @@ install: badshell bininstall datafiles @echo " +-------------------------------------------+" @$(MAKE) -s oldmodcheck @$(MAKE) -s ld-cache-update + @$(MAKE) -s check-old-libdir isntall: install @@ -912,6 +944,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)" @@ -944,6 +977,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)" @@ -1058,6 +1092,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) diff --git a/bridges/bridge_native_rtp.c b/bridges/bridge_native_rtp.c index a106d2d5f..a80ef4c5a 100644 --- a/bridges/bridge_native_rtp.c +++ b/bridges/bridge_native_rtp.c @@ -131,7 +131,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); @@ -147,7 +147,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: diff --git a/configs/samples/pjsip.conf.sample b/configs/samples/pjsip.conf.sample index bb2ad94f8..f66161329 100644 --- a/configs/samples/pjsip.conf.sample +++ b/configs/samples/pjsip.conf.sample @@ -640,7 +640,7 @@ ;moh_suggest=default ; Default Music On Hold class (default: "default") ;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") @@ -865,8 +865,8 @@ ;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========================= @@ -898,11 +898,10 @@ ;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 @@ -1033,8 +1032,8 @@ ;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 diff --git a/include/asterisk/bridge_technology.h b/include/asterisk/bridge_technology.h index 7f5d746f8..402b54e98 100644 --- a/include/asterisk/bridge_technology.h +++ b/include/asterisk/bridge_technology.h @@ -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); /*! diff --git a/main/Makefile b/main/Makefile index fb473141e..599803a10 100644 --- a/main/Makefile +++ b/main/Makefile @@ -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 diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c index efb733c88..e74b73036 100644 --- a/res/res_config_pgsql.c +++ b/res/res_config_pgsql.c @@ -768,6 +768,7 @@ static int update_pgsql(const char *database, const char *tablename, const char ast_mutex_lock(&pgsql_lock); if (!pgsql_reconnect(database)) { ast_mutex_unlock(&pgsql_lock); + release_table(table); return -1; } @@ -913,6 +914,7 @@ static int update2_pgsql(const char *database, const char *tablename, const stru ast_mutex_lock(&pgsql_lock); if (!pgsql_reconnect(database)) { ast_mutex_unlock(&pgsql_lock); + release_table(table); return -1; } @@ -1317,6 +1319,7 @@ static int require_pgsql(const char *database, const char *tablename, va_list ap if (!column) { if (requirements == RQ_WARN) { ast_log(LOG_WARNING, "Table %s requires a column '%s' of size '%d', but no such column exists.\n", tablename, elm, size); + res = -1; } else { struct ast_str *sql = ast_str_create(100); char fieldtype[15]; @@ -1357,6 +1360,7 @@ static int require_pgsql(const char *database, const char *tablename, va_list ap if (pgsql_exec(database, tablename, ast_str_buffer(sql), &result) != 0) { ast_mutex_unlock(&pgsql_lock); + release_table(table); return -1; } diff --git a/res/res_pjsip.c b/res/res_pjsip.c index 92dca7fb8..54a0a5f39 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -349,7 +349,7 @@ </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> diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c index d4159f508..d4ea911c9 100644 --- a/res/res_pjsip/pjsip_options.c +++ b/res/res_pjsip/pjsip_options.c @@ -1260,8 +1260,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); diff --git a/res/res_pjsip_outbound_publish.c b/res/res_pjsip_outbound_publish.c index 37f64481e..0273c6a68 100644 --- a/res/res_pjsip_outbound_publish.c +++ b/res/res_pjsip_outbound_publish.c @@ -68,7 +68,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> diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c index 122d5bb69..7a0b60ac8 100644 --- a/res/res_pjsip_outbound_registration.c +++ b/res/res_pjsip_outbound_registration.c @@ -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> @@ -180,12 +180,12 @@ <syntax> <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> <parameter name="Registration" required="true"> - <para>The outbound registration to unregister.</para> + <para>The outbound registration to unregister or '*all' to unregister them all.</para> </parameter> </syntax> <description> <para> - Unregisters the specified outbound registration and stops future registration attempts. + Unregisters the specified (or all) outbound registration(s) and stops future registration attempts. Call PJSIPRegister to start registration and schedule re-registrations according to configuration. </para> </description> @@ -197,14 +197,13 @@ <syntax> <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> <parameter name="Registration" required="true"> - <para>The outbound registration to register.</para> + <para>The outbound registration to register or '*all' to register them all.</para> </parameter> </syntax> <description> <para> - Unregisters the specified outbound registration then starts registration and schedules re-registrations + Unregisters the specified (or all) outbound registration(s) then starts registration and schedules re-registrations according to configuration. - future registrations. </para> </description> </manager> @@ -379,6 +378,9 @@ static struct ast_serializer_shutdown_group *shutdown_group; #define DEFAULT_STATE_BUCKETS 53 static AO2_GLOBAL_OBJ_STATIC(current_states); +/*! subscription id for network change events */ +static struct stasis_subscription *network_change_sub; + /*! \brief hashing function for state objects */ static int registration_state_hash(const void *obj, const int flags) { @@ -1210,6 +1212,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); @@ -1459,6 +1472,26 @@ static int queue_register(struct sip_outbound_registration_state *state) return 0; } +static void unregister_all(void) +{ + struct ao2_container *states; + + states = ao2_global_obj_ref(current_states); + if (!states) { + return; + } + + /* Clean out all the states and let sorcery handle recreating the registrations */ + ao2_callback(states, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL, NULL); + ao2_ref(states, -1); +} + +static void reregister_all(void) +{ + unregister_all(); + ast_sorcery_load_object(ast_sip_get_sorcery(), "registration"); +} + static char *cli_complete_registration(const char *line, const char *word, int pos, int state) { @@ -1474,6 +1507,10 @@ static char *cli_complete_registration(const char *line, const char *word, } wordlen = strlen(word); + if (wordlen == 0 && ++which > state) { + return ast_strdup("*all"); + } + registrations = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), "registration", AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL); if (!registrations) { @@ -1508,8 +1545,9 @@ static char *cli_unregister(struct ast_cli_entry *e, int cmd, struct ast_cli_arg case CLI_INIT: e->command = "pjsip send unregister"; e->usage = - "Usage: pjsip send unregister <registration>\n" - " Unregisters the specified outbound registration and stops future registration attempts.\n"; + "Usage: pjsip send unregister <registration> | *all\n" + " Unregisters the specified (or all) outbound registration(s) " + "and stops future registration attempts.\n"; return NULL; case CLI_GENERATE: return cli_complete_registration(a->line, a->word, a->pos, a->n); @@ -1521,6 +1559,12 @@ static char *cli_unregister(struct ast_cli_entry *e, int cmd, struct ast_cli_arg registration_name = a->argv[3]; + if (strcmp(registration_name, "*all") == 0) { + unregister_all(); + ast_cli(a->fd, "Unregister all queued\n"); + return CLI_SUCCESS; + } + state = get_state(registration_name); if (!state) { ast_cli(a->fd, "Unable to retrieve registration %s\n", registration_name); @@ -1544,9 +1588,9 @@ static char *cli_register(struct ast_cli_entry *e, int cmd, struct ast_cli_args case CLI_INIT: e->command = "pjsip send register"; e->usage = - "Usage: pjsip send register <registration>\n" - " Unregisters the specified outbound " - "registration then re-registers and re-schedules it.\n"; + "Usage: pjsip send register <registration> | *all \n" + " Unregisters the specified (or all) outbound " + "registration(s) then starts registration(s) and schedules re-registrations.\n"; return NULL; case CLI_GENERATE: return cli_complete_registration(a->line, a->word, a->pos, a->n); @@ -1558,6 +1602,12 @@ static char *cli_register(struct ast_cli_entry *e, int cmd, struct ast_cli_args registration_name = a->argv[3]; + if (strcmp(registration_name, "*all") == 0) { + reregister_all(); + ast_cli(a->fd, "Re-register all queued\n"); + return CLI_SUCCESS; + } + state = get_state(registration_name); if (!state) { ast_cli(a->fd, "Unable to retrieve registration %s\n", registration_name); @@ -1587,6 +1637,12 @@ static int ami_unregister(struct mansession *s, const struct message *m) return 0; } + if (strcmp(registration_name, "*all") == 0) { + unregister_all(); + astman_send_ack(s, m, "Unregistrations queued."); + return 0; + } + state = get_state(registration_name); if (!state) { astman_send_error(s, m, "Unable to retrieve registration entry\n"); @@ -1613,6 +1669,12 @@ static int ami_register(struct mansession *s, const struct message *m) return 0; } + if (strcmp(registration_name, "*all") == 0) { + reregister_all(); + astman_send_ack(s, m, "Reregistrations queued."); + return 0; + } + state = get_state(registration_name); if (!state) { astman_send_error(s, m, "Unable to retrieve registration entry\n"); @@ -1788,10 +1850,6 @@ static int cli_print_body(void *obj, void *arg, int flags) ast_assert(context->output_buffer != NULL); - if (!state) { - return 0; - } - ast_str_append(&context->output_buffer, 0, " %-s/%-*.*s %-16s %-16s\n", id, (int) (REGISTRATION_URI_FIELD_LEN - strlen(id)), @@ -1800,8 +1858,8 @@ static int cli_print_body(void *obj, void *arg, int flags) AST_VECTOR_SIZE(®istration->outbound_auths) ? AST_VECTOR_GET(®istration->outbound_auths, 0) : "n/a", - sip_outbound_registration_status_str(state->client_state->status)); - ao2_ref(state, -1); + (state ? sip_outbound_registration_status_str(state->client_state->status) : "Unregistered")); + ao2_cleanup(state); if (context->show_details || (context->show_details_only_level_0 && context->indent_level == 0)) { @@ -1961,10 +2019,23 @@ static const struct ast_sorcery_observer registration_observer = { .deleted = registration_deleted_observer, }; +static void network_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message) +{ + /* This callback is only concerned with network change messages from the system topic. */ + if (stasis_message_type(message) != ast_network_change_type()) { + return; + } + ast_debug(3, "Received network change event\n"); + + reregister_all(); +} + static int unload_module(void) { int remaining; + network_change_sub = stasis_unsubscribe_and_join(network_change_sub); + ast_manager_unregister("PJSIPShowRegistrationsOutbound"); ast_manager_unregister("PJSIPUnregister"); ast_manager_unregister("PJSIPRegister"); @@ -2102,6 +2173,9 @@ static int load_module(void) /* Load configuration objects */ ast_sorcery_load_object(ast_sip_get_sorcery(), "registration"); + network_change_sub = stasis_subscribe(ast_system_topic(), + network_change_stasis_cb, NULL); + return AST_MODULE_LOAD_SUCCESS; } diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c index 644a4d293..1892a20e9 100644 --- a/res/res_pjsip_pubsub.c +++ b/res/res_pjsip_pubsub.c @@ -1478,7 +1478,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; } |