提交 006e0f8d authored 作者: Anthony Minessale's avatar Anthony Minessale

add network_addr to profile (had to add a func to get it for iax)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@175 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 e4aae70c
...@@ -225,6 +225,8 @@ extern unsigned int iax_session_get_capability(struct iax_session *s); ...@@ -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 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 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 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) #if defined(__cplusplus)
} }
......
...@@ -3145,6 +3145,16 @@ struct sockaddr_in iax_get_peer_addr(struct iax_session *session) ...@@ -3145,6 +3145,16 @@ struct sockaddr_in iax_get_peer_addr(struct iax_session *session)
return session->peeraddr; 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) void iax_session_destroy(struct iax_session **session)
{ {
destroy_session(*session); destroy_session(*session);
......
...@@ -139,7 +139,6 @@ extern int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen); ...@@ -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_frames(void);
extern int iax_get_iframes(void); extern int iax_get_iframes(void);
extern int iax_get_oframes(void); extern int iax_get_oframes(void);
extern void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f); 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 struct iax_frame *iax_frame_new(int direction, int datalen);
extern void iax_frame_free(struct iax_frame *fr); extern void iax_frame_free(struct iax_frame *fr);
......
...@@ -38,57 +38,59 @@ extern "C" { ...@@ -38,57 +38,59 @@ extern "C" {
#include <switch.h> #include <switch.h>
struct switch_caller_step { struct switch_caller_step {
char *step_name; char *step_name;
struct switch_caller_step *next_step; struct switch_caller_step *next_step;
}; };
struct switch_caller_profile { struct switch_caller_profile {
char *dialplan; char *dialplan;
char *caller_id_name; char *caller_id_name;
char *caller_id_number; char *caller_id_number;
char *ani; char *network_addr;
char *ani2; char *ani;
char *destination_number; char *ani2;
struct switch_caller_step *steps; char *destination_number;
}; struct switch_caller_step *steps;
};
struct switch_caller_application {
char *application_name; struct switch_caller_application {
char *application_data; char *application_name;
switch_application_function application_function; char *application_data;
struct switch_caller_application *next; switch_application_function application_function;
}; struct switch_caller_application *next;
};
struct switch_caller_extension {
char *extension_name; struct switch_caller_extension {
char *extension_number; char *extension_name;
struct switch_caller_application *current_application; char *extension_number;
struct switch_caller_application *last_application; struct switch_caller_application *current_application;
struct switch_caller_application *applications; 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, SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_core_session *session,
char *extension_number char *extension_name,
); char *extension_number
);
SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session *session,
switch_caller_extension *caller_extension, SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session *session,
char *application_name, switch_caller_extension *caller_extension,
char *extra_data); char *application_name,
char *extra_data);
SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_core_session *session,
char *dialplan, SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_core_session *session,
char *caller_id_name, char *dialplan,
char *caller_id_number, char *caller_id_name,
char *ani, char *caller_id_number,
char *ani2, char *network_addr,
char *destination_number); char *ani,
char *ani2,
SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_session *session, char *destination_number);
switch_caller_profile *tocopy);
SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_session *session,
switch_caller_profile *tocopy);
......
...@@ -171,12 +171,13 @@ static void audio_bridge_function(switch_core_session *session, char *data) ...@@ -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_caller_profile = switch_channel_get_caller_profile(caller_channel);
caller_profile = switch_caller_profile_new(session, caller_profile = switch_caller_profile_new(session,
caller_caller_profile->dialplan, caller_caller_profile->dialplan,
caller_caller_profile->caller_id_name, caller_caller_profile->caller_id_name,
caller_caller_profile->caller_id_number, caller_caller_profile->caller_id_number,
NULL, caller_caller_profile->network_addr,
NULL, NULL,
chan_data); NULL,
chan_data);
......
...@@ -803,12 +803,13 @@ static switch_status exosip_create_call(eXosip_event_t *event) ...@@ -803,12 +803,13 @@ static switch_status exosip_create_call(eXosip_event_t *event)
} }
if ((tech_pvt->caller_profile = switch_caller_profile_new(session, if ((tech_pvt->caller_profile = switch_caller_profile_new(session,
globals.dialplan, globals.dialplan,
event->request->from->displayname, event->request->from->displayname,
event->request->from->url->username, event->request->from->url->username,
event->request->from->url->username, event->request->req_uri->host,
NULL, NULL,
event->request->req_uri->username))) { NULL,
event->request->req_uri->username))) {
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
} }
......
...@@ -872,12 +872,13 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) ...@@ -872,12 +872,13 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
break; break;
} }
if ((tech_pvt->caller_profile = switch_caller_profile_new(session, if ((tech_pvt->caller_profile = switch_caller_profile_new(session,
globals.dialplan, globals.dialplan,
iaxevent->ies.calling_name, iaxevent->ies.calling_name,
iaxevent->ies.calling_number, iaxevent->ies.calling_number,
NULL, iax_get_peer_ip(iaxevent->session),
iaxevent->ies.calling_ani,
NULL, NULL,
iaxevent->ies.called_number))) { iaxevent->ies.called_number))) {
char name[128]; char name[128];
......
...@@ -794,6 +794,7 @@ static switch_status place_call(char *dest, char *out, size_t outlen) ...@@ -794,6 +794,7 @@ static switch_status place_call(char *dest, char *out, size_t outlen)
globals.cid_num, globals.cid_num,
NULL, NULL,
NULL, NULL,
NULL,
dest))) { dest))) {
char name[128]; char name[128];
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
......
...@@ -1052,6 +1052,7 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj) ...@@ -1052,6 +1052,7 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj)
char *exten; char *exten;
char cid_name[512]; char cid_name[512];
char *cid_num; char *cid_num;
char *ip;
char *p; char *p;
switch_clear_flag(tech_pvt, TFLAG_PARSE_INCOMING); switch_clear_flag(tech_pvt, TFLAG_PARSE_INCOMING);
switch_set_flag(tech_pvt, TFLAG_INCOMING); switch_set_flag(tech_pvt, TFLAG_INCOMING);
...@@ -1072,14 +1073,16 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj) ...@@ -1072,14 +1073,16 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj)
} else { } else {
cid_num = woomera_message_header(&wmsg, "Remote-Number"); 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, if ((tech_pvt->caller_profile = switch_caller_profile_new(session,
tech_pvt->profile->dialplan, tech_pvt->profile->dialplan,
cid_name, cid_name,
cid_num, cid_num,
NULL, ip,
NULL, NULL,
exten))) { NULL,
exten))) {
char name[128]; char name[128];
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); 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); snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
......
...@@ -32,12 +32,13 @@ ...@@ -32,12 +32,13 @@
#include <switch_caller.h> #include <switch_caller.h>
SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_core_session *session, SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_core_session *session,
char *dialplan, char *dialplan,
char *caller_id_name, char *caller_id_name,
char *caller_id_number, char *caller_id_number,
char *ani, char *network_addr,
char *ani2, char *ani,
char *destination_number) char *ani2,
char *destination_number)
{ {
...@@ -47,6 +48,7 @@ SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_core_se ...@@ -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->dialplan = switch_core_session_strdup(session, dialplan);
profile->caller_id_name = switch_core_session_strdup(session, caller_id_name); 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->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->ani = switch_core_session_strdup(session, ani);
profile->ani2 = switch_core_session_strdup(session, ani2); profile->ani2 = switch_core_session_strdup(session, ani2);
profile->destination_number = switch_core_session_strdup(session, destination_number); 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 ...@@ -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_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; switch_caller_profile *profile = NULL;
if ((profile = switch_core_session_alloc(session, sizeof(switch_caller_profile)))) { 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_ ...@@ -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->ani = switch_core_session_strdup(session, tocopy->ani);
profile->ani2 = switch_core_session_strdup(session, tocopy->ani2); profile->ani2 = switch_core_session_strdup(session, tocopy->ani2);
profile->caller_id_number = switch_core_session_strdup(session, tocopy->caller_id_number); 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); 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_ ...@@ -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, SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_core_session *session,
char *extension_name, char *extension_name,
char *extension_number char *extension_number
) )
{ {
switch_caller_extension *caller_extension = NULL; switch_caller_extension *caller_extension = NULL;
...@@ -90,9 +93,9 @@ SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_cor ...@@ -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_DECLARE(void) switch_caller_extension_add_application(switch_core_session *session,
switch_caller_extension *caller_extension, switch_caller_extension *caller_extension,
char *application_name, char *application_name,
char *application_data) char *application_data)
{ {
switch_caller_application *caller_application = NULL; switch_caller_application *caller_application = NULL;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论