RADIUS Lua Agent

Introduction

The RadiusLuaAgent is an asynchronous helper for Lua scripts running within the LogicApp. It is used for sending out RADIUS client requests.

The RadiusLuaAgent communicates with one or more instances of the RadiusApp which can be used to communicate with one or more external RADIUS servers.

The RadiusLuaAgent communicates with the RadiusApp using the RADIUS-C-… messages.

RADIUS Agent API methods are accessed via the “n2.n2svcd.radius_agent” module:

local radius_agent_api = require "n2.n2svcd.radius_agent"

Configuring RadiusLuaAgent

The RadiusLuaAgent is configured within a LogicApp.

    <?xml version="1.0" encoding="utf-8"?>
    <n2svcd>
      ...
      <applications>
        ...
        <application name="Logic" module="LogicApp">
          <include>
            <lib>../apps/logic/lib</lib>
          </include>
          <parameters>
            ...
            <parameter name="default_radius_app_name" value="RADIUS-CLIENT-AUTH"/>
            <parameter name="radius_app_name_auth" value="RADIUS-CLIENT-AUTH"/>
            <parameter name="radius_app_name_acct" value="RADIUS-CLIENT-ACCT"/>
          </parameters>
          <config>
            <services>
              ...
            </services>
            <agents>
              <agent module="RadiusApp::RadiusLuaAgent" libs="../apps/radius/lib"/>
            </agents>
          </config>
        </application>
        ...
      </application>
      ...
    </n2svcd>

Under normal installation, following agent attributes apply:

Parameter Name Type XML Type Description
module RadiusApp:: RadiusLuaAgent Attribute [Required] The module name containing the Lua Agent code.
libs ../apps/radius/lib Attribute Location of the module for RadiusLuaAgent.

In addition, the RadiusLuaAgent must be configured with the name of the RadiusApp with which it will communicate. This is configured within the parameters of the containing LogicApp.

Parameter Name Type XML Type Description
parameters Array Element Array of name = value Parameters for this Application instance.
.default_radius_app_name String Attribute Default name for the RadiusApp with which RadiusLuaAgent will communicate.
.radius_app_name_<route> String Attribute Use this format when RadiusLuaAgent will communicate with more than one RadiusApp.

The RadiusLuaAgent API

All methods may raise a Lua Error in the case of exception, including:

.request_response [Asynchronous]

The request_response method sends a RADIUS request, and returns the response. The following parameters are accepted.

Parameter Type Description
route String Optional RADIUS route to use to submit the message. If undefined the default route will be used.
(Default = undef)
packet_type String or Integer [Required] The String packet type name or Integer packet type code of the request to send.
If specifying a packet type name, this must be the name of a supported packet type within N2::RADIUS::Codec.
attributes Array of Object Array of RADIUS attribute objects, each with the following fields.
[].name String The name of a RADIUS attribute, e.g. User-Name.
This must be the name of a supported attribute within N2::RADIUS::Codec.
If the attribute is not supported, you may instead specify [].type and [].data_type.
[].type Integer The type identifer of the RADIUS attribute, if not specifying by [].name.
[].vendor_id Integer The identifier of the vendor that defines the attribute if the attribute is a vendor-specific attribute.
This field is optional and can be used to disambiguate attribute definitions when [].name and/or [].type are not unique.
[].data_type String One of enum, ifid, integer, ipv4addr, ipv4prefix, ipv6addr, ipv6prefix, string, other, text, time.
This field is used only when the attribute is not supported in N2::RADIUS::Codec. For supported attributes the data type is pre-defined.
[].value Various The value for this attribute.
For most attributes this will be a SCALAR of the appropriate type.
For attributes with data type other this may be a table.
[].value_name String This field can be used to specify the value by constant name for attributes with [].data type value enum that have their value mapping defined in N2::RADIUS::Codec.
auto_acct_session_id 0/1 Flag to indicate if the Acct-Session-Id attribute should be automatically included.
(Default = 0)

The request_response method returns a RADIUS response object with the following fields.

Field Type Description
.name String The name of the RADIUS packet type, e.g. Access-Accept.
This field will only be populated if the packet type is supported within N2::RADIUS::Codec.
.code Integer [Required] The packet type identifier from the received response.
.identifier Integer [Required] The identifier field from the received response.
.length Integer [Required] The length field from the received response.
.authenticator String [Required] The authenticator field from the received response.
.attributes Array of Object Array of RADIUS attribute objects, each with the fields described as for a request.

Example (RADIUS Client Request):

local n2svcd = require "n2.n2svcd"
local radius_agent_api = require "n2.n2svcd.radius_agent"

local soap_args = ...

local result = radius_agent_api.request_response ('auth', 'Access-Request', {
    { name = "User-Name", value = "John.Smith" },
    { name = "User-Password", value = "secret_password" },
    { type = 42, vendor_id = 42, data_type = "integer", value = 789 }
}, false)

soap_response = {}
soap_response['status'] = 'ok'

return soap_response

The above example shows a LogicApp script invoked by a SoapLuaService.

Note that the decoded .attributes array will contain all fields, i.e. the [].name, [].type, [].data_type etc. will all be present.

The only exception will be when decoding attributes which are not part of the core fields defined within N2::RADIUS::Codec. In these cases, the [].name, [].vendor_id, and [].value_name fields will not be present, the [].data_type field value will be unknown, and the [].value will be the raw undecoded attribute value bytes without any interpretation.

.get_first_attribute [Synchronous]

The get_first_attribute method searches an array of attributes, returning the first attribute with matching name or type. The following parameters are accepted.

Parameter Type Description
attributes Array of Object Array of attribute objects, each with the fields described for the result.
match_type String or Integer [Required] The attribute name or type.

If a matching attribute is found, the get_first_attribute method returns an attribute object with the following fields.

Field Type Description
.name String The name of the RADIUS attribute, e.g. User-Name.
This field will only be present if the attribute is supported in N2::RADIUS::Codec.
.type Integer [Required] The code that identifies the RADIUS attribute.
.vendor_id Integer The identifier of the vendor that defines the attribute if the attribute is a vendor-specific attribute.
This field will only be present if the attribute is supported in N2::RADIUS::Codec.
.data_type String [Required] One of enum, ifid, integer, ipv4addr, ipv4prefix, ipv6addr, ipv6prefix, string, other, text, time, unknown.
.value Various [Required] The attribute's value.
For most attributes this will be a SCALAR of the appropriate type.
For attributes with data type other this may be a table.
.value_name String The name associated with value.
This field will only be present if the attribute .data_type is enum and the value mapping is defined in N2::RADIUS::Codec.

.get_first_attribute_value [Synchronous]

The get_first_attribute_value method searches an array of attributes, returning the value of the first attribute with matching name or type. The following parameters are accepted.

Parameter Type Description
attributes Array of Object Array of attribute objects, each with the fields described for the get_first_attribute result.
match_type String or Integer [Required] The attribute name or type.

If a matching attribute is found, the get_first_attribute_value method returns that attribute’s value. For most attributes this will be a SCALAR of the appropriate type. For attributes with data type other this may be a table.

.get_all_attributes [Synchronous]

The get_all_attributes method searches an array of attributes, returning all attributes with matching name or type. The following parameters are accepted.

Parameter Type Description
attributes Array of Object Array of attribute objects, each with the fields described for the get_first_attribute result.
match_type String or Integer [Required] The attribute name or type.

If at least one matching attribute is found, the get_all_attributes method returns an array of attribute objects as described for get_first_attribute. Otherwise an empty array is returned.

Built-In N2::RADIUS::Codec Packet Types

The following list of packet type names is built-in to the N2::RADIUS::Codec encoding and decoding library. Packet types not in this list may be referenced by numeric code.

Name Code
Access-Request1
Access-Accept2
Access-Reject3
Accounting-Request4
Accounting-Response5
Access-Challenge11
Disconnect-Request40
Disconnect-ACK41
Disconnect-NAK42
CoA-Request43
CoA-ACK44
CoA-NAK45

Built-In N2::RADIUS::Codec Attributes

The following list of attributes is built-in to the N2::RADIUS::Codec encoding and decoding library.

Name Type Data Type
User-Name1string
User-Password2string
CHAP-Password3other
NAS-IP-Address4ipv4addr
NAS-Port5integer
Service-Type6enum
Framed-Protocol7enum
Framed-IP-Address8ipv4addr
Framed-IP-Netmask9ipv4addr
Framed-Routing10enum
Filter-Id11text
Framed-MTU12integer
Framed-Compression13enum
Login-IP-Host14ipv4addr
Login-Service15enum
Login-TCP-Port16integer
Reply-Message18text
Callback-Number19string
Callback-Id20string
Framed-Route22text
Framed-IPX-Network23integer
State24string
Class25string
Vendor-Specific26other
Session-Timeout27integer
Idle-Timeout28integer
Termination-Action29enum
Called-Station-Id30string
Calling-Station-Id31string
NAS-Identifier32string
Proxy-State33string
Login-LAT-Service34string
Login-LAT-Node35string
Login-LAT-Group36string
Framed-AppleTalk-Link37integer
Framed-AppleTalk-Network38integer
Framed-AppleTalk-Zone39string
Acct-Status-Type40enum
Acct-Delay-Time41integer
Acct-Input-Octets42integer
Acct-Output-Octets43integer
Acct-Session-Id44text
Acct-Authentic45enum
Acct-Session-Time46integer
Acct-Input-Packets47integer
Acct-Output-Packets48integer
Acct-Terminate-Cause49enum
Acct-Multi-Session-Id50text
Acct-Link-Count51integer
Acct-Input-Gigawords52integer
Acct-Output-Gigawords53integer
Event-Timestamp55time
Egress-VLANID56other
Ingress-Filters57enum
Egress-VLAN-Name58other
User-Priority-Table59string
CHAP-Challenge60string
NAS-Port-Type61enum
Port-Limit62integer
Login-LAT-Port63string
Tunnel-Type64other
Tunnel-Medium-Type65other
Tunnel-Client-Endpoint66other
Tunnel-Server-Endpoint67other
Tunnel-Password69other
ARAP-Password70other
ARAP-Features71other
ARAP-Zone-Access72enum
ARAP-Security73integer
ARAP-Security-Data74string
Password-Retry75integer
Prompt76enum
Connect-Info77text
Configuration-Token78string
EAP-Message79string
Message-Authenticator80string
Tunnel-Private-Group-ID81other
Tunnel-Assignment-ID82other
Tunnel-Preference83other
ARAP-Challenge-Response84string
Acct-Interim-Interval85integer
NAS-Port-Id87text
Framed-Pool88text
Chargeable-User-Identity89string
Tunnel-Client-Auth-ID90other
Tunnel-Server-Auth-ID91other
NAS-Filter-Rule92string
Originating-Line-Info94string
NAS-IPv6-Address95ipv6addr
Framed-Interface-Id96ifid
Framed-IPv6-Prefix97ipv6prefix
Login-IPv6-Host98ipv6addr
Framed-IPv6-Route99text
Framed-IPv6-Pool100text
Error-Cause101enum
Delegated-IPv6-Prefix123ipv6prefix
Vendor ID = 311
MS-CHAP-Response1other
MS-CHAP-Error2other
MS-CHAP-CPW-13other
MS-CHAP-CPW-24other
MS-CHAP-LM-Enc-PW5other
MS-CHAP-NT-Enc-PW6other
MS-MPPE-Encryption-Policy7enum
MS-MPPE-Encryption-Types8integer
MS-RAS-Vendor9integer
MS-CHAP-Domain10other
MS-CHAP-Challenge11string
MS-CHAP-MPPE-Keys12string
MS-BAP-Usage13enum
MS-Link-Utilization-Threshold14integer
MS-Link-Drop-Time-Limit15integer
MS-MPPE-Send-Key16other
MS-MPPE-Recv-Key17other
MS-RAS-Version18string
MS-Old-ARAP-Password19string
MS-New-ARAP-Password20string
MS-ARAP-Password-Change-Reason21enum
MS-Filter22string
MS-Acct-Auth-Type23enum
MS-Acct-EAP-Type24enum
MS-CHAP2-Response25other
MS-CHAP2-Success26other
MS-CHAP2-CPW27other
MS-Primary-DNS-Server28ipv4addr
MS-Secondary-DNS-Server29ipv4addr
MS-Primary-NBNS-Server30ipv4addr
MS-Secondary-NBNS-Server31ipv4addr
MS-ARAP-Challenge33string
Vendor ID = 10415
3GPP-IMSI1text
3GPP-Charging-Id2integer
3GPP-PDP-Type3enum
3GPP-CG-Address4ipv4addr
3GPP-GPRS-Negotiated-QoS-Profile5text
3GPP-SGSN-Address6ipv4addr
3GPP-GGSN-Address7ipv4addr
3GPP-IMSI-MCC-MNC8text
3GPP-GGSN-MCC-MNC9text
3GPP-NSAPI10text
3GPP-Session-Stop-Indicator11string
3GPP-Selection-Mode12text
3GPP-Charging-Characteristics13text
3GPP-CG-IPv6-Address14ipv6addr
3GPP-SGSN-IPv6-Address15ipv6addr
3GPP-GGSN-IPv6-Address16ipv6addr
3GPP-IPv6-DNS-Servers17other
3GPP-SGSN-MCC-MNC18text
3GPP-Teardown-Indicator19string
3GPP-IMEISV20text
3GPP-RAT-Type21string
3GPP-User-Location-Info22other
3GPP-MS-TimeZone23other
3GPP-CAMEL-Charging-Info24string
3GPP-Packet-Filter25other
3GPP-Negotiated-DSCP26string
3GPP-Allocate-IP-Type27string
External-Identifier28text
TWAN-Identifier29string
3GPP-User-Location-Info-Time30integer
3GPP-Secondary-RAT-Usage31other
3GPP-UE-Local-IP-Address32other
3GPP-UE-Source-Port33other