From 6547e4c09a0e2314b0a187f2a0e05366d3323b6f Mon Sep 17 00:00:00 2001 From: Chris Parker Date: Tue, 5 Feb 2008 18:00:03 +0000 Subject: [PATCH] Enhancements from MODEVENT-13 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7529 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../mod_radius_cdr/mod_radius_cdr.c | 112 ++++++++++++++++++ .../mod_radius_cdr/mod_radius_cdr.h | 4 + .../mod_radius_cdr/radius/dictionary | 10 +- 3 files changed, 122 insertions(+), 4 deletions(-) diff --git a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c b/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c index bb3818ba28..6a215a4569 100644 --- a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c +++ b/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c @@ -182,6 +182,14 @@ static switch_status_t my_on_ring(switch_core_session_t *session) profile = switch_channel_get_caller_profile(channel); if(profile) { + if(profile->username) { + if (rc_avpair_add(rad_config, &send, PW_USER_NAME, (void *)profile->username, -1, 0) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "failed adding User-Name: %s\n", profile->username); + rc_destroy(rad_config); + return SWITCH_STATUS_TERM; + } + } if(profile->caller_id_number) { if (rc_avpair_add(rad_config, &send, PW_FS_SRC, (void *)profile->caller_id_number, -1, PW_FS_PEC) == NULL) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, @@ -214,6 +222,54 @@ static switch_status_t my_on_ring(switch_core_session_t *session) return SWITCH_STATUS_TERM; } } + if(profile->network_addr) { + if (rc_avpair_add(rad_config, &send, PW_FRAMED_IP_ADDRESS, (void *)profile->network_addr, -1, 0) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "failed adding Framed-IP-Address: %s\n", profile->network_addr); + rc_destroy(rad_config); + return SWITCH_STATUS_TERM; + } + } + if(profile->rdnis) { + if (rc_avpair_add(rad_config, &send, PW_FS_RDNIS, (void *)profile->rdnis, -1, PW_FS_PEC) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "failed adding Freeswitch-RDNIS: %s\n", profile->rdnis); + rc_destroy(rad_config); + return SWITCH_STATUS_TERM; + } + } + if(profile->context) { + if (rc_avpair_add(rad_config, &send, PW_FS_CONTEXT, (void *)profile->context, -1, PW_FS_PEC) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "failed adding Freeswitch-Context: %s\n", profile->context); + rc_destroy(rad_config); + return SWITCH_STATUS_TERM; + } + } + if(profile->ani) { + if (rc_avpair_add(rad_config, &send, PW_FS_ANI, (void *)profile->ani, -1, PW_FS_PEC) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "failed adding Freeswitch-ANI: %s\n", profile->ani); + rc_destroy(rad_config); + return SWITCH_STATUS_TERM; + } + } + if(profile->aniii) { + if (rc_avpair_add(rad_config, &send, PW_FS_ANIII, (void *)profile->aniii, -1, PW_FS_PEC) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "failed adding Freeswitch-ANIII: %s\n", profile->aniii); + rc_destroy(rad_config); + return SWITCH_STATUS_TERM; + } + } + if(profile->source) { + if (rc_avpair_add(rad_config, &send, PW_FS_SOURCE, (void *)profile->source, -1, PW_FS_PEC) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "failed adding Freeswitch-Source: %s\n", profile->source); + rc_destroy(rad_config); + return SWITCH_STATUS_TERM; + } + } if(profile->caller_extension && profile->caller_extension->last_application->application_name) { if (rc_avpair_add(rad_config, &send, PW_FS_LASTAPP, (void *)profile->caller_extension->last_application->application_name, -1, PW_FS_PEC) == NULL) { @@ -330,6 +386,14 @@ static switch_status_t my_on_hangup(switch_core_session_t *session) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[mod_radius_cdr] Finished calculating billable time\n"); + if(profile->username) { + if (rc_avpair_add(rad_config, &send, PW_USER_NAME, (void *)profile->username, -1, 0) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "failed adding User-Name: %s\n", profile->username); + rc_destroy(rad_config); + return SWITCH_STATUS_TERM; + } + } if(profile->caller_id_number) { if (rc_avpair_add(rad_config, &send, PW_FS_SRC, (void *)profile->caller_id_number, -1, PW_FS_PEC) == NULL) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, @@ -362,6 +426,54 @@ static switch_status_t my_on_hangup(switch_core_session_t *session) return SWITCH_STATUS_TERM; } } + if(profile->network_addr) { + if (rc_avpair_add(rad_config, &send, PW_FRAMED_IP_ADDRESS, (void *)profile->network_addr, -1, 0) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "failed adding Framed-IP-Address: %s\n", profile->network_addr); + rc_destroy(rad_config); + return SWITCH_STATUS_TERM; + } + } + if(profile->rdnis) { + if (rc_avpair_add(rad_config, &send, PW_FS_RDNIS, (void *)profile->rdnis, -1, PW_FS_PEC) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "failed adding Freeswitch-RDNIS: %s\n", profile->rdnis); + rc_destroy(rad_config); + return SWITCH_STATUS_TERM; + } + } + if(profile->context) { + if (rc_avpair_add(rad_config, &send, PW_FS_CONTEXT, (void *)profile->context, -1, PW_FS_PEC) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "failed adding Freeswitch-Context: %s\n", profile->context); + rc_destroy(rad_config); + return SWITCH_STATUS_TERM; + } + } + if(profile->ani) { + if (rc_avpair_add(rad_config, &send, PW_FS_ANI, (void *)profile->ani, -1, PW_FS_PEC) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "failed adding Freeswitch-ANI: %s\n", profile->ani); + rc_destroy(rad_config); + return SWITCH_STATUS_TERM; + } + } + if(profile->aniii) { + if (rc_avpair_add(rad_config, &send, PW_FS_ANIII, (void *)profile->aniii, -1, PW_FS_PEC) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "failed adding Freeswitch-ANIII: %s\n", profile->aniii); + rc_destroy(rad_config); + return SWITCH_STATUS_TERM; + } + } + if(profile->source) { + if (rc_avpair_add(rad_config, &send, PW_FS_SOURCE, (void *)profile->source, -1, PW_FS_PEC) == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "failed adding Freeswitch-Source: %s\n", profile->source); + rc_destroy(rad_config); + return SWITCH_STATUS_TERM; + } + } if(profile->caller_extension && profile->caller_extension->last_application->application_name) { if (rc_avpair_add(rad_config, &send, PW_FS_LASTAPP, (void *)profile->caller_extension->last_application->application_name, -1, PW_FS_PEC) == NULL) { diff --git a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.h b/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.h index 918f24240f..e4e5a38afc 100644 --- a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.h +++ b/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.h @@ -51,9 +51,13 @@ #define PW_FS_HANGUPCAUSE 13 #define PW_FS_BILLUSEC 15 #define PW_FS_AMAFLAGS 16 +#define PW_FS_RDNIS 17 +#define PW_FS_CONTEXT 18 +#define PW_FS_SOURCE 19 #define PW_FS_CALLSTARTDATE 20 #define PW_FS_CALLANSWERDATE 21 #define PW_FS_CALLTRANSFERDATE 22 #define PW_FS_CALLENDDATE 23 + #endif diff --git a/src/mod/event_handlers/mod_radius_cdr/radius/dictionary b/src/mod/event_handlers/mod_radius_cdr/radius/dictionary index 0b173820a3..fd84ffd771 100644 --- a/src/mod/event_handlers/mod_radius_cdr/radius/dictionary +++ b/src/mod/event_handlers/mod_radius_cdr/radius/dictionary @@ -266,10 +266,12 @@ ATTRIBUTE Freeswitch-Aniii 9 string Freeswitch ATTRIBUTE Freeswitch-Lastapp 10 string Freeswitch ATTRIBUTE Freeswitch-Lastdata 11 string Freeswitch ATTRIBUTE Freeswitch-Disposition 12 string Freeswitch -ATTRIBUTE Freeswitch-Hangupcause 13 integer Freeswitch -ATTRIBUTE Freeswitch-Billusec 15 integer Freeswitch -ATTRIBUTE Freeswitch-AMAFlags 16 integer Freeswitch - +ATTRIBUTE Freeswitch-Hangupcause 13 integer Freeswitch +ATTRIBUTE Freeswitch-Billusec 15 integer Freeswitch +ATTRIBUTE Freeswitch-AMAFlags 16 integer Freeswitch +ATTRIBUTE Freeswitch-RDNIS 17 string Freeswitch +ATTRIBUTE Freeswitch-Context 18 string Freeswitch +ATTRIBUTE Freeswitch-Source 19 string Freeswitch ATTRIBUTE Freeswitch-Callstartdate 20 string Freeswitch ATTRIBUTE Freeswitch-Callanswerdate 21 string Freeswitch ATTRIBUTE Freeswitch-Calltransferdate 22 string Freeswitch