Class: Radius::Packet

Class Radius::Packet |
In: | radius/packet.rb
Parent: | Object

Methods

attr auth_resp each each_vsa each_vsaval new pack password set_attr set_password set_vsattr to_s unpack unset_all unset_all_attr unset_all_vsattr unset_attr unset_vsattr vsattr

Attributes

:authenticator | [W] | The authenticator field can be changed with this attribute writer.
:authenticator | [R] | The 16-byte Authenticator field can be read as a character string with this attribute reader.
:code | [W] | The code may be set to any of the strings described above in the code attribute reader.
:code | [R] | The code field is returned as a string. As of this writing, the following codes are recognized:
      Access-Request          Access-Accept
      Access-Reject           Accounting-Request
      Accounting-Response     Access-Challenge
      Status-Server           Status-Client
:identifier | [R] | The one-byte Identifier used to match requests and responses is obtained as a character.
:identifier | [W] | The Identifer used to match RADIUS requests and responses can also be directly set using this.

Public Class methods

new(dict)

To initialize the object, pass a Radius::Dictionary object to it.

auth_resp(packed_packet, secret)

Given a (packed) RADIUS packet and a shared secret, returns a new packet with the authenticator field changed in accordance with RADIUS protocol requirements.

#### Parameters

`packed_packet`: | The packed packet to compute a new Authenticator field for.
`secret`: | The shared secret of the RADIUS system.

#### Return value

a new packed packet with the authenticator field recomputed.

Public Instance methods

unpack(data)

Given a raw RADIUS packet `data`, unpacks its contents so it can be analyzed with other methods, (e.g. `code`, `attr`, etc.). It also clears all present attributes.

##### Parameters

`data`: | The raw RADIUS packet to decode

pack()

The Radius::Packet object contains attributes that can be set and altered with the object's accessor methods, or obtained from the unpack method. This method will return a raw RADIUS packet that should be suitable for sending to a RADIUS client or server over UDP as per RFC 2138.

##### Return Value

The RADIUS packet corresponding to the object's current internal state.

each() {|key, value| ...}

This method is provided a block which will pass every attribute-value pair currently available.

attr(name)

The value of the named attribute in the object's internal state can be obtained.

#### Parameters

`name`: | the name of the attribute to obtain

#### Return value:

The value of the attribute is returned.

set_attr(name, value)

Changes the value of the named attribute.

#### Parameters

`name`: | The name of the attribute to set
`value`: | The value of the attribute

unset_attr(name)

Undefines the current value of the named attribute.

#### Parameters

`name`: | The name of the attribute to unset

unset_all_attr()

Undefines all attributes.

each_vsa() {|vendorid, key, val| ...}

This method will pass each vendor-specific attribute available to a passed block. The parameters to the block are the vendor ID, the attribute name, and the attribute value.

each_vsaval(vendorid) {|key, value| ...}

This method is an iterator that passes each vendor-specific attribute associated with a vendor ID.

set_vsattr(vendorid, name, value)

Changes the value of the named vendor-specific attribute.

#### Parameters

`vendorid`: | The vendor ID for the VSA to set
`name`: | The name of the attribute to set
`value`: | The value of the attribute

unset_vsattr(vendorid, name)

Undefines the current value of the named vendor-specific attribute.

#### Parameters

`vendorid`: | The vendor ID for the VSA to set
`name`: | The name of the attribute to unset

unset_all_vsattr()

Undefines all vendor-specific attributes.

unset_all()

Undefines all regular and vendor-specific attributes

vsattr(vendorid, name)

This method obtains the value of a vendor-specific attribute, given the vendor ID and the name of the vendor-specific attribute.

#### Parameters

`vendorid`: | the vendor ID
`name`: | the name of the attribute to obtain

#### Return value:

The value of the vendor-specific attribute is returned.

password(secret)

The RADIUS User-Password attribute is encoded with a shared secret. This method will return the decoded version given the shared secret. This also works when the attribute name is 'Password' for compatibility reasons.

#### Parameters

`secret`: | The shared secret of the RADIUS system

#### Return

The cleartext version of the User-Password.

set_password(pwdin, secret)

The RADIUS User-Password attribute is encoded with a shared secret. This method will prepare the encoded version of the password. Note that this method always stores the encrypted password in the 'User-Password' attribute. Some (non-RFC 2138-compliant) servers have been reported that insist on using the 'Password' attribute instead.

#### Parameters

`passwd`: | The password to encrypt
`secret`: | The shared secret of the RADIUS system

to_s(secret)

This method will convert a RADIUS packet into a printable string. Any fields in the packet that might possibly contain non-printable characters are turned into Base64 strings.

#### Parameters

`secret`: | The shared secret of the RADIUS system. Pass nil if

you don't want to see `User-Password` attributes decoded.

#### Return

The string representation of the RADIUS packet.