Documentation
¶
Overview ¶
Package sap provides SAP (Session Announcement Protocol) parsing
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeMsgIdHash ¶
Types ¶
type AddressType ¶
type AddressType uint8
If the origination source is from an IPv4 or IPv6 address
const ( IPv4 AddressType = 0 IPv6 AddressType = 1 )
type Header ¶
type Header struct { // The version number field MUST be set to 1 Version uint8 // If the A bit is 0, the originating source field contains a 32-bit IPv4 address. // If the A bit is 1, the originating source contains a 128-bit IPv6 address. AddressType AddressType // SAP announcers MUST set this to 0, SAP listeners MUST ignore the contents of this field. Reserved uint8 // If this bit is set to 0 this is a session announcement packet // If this bit is set to 1 this is a session deletion packet. MessageType MessageType // If the encryption bit is set to 1, the payload of the SAP packet is encrypted. // If this bit is 0 the packet is not encrypted. Encrypted uint8 // If the compressed bit is set to 1, the payload is // compressed using the zlib compression algorithm (https://datatracker.ietf.org/doc/html/rfc2974#ref-3) Compressed uint8 // An 8 bit unsigned quantity giving the number of 32 bit words following the main SAP header that contain aauthentication data. // If it is zero, no authentication header is present. AuthenticationLength uint8 // Digital signature of the packet, with length as specified by the authentication length header field. AuthenticationData []uint32 // A 16 bit quantity that, used in combination with the originating source, provides a globally unique identifier // indicating the precise version of this announcement. // // It MUST be unique for each session announced by a particular SAP announcer // and it MUST be changed if the session description is modified // (and a session deletion message SHOULD be sent for the old version of the session). // // SAP listeners MAY silently discard messages if the message // identifier hash is set to zero. MessageIDHash uint16 // This gives the IP address of the original source // of the message. This is an IPv4 address if the A field is set to // zero, else it is an IPv6 address. The address is stored in // network byte order. OriginatingSource net.IP // The payload type field is a MIME content type specifier, describing the format of the payload. // // This is a variable length ASCII text string, followed by a single zero byte (ASCII NUL). // The payload type SHOULD be included in all packets. // If the payload type is `application/sdp' both the payload type and its terminating zero byte MAY be omitted // // Technically, it is part of the Payload, but makes more sense to parse it with the rest of the header PayloadType string }
Header represents an SAP packet header
func (Header) MarshalSize ¶
MarshalSize returns the size of the header once marshaled.
type MessageType ¶
type MessageType uint8
If this is an announcement or deletion packet
const ( Announcement MessageType = 0 Deletion MessageType = 1 )
type Option ¶
type Option func(*Header)
func WithMessageType ¶
func WithMessageType(msgType MessageType) Option
Set the MessageType of the Header struct
func WithPayloadType ¶
Set the PayloadType of the Header struct
type Packet ¶
Packet represents an SAP Packet
func NewPacket ¶
Factory function for creating a new SAP packet Creates an IPv4, unencrypted, uncompressed, unauthenticated, SAP/SDP announcement packet by default
func (Packet) MarshalSize ¶
MarshalSize returns the size of the packet once marshaled.
func (Packet) MarshalTo ¶
MarshalTo serializes the packet and writes to the buffer. It returns the number of bytes read and any error.