mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-04 03:20:33 +00:00
res_pjsip: Update logging to show contact->uri in messages
An earlier commit changed the id of dynamic contacts to contain a hash instead of the uri. This patch updates status change logging to show the aor/uri instead of the id. This required adding the aor id to contact and contact_status and adding uri to contact_status. The aor id gets added to contact and contact_status in their allocators and the uri gets added to contact_status in pjsip_options when the contact_status is created or updated. ASTERISK-25598 #close Reported-by: George Joseph Tested-by: George Joseph Change-Id: I56cbec1d2ddbe8461367dd8b6da8a6f47f6fe511
This commit is contained in:
@@ -92,6 +92,7 @@ static void contact_destroy(void *obj)
|
||||
struct ast_sip_contact *contact = obj;
|
||||
|
||||
ast_string_field_free_memory(contact);
|
||||
ast_free(contact->aor);
|
||||
ao2_cleanup(contact->endpoint);
|
||||
}
|
||||
|
||||
@@ -99,6 +100,9 @@ static void contact_destroy(void *obj)
|
||||
static void *contact_alloc(const char *name)
|
||||
{
|
||||
struct ast_sip_contact *contact = ast_sorcery_generic_alloc(sizeof(*contact), contact_destroy);
|
||||
char *id = ast_strdupa(name);
|
||||
char *aor = id;
|
||||
char *aor_separator = NULL;
|
||||
|
||||
if (!contact) {
|
||||
return NULL;
|
||||
@@ -109,6 +113,18 @@ static void *contact_alloc(const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Dynamic contacts are delimited with ";@" and static ones with "@@" */
|
||||
if ((aor_separator = strstr(id, ";@")) || (aor_separator = strstr(id, "@@"))) {
|
||||
*aor_separator = '\0';
|
||||
}
|
||||
ast_assert(aor_separator != NULL);
|
||||
|
||||
contact->aor = ast_strdup(aor);
|
||||
if (!contact->aor) {
|
||||
ao2_cleanup(contact);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return contact;
|
||||
}
|
||||
|
||||
@@ -790,13 +806,14 @@ static int cli_contact_print_body(void *obj, void *arg, int flags)
|
||||
ast_assert(context->output_buffer != NULL);
|
||||
|
||||
indent = CLI_INDENT_TO_SPACES(context->indent_level);
|
||||
flexwidth = CLI_LAST_TABSTOP - indent - 2;
|
||||
flexwidth = CLI_LAST_TABSTOP - indent - 2 - strlen(contact->aor) + 1;
|
||||
|
||||
ast_str_append(&context->output_buffer, 0, "%*s: %-*.*s %-12.12s %11.3f\n",
|
||||
ast_str_append(&context->output_buffer, 0, "%*s: %s/%-*.*s %-12.12s %11.3f\n",
|
||||
indent,
|
||||
"Contact",
|
||||
contact->aor,
|
||||
flexwidth, flexwidth,
|
||||
wrapper->contact_id,
|
||||
contact->uri,
|
||||
ast_sip_get_contact_short_status_label(status ? status->status : UNKNOWN),
|
||||
(status && (status->status != UNKNOWN) ? ((long long) status->rtt) / 1000.0 : NAN));
|
||||
|
||||
|
Reference in New Issue
Block a user