Radius.Packet (elixir_radius v1.2.0)

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)

Decode radius packet

Link to this function

encode(packet, options \\ [])

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 \\ [])

@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.

Link to this function

encode_request(packet, options \\ [])

@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)

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)