Radius Example Analysis Agent(3.2)
All decoding, validation and manipulation is performed from the Analysis agent. The code logic is as follows:
Each time the workflow is activated, a subscriber table is read into memory. To keep the example simple, the table content are assumed to be static. For a real implementation, it is recommended to re-read the table on a regular basis.
Decode the UDP packet. Consider only UDRs of type Default.extendedRadius.Access_Request_Int.
Perform a lookup against the subscriber table, and create a reply of type Default.extendedRadius.Access_Accept_Int or Default.extendedRadius.Access_Reject_Int, depending on if the subscriber was found in the table.
Route the reply back to the Radius agent.
table tmp_tab; initialize { tmp_tab = tableCreate("select SUBSCRIBER from VALID_SUBSCRIBERS"); } consume { list<drudr> reqList = listCreate(drudr); radius.Radius r = (radius.Radius) input; string err = udrDecode("Radius.Request_Dec", reqList, r.requestMessage, true); if ( (err != null) || (listSize(reqList) != 1) ) { debug("Decoding error: " + err); return; } drudr elem = (drudr) listGet(reqList, 0); if (instanceOf(elem, Default.extendedRadius.Access_Request_Int)) { Default.extendedRadius.Access_Request_Int req = (Default.extendedRadius.Access_Request_Int) elem; table rowFound = tableLookup( tmp_tab, "SUBSCRIBER", "=", req.User_Name ); if (tableRowCount(rowFound) > 0) { Default.extendedRadius.Access_Accept_Int resp = udrCreate(Default.extendedRadius.Access_Accept_Int); resp.Identifier = req.Identifier; r.responseMessage = udrEncode("Default.extendedRadius.Response_Enc", resp); udrRoute( r ); } else { Default.extendedRadius.Access_Reject_Int resp = udrCreate(Default.extendedRadius.Access_Reject_Int); resp.Identifier = req.Identifier; r.responseMessage = udrEncode("Default.extendedRadius.Response_Enc", resp); udrRoute( r, "Response" ); } } else { debug("Invalid request type"); } }