Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 

AttributeFilter Object

 

Objects of the AttributeFilter class are used to read, write, modify, and reset attributes in the RADIUS request or response packets. To use the AttributeFilter class, scripts must first create an object instance by calling the new AttributeFilter() constructor.

In javascripting, new AttributeFilter() should take either AttributeFilter.ATTR_LIST_REQUEST or AttributeFilter.ATTR_LIST_RESPONSE as an argument. This ensures that the new object will always point to either the request or response list attributes. Without this argument in the constructor, the new object might not always point to the appropriate list.

Constructor

Constructor

new AttributeFilter()

new AttributeFilter()

Purpose

The new AttributeFilter() constructor is used to create a new object instance of the AttributeFilter class.

Syntax

new AttributeFilter()

Parameters

Nothing.

Returns

The new AttributeFilter() object reference.

Example

AttributeFilter Methods

AttributeFilter Methods

Methods of the AttributeFilter class operate on either the request or the response attribute list, depending on the context in which they are called. All of the methods of the AttributeFilter class are available to attribute filter scripts. The AttributeFilter.Get() method is also available to realm selection scripts.

Get()

Get()

Purpose

The Get() method is used to get a named attribute from the request or response attribute list.

Syntax

Get(name, [index])

Parameters

Table 159: Get() Parameters—AttributeFilter Methods

Parameter

Description

name

Specifies the name of the attribute dictionary.

index

Specifies the optional index for multi-value attributes; default is 0.

Returns

The attribute value or JavaScript null if not found.

Example

filter.Get(“Calling -Station-ID” );

Add()

Add()

Purpose

The Add() method is used to add a named attribute to the request or response attribute list. If an attribute of the same name already exists, the new data value is appended to the end of the attribute list.

Syntax

Add(name, value)

Parameters

Table 160: Add() Parameters

Parameter

Description

  name

Specifies the name of the attribute dictionary.

  value

Specifies the string representation of the attribute value.

Returns

Nothing.

Example

filter.Add(“NAS-IP-Address”, “1.2.3.4” );

Reset()

Reset()

Purpose

The Reset() method is used to remove one or all instances of a named attribute from the request or response attribute list. If the index is given, the specified value is removed from the attribute list and higher-indexed values drop down to fill in the vacancy.

Syntax

Reset(name, [index])

Parameters

Table 161: Reset() Parameters

Parameter

Description

name

Specifies the name of the attribute dictionary.

index

Specifies the optional index for multi-value attributes; default is remove all.

Returns

Nothing.

Example

filter.Reset(“NAS-IP-Address”, 3);

Replace()

Replace()

Purpose

The Replace() method is used to delete a named attribute and add a new attribute of the same name and given value. This is equivalent to Reset() followed by Add(). When an index is given, the specified attribute value is removed, the remaining higher-indexed values drop down to fill in the vacancy, and the new value is appended to the end of the attribute list. List order is not preserved.

Syntax

Replace(name, value, [index])

Parameters

Table 162: Replace() Parameters

Parameter

Description

name

Specifies the name of the attribute dictionary.

value

Specifies the string representation of the new attribute value.

index

Specifies the optional index for multi-value attributes; default is remove all.

Returns

Nothing.

Example

filter.Replace(“Calling-Station-ID”, “5551212”, 2);

Execute()

Execute()

Purpose

The Execute() method is used to execute a statically-defined attribute filter.

Syntax

Execute(name)

Parameters

Table 163: Execute() Parameters—AttributeFilter Methods

Parameter

Description

name

Specifies the name of the filter defined in filter.ini.

Returns

Nothing.

Example

AttributeFilter API

AttributeFilter API

Table 164 provides a list of the RADIUS attribute data types supported by the AttributeFilter API.

Table 164: AttributeFilter API Data Types

RADIUS Attribute Type

JavaScript Type

  • 8-bit integer

  • 32-bit integer

  • 32-bit hex (HEX4) (Get only)

integer

  • Fixed-length string

  • Zero-terminated string

string

Arbitrary length hex (HEXSTRING)

hexadecimal-coded string

  • IPv4 address

  • IPv4 address pool

  • IPv6 address

  • IPv6 prefix

  • IPv6 interface

type-specific formatted string

Time

time string ( yyyy/mm/dd [hh[:mm[:ss]]] )

Script developers do not control attribute types; a given attribute’s type is determined from its name and dictionary entry. Many bit-length variations of integer and hex data types are possible, but not all are supported or used by Steel-Belted Radius Carrier.

When AttributeFilter.Get() is called, the binary data in the attribute are converted into a JavaScript variable. When either AttributeFilter.Add() or AttributeFilter.Replace() is called, the data in a JavaScript variable are converted into the appropriate RADIUS attribute binary type.

Note

Due to an internal limitation in Steel-Belted Radius Carrier, the HEX4 attribute type is supported for Get() only. Attempting to Add() or Replace() a variable of type HEX4 causes a script error.