Skip to content
Snippets Groups Projects
Commit d1957285 authored by John Bigelow's avatar John Bigelow
Browse files

Add test suite events for when contacts are added or removed from an AOR

These are needed by the pjsip inbound registration test suite tests.

(issue ASTERISK-21833)
(issue ASTERISK-21834)
(issue ASTERISK-21835)
(issue ASTERISK-21837)

Review: https://reviewboard.asterisk.org/r/2700/
Review: https://reviewboard.asterisk.org/r/2739/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396552 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 63b5bf26
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "asterisk/res_pjsip.h" #include "asterisk/res_pjsip.h"
#include "asterisk/module.h" #include "asterisk/module.h"
#include "asterisk/test.h"
/*! \brief Internal function which returns the expiration time for a contact */ /*! \brief Internal function which returns the expiration time for a contact */
static int registrar_get_expiration(const struct ast_sip_aor *aor, const pjsip_contact_hdr *contact, const pjsip_rx_data *rdata) static int registrar_get_expiration(const struct ast_sip_aor *aor, const pjsip_contact_hdr *contact, const pjsip_rx_data *rdata)
...@@ -142,8 +143,17 @@ static int registrar_prune_static(void *obj, void *arg, int flags) ...@@ -142,8 +143,17 @@ static int registrar_prune_static(void *obj, void *arg, int flags)
static int registrar_delete_contact(void *obj, void *arg, int flags) static int registrar_delete_contact(void *obj, void *arg, int flags)
{ {
struct ast_sip_contact *contact = obj; struct ast_sip_contact *contact = obj;
const char *aor_name = arg;
ast_sip_location_delete_contact(contact); ast_sip_location_delete_contact(contact);
if (!ast_strlen_zero(aor_name)) {
ast_verb(3, "Removed contact '%s' from AOR '%s' due to request\n", contact->uri, aor_name);
ast_test_suite_event_notify("AOR_CONTACT_REMOVED",
"Contact: %s\r\n"
"AOR: %s",
contact->uri,
aor_name);
}
return 0; return 0;
} }
...@@ -284,7 +294,7 @@ static pj_bool_t registrar_on_rx_request(struct pjsip_rx_data *rdata) ...@@ -284,7 +294,7 @@ static pj_bool_t registrar_on_rx_request(struct pjsip_rx_data *rdata)
if (contact_hdr->star) { if (contact_hdr->star) {
/* A star means to unregister everything, so do so for the possible contacts */ /* A star means to unregister everything, so do so for the possible contacts */
ao2_callback(contacts, OBJ_NODATA | OBJ_MULTIPLE, registrar_delete_contact, NULL); ao2_callback(contacts, OBJ_NODATA | OBJ_MULTIPLE, registrar_delete_contact, aor_name);
break; break;
} }
...@@ -308,6 +318,13 @@ static pj_bool_t registrar_on_rx_request(struct pjsip_rx_data *rdata) ...@@ -308,6 +318,13 @@ static pj_bool_t registrar_on_rx_request(struct pjsip_rx_data *rdata)
ast_sip_location_add_contact(aor, contact_uri, ast_tvadd(ast_tvnow(), ast_samp2tv(expiration, 1))); ast_sip_location_add_contact(aor, contact_uri, ast_tvadd(ast_tvnow(), ast_samp2tv(expiration, 1)));
ast_verb(3, "Added contact '%s' to AOR '%s' with expiration of %d seconds\n", ast_verb(3, "Added contact '%s' to AOR '%s' with expiration of %d seconds\n",
contact_uri, aor_name, expiration); contact_uri, aor_name, expiration);
ast_test_suite_event_notify("AOR_CONTACT_ADDED",
"Contact: %s\r\n"
"AOR: %s\r\n"
"Expiration: %d",
contact_uri,
aor_name,
expiration);
} else if (expiration) { } else if (expiration) {
RAII_VAR(struct ast_sip_contact *, updated, ast_sorcery_copy(ast_sip_get_sorcery(), contact), ao2_cleanup); RAII_VAR(struct ast_sip_contact *, updated, ast_sorcery_copy(ast_sip_get_sorcery(), contact), ao2_cleanup);
updated->expiration_time = ast_tvadd(ast_tvnow(), ast_samp2tv(expiration, 1)); updated->expiration_time = ast_tvadd(ast_tvnow(), ast_samp2tv(expiration, 1));
...@@ -317,9 +334,21 @@ static pj_bool_t registrar_on_rx_request(struct pjsip_rx_data *rdata) ...@@ -317,9 +334,21 @@ static pj_bool_t registrar_on_rx_request(struct pjsip_rx_data *rdata)
ast_sip_location_update_contact(updated); ast_sip_location_update_contact(updated);
ast_debug(3, "Refreshed contact '%s' on AOR '%s' with new expiration of %d seconds\n", ast_debug(3, "Refreshed contact '%s' on AOR '%s' with new expiration of %d seconds\n",
contact_uri, aor_name, expiration); contact_uri, aor_name, expiration);
ast_test_suite_event_notify("AOR_CONTACT_REFRESHED",
"Contact: %s\r\n"
"AOR: %s\r\n"
"Expiration: %d",
contact_uri,
aor_name,
expiration);
} else { } else {
ast_sip_location_delete_contact(contact); ast_sip_location_delete_contact(contact);
ast_verb(3, "Removed contact '%s' from AOR '%s' due to request\n", contact_uri, aor_name); ast_verb(3, "Removed contact '%s' from AOR '%s' due to request\n", contact_uri, aor_name);
ast_test_suite_event_notify("AOR_CONTACT_REMOVED",
"Contact: %s\r\n"
"AOR: %s",
contact_uri,
aor_name);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment