From 9911004b5269539a5b874bd8940eef2005d37268 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Mon, 10 Dec 2018 22:04:16 +0800 Subject: [PATCH] FS-11562 #resolve add register ip and port to gateway register state change events --- src/mod/endpoints/mod_sofia/mod_sofia.h | 2 ++ src/mod/endpoints/mod_sofia/sofia_reg.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 6b9b90ad5b..cdb311f35a 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -561,6 +561,8 @@ struct sofia_gateway { sofia_gateway_subscription_t *subscriptions; int distinct_to; sofia_cid_type_t cid_type; + char register_network_ip[80]; + int register_network_port; }; typedef enum { diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 601824c334..d6db3d19e6 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -151,6 +151,9 @@ void sofia_reg_fire_custom_gateway_state_event(sofia_gateway_t *gateway, int sta switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "Gateway", gateway->name); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "State", sofia_state_string(gateway->state)); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "Ping-Status", sofia_gateway_status_name(gateway->status)); + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "Register-Network-IP", gateway->register_network_ip); + switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "Register-Network-Port", "%d", gateway->register_network_port); + if (!zstr(phrase)) { switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "Phrase", phrase); } @@ -2402,6 +2405,11 @@ void sofia_reg_handle_sip_r_register(int status, if (sofia_private && gateway) { reg_state_t ostate = gateway->state; + char network_ip[80]; + + sofia_glue_get_addr(de->data->e_msg, network_ip, sizeof(network_ip), &gateway->register_network_port); + snprintf(gateway->register_network_ip, sizeof(gateway->register_network_ip), (msg_addrinfo(de->data->e_msg))->ai_addr->sa_family == AF_INET6 ? "[%s]" : "%s", network_ip); + switch (status) { case 200: if (sip && sip->sip_contact) {