View Source Radius.Packet (Radius v2.0.1)

This module defines a struct and provides the main functions to encode and decode requests and replies.

Link to this section Summary

Functions

Decode radius packet

Return an iolist of encoded packet

Encode the reply packet into an iolist and put the result in the :raw key. The :auth key needs to be filled with the authenticator of the request packet.

Encode the request packet into an iolist and put the result in the :raw key. The :auth key will contain the authenticator used on the request.

Return the value of a given attribute, if found, or default otherwise.

Verify if the packet signature is valid.

Link to this section Types

@type t() :: %{
  code: String.t(),
  id: integer(),
  length: integer(),
  auth: binary(),
  attrs: keyword(),
  raw: iolist(),
  secret: binary()
}

Link to this section Functions

Link to this function

decode(data, secret, opts \\ [])

View Source

Decode radius packet

Options:

  • attributes - leave attributes as :integers, defaults to :strings. :integers can be pattern matched with the macro's provided by Radius.Dict
Link to this function

encode(packet, options \\ [])

View Source
This function is deprecated. Use encode_request/1-2 or encode_reply/1-2 instead.

Return an iolist of encoded packet

for request packets, leave packet.auth == nil, then I will generate one from random bytes. for reply packets, set packet.auth = request.auth, I will calc the reply hash with it.

packet.attrs :: [attr]
attr :: {type,value}
type :: String.t | integer | {"Vendor-Specific", vendor}
value :: integer | String.t | ipaddr
vendor :: String.t | integer
ipaddr :: {a,b,c,d} | {a,b,c,d,e,f,g,h}
Link to this function

encode_reply(packet, request_authenticator, options \\ [])

View Source
@spec encode_reply(
  packet :: t(),
  request_authenticator :: binary(),
  options :: keyword()
) :: t()

Encode the reply packet into an iolist and put the result in the :raw key. The :auth key needs to be filled with the authenticator of the request packet.

Options:

  • sign - true if you want to sign the request, false by default
Link to this function

encode_request(packet, options \\ [])

View Source
@spec encode_request(packet :: t(), options :: keyword()) :: t()

Encode the request packet into an iolist and put the result in the :raw key. The :auth key will contain the authenticator used on the request.

Link to this function

get_attr(packet, attr_name)

View Source

Return the value of a given attribute, if found, or default otherwise.

Verify if the packet signature is valid.

(https://www.ietf.org/rfc/rfc2865.txt) (https://www.ietf.org/rfc/rfc2869.txt)

Link to this function

verify(packet, request_authenticator)

View Source