Jerboa v0.2.0 Jerboa.Params

Data structure representing STUN message parameters

Summary

Types

t()

The main data structure representing STUN message parameters

Functions

Generates STUN transaction ID

Retrieves single attribute from params struct

Retrieves all attributes from params struct

Retrieves all attributes with given name from params struct

Retrieves class field from params struct

Retrieves transaction ID from params struct

Retrieves method field from params struct

Returns params struct with filled in transaction id

Puts single attribute in params struct

Adds list of attriubutes to params struct

Sets STUN class in params struct

Sets STUN transaction identifier in params struct

Sets STUN method in params struct

Sets whole attributes list in params struct

Types

t()
t() :: %Jerboa.Params{attributes: [Jerboa.Format.Body.Attribute.t], class: Jerboa.Format.Header.Type.Class.t, identifier: binary, method: Jerboa.Format.Header.Type.Method.t, signed?: boolean, verified?: boolean}

The main data structure representing STUN message parameters

The following fields coresspond to the those described in the STUN RFC:

  • class is one of request, success or failure response, or indication
  • method is a STUN (or TURN) message method described in one of the respective RFCs
  • identifier is a unique transaction identifier
  • attributes is a list of STUN (or TURN) attributes as described in their respective RFCs
  • signed? indicates wheter STUN message was signed with MESSAGE-INTEGRITY attribute - it isn’t important when encoding a message
  • verified? - indicates wheter MESSAGE-INTEGRIY from STUN message was successfully verified. Same as signed?, it’s only relevant when decoding messages. Note that messages which are verified? are also signed?, but not the other way around.

Functions

generate_id()
generate_id() :: binary

Generates STUN transaction ID

get_attr(params, attr_name)
get_attr(t, attr_name :: module) ::
  Jerboa.Format.Body.Attribute.t |
  nil

Retrieves single attribute from params struct

Returns nil if attribute is not present.

get_attrs(params)

Retrieves all attributes from params struct

get_attrs(params, attr_name)
get_attrs(t, attr_name :: module) :: [Jerboa.Format.Body.Attribute.t]

Retrieves all attributes with given name from params struct

get_class(params)
get_class(t) :: Jerboa.Format.Header.Type.Class.t | nil

Retrieves class field from params struct

get_id(params)
get_id(t) :: binary | nil

Retrieves transaction ID from params struct

get_method(params)
get_method(t) :: Jerboa.Format.Header.Type.Method.t | nil

Retrieves method field from params struct

new()
new() :: t

Returns params struct with filled in transaction id

put_attr(params, attr, opts \\ [overwrite: true])
put_attr(t, Jerboa.Format.Body.Attribute.t, [{:overwrite, boolean}]) :: t

Puts single attribute in params struct

:overwrite option determines wheter attributes of the same type will be removed and the new one will be put in their place. Defaults to true.

put_attrs(params, attrs)

Adds list of attriubutes to params struct

It’s functionally equal to recursively calling put_attr/2 with overwrite: false on params struct.

put_class(params, class)

Sets STUN class in params struct

put_id(params, id)
put_id(t, binary) :: t

Sets STUN transaction identifier in params struct

put_method(params, method)

Sets STUN method in params struct

set_attrs(params, attrs)

Sets whole attributes list in params struct