Mercurial > hg > freeDiameter
comparison extensions/app_radgw/rgwx_acct.c @ 277:c94e4ea39f97
Add missing mandatory AVP
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 23 Apr 2010 14:33:26 +0900 |
parents | 0941db40bcba |
children | 0e940240c436 |
comparison
equal
deleted
inserted
replaced
276:17739001c00e | 277:c94e4ea39f97 |
---|---|
49 | 49 |
50 | 50 |
51 /* The state we keep for this plugin */ | 51 /* The state we keep for this plugin */ |
52 struct rgwp_config { | 52 struct rgwp_config { |
53 struct { | 53 struct { |
54 struct dict_object * Accounting_Record_Number; /* Accounting-Record-Number */ | |
54 struct dict_object * Accounting_Record_Type; /* Accounting-Record-Type */ | 55 struct dict_object * Accounting_Record_Type; /* Accounting-Record-Type */ |
55 struct dict_object * Acct_Application_Id; /* Acct-Application-Id */ | 56 struct dict_object * Acct_Application_Id; /* Acct-Application-Id */ |
56 struct dict_object * Acct_Delay_Time; /* Acct-Delay-Time */ | 57 struct dict_object * Acct_Delay_Time; /* Acct-Delay-Time */ |
57 struct dict_object * Accounting_Input_Octets; /* Accounting-Input-Octets */ | 58 struct dict_object * Accounting_Input_Octets; /* Accounting-Input-Octets */ |
58 struct dict_object * Accounting_Output_Octets; /* Accounting-Output-Octets */ | 59 struct dict_object * Accounting_Output_Octets; /* Accounting-Output-Octets */ |
172 | 173 |
173 CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, free ) ); | 174 CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, free ) ); |
174 new->confstr = conffile; | 175 new->confstr = conffile; |
175 | 176 |
176 /* Resolve all dictionary objects we use */ | 177 /* Resolve all dictionary objects we use */ |
178 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Record-Number", &new->dict.Accounting_Record_Number, ENOENT) ); | |
177 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Record-Type", &new->dict.Accounting_Record_Type, ENOENT) ); | 179 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Record-Type", &new->dict.Accounting_Record_Type, ENOENT) ); |
178 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Acct-Application-Id", &new->dict.Acct_Application_Id, ENOENT) ); | 180 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Acct-Application-Id", &new->dict.Acct_Application_Id, ENOENT) ); |
179 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Acct-Delay-Time", &new->dict.Acct_Delay_Time, ENOENT) ); | 181 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Acct-Delay-Time", &new->dict.Acct_Delay_Time, ENOENT) ); |
180 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Input-Octets", &new->dict.Accounting_Input_Octets, ENOENT) ); | 182 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Input-Octets", &new->dict.Accounting_Input_Octets, ENOENT) ); |
181 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Output-Octets", &new->dict.Accounting_Output_Octets, ENOENT) ); | 183 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Output-Octets", &new->dict.Accounting_Output_Octets, ENOENT) ); |
285 static int acct_rad_req( struct rgwp_config * cs, struct session * session, struct radius_msg * rad_req, struct radius_msg ** rad_ans, struct msg ** diam_fw, struct rgw_client * cli ) | 287 static int acct_rad_req( struct rgwp_config * cs, struct session * session, struct radius_msg * rad_req, struct radius_msg ** rad_ans, struct msg ** diam_fw, struct rgw_client * cli ) |
286 { | 288 { |
287 int idx; | 289 int idx; |
288 int send_str=0; | 290 int send_str=0; |
289 uint32_t str_cause=0; | 291 uint32_t str_cause=0; |
292 uint32_t e2eid = 0; | |
290 application_id_t auth_appl=0; | 293 application_id_t auth_appl=0; |
291 int got_id = 0; | 294 int got_id = 0; |
292 uint32_t status_type; | 295 uint32_t status_type; |
293 uint32_t termination_action = 0; | 296 uint32_t termination_action = 0; |
294 uint32_t gigawords_in=0, gigawords_out=0; | 297 uint32_t gigawords_in=0, gigawords_out=0; |
425 /* Add the Acct-Application-Id */ | 428 /* Add the Acct-Application-Id */ |
426 CHECK_FCT( fd_msg_avp_new ( cs->dict.Acct_Application_Id, 0, &avp ) ); | 429 CHECK_FCT( fd_msg_avp_new ( cs->dict.Acct_Application_Id, 0, &avp ) ); |
427 value.i32 = header->msg_appl; | 430 value.i32 = header->msg_appl; |
428 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); | 431 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); |
429 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); | 432 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); |
433 | |
434 /* save the end to end id */ | |
435 e2eid = header->msg_eteid; | |
430 } | 436 } |
431 | 437 |
432 /* Convert the RADIUS attributes, as they appear in the message */ | 438 /* Convert the RADIUS attributes, as they appear in the message */ |
433 for (idx = 0; idx < rad_req->attr_used; idx++) { | 439 for (idx = 0; idx < rad_req->attr_used; idx++) { |
434 struct radius_attr_hdr * attr = (struct radius_attr_hdr *)(rad_req->buf + rad_req->attr_pos[idx]); | 440 struct radius_attr_hdr * attr = (struct radius_attr_hdr *)(rad_req->buf + rad_req->attr_pos[idx]); |
733 return ENOTSUP; | 739 return ENOTSUP; |
734 } | 740 } |
735 CHECK_FCT( fd_msg_avp_new ( cs->dict.Accounting_Record_Type, 0, &avp ) ); | 741 CHECK_FCT( fd_msg_avp_new ( cs->dict.Accounting_Record_Type, 0, &avp ) ); |
736 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); | 742 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); |
737 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); | 743 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); |
744 | |
745 /* While here, we also add the Accouting-Record-Number AVP. | |
746 We don't have a dedicated counter nor a state, so we just use the Diameter message End-to-end id here, which fits the conditions on the value. */ | |
747 CHECK_FCT( fd_msg_avp_new ( cs->dict.Accounting_Record_Number, 0, &avp ) ); | |
748 value.u32 = e2eid; | |
749 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); | |
750 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); | |
751 | |
738 break; | 752 break; |
739 | 753 |
740 case RADIUS_ATTR_ACCT_DELAY_TIME: | 754 case RADIUS_ATTR_ACCT_DELAY_TIME: |
741 CONV2DIAM_32B( Acct_Delay_Time ); | 755 CONV2DIAM_32B( Acct_Delay_Time ); |
742 break; | 756 break; |