From 341a341fbbb785f66b68ffdc7acd6ee21743a9a8 Mon Sep 17 00:00:00 2001 From: Nadin Zajimovic Date: Wed, 15 Nov 2023 09:50:00 +0100 Subject: [PATCH 1/3] send event on incoming ACK --- src/mod/endpoints/mod_sofia/mod_sofia.c | 6 ++++++ src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index f58bb40ac0..6df133a799 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -6634,6 +6634,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) switch_goto_status(SWITCH_STATUS_TERM, err); } + if (switch_event_reserve_subclass(MY_EVENT_ACK_REQUEST) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_ACK_REQUEST); + switch_goto_status(SWITCH_STATUS_TERM, err); + } + switch_find_local_ip(mod_sofia_globals.guess_ip, sizeof(mod_sofia_globals.guess_ip), &mod_sofia_globals.guess_mask, AF_INET); in.s_addr = mod_sofia_globals.guess_mask; switch_set_string(mod_sofia_globals.guess_mask_str, inet_ntoa(in)); @@ -6853,6 +6858,7 @@ void mod_sofia_shutdown_cleanup(void) { switch_event_free_subclass(MY_EVENT_REGISTER); switch_event_free_subclass(MY_EVENT_GATEWAY_ADD); switch_event_free_subclass(MY_EVENT_BYE_RESPONSE); + switch_event_free_subclass(MY_EVENT_ACK_REQUEST); switch_console_del_complete_func("::sofia::list_profiles"); switch_console_set_complete("del sofia"); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index bfd682c1f1..2d87420a7f 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -108,6 +108,7 @@ typedef struct private_object private_object_t; #define MY_EVENT_INTERCEPTED "sofia::intercepted" #define MY_EVENT_BYE_RESPONSE "sofia::bye_response" +#define MY_EVENT_ACK_REQUEST "sofia::ack_request" #define MULTICAST_EVENT "multicast::event" #define SOFIA_REPLACES_HEADER "_sofia_replaces_" diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index c5b5bcc190..86f3dca689 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1669,6 +1669,7 @@ static void our_sofia_event_callback(nua_event_t event, { if (channel && sip) { const char *r_sdp = NULL; + switch_event_t *event; sofia_glue_store_session_id(session, profile, sip, 0); if (sip->sip_payload && sip->sip_payload->pl_data) { @@ -1749,6 +1750,10 @@ static void our_sofia_event_callback(nua_event_t event, } + if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_ACK_REQUEST) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "ack_received", "true"); + switch_event_fire(&event); + } } } From 1af73396ddaa8405c4c1885cc42b3f492591c2cb Mon Sep 17 00:00:00 2001 From: Nadin Zajimovic Date: Tue, 28 Nov 2023 15:08:38 +0100 Subject: [PATCH 2/3] add Unique-ID to sofia::ack_request --- src/mod/endpoints/mod_sofia/sofia.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 86f3dca689..c854ae7872 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1751,6 +1751,7 @@ static void our_sofia_event_callback(nua_event_t event, } if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_ACK_REQUEST) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session)); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "ack_received", "true"); switch_event_fire(&event); } From c71a9132f67d4eab28f392e75e92336d43c0541d Mon Sep 17 00:00:00 2001 From: Nadin Zajimovic Date: Wed, 29 Nov 2023 10:41:56 +0100 Subject: [PATCH 3/3] set channel data to sofia::ack_request --- src/mod/endpoints/mod_sofia/sofia.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index c854ae7872..4cbd7fa8c2 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1751,6 +1751,7 @@ static void our_sofia_event_callback(nua_event_t event, } if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_ACK_REQUEST) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session)); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "ack_received", "true"); switch_event_fire(&event);