SMPPEX.Pdu.UDH.extract

You're seeing just the function extract, go back to SMPPEX.Pdu.UDH module for more information.

Specs

extract(message :: binary()) :: {:error, term()} | {:ok, [ie()], binary()}

Extracts list of IEs from UDH.

Returns one of the following

  • {:ok, ies, message} where ies is a list of IE tuples {id, value} and message is the original message without UDH;
  • {:error, reason} in case of errors.

Example

iex> data = <<5, 0, 3, 197, 3, 3, "message">>
iex> SMPPEX.Pdu.UDH.extract(data)
{:ok, [{0, <<197, 3, 3>>}], "message"}

iex> data = <<0x0B, 0x05, 0x04, 0x06, 0x2d, 0x00, 0x00, 0x00, 0x03, 0x01, 0x02, 0x01, "message">>
iex> SMPPEX.Pdu.UDH.extract(data)
{:ok, [{0x05, <<0x06, 0x2d, 0x00, 0x00>>}, {0x00, <<0x01, 0x02, 0x01>>}], "message"}

iex> data = <<0x10, "short">>
iex> SMPPEX.Pdu.UDH.extract(data)
{:error, "Invalid UDH length"}

iex> data = <<0x06, 0x00, 0x03, 0x01, 0x02, 0x01, "message">>
iex> SMPPEX.Pdu.UDH.extract(data)
{:error, "Invalid UDH data"}

iex> data = <<5, 0, 4, 197, 3, 3, "message">>
iex> SMPPEX.Pdu.UDH.extract(data)
{:error, "Invalid UDH IE length"}