parser

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2016 License: LGPL-2.1 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_CSEQ = 2147483647

The maximum permissible CSeq number in a SIP message (2**31 - 1). C.f. RFC 3261 S. 8.1.1.5.

Variables

This section is empty.

Functions

func ParseMessage

func ParseMessage(msgData []byte) (base.SipMessage, error)

Parse a SIP message by creating a parser on the fly. This is more costly than reusing a parser, but is necessary when we do not have a guarantee that all messages coming over a connection are from the same endpoint (e.g. UDP).

func ParseSipUri

func ParseSipUri(uriStr string) (uri base.SipUri, err error)

ParseSipUri converts a string representation of a SIP or SIPS URI into a SipUri object.

func ParseUri

func ParseUri(uriStr string) (uri base.Uri, err error)

parseUri converts a string representation of a URI into a Uri object. If the URI is malformed, or the URI schema is not recognised, an error is returned. URIs have the general form of schema:address.

Types

type HeaderParser

type HeaderParser func(headerName string, headerData string) (
	headers []base.SipHeader, err error)

A HeaderParser is any function that turns raw header data into one or more SipHeader objects. The HeaderParser will receive arguments of the form ("max-forwards", "70"). It should return a slice of headers, which should have length > 1 unless it also returns an error.

type Parser

type Parser interface {
	// Implements io.Writer. Queues the given bytes to be parsed.
	// If the parser has terminated due to a previous fatal error, it will return n=0 and an appropriate error.
	// Otherwise, it will return n=len(p) and err=nil.
	// Note that err=nil does not indicate that the data provided is valid - simply that the data was successfully queued for parsing.
	Write(p []byte) (n int, err error)

	// Register a custom header parser for a particular header type.
	// This will overwrite any existing registered parser for that header type.
	// If a parser is not available for a header type in a message, the parser will produce a base.GenericHeader struct.
	SetHeaderParser(headerName string, headerParser HeaderParser)

	Stop()
}

A Parser converts the raw bytes of SIP messages into base.SipMessage objects. It allows

func NewParser

func NewParser(output chan<- base.SipMessage, errs chan<- error, streamed bool) Parser

'streamed' should be set to true whenever the caller cannot reliably identify the starts and ends of messages from the transport frames, e.g. when using streamed protocols such as TCP.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL