pjsip: Add 'PJSIP_AOR' and 'PJSIP_CONTACT' dialplan functions.

The PJSIP_AOR dialplan function allows inspection of configured AORs including
what contacts are currently bound to them.

The PJSIP_CONTACT dialplan function allows inspection of contacts in existence.
These can include both externally added (by way of registration) or permanent
ones.

ASTERISK-24341
Reported by: xrobau

Review: https://reviewboard.asterisk.org/r/4308/


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@430179 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2015-01-05 17:51:59 +00:00
parent cca262e7d3
commit a7c38428af
7 changed files with 466 additions and 8 deletions

View File

@@ -144,30 +144,46 @@ struct ao2_container *ast_sip_location_retrieve_aor_contacts(const struct ast_si
return contacts;
}
struct ast_sip_contact *ast_sip_location_retrieve_contact_from_aor_list(const char *aor_list)
void ast_sip_location_retrieve_contact_and_aor_from_list(const char *aor_list, struct ast_sip_aor **aor,
struct ast_sip_contact **contact)
{
char *aor_name;
char *rest;
struct ast_sip_contact *contact = NULL;
/* If the location is still empty we have nowhere to go */
if (ast_strlen_zero(aor_list) || !(rest = ast_strdupa(aor_list))) {
ast_log(LOG_WARNING, "Unable to determine contacts from empty aor list\n");
return NULL;
return;
}
*aor = NULL;
*contact = NULL;
while ((aor_name = strsep(&rest, ","))) {
RAII_VAR(struct ast_sip_aor *, aor, ast_sip_location_retrieve_aor(aor_name), ao2_cleanup);
*aor = ast_sip_location_retrieve_aor(aor_name);
if (!aor) {
if (!(*aor)) {
continue;
}
contact = ast_sip_location_retrieve_first_aor_contact(aor);
*contact = ast_sip_location_retrieve_first_aor_contact(*aor);
/* If a valid contact is available use its URI for dialing */
if (contact) {
if (*contact) {
break;
}
ao2_ref(*aor, -1);
*aor = NULL;
}
}
struct ast_sip_contact *ast_sip_location_retrieve_contact_from_aor_list(const char *aor_list)
{
struct ast_sip_aor *aor;
struct ast_sip_contact *contact;
ast_sip_location_retrieve_contact_and_aor_from_list(aor_list, &aor, &contact);
ao2_cleanup(aor);
return contact;
}