diff options
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rwxr-xr-x | build_tools/make_buildopts_h | 19 | ||||
-rw-r--r-- | channels/chan_iax2.c | 62 | ||||
-rw-r--r-- | channels/chan_vpb.cc | 2 | ||||
-rw-r--r-- | configs/samples/extensions_minivm.conf.sample | 2 | ||||
-rw-r--r-- | doc/.gitignore | 1 | ||||
-rw-r--r-- | include/asterisk/astobj2.h | 23 | ||||
-rw-r--r-- | include/asterisk/res_pjsip.h | 6 | ||||
-rw-r--r-- | main/ast_expr2.fl | 2 | ||||
-rw-r--r-- | main/ast_expr2.y | 2 | ||||
-rw-r--r-- | main/astobj2.c | 27 | ||||
-rw-r--r-- | res/ael/ael.flex | 2 | ||||
-rw-r--r-- | res/ael/ael.y | 2 | ||||
-rw-r--r-- | res/res_pjsip.c | 6 | ||||
-rw-r--r-- | res/res_pjsip/pjsip_outbound_auth.c | 2 | ||||
-rw-r--r-- | res/res_pjsip/presence_xml.c | 12 | ||||
-rw-r--r-- | res/res_pjsip_outbound_authenticator_digest.c | 6 | ||||
-rw-r--r-- | res/res_pjsip_outbound_publish.c | 4 | ||||
-rw-r--r-- | res/res_pjsip_outbound_registration.c | 67 | ||||
-rw-r--r-- | res/res_sorcery_config.c | 12 | ||||
-rw-r--r-- | rest-api-templates/ari_model_validators.c.mustache | 2 | ||||
-rw-r--r-- | rest-api-templates/ari_resource.c.mustache | 2 | ||||
-rw-r--r-- | rest-api-templates/res_ari_resource.c.mustache | 2 | ||||
-rw-r--r-- | tests/test_astobj2_weaken.c | 22 |
25 files changed, 207 insertions, 85 deletions
@@ -141,8 +141,8 @@ CEL Backends cel_pgsql ------------------ -* Added a new option, 'usegmtime', which causes timestamps in CEL events - to be logged in GMT. + * Added a new option, 'usegmtime', which causes timestamps in CEL events + to be logged in GMT. ------------------------------------------------------------------------------ --- Functionality changes from Asterisk 13.3.0 to Asterisk 13.4.0 ------------ @@ -982,6 +982,7 @@ ifeq ($(PYTHON),:) @echo "--------------------------------------------------------------------------" @false else + @$(INSTALL) -d doc/rest-api $(PYTHON) rest-api-templates/make_ari_stubs.py \ rest-api/resources.json . endif diff --git a/build_tools/make_buildopts_h b/build_tools/make_buildopts_h index df506edbe..c96e50876 100755 --- a/build_tools/make_buildopts_h +++ b/build_tools/make_buildopts_h @@ -10,6 +10,13 @@ cat << END */ END + +if ${GREP} "AST_DEVMODE" makeopts | ${GREP} -q "yes" +then + echo "#define AST_DEVMODE 1" + BUILDOPTS="AST_DEVMODE" +fi + TMP=`${GREP} -e "^MENUSELECT_CFLAGS" menuselect.makeopts | sed 's/MENUSELECT_CFLAGS\=//g' | sed 's/-D//g'` for x in ${TMP}; do echo "#define ${x} 1" @@ -33,18 +40,8 @@ for x in ${TMP}; do BUILDOPTS="${x}" fi done -TMP=`${GREP} -e "^MENUSELECT_BUILD_DEPS" menuselect.makeopts | sed 's/MENUSELECT_BUILD_DEPS\=//g'` -for x in ${TMP}; do - x2=`echo ${x} | tr a-z A-Z` - echo "#define AST_MODULE_${x2} 1" -done -if ${GREP} "AST_DEVMODE" makeopts | ${GREP} -q "yes" -then - echo "#define AST_DEVMODE 1" - TMP="${TMP} AST_DEVMODE" -fi -BUILDSUM=`echo ${TMP} | ${MD5} | cut -c1-32` +BUILDSUM=`echo ${BUILDOPTS} | ${MD5} | cut -c1-32` echo "#define AST_BUILDOPT_SUM \"${BUILDSUM}\"" echo "#define AST_BUILDOPTS \"${BUILDOPTS}\"" diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 8d3e7f145..253160a92 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -435,37 +435,37 @@ struct iax2_context { }; -#define IAX_HASCALLERID (uint64_t)(1 << 0) /*!< CallerID has been specified */ -#define IAX_DELME (uint64_t)(1 << 1) /*!< Needs to be deleted */ -#define IAX_TEMPONLY (uint64_t)(1 << 2) /*!< Temporary (realtime) */ -#define IAX_TRUNK (uint64_t)(1 << 3) /*!< Treat as a trunk */ -#define IAX_NOTRANSFER (uint64_t)(1 << 4) /*!< Don't native bridge */ -#define IAX_USEJITTERBUF (uint64_t)(1 << 5) /*!< Use jitter buffer */ -#define IAX_DYNAMIC (uint64_t)(1 << 6) /*!< dynamic peer */ -#define IAX_SENDANI (uint64_t)(1 << 7) /*!< Send ANI along with CallerID */ -#define IAX_RTSAVE_SYSNAME (uint64_t)(1 << 8) /*!< Save Systname on Realtime Updates */ -#define IAX_ALREADYGONE (uint64_t)(1 << 9) /*!< Already disconnected */ -#define IAX_PROVISION (uint64_t)(1 << 10) /*!< This is a provisioning request */ -#define IAX_QUELCH (uint64_t)(1 << 11) /*!< Whether or not we quelch audio */ -#define IAX_ENCRYPTED (uint64_t)(1 << 12) /*!< Whether we should assume encrypted tx/rx */ -#define IAX_KEYPOPULATED (uint64_t)(1 << 13) /*!< Whether we have a key populated */ -#define IAX_CODEC_USER_FIRST (uint64_t)(1 << 14) /*!< are we willing to let the other guy choose the codec? */ -#define IAX_CODEC_NOPREFS (uint64_t)(1 << 15) /*!< Force old behaviour by turning off prefs */ -#define IAX_CODEC_NOCAP (uint64_t)(1 << 16) /*!< only consider requested format and ignore capabilities*/ -#define IAX_RTCACHEFRIENDS (uint64_t)(1 << 17) /*!< let realtime stay till your reload */ -#define IAX_RTUPDATE (uint64_t)(1 << 18) /*!< Send a realtime update */ -#define IAX_RTAUTOCLEAR (uint64_t)(1 << 19) /*!< erase me on expire */ -#define IAX_RTIGNOREREGEXPIRE (uint64_t)(1 << 21) /*!< When using realtime, ignore registration expiration */ -#define IAX_TRUNKTIMESTAMPS (uint64_t)(1 << 22) /*!< Send trunk timestamps */ -#define IAX_TRANSFERMEDIA (uint64_t)(1 << 23) /*!< When doing IAX2 transfers, transfer media only */ -#define IAX_MAXAUTHREQ (uint64_t)(1 << 24) /*!< Maximum outstanding AUTHREQ restriction is in place */ -#define IAX_DELAYPBXSTART (uint64_t)(1 << 25) /*!< Don't start a PBX on the channel until the peer sends us a response, so that we've achieved a three-way handshake with them before sending voice or anything else */ -#define IAX_ALLOWFWDOWNLOAD (uint64_t)(1 << 26) /*!< Allow the FWDOWNL command? */ -#define IAX_IMMEDIATE (uint64_t)(1 << 27) /*!< Allow immediate off-hook to extension s */ -#define IAX_SENDCONNECTEDLINE (uint64_t)(1 << 28) /*!< Allow sending of connected line updates */ -#define IAX_RECVCONNECTEDLINE (uint64_t)(1 << 29) /*!< Allow receiving of connected line updates */ -#define IAX_FORCE_ENCRYPT (uint64_t)(1 << 30) /*!< Forces call encryption, if encryption not possible hangup */ -#define IAX_SHRINKCALLERID (uint64_t)(1 << 31) /*!< Turn on and off caller id shrinking */ +#define IAX_HASCALLERID (uint64_t)(1LLU << 0) /*!< CallerID has been specified */ +#define IAX_DELME (uint64_t)(1LLU << 1) /*!< Needs to be deleted */ +#define IAX_TEMPONLY (uint64_t)(1LLU << 2) /*!< Temporary (realtime) */ +#define IAX_TRUNK (uint64_t)(1LLU << 3) /*!< Treat as a trunk */ +#define IAX_NOTRANSFER (uint64_t)(1LLU << 4) /*!< Don't native bridge */ +#define IAX_USEJITTERBUF (uint64_t)(1LLU << 5) /*!< Use jitter buffer */ +#define IAX_DYNAMIC (uint64_t)(1LLU << 6) /*!< dynamic peer */ +#define IAX_SENDANI (uint64_t)(1LLU << 7) /*!< Send ANI along with CallerID */ +#define IAX_RTSAVE_SYSNAME (uint64_t)(1LLU << 8) /*!< Save Systname on Realtime Updates */ +#define IAX_ALREADYGONE (uint64_t)(1LLU << 9) /*!< Already disconnected */ +#define IAX_PROVISION (uint64_t)(1LLU << 10) /*!< This is a provisioning request */ +#define IAX_QUELCH (uint64_t)(1LLU << 11) /*!< Whether or not we quelch audio */ +#define IAX_ENCRYPTED (uint64_t)(1LLU << 12) /*!< Whether we should assume encrypted tx/rx */ +#define IAX_KEYPOPULATED (uint64_t)(1LLU << 13) /*!< Whether we have a key populated */ +#define IAX_CODEC_USER_FIRST (uint64_t)(1LLU << 14) /*!< are we willing to let the other guy choose the codec? */ +#define IAX_CODEC_NOPREFS (uint64_t)(1LLU << 15) /*!< Force old behaviour by turning off prefs */ +#define IAX_CODEC_NOCAP (uint64_t)(1LLU << 16) /*!< only consider requested format and ignore capabilities*/ +#define IAX_RTCACHEFRIENDS (uint64_t)(1LLU << 17) /*!< let realtime stay till your reload */ +#define IAX_RTUPDATE (uint64_t)(1LLU << 18) /*!< Send a realtime update */ +#define IAX_RTAUTOCLEAR (uint64_t)(1LLU << 19) /*!< erase me on expire */ +#define IAX_RTIGNOREREGEXPIRE (uint64_t)(1LLU << 21) /*!< When using realtime, ignore registration expiration */ +#define IAX_TRUNKTIMESTAMPS (uint64_t)(1LLU << 22) /*!< Send trunk timestamps */ +#define IAX_TRANSFERMEDIA (uint64_t)(1LLU << 23) /*!< When doing IAX2 transfers, transfer media only */ +#define IAX_MAXAUTHREQ (uint64_t)(1LLU << 24) /*!< Maximum outstanding AUTHREQ restriction is in place */ +#define IAX_DELAYPBXSTART (uint64_t)(1LLU << 25) /*!< Don't start a PBX on the channel until the peer sends us a response, so that we've achieved a three-way handshake with them before sending voice or anything else */ +#define IAX_ALLOWFWDOWNLOAD (uint64_t)(1LLU << 26) /*!< Allow the FWDOWNL command? */ +#define IAX_IMMEDIATE (uint64_t)(1LLU << 27) /*!< Allow immediate off-hook to extension s */ +#define IAX_SENDCONNECTEDLINE (uint64_t)(1LLU << 28) /*!< Allow sending of connected line updates */ +#define IAX_RECVCONNECTEDLINE (uint64_t)(1LLU << 29) /*!< Allow receiving of connected line updates */ +#define IAX_FORCE_ENCRYPT (uint64_t)(1LLU << 30) /*!< Forces call encryption, if encryption not possible hangup */ +#define IAX_SHRINKCALLERID (uint64_t)(1LLU << 31) /*!< Turn on and off caller id shrinking */ static int global_rtautoclear = 120; static int reload_config(int forced_reload); diff --git a/channels/chan_vpb.cc b/channels/chan_vpb.cc index 6a9e9a667..16a66b908 100644 --- a/channels/chan_vpb.cc +++ b/channels/chan_vpb.cc @@ -59,7 +59,7 @@ extern "C" { #include "asterisk.h" -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +ASTERISK_REGISTER_FILE() #include "asterisk/lock.h" #include "asterisk/utils.h" diff --git a/configs/samples/extensions_minivm.conf.sample b/configs/samples/extensions_minivm.conf.sample index 2f9d24637..7bd1df1d2 100644 --- a/configs/samples/extensions_minivm.conf.sample +++ b/configs/samples/extensions_minivm.conf.sample @@ -1,7 +1,5 @@ ; MINI-VOICEMAIL dialplan example ; --------------------------------------------------------------------------------------- -; ASTERISK_FILE_VERSION(__FILE__, "$Revision$") -; ; ; This is an example on how to use the Mini-Voicemail system to build ; voicemail systems. diff --git a/doc/.gitignore b/doc/.gitignore index 27acdb324..e098ec027 100644 --- a/doc/.gitignore +++ b/doc/.gitignore @@ -1 +1,2 @@ core-en_US.xml +rest-api
\ No newline at end of file diff --git a/include/asterisk/astobj2.h b/include/asterisk/astobj2.h index de35bb324..e02a4cd85 100644 --- a/include/asterisk/astobj2.h +++ b/include/asterisk/astobj2.h @@ -560,6 +560,29 @@ int __ao2_weakproxy_set_object(void *weakproxy, void *obj, int flags, /*! * \since 14.0.0 + * \brief Run ao2_t_ref on the object associated with weakproxy. + * + * \param weakproxy The weakproxy to read from. + * \param delta Value to add to the reference counter. + * \param flags OBJ_NOLOCK to avoid locking weakproxy. + * + * \retval -2 weakproxy is not a valid ao2_weakproxy. + * \retval -1 weakproxy has no associated object. + * + * \return The value of the reference counter before the operation. + */ +int __ao2_weakproxy_ref_object(void *weakproxy, int delta, int flags, + const char *tag, const char *file, int line, const char *func); + +#define ao2_t_weakproxy_ref_object(weakproxy, delta, flags, tag) \ + __ao2_weakproxy_ref_object(weakproxy, delta, flags, \ + tag, __FILE__, __LINE__, __PRETTY_FUNCTION__) + +#define ao2_weakproxy_ref_object(weakproxy, delta, flags) \ + ao2_t_weakproxy_ref_object(weakproxy, delta, flags, "") + +/*! + * \since 14.0.0 * \brief Get the object associated with weakproxy. * * \param weakproxy The weakproxy to read from. diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h index 12fc400d2..67c9c4b16 100644 --- a/include/asterisk/res_pjsip.h +++ b/include/asterisk/res_pjsip.h @@ -697,13 +697,13 @@ struct ast_sip_outbound_authenticator { * * \param auths A vector of IDs of auth sorcery objects * \param challenge The SIP response with authentication challenge(s) - * \param tsx The transaction in which the challenge was received + * \param old_request The request that received the auth challenge(s) * \param new_request The new SIP request with challenge response(s) * \retval 0 Successfully created new request * \retval -1 Failed to create a new request */ int (*create_request_with_auth)(const struct ast_sip_auth_vector *auths, struct pjsip_rx_data *challenge, - struct pjsip_transaction *tsx, struct pjsip_tx_data **new_request); + struct pjsip_tx_data *old_request, struct pjsip_tx_data **new_request); }; /*! @@ -1396,7 +1396,7 @@ enum ast_sip_check_auth_result ast_sip_check_authentication(struct ast_sip_endpo * the parameters and return values. */ int ast_sip_create_request_with_auth(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge, - pjsip_transaction *tsx, pjsip_tx_data **new_request); + pjsip_tx_data *tdata, pjsip_tx_data **new_request); /*! * \brief Determine the endpoint that has sent a SIP message diff --git a/main/ast_expr2.fl b/main/ast_expr2.fl index e10dde200..af03c013f 100644 --- a/main/ast_expr2.fl +++ b/main/ast_expr2.fl @@ -26,7 +26,7 @@ #include <stdio.h> #if !defined(STANDALONE) -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +ASTERISK_REGISTER_FILE() #else #ifndef __USE_ISOC99 #define __USE_ISOC99 1 diff --git a/main/ast_expr2.y b/main/ast_expr2.y index e8c68e333..8a151679d 100644 --- a/main/ast_expr2.y +++ b/main/ast_expr2.y @@ -20,7 +20,7 @@ #if !defined(STANDALONE) && !defined(STANDALONE2) \ -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +ASTERISK_REGISTER_FILE() #else #ifndef __USE_ISOC99 #define __USE_ISOC99 1 diff --git a/main/astobj2.c b/main/astobj2.c index c5b5cd957..f9dd8d490 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -836,6 +836,33 @@ int __ao2_weakproxy_set_object(void *weakproxy, void *obj, int flags, return ret; } +int __ao2_weakproxy_ref_object(void *weakproxy, int delta, int flags, + const char *tag, const char *file, int line, const char *func) +{ + struct astobj2 *internal = __INTERNAL_OBJ_CHECK(weakproxy, file, line, func); + int ret = -1; + + if (!internal || internal->priv_data.magic != AO2_WEAK) { + /* This method is meant to be run on weakproxy objects! */ + return -2; + } + + /* We have a weak object, grab lock. */ + if (!(flags & OBJ_NOLOCK)) { + ao2_lock(weakproxy); + } + + if (internal->priv_data.weakptr) { + ret = __ao2_ref(internal->priv_data.weakptr, delta, tag, file, line, func); + } + + if (!(flags & OBJ_NOLOCK)) { + ao2_unlock(weakproxy); + } + + return ret; +} + void *__ao2_weakproxy_get_object(void *weakproxy, int flags, const char *tag, const char *file, int line, const char *func) { diff --git a/res/ael/ael.flex b/res/ael/ael.flex index 5a7fd8304..a412eaf34 100644 --- a/res/ael/ael.flex +++ b/res/ael/ael.flex @@ -70,7 +70,7 @@ %{ #define WRAP_LIBC_MALLOC #include "asterisk.h" -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +ASTERISK_REGISTER_FILE() #include <sys/types.h> #include <sys/stat.h> diff --git a/res/ael/ael.y b/res/ael/ael.y index c1a6f0f2b..5ab9c969f 100644 --- a/res/ael/ael.y +++ b/res/ael/ael.y @@ -25,7 +25,7 @@ #define WRAP_LIBC_MALLOC #include "asterisk.h" -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +ASTERISK_REGISTER_FILE() #include <stdio.h> #include <stdlib.h> diff --git a/res/res_pjsip.c b/res/res_pjsip.c index a613bccf6..8be019f87 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -2009,13 +2009,13 @@ void ast_sip_unregister_outbound_authenticator(struct ast_sip_outbound_authentic } int ast_sip_create_request_with_auth(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge, - pjsip_transaction *tsx, pjsip_tx_data **new_request) + pjsip_tx_data *old_request, pjsip_tx_data **new_request) { if (!registered_outbound_authenticator) { ast_log(LOG_WARNING, "No SIP outbound authenticator registered. Cannot respond to authentication challenge\n"); return -1; } - return registered_outbound_authenticator->create_request_with_auth(auths, challenge, tsx, new_request); + return registered_outbound_authenticator->create_request_with_auth(auths, challenge, old_request, new_request); } struct endpoint_identifier_list { @@ -3107,7 +3107,7 @@ static void send_request_cb(void *token, pjsip_event *e) && endpoint && ++req_data->challenge_count < MAX_RX_CHALLENGES /* Not in a challenge loop */ && !ast_sip_create_request_with_auth(&endpoint->outbound_auths, - challenge, tsx, &tdata) + challenge, tsx->last_tx, &tdata) && endpt_send_request(endpoint, tdata, -1, req_data, send_request_cb) == PJ_SUCCESS; ao2_cleanup(endpoint); diff --git a/res/res_pjsip/pjsip_outbound_auth.c b/res/res_pjsip/pjsip_outbound_auth.c index 1f754227a..8b39b000d 100644 --- a/res/res_pjsip/pjsip_outbound_auth.c +++ b/res/res_pjsip/pjsip_outbound_auth.c @@ -63,7 +63,7 @@ static pj_bool_t outbound_auth(pjsip_rx_data *rdata) return PJ_FALSE; } - if (ast_sip_create_request_with_auth(&endpoint->outbound_auths, rdata, tsx, &tdata)) { + if (ast_sip_create_request_with_auth(&endpoint->outbound_auths, rdata, tsx->last_tx, &tdata)) { return PJ_FALSE; } diff --git a/res/res_pjsip/presence_xml.c b/res/res_pjsip/presence_xml.c index 2fe6bdc00..12bfa078c 100644 --- a/res/res_pjsip/presence_xml.c +++ b/res/res_pjsip/presence_xml.c @@ -16,14 +16,6 @@ * at the top of the source tree. */ -/*** MODULEINFO - <depend>pjproject</depend> - <depend>res_pjsip</depend> - <depend>res_pjsip_pubsub</depend> - <depend>res_pjsip_exten_state</depend> - <support_level>core</support_level> - ***/ - #include "asterisk.h" #include <pjsip.h> @@ -31,10 +23,8 @@ #include <pjlib.h> #include "asterisk/module.h" -#include "asterisk/res_pjsip.h" -#include "asterisk/res_pjsip_pubsub.h" +#include "asterisk/pbx.h" #include "asterisk/res_pjsip_presence_xml.h" -#include "asterisk/res_pjsip_body_generator_types.h" void ast_sip_sanitize_xml(const char *input, char *output, size_t len) { diff --git a/res/res_pjsip_outbound_authenticator_digest.c b/res/res_pjsip_outbound_authenticator_digest.c index 35e59f21a..de77616fd 100644 --- a/res/res_pjsip_outbound_authenticator_digest.c +++ b/res/res_pjsip_outbound_authenticator_digest.c @@ -102,13 +102,13 @@ cleanup: } static int digest_create_request_with_auth(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge, - pjsip_transaction *tsx, pjsip_tx_data **new_request) + pjsip_tx_data *old_request, pjsip_tx_data **new_request) { pjsip_auth_clt_sess auth_sess; pjsip_cseq_hdr *cseq; if (pjsip_auth_clt_init(&auth_sess, ast_sip_get_pjsip_endpoint(), - tsx->pool, 0) != PJ_SUCCESS) { + old_request->pool, 0) != PJ_SUCCESS) { ast_log(LOG_WARNING, "Failed to initialize client authentication session\n"); return -1; } @@ -119,7 +119,7 @@ static int digest_create_request_with_auth(const struct ast_sip_auth_vector *aut } switch (pjsip_auth_clt_reinit_req(&auth_sess, challenge, - tsx->last_tx, new_request)) { + old_request, new_request)) { case PJ_SUCCESS: /* PJSIP creates a new transaction for new_request (meaning it creates a new * branch). However, it recycles the Call-ID, from-tag, and CSeq from the diff --git a/res/res_pjsip_outbound_publish.c b/res/res_pjsip_outbound_publish.c index 8b6f6e41e..f7669932e 100644 --- a/res/res_pjsip_outbound_publish.c +++ b/res/res_pjsip_outbound_publish.c @@ -867,8 +867,10 @@ static void sip_outbound_publish_callback(struct pjsip_publishc_cbparam *param) } if (param->code == 401 || param->code == 407) { + pjsip_transaction *tsx = pjsip_rdata_get_tsx(param->rdata); + if (!ast_sip_create_request_with_auth(&publish->outbound_auths, - param->rdata, pjsip_rdata_get_tsx(param->rdata), &tdata)) { + param->rdata, tsx->last_tx, &tdata)) { pjsip_publishc_send(client->client, tdata); } client->auth_attempts++; diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c index e30a32ee3..c2eb62b32 100644 --- a/res/res_pjsip_outbound_registration.c +++ b/res/res_pjsip_outbound_registration.c @@ -479,10 +479,18 @@ static int handle_client_registration(void *data) static void sip_outbound_registration_timer_cb(pj_timer_heap_t *timer_heap, struct pj_timer_entry *entry) { struct sip_outbound_registration_client_state *client_state = entry->user_data; + pjsip_regc_info info; + + pjsip_regc_get_info(client_state->client, &info); + ast_debug(1, "Attempting scheduled outbound registration attempt to server '%.*s' from client '%.*s'\n", + (int) info.server_uri.slen, info.server_uri.ptr, + (int) info.client_uri.slen, info.client_uri.ptr); ao2_ref(client_state, +1); if (ast_sip_push_task(client_state->serializer, handle_client_registration, client_state)) { - ast_log(LOG_WARNING, "Failed to pass outbound registration to threadpool\n"); + ast_log(LOG_WARNING, "Scheduled outbound registration to server '%.*s' from client '%.*s' could not be executed\n", + (int) info.server_uri.slen, info.server_uri.ptr, + (int) info.client_uri.slen, info.client_uri.ptr); ao2_ref(client_state, -1); } ao2_ref(client_state, -1); @@ -494,12 +502,21 @@ static void sip_outbound_registration_timer_cb(pj_timer_heap_t *timer_heap, stru static void schedule_registration(struct sip_outbound_registration_client_state *client_state, unsigned int seconds) { pj_time_val delay = { .sec = seconds, }; + pjsip_regc_info info; cancel_registration(client_state); + pjsip_regc_get_info(client_state->client, &info); + ast_debug(1, "Scheduling outbound registration to server '%.*s' from client '%.*s' in %d seconds\n", + (int) info.server_uri.slen, info.server_uri.ptr, + (int) info.client_uri.slen, info.client_uri.ptr, + seconds); + ao2_ref(client_state, +1); if (pjsip_endpt_schedule_timer(ast_sip_get_pjsip_endpoint(), &client_state->timer, &delay) != PJ_SUCCESS) { - ast_log(LOG_WARNING, "Failed to pass timed registration to scheduler\n"); + ast_log(LOG_WARNING, "Failed to schedule registration to server '%.*s' from client '%.*s'\n", + (int) info.server_uri.slen, info.server_uri.ptr, + (int) info.client_uri.slen, info.client_uri.ptr); ao2_ref(client_state, -1); } } @@ -551,8 +568,8 @@ struct registration_response { struct sip_outbound_registration_client_state *client_state; /*! \brief The response message */ pjsip_rx_data *rdata; - /*! \brief The response transaction */ - pjsip_transaction *tsx; + /*! \brief Request for which the response was received */ + pjsip_tx_data *old_request; }; /*! \brief Registration response structure destructor */ @@ -564,6 +581,10 @@ static void registration_response_destroy(void *obj) pjsip_rx_data_free_cloned(response->rdata); } + if (response->old_request) { + pjsip_tx_data_dec_ref(response->old_request); + } + ao2_cleanup(response->client_state); } @@ -611,26 +632,36 @@ static int handle_registration_response(void *data) pjsip_regc_info info; char server_uri[PJSIP_MAX_URL_SIZE], client_uri[PJSIP_MAX_URL_SIZE]; + pjsip_regc_get_info(response->client_state->client, &info); + ast_copy_pj_str(server_uri, &info.server_uri, sizeof(server_uri)); + ast_copy_pj_str(client_uri, &info.client_uri, sizeof(client_uri)); + if (response->client_state->status == SIP_REGISTRATION_STOPPED) { + ast_debug(1, "Not handling registration response from server '%s' for client '%s'. Registration already stopped\n", + server_uri, client_uri); return 0; } - pjsip_regc_get_info(response->client_state->client, &info); - ast_copy_pj_str(server_uri, &info.server_uri, sizeof(server_uri)); - ast_copy_pj_str(client_uri, &info.client_uri, sizeof(client_uri)); + ast_debug(1, "Processing REGISTER response %d from server '%s' for client '%s'\n", + response->code, server_uri, client_uri); if (!response->client_state->auth_attempted && (response->code == 401 || response->code == 407)) { pjsip_tx_data *tdata; if (!ast_sip_create_request_with_auth(&response->client_state->outbound_auths, - response->rdata, response->tsx, &tdata)) { + response->rdata, response->old_request, &tdata)) { ao2_ref(response->client_state, +1); response->client_state->auth_attempted = 1; + ast_debug(1, "Sending authenticated REGISTER to server '%s' from client '%s'\n", + server_uri, client_uri); if (pjsip_regc_send(response->client_state->client, tdata) != PJ_SUCCESS) { response->client_state->auth_attempted = 0; ao2_cleanup(response->client_state); } return 0; + } else { + ast_log(LOG_WARNING, "Failed to create authenticated REGISTER request to server '%s' from client '%s'\n", + server_uri, client_uri); } /* Otherwise, fall through so the failure is processed appropriately */ } @@ -700,6 +731,7 @@ static void sip_outbound_registration_response_cb(struct pjsip_regc_cbparam *par { RAII_VAR(struct sip_outbound_registration_client_state *, client_state, param->token, ao2_cleanup); struct registration_response *response; + pjsip_regc_info info; ast_assert(client_state != NULL); @@ -712,11 +744,20 @@ static void sip_outbound_registration_response_cb(struct pjsip_regc_cbparam *par response->client_state = client_state; ao2_ref(response->client_state, +1); + pjsip_regc_get_info(client_state->client, &info); + ast_debug(1, "Received REGISTER response %d(%.*s) from server '%.*s' for client '%.*s\n", + param->code, (int) param->reason.slen, param->reason.ptr, + (int) info.server_uri.slen, info.server_uri.ptr, + (int) info.client_uri.slen, info.client_uri.ptr); + if (param->rdata) { struct pjsip_retry_after_hdr *retry_after = pjsip_msg_find_hdr(param->rdata->msg_info.msg, PJSIP_H_RETRY_AFTER, NULL); + pjsip_transaction *tsx; response->retry_after = retry_after ? retry_after->ivalue : 0; - response->tsx = pjsip_rdata_get_tsx(param->rdata); + tsx = pjsip_rdata_get_tsx(param->rdata); + response->old_request = tsx->last_tx; + pjsip_tx_data_add_ref(response->old_request); pjsip_rx_data_clone(param->rdata, 0, &response->rdata); } @@ -731,6 +772,9 @@ static void sip_outbound_registration_state_destroy(void *obj) { struct sip_outbound_registration_state *state = obj; + ast_debug(3, "Destroying registration state for registration to server '%s' from client '%s'\n", + state->registration->server_uri, state->registration->client_uri); + ao2_cleanup(state->registration); if (!state->client_state) { @@ -1146,6 +1190,11 @@ static int unregister_task(void *obj) RAII_VAR(struct sip_outbound_registration_state*, state, obj, ao2_cleanup); struct pjsip_regc *client = state->client_state->client; pjsip_tx_data *tdata; + pjsip_regc_info info; + + pjsip_regc_get_info(client, &info); + ast_debug(1, "Unregistering contacts with server '%s' from client '%s'\n", + state->registration->server_uri, state->registration->client_uri); cancel_registration(state->client_state); diff --git a/res/res_sorcery_config.c b/res/res_sorcery_config.c index 60ecb8311..b6ad0ccf5 100644 --- a/res/res_sorcery_config.c +++ b/res/res_sorcery_config.c @@ -294,6 +294,18 @@ static void sorcery_config_internal_load(void *data, const struct ast_sorcery *s continue; } + /* Confirm an object with this id does not already exist in the bucket. + * If it exists, however, the configuration is invalid so stop + * processing and destroy it. */ + obj = ao2_find(objects, id, OBJ_KEY); + + if (obj) { + ast_log(LOG_ERROR, "Config file '%s' could not be loaded; configuration contains a duplicate object: '%s' of type '%s'\n", + config->filename, id, type); + ast_config_destroy(cfg); + return; + } + if (!(obj = ast_sorcery_alloc(sorcery, type, id)) || ast_sorcery_objectset_apply(sorcery, obj, ast_category_first(category))) { diff --git a/rest-api-templates/ari_model_validators.c.mustache b/rest-api-templates/ari_model_validators.c.mustache index 9d3167156..9603fadbf 100644 --- a/rest-api-templates/ari_model_validators.c.mustache +++ b/rest-api-templates/ari_model_validators.c.mustache @@ -27,7 +27,7 @@ #include "asterisk.h" -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +ASTERISK_REGISTER_FILE() #include "asterisk/logger.h" #include "asterisk/module.h" diff --git a/rest-api-templates/ari_resource.c.mustache b/rest-api-templates/ari_resource.c.mustache index e2b234240..b8f20e675 100644 --- a/rest-api-templates/ari_resource.c.mustache +++ b/rest-api-templates/ari_resource.c.mustache @@ -26,7 +26,7 @@ #include "asterisk.h" -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +ASTERISK_REGISTER_FILE() #include "resource_{{c_name}}.h" diff --git a/rest-api-templates/res_ari_resource.c.mustache b/rest-api-templates/res_ari_resource.c.mustache index 896ee0d1d..9893c9731 100644 --- a/rest-api-templates/res_ari_resource.c.mustache +++ b/rest-api-templates/res_ari_resource.c.mustache @@ -44,7 +44,7 @@ #include "asterisk.h" -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +ASTERISK_REGISTER_FILE() #include "asterisk/app.h" #include "asterisk/module.h" diff --git a/tests/test_astobj2_weaken.c b/tests/test_astobj2_weaken.c index e53ab7a00..6a5eaeb99 100644 --- a/tests/test_astobj2_weaken.c +++ b/tests/test_astobj2_weaken.c @@ -223,7 +223,29 @@ AST_TEST_DEFINE(astobj2_weak1) goto fail_cleanup; } + if (ao2_t_weakproxy_ref_object(obj3, +1, 0, "ao2_ref should never see this") != -2) { + ast_test_status_update(test, + "Expected -2 from ao2_t_weakproxy_ref_object against normal ao2 object.\n"); + goto fail_cleanup; + } + + if (ao2_t_weakproxy_ref_object(weakref2, +1, 0, "weakref2 ref_object") != 2) { + ast_test_status_update(test, "Expected 2 from weakref2 ref_object.\n"); + goto fail_cleanup; + } + + if (ao2_t_ref(obj3, -1, "balance weakref2 ref_object") != 3) { + ast_test_status_update(test, "Expected 3 from obj3 ao2_t_ref.\n"); + goto fail_cleanup; + } + ao2_ref(obj3, -1); + + if (ao2_weakproxy_ref_object(weakref2, +1, 0) != -1) { + ast_test_status_update(test, "Expected -1 from weakref2 ref_object because obj3 is gone.\n"); + goto fail_cleanup; + } + ao2_t_ref(weakref2, -1, "weakref2"); if (!weakproxydestroyed) { |