diff --git a/libs/iax/src/iax-client.h b/libs/iax/src/iax-client.h index f425eedf26..a50e70c80f 100644 --- a/libs/iax/src/iax-client.h +++ b/libs/iax/src/iax-client.h @@ -225,6 +225,8 @@ extern unsigned int iax_session_get_capability(struct iax_session *s); extern char iax_pref_codec_add(struct iax_session *session, unsigned int format); extern void iax_pref_codec_del(struct iax_session *session, unsigned int format); extern int iax_pref_codec_get(struct iax_session *session, unsigned int *array, int len); +extern char *iax_get_peer_ip(struct iax_session *session); +extern char *iax_event_get_apparent_ip(struct iax_event *event); #if defined(__cplusplus) } diff --git a/libs/iax/src/iax.c b/libs/iax/src/iax.c index 0e1e987186..5d3d1aae55 100644 --- a/libs/iax/src/iax.c +++ b/libs/iax/src/iax.c @@ -3145,6 +3145,16 @@ struct sockaddr_in iax_get_peer_addr(struct iax_session *session) return session->peeraddr; } +char *iax_get_peer_ip(struct iax_session *session) +{ + return inet_ntoa(session->peeraddr.sin_addr); +} + +char *iax_event_get_apparent_ip(struct iax_event *event) +{ + return inet_ntoa(event->ies.apparent_addr->sin_addr); +} + void iax_session_destroy(struct iax_session **session) { destroy_session(*session); diff --git a/libs/iax/src/iax2-parser.h b/libs/iax/src/iax2-parser.h index 0a97e46870..666042a18d 100644 --- a/libs/iax/src/iax2-parser.h +++ b/libs/iax/src/iax2-parser.h @@ -139,7 +139,6 @@ extern int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen); extern int iax_get_frames(void); extern int iax_get_iframes(void); extern int iax_get_oframes(void); - extern void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f); extern struct iax_frame *iax_frame_new(int direction, int datalen); extern void iax_frame_free(struct iax_frame *fr); diff --git a/src/include/switch_caller.h b/src/include/switch_caller.h index e133b42ba9..b248bf1eb1 100644 --- a/src/include/switch_caller.h +++ b/src/include/switch_caller.h @@ -38,57 +38,59 @@ extern "C" { #include -struct switch_caller_step { - char *step_name; - struct switch_caller_step *next_step; -}; + struct switch_caller_step { + char *step_name; + struct switch_caller_step *next_step; + }; -struct switch_caller_profile { - char *dialplan; - char *caller_id_name; - char *caller_id_number; - char *ani; - char *ani2; - char *destination_number; - struct switch_caller_step *steps; -}; + struct switch_caller_profile { + char *dialplan; + char *caller_id_name; + char *caller_id_number; + char *network_addr; + char *ani; + char *ani2; + char *destination_number; + struct switch_caller_step *steps; + }; -struct switch_caller_application { - char *application_name; - char *application_data; - switch_application_function application_function; - struct switch_caller_application *next; -}; + struct switch_caller_application { + char *application_name; + char *application_data; + switch_application_function application_function; + struct switch_caller_application *next; + }; -struct switch_caller_extension { - char *extension_name; - char *extension_number; - struct switch_caller_application *current_application; - struct switch_caller_application *last_application; - struct switch_caller_application *applications; -}; + struct switch_caller_extension { + char *extension_name; + char *extension_number; + struct switch_caller_application *current_application; + struct switch_caller_application *last_application; + struct switch_caller_application *applications; + }; -SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_core_session *session, - char *extension_name, - char *extension_number - ); + SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_core_session *session, + char *extension_name, + char *extension_number + ); -SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session *session, - switch_caller_extension *caller_extension, - char *application_name, - char *extra_data); + SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session *session, + switch_caller_extension *caller_extension, + char *application_name, + char *extra_data); -SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_core_session *session, - char *dialplan, - char *caller_id_name, - char *caller_id_number, - char *ani, - char *ani2, - char *destination_number); + SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_core_session *session, + char *dialplan, + char *caller_id_name, + char *caller_id_number, + char *network_addr, + char *ani, + char *ani2, + char *destination_number); -SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_session *session, - switch_caller_profile *tocopy); + SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_session *session, + switch_caller_profile *tocopy); diff --git a/src/mod/mod_bridgecall/mod_bridgecall.c b/src/mod/mod_bridgecall/mod_bridgecall.c index 9ebf6a1757..b8353fcf4c 100644 --- a/src/mod/mod_bridgecall/mod_bridgecall.c +++ b/src/mod/mod_bridgecall/mod_bridgecall.c @@ -171,12 +171,13 @@ static void audio_bridge_function(switch_core_session *session, char *data) caller_caller_profile = switch_channel_get_caller_profile(caller_channel); caller_profile = switch_caller_profile_new(session, - caller_caller_profile->dialplan, - caller_caller_profile->caller_id_name, - caller_caller_profile->caller_id_number, - NULL, - NULL, - chan_data); + caller_caller_profile->dialplan, + caller_caller_profile->caller_id_name, + caller_caller_profile->caller_id_number, + caller_caller_profile->network_addr, + NULL, + NULL, + chan_data); diff --git a/src/mod/mod_exosip/mod_exosip.c b/src/mod/mod_exosip/mod_exosip.c index a5e1b376fe..e8f0863b98 100644 --- a/src/mod/mod_exosip/mod_exosip.c +++ b/src/mod/mod_exosip/mod_exosip.c @@ -803,12 +803,13 @@ static switch_status exosip_create_call(eXosip_event_t *event) } if ((tech_pvt->caller_profile = switch_caller_profile_new(session, - globals.dialplan, - event->request->from->displayname, - event->request->from->url->username, - event->request->from->url->username, - NULL, - event->request->req_uri->username))) { + globals.dialplan, + event->request->from->displayname, + event->request->from->url->username, + event->request->req_uri->host, + NULL, + NULL, + event->request->req_uri->username))) { switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); } diff --git a/src/mod/mod_iaxchan/mod_iaxchan.c b/src/mod/mod_iaxchan/mod_iaxchan.c index 524d16ff56..df1d4ed9cd 100644 --- a/src/mod/mod_iaxchan/mod_iaxchan.c +++ b/src/mod/mod_iaxchan/mod_iaxchan.c @@ -872,12 +872,13 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) break; } - + if ((tech_pvt->caller_profile = switch_caller_profile_new(session, globals.dialplan, iaxevent->ies.calling_name, iaxevent->ies.calling_number, - NULL, + iax_get_peer_ip(iaxevent->session), + iaxevent->ies.calling_ani, NULL, iaxevent->ies.called_number))) { char name[128]; diff --git a/src/mod/mod_portaudio/mod_portaudio.c b/src/mod/mod_portaudio/mod_portaudio.c index 9d687cf45e..bfbbf33139 100644 --- a/src/mod/mod_portaudio/mod_portaudio.c +++ b/src/mod/mod_portaudio/mod_portaudio.c @@ -794,6 +794,7 @@ static switch_status place_call(char *dest, char *out, size_t outlen) globals.cid_num, NULL, NULL, + NULL, dest))) { char name[128]; switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); diff --git a/src/mod/mod_woomerachan/mod_woomerachan.c b/src/mod/mod_woomerachan/mod_woomerachan.c index a1e05be8f0..2a76d080a0 100644 --- a/src/mod/mod_woomerachan/mod_woomerachan.c +++ b/src/mod/mod_woomerachan/mod_woomerachan.c @@ -1052,6 +1052,7 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj) char *exten; char cid_name[512]; char *cid_num; + char *ip; char *p; switch_clear_flag(tech_pvt, TFLAG_PARSE_INCOMING); switch_set_flag(tech_pvt, TFLAG_INCOMING); @@ -1072,14 +1073,16 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj) } else { cid_num = woomera_message_header(&wmsg, "Remote-Number"); } - + ip = woomera_message_header(&wmsg, "Remote-Address"); + if ((tech_pvt->caller_profile = switch_caller_profile_new(session, - tech_pvt->profile->dialplan, - cid_name, - cid_num, - NULL, - NULL, - exten))) { + tech_pvt->profile->dialplan, + cid_name, + cid_num, + ip, + NULL, + NULL, + exten))) { char name[128]; switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff); diff --git a/src/switch_caller.c b/src/switch_caller.c index 52d0afeb31..54032df92a 100644 --- a/src/switch_caller.c +++ b/src/switch_caller.c @@ -32,12 +32,13 @@ #include SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_core_session *session, - char *dialplan, - char *caller_id_name, - char *caller_id_number, - char *ani, - char *ani2, - char *destination_number) + char *dialplan, + char *caller_id_name, + char *caller_id_number, + char *network_addr, + char *ani, + char *ani2, + char *destination_number) { @@ -47,6 +48,7 @@ SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_core_se profile->dialplan = switch_core_session_strdup(session, dialplan); profile->caller_id_name = switch_core_session_strdup(session, caller_id_name); profile->caller_id_number = switch_core_session_strdup(session, caller_id_number); + profile->network_addr = switch_core_session_strdup(session, network_addr); profile->ani = switch_core_session_strdup(session, ani); profile->ani2 = switch_core_session_strdup(session, ani2); profile->destination_number = switch_core_session_strdup(session, destination_number); @@ -57,7 +59,7 @@ SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_core_se SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_session *session, - switch_caller_profile *tocopy) + switch_caller_profile *tocopy) { switch_caller_profile *profile = NULL; if ((profile = switch_core_session_alloc(session, sizeof(switch_caller_profile)))) { @@ -66,6 +68,7 @@ SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_ profile->ani = switch_core_session_strdup(session, tocopy->ani); profile->ani2 = switch_core_session_strdup(session, tocopy->ani2); profile->caller_id_number = switch_core_session_strdup(session, tocopy->caller_id_number); + profile->network_addr = switch_core_session_strdup(session, tocopy->network_addr); profile->destination_number = switch_core_session_strdup(session, tocopy->destination_number); } @@ -73,9 +76,9 @@ SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_ } SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_core_session *session, - char *extension_name, - char *extension_number - ) + char *extension_name, + char *extension_number + ) { switch_caller_extension *caller_extension = NULL; @@ -90,9 +93,9 @@ SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_cor SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session *session, - switch_caller_extension *caller_extension, - char *application_name, - char *application_data) + switch_caller_extension *caller_extension, + char *application_name, + char *application_data) { switch_caller_application *caller_application = NULL;