Parrot.Sip.Headers.CSeq (Parrot Platform v0.0.1-alpha.2)

Module for working with SIP CSeq headers as defined in RFC 3261 Section 20.16.

The CSeq (Command Sequence) header field serves as a way to identify and order transactions within a dialog. It consists of a sequence number and a method name.

The CSeq serves several critical functions in SIP:

  • Uniquely identifying transactions within dialogs
  • Distinguishing between new requests and retransmissions
  • Ensuring proper message ordering
  • Matching responses to requests

Each new request within a dialog increments the CSeq number. ACK and CANCEL requests use the same CSeq number as the request they reference but with different methods, as described in RFC 3261 Sections 17.1.1.3 and 9.1.

References:

  • RFC 3261 Section 8.1.1.5: CSeq
  • RFC 3261 Section 12.2.1.1: UAC Behavior - Generating the Request (CSeq in dialogs)
  • RFC 3261 Section 17.1.1.3: CSeq for CANCEL
  • RFC 3261 Section 20.16: CSeq Header Field

Summary

Functions

Converts a CSeq header to a string representation.

Increments the sequence number of a CSeq header.

Creates a new CSeq header.

Parses a CSeq header string into a CSeq struct.

Creates a new CSeq header with the same sequence number but a different method.

Types

t()

@type t() :: %Parrot.Sip.Headers.CSeq{method: atom(), number: integer()}

Functions

format(cseq)

@spec format(t()) :: String.t()

Converts a CSeq header to a string representation.

increment(cseq)

@spec increment(t()) :: t()

Increments the sequence number of a CSeq header.

new(number, method)

@spec new(integer(), atom()) :: t()

Creates a new CSeq header.

parse(string)

@spec parse(String.t()) :: t()

Parses a CSeq header string into a CSeq struct.

Examples

iex> Parrot.Sip.Headers.CSeq.parse("314159 INVITE")
%Parrot.Sip.Headers.CSeq{number: 314159, method: :invite}

iex> Parrot.Sip.Headers.CSeq.parse("1 ACK")
%Parrot.Sip.Headers.CSeq{number: 1, method: :ack}

with_method(cseq, method)

@spec with_method(t(), atom()) :: t()

Creates a new CSeq header with the same sequence number but a different method.