# HG changeset patch # User Sebastien Decugis # Date 1284083954 -32400 # Node ID f95cfc35d96069c3d860e66c2d2b3b2edeb0ddb0 # Parent 72c511043f05794a2f67af6417b8bcfb15fd76a3 Add User Name in translated Accounting Responses diff -r 72c511043f05 -r f95cfc35d960 extensions/app_radgw/rgwx_acct.c --- a/extensions/app_radgw/rgwx_acct.c Thu Sep 09 14:17:54 2010 +0900 +++ b/extensions/app_radgw/rgwx_acct.c Fri Sep 10 10:59:14 2010 +0900 @@ -158,8 +158,17 @@ application_id_t auth_appl; /* Auth-Application-Id used for this session, if available (stored in a Class attribute) */ int send_str; /* If not 0, we must send a STR when the ACA is received. */ uint32_t term_cause; /* If not 0, the Termination-Cause to put in the STR. */ + /* Temporary : try sending the User-Name back in Accounting-Response for RADIUS */ + uint8_t *username; + size_t un_size; }; +static void free_sess_state(struct sess_state *s) { + if (s) + free(s->username); + free(s); +} + /* Initialize the plugin */ static int acct_conf_parse(char * conffile, struct rgwp_config ** state) { @@ -172,7 +181,7 @@ CHECK_MALLOC( new = malloc(sizeof(struct rgwp_config)) ); memset(new, 0, sizeof(struct rgwp_config)); - CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, free ) ); + CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, free_sess_state ) ); new->confstr = conffile; if (conffile && strstr(conffile, "nonai")) @@ -1186,6 +1195,11 @@ st->send_str = send_str; } st->term_cause = str_cause; + if (un && un_len) { + CHECK_MALLOC( st->username = malloc(un_len) ); + memcpy(st->username, un, un_len); + st->un_size = un_len; + } CHECK_FCT( fd_sess_state_store( cs->sess_hdl, *session, &st ) ); } @@ -1352,6 +1366,11 @@ Accounting-Response packets except Proxy-State and possibly Vendor- Specific. */ + + /* Well, it seems some devices are expecting the user name ??? */ + if (st->username) { + CHECK_MALLOC(radius_msg_add_attr(*rad_fw, RADIUS_ATTR_USER_NAME, st->username, st->un_size)); + } /* Now loop in the list of AVPs and convert those that we know how */ CHECK_FCT( fd_msg_browse(*diam_ans, MSG_BRW_FIRST_CHILD, &next, NULL) ); @@ -1424,6 +1443,8 @@ -- done in radius_msg_finish_srv */ + + free_sess_state(st); return 0; }