@@ -1201,16 +1201,11 @@ static inline void find_matching_request(radius_parsed_t *raddata) {
12011201 uint32_t reqid ;
12021202 int rcint , i ;
12031203
1204- if (raddata -> msgtype == RADIUS_CODE_ACCOUNT_RESPONSE ) {
1205- reqid = DERIVE_REQUEST_ID (raddata , RADIUS_CODE_ACCOUNT_REQUEST );
1206- } else {
1207- reqid = DERIVE_REQUEST_ID (raddata , RADIUS_CODE_ACCESS_REQUEST );
1208- }
1204+ reqid = DERIVE_REQUEST_ID (raddata , RADIUS_CODE_ACCESS_REQUEST );
12091205
12101206 if (raddata -> msgtype == RADIUS_CODE_ACCESS_ACCEPT ||
12111207 raddata -> msgtype == RADIUS_CODE_ACCESS_REJECT ||
1212- raddata -> msgtype == RADIUS_CODE_ACCESS_CHALLENGE ||
1213- raddata -> msgtype == RADIUS_CODE_ACCOUNT_RESPONSE ) {
1208+ raddata -> msgtype == RADIUS_CODE_ACCESS_CHALLENGE ) {
12141209
12151210 radius_saved_req_t * req = NULL ;
12161211
@@ -1254,6 +1249,11 @@ static user_identity_t *radius_get_userid(access_plugin_t *p UNUSED,
12541249 raddata = (radius_parsed_t * )parsed ;
12551250 * numberids = 0 ;
12561251
1252+ if (raddata -> msgtype == RADIUS_CODE_ACCOUNT_RESPONSE ) {
1253+ raddata -> muser_count = 0 ;
1254+ return NULL ;
1255+ }
1256+
12571257 if (raddata -> muser_count == 0 ) {
12581258 if (!raddata -> matchednas ) {
12591259 logger (LOG_INFO , "OpenLI RADIUS: please parse the packet before attempting to get the user id." );
@@ -1268,9 +1268,7 @@ static user_identity_t *radius_get_userid(access_plugin_t *p UNUSED,
12681268
12691269 //process_nasport_attribute(raddata);
12701270
1271- if (raddata -> msgtype == RADIUS_CODE_ACCESS_REQUEST ||
1272- raddata -> msgtype == RADIUS_CODE_ACCOUNT_REQUEST ) {
1273-
1271+ if (raddata -> msgtype == RADIUS_CODE_ACCESS_REQUEST ) {
12741272 if (raddata -> muser_count == 0 ) {
12751273 return NULL ;
12761274 }
@@ -1328,12 +1326,18 @@ static inline void apply_fsm_logic(
13281326 /* TODO figure out what Access-Failed is, since it is in the ETSI spec */
13291327 if ((radsess -> current == SESSION_STATE_NEW ||
13301328 radsess -> current == SESSION_STATE_OVER ) && (
1331- msgtype == RADIUS_CODE_ACCESS_REQUEST ||
1332- (msgtype == RADIUS_CODE_ACCOUNT_REQUEST &&
1333- accttype == RADIUS_ACCT_START ))) {
1329+ msgtype == RADIUS_CODE_ACCESS_REQUEST )) {
13341330
13351331 radsess -> current = SESSION_STATE_AUTHING ;
13361332 * action = ACCESS_ACTION_ATTEMPT ;
1333+ } else if ((radsess -> current == SESSION_STATE_NEW ||
1334+ radsess -> current == SESSION_STATE_OVER ) && (
1335+ msgtype == RADIUS_CODE_ACCOUNT_REQUEST &&
1336+ accttype == RADIUS_ACCT_START )) {
1337+
1338+ radsess -> current = SESSION_STATE_ACTIVE ;
1339+ * action = ACCESS_ACTION_ACCEPT ;
1340+
13371341 } else if (radsess -> current == SESSION_STATE_AUTHING && (
13381342 msgtype == RADIUS_CODE_ACCESS_REJECT )) {
13391343
@@ -1346,24 +1350,15 @@ static inline void apply_fsm_logic(
13461350 radsess -> current = SESSION_STATE_AUTHING ;
13471351 * action = ACCESS_ACTION_RETRY ;
13481352
1349- } else if (radsess -> current == SESSION_STATE_AUTHING && (
1350- msgtype == RADIUS_CODE_ACCOUNT_REQUEST &&
1351- accttype == RADIUS_ACCT_STOP )) {
1352-
1353- radsess -> current = SESSION_STATE_OVER ;
1354- * action = ACCESS_ACTION_FAILED ;
1355-
1356- } else if (radsess -> current == SESSION_STATE_AUTHING && (
1357- msgtype == RADIUS_CODE_ACCESS_ACCEPT ||
1358- (msgtype == RADIUS_CODE_ACCOUNT_RESPONSE &&
1359- accttype == RADIUS_ACCT_START ))) {
1353+ } else if (radsess -> current == SESSION_STATE_AUTHING &&
1354+ msgtype == RADIUS_CODE_ACCESS_ACCEPT ) {
13601355
13611356 radsess -> current = SESSION_STATE_ACTIVE ;
13621357 * action = ACCESS_ACTION_ACCEPT ;
13631358
13641359 } else if ((radsess -> current == SESSION_STATE_ACTIVE ||
13651360 radsess -> current == SESSION_STATE_ACTIVE_NO_IP ) &&
1366- (msgtype == RADIUS_CODE_ACCOUNT_RESPONSE &&
1361+ (msgtype == RADIUS_CODE_ACCOUNT_REQUEST &&
13671362 (accttype == RADIUS_ACCT_START ||
13681363 accttype == RADIUS_ACCT_INTERIM_UPDATE ))) {
13691364
@@ -1375,15 +1370,15 @@ static inline void apply_fsm_logic(
13751370
13761371 } else if ((radsess -> current == SESSION_STATE_ACTIVE ||
13771372 radsess -> current == SESSION_STATE_ACTIVE_NO_IP ) &&
1378- (msgtype == RADIUS_CODE_ACCOUNT_RESPONSE &&
1373+ (msgtype == RADIUS_CODE_ACCOUNT_REQUEST &&
13791374 accttype == RADIUS_ACCT_STOP )) {
13801375
13811376 radsess -> current = SESSION_STATE_OVER ;
13821377 * action = ACCESS_ACTION_END ;
13831378
13841379 } else if ((radsess -> current == SESSION_STATE_NEW ||
13851380 radsess -> current == SESSION_STATE_OVER ) && (
1386- msgtype == RADIUS_CODE_ACCOUNT_RESPONSE &&
1381+ msgtype == RADIUS_CODE_ACCOUNT_REQUEST &&
13871382 accttype == RADIUS_ACCT_INTERIM_UPDATE )) {
13881383
13891384 /* session was already underway when we started the intercept,
@@ -1552,7 +1547,7 @@ static inline void update_first_action(radius_parsed_t *raddata,
15521547 /* handle rare case where assigned IPs were missing from access
15531548 * accept message -- seen this in the wild */
15541549 raddata -> firstattrs = raddata -> savedreq -> attrs ;
1555- if (raddata -> msgtype == RADIUS_CODE_ACCOUNT_RESPONSE &&
1550+ if (raddata -> msgtype == RADIUS_CODE_ACCOUNT_REQUEST &&
15561551 raddata -> accttype == RADIUS_ACCT_START &&
15571552 sess -> sessipcount == 0 ) {
15581553 extract_assigned_ip_address (raddata , raddata -> firstattrs ,
@@ -1579,14 +1574,6 @@ static inline void update_second_action(radius_parsed_t *raddata,
15791574 TIMESTAMP_TO_TV ((& (sess -> started )), raddata -> savedresp -> tvsec );
15801575 return ;
15811576
1582- } else if ((raddata -> secondaction == ACCESS_ACTION_ACCEPT ||
1583- raddata -> secondaction == ACCESS_ACTION_ALREADY_ACTIVE ) &&
1584- raddata -> savedresp -> resptype == RADIUS_CODE_ACCOUNT_RESPONSE ) {
1585-
1586- raddata -> secondattrs = raddata -> attrs ;
1587- extract_assigned_ip_address (raddata , raddata -> secondattrs , sess );
1588- TIMESTAMP_TO_TV ((& (sess -> started )), raddata -> savedresp -> tvsec );
1589- return ;
15901577 }
15911578
15921579 switch (raddata -> secondaction ) {
@@ -1609,7 +1596,9 @@ static access_session_t *radius_update_session_state(access_plugin_t *p,
16091596 radius_user_t * raduser = (radius_user_t * )plugindata ;
16101597 access_session_t * thissess ;
16111598 radius_user_session_t * usess ;
1599+ radius_saved_req_t * req = NULL ;
16121600
1601+ uint32_t reqid ;
16131602 char sessionid [5000 ];
16141603 char tempstr [24 ];
16151604 char * ptr ;
@@ -1648,11 +1637,33 @@ static access_session_t *radius_update_session_state(access_plugin_t *p,
16481637 strlen (thissess -> sessionid ), thissess );
16491638 }
16501639
1651- if (raddata -> msgtype == RADIUS_CODE_ACCESS_REQUEST ||
1652- raddata -> msgtype == RADIUS_CODE_ACCOUNT_REQUEST ) {
1640+ if (raddata -> msgtype == RADIUS_CODE_ACCOUNT_REQUEST ) {
1641+ if (glob -> freeaccreqs == NULL ) {
1642+ req = (radius_saved_req_t * )malloc (
1643+ sizeof (radius_saved_req_t ));
1644+ } else {
1645+ req = glob -> freeaccreqs ;
1646+ glob -> freeaccreqs = req -> next ;
1647+ }
1648+ reqid = DERIVE_REQUEST_ID (raddata , raddata -> msgtype );
1649+
1650+ req -> reqid = reqid ;
1651+ req -> statustype = raddata -> accttype ;
1652+ req -> acctsess_hash = raddata -> acctsess_hash ;
1653+ req -> tvsec = raddata -> tvsec ;
1654+ req -> next = NULL ;
1655+ req -> attrs = raddata -> attrs ;
1656+ req -> targetuser_count = raddata -> muser_count ;
1657+ req -> active_targets = raddata -> muser_count ;
1658+ memcpy (req -> targetusers , raddata -> matchedusers ,
1659+ sizeof (radius_user_t * ) * USER_IDENT_MAX );
1660+
1661+ raddata -> savedreq = req ;
1662+ }
1663+
1664+ if (raddata -> msgtype == RADIUS_CODE_ACCESS_REQUEST ) {
16531665
16541666 /* Save the request so we can match the reply later on */
1655- radius_saved_req_t * req = NULL ;
16561667 radius_saved_req_t * check = NULL ;
16571668
16581669 radius_orphaned_resp_t * orphan = NULL ;
@@ -1664,7 +1675,6 @@ static access_session_t *radius_update_session_state(access_plugin_t *p,
16641675 if (orphan ) {
16651676 raddata -> savedresp = orphan ;
16661677 } else if (!raddata -> savedresp ) {
1667- uint32_t reqid ;
16681678 reqid = DERIVE_REQUEST_ID (raddata , raddata -> msgtype );
16691679
16701680 HASH_FIND (hh , raddata -> matchednas -> request_map , & (reqid ),
0 commit comments