diff options
author | Joshua Colp <jcolp@digium.com> | 2015-12-03 12:39:08 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2015-12-03 12:39:08 -0600 |
commit | 59134eb7cb7ef06d456fc8bff21b3e1c85489062 (patch) | |
tree | 2ef9c97b26cd91643a6545384dcd084efe3c73f4 /res/res_pjsip/location.c | |
parent | 1d5ddb4b990b7cc275eb666d1e7a2c59ae77ded9 (diff) | |
parent | ed9134282e22c6985ce853f53d7569aa5b93ebe0 (diff) |
Merge "res_pjsip: Update logging to show contact->uri in messages" into 13
Diffstat (limited to 'res/res_pjsip/location.c')
-rw-r--r-- | res/res_pjsip/location.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c index 2e0d84b84..16913c2c8 100644 --- a/res/res_pjsip/location.c +++ b/res/res_pjsip/location.c @@ -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)); |