Mercurial > hg > freeDiameter
comparison extensions/app_radgw/rgwx_acct.c @ 536:f95cfc35d960
Add User Name in translated Accounting Responses
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 10 Sep 2010 10:59:14 +0900 |
parents | 72c511043f05 |
children | 616848d6f020 |
comparison
equal
deleted
inserted
replaced
535:72c511043f05 | 536:f95cfc35d960 |
---|---|
156 /* The state we store in the session */ | 156 /* The state we store in the session */ |
157 struct sess_state { | 157 struct sess_state { |
158 application_id_t auth_appl; /* Auth-Application-Id used for this session, if available (stored in a Class attribute) */ | 158 application_id_t auth_appl; /* Auth-Application-Id used for this session, if available (stored in a Class attribute) */ |
159 int send_str; /* If not 0, we must send a STR when the ACA is received. */ | 159 int send_str; /* If not 0, we must send a STR when the ACA is received. */ |
160 uint32_t term_cause; /* If not 0, the Termination-Cause to put in the STR. */ | 160 uint32_t term_cause; /* If not 0, the Termination-Cause to put in the STR. */ |
161 /* Temporary : try sending the User-Name back in Accounting-Response for RADIUS */ | |
162 uint8_t *username; | |
163 size_t un_size; | |
161 }; | 164 }; |
165 | |
166 static void free_sess_state(struct sess_state *s) { | |
167 if (s) | |
168 free(s->username); | |
169 free(s); | |
170 } | |
162 | 171 |
163 /* Initialize the plugin */ | 172 /* Initialize the plugin */ |
164 static int acct_conf_parse(char * conffile, struct rgwp_config ** state) | 173 static int acct_conf_parse(char * conffile, struct rgwp_config ** state) |
165 { | 174 { |
166 struct rgwp_config * new; | 175 struct rgwp_config * new; |
170 CHECK_PARAMS( state ); | 179 CHECK_PARAMS( state ); |
171 | 180 |
172 CHECK_MALLOC( new = malloc(sizeof(struct rgwp_config)) ); | 181 CHECK_MALLOC( new = malloc(sizeof(struct rgwp_config)) ); |
173 memset(new, 0, sizeof(struct rgwp_config)); | 182 memset(new, 0, sizeof(struct rgwp_config)); |
174 | 183 |
175 CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, free ) ); | 184 CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, free_sess_state ) ); |
176 new->confstr = conffile; | 185 new->confstr = conffile; |
177 | 186 |
178 if (conffile && strstr(conffile, "nonai")) | 187 if (conffile && strstr(conffile, "nonai")) |
179 new->ignore_nai = 1; | 188 new->ignore_nai = 1; |
180 | 189 |
1184 st->auth_appl = auth_appl; | 1193 st->auth_appl = auth_appl; |
1185 if (auth_appl) { /* We use the value 0 for servers which indicated NO STATE MAINTAINED, hence have no need for STR */ | 1194 if (auth_appl) { /* We use the value 0 for servers which indicated NO STATE MAINTAINED, hence have no need for STR */ |
1186 st->send_str = send_str; | 1195 st->send_str = send_str; |
1187 } | 1196 } |
1188 st->term_cause = str_cause; | 1197 st->term_cause = str_cause; |
1198 if (un && un_len) { | |
1199 CHECK_MALLOC( st->username = malloc(un_len) ); | |
1200 memcpy(st->username, un, un_len); | |
1201 st->un_size = un_len; | |
1202 } | |
1189 CHECK_FCT( fd_sess_state_store( cs->sess_hdl, *session, &st ) ); | 1203 CHECK_FCT( fd_sess_state_store( cs->sess_hdl, *session, &st ) ); |
1190 } | 1204 } |
1191 | 1205 |
1192 return 0; | 1206 return 0; |
1193 } | 1207 } |
1350 /* | 1364 /* |
1351 No attributes should be found in | 1365 No attributes should be found in |
1352 Accounting-Response packets except Proxy-State and possibly Vendor- | 1366 Accounting-Response packets except Proxy-State and possibly Vendor- |
1353 Specific. | 1367 Specific. |
1354 */ | 1368 */ |
1369 | |
1370 /* Well, it seems some devices are expecting the user name ??? */ | |
1371 if (st->username) { | |
1372 CHECK_MALLOC(radius_msg_add_attr(*rad_fw, RADIUS_ATTR_USER_NAME, st->username, st->un_size)); | |
1373 } | |
1355 | 1374 |
1356 /* Now loop in the list of AVPs and convert those that we know how */ | 1375 /* Now loop in the list of AVPs and convert those that we know how */ |
1357 CHECK_FCT( fd_msg_browse(*diam_ans, MSG_BRW_FIRST_CHILD, &next, NULL) ); | 1376 CHECK_FCT( fd_msg_browse(*diam_ans, MSG_BRW_FIRST_CHILD, &next, NULL) ); |
1358 | 1377 |
1359 while (next) { | 1378 while (next) { |
1422 resulting 16 octet MD5 hash value is stored in the Authenticator | 1441 resulting 16 octet MD5 hash value is stored in the Authenticator |
1423 field of the Accounting-Response packet. | 1442 field of the Accounting-Response packet. |
1424 | 1443 |
1425 -- done in radius_msg_finish_srv | 1444 -- done in radius_msg_finish_srv |
1426 */ | 1445 */ |
1446 | |
1447 free_sess_state(st); | |
1427 | 1448 |
1428 return 0; | 1449 return 0; |
1429 } | 1450 } |
1430 | 1451 |
1431 /* The exported symbol */ | 1452 /* The exported symbol */ |