[Freeswitch-branches] [commit] r5138 - freeswitch/branches/cparker/src/mod/event_handlers/mod_radius_cdr
Freeswitch SVN
cparker at freeswitch.org
Thu May 10 17:20:54 EDT 2007
Author: cparker
Date: Thu May 10 17:20:54 2007
New Revision: 5138
Modified:
freeswitch/branches/cparker/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c
Log:
more making it work, and getting some real channel information passed
Modified: freeswitch/branches/cparker/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c
==============================================================================
--- freeswitch/branches/cparker/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c (original)
+++ freeswitch/branches/cparker/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c Thu May 10 17:20:54 2007
@@ -48,13 +48,13 @@
static switch_status_t my_on_hangup(switch_core_session_t *session)
{
switch_xml_t cdr;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
rc_handle *rad_config;
int retval = 0;
VALUE_PAIR *send = NULL;
UINT4 client_port = 0;
UINT4 status_type = PW_STATUS_STOP;
- char src[] = "8475551212";
char *uuid_str;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_radius_cdr] Entering my_on_hangup\n");
@@ -75,7 +75,6 @@
}
if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
- /*switch_channel_t *channel = switch_core_session_get_channel(session);*/
uuid_str = switch_core_session_get_uuid(session);
/* Some hardcoded ( for now ) defaults needed to initialize radius */
@@ -153,12 +152,66 @@
return SWITCH_STATUS_TERM;
}
- /* Add VSA */
- if (rc_avpair_add(rad_config, &send, PW_FS_SRC, src, -1, PW_FS_PEC) == NULL) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Freeswitch-Src: %s\n", src);
- rc_destroy(rad_config);
- return SWITCH_STATUS_TERM;
- }
+ /* Add VSAs */
+
+ if(channel) {
+ switch_call_cause_t cause;
+ switch_caller_profile_t *profile;
+
+ cause = switch_channel_get_cause(channel);
+ if (rc_avpair_add(rad_config, &send, PW_FS_HANGUPCAUSE, &cause, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Freeswitch-Hangupcause: %d\n", cause);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+
+ profile = switch_channel_get_caller_profile(channel);
+
+ if(profile) {
+ if(profile->caller_id_number) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_SRC, profile->caller_id_number, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-Src: %s\n", profile->caller_id_number);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ if(profile->caller_id_name) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_CLID, profile->caller_id_name, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-CLID: %s\n", profile->caller_id_name);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ if(profile->destination_number) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_DST, profile->destination_number, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-Dst: %s\n", profile->destination_number);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ if(profile->dialplan) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_DIALPLAN, profile->dialplan, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-Dialplan: %s\n", profile->dialplan);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ if(profile->source) {
+ if (rc_avpair_add(rad_config, &send, PW_FS_LASTAPP, profile->source, -1, PW_FS_PEC) == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "failed adding Freeswitch-Lastapp: %s\n", profile->source);
+ rc_destroy(rad_config);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "profile == NULL\n");
+ }
+ }
if(rc_acct(rad_config, client_port, send) == OK_RC) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RADIUS Accounting OK\n");
More information about the Freeswitch-branches
mailing list