parser

package
v0.0.0-...-4380dcc Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLineNoCRLF = errors.New("line has no CRLF")
)

Functions

func DefaultHeadersParser

func DefaultHeadersParser() map[string]HeaderParser

DefaultHeadersParser returns minimal version header parser. It can be extended or overwritten. Removing some defaults can break SIP functionality

NOTE this API call may change

func ParseAddressValue

func ParseAddressValue(addressText string, uri *sip.Uri, headerParams sip.HeaderParams) (displayName string, err error)

ParseAddressValue parses an address - such as from a From, To, or Contact header. It returns: See RFC 3261 section 20.10 for details on parsing an address. Note that this method will not accept a comma-separated list of addresses; addresses in that form should be handled by ParseAddressValues.

func ParseLine

func ParseLine(startLine string) (msg sip.Message, err error)

func ParseMessage

func ParseMessage(msgData []byte) (sip.Message, error)

func ParseRequestLine

func ParseRequestLine(requestLine string, recipient *sip.Uri) (
	method sip.RequestMethod, sipVersion string, err error)

Parse the first line of a SIP request, e.g:

INVITE bob@example.com SIP/2.0
REGISTER jane@telco.com SIP/1.0

func ParseStatusLine

func ParseStatusLine(statusLine string) (
	sipVersion string, statusCode sip.StatusCode, reasonPhrase string, err error)

Parse the first line of a SIP response, e.g:

SIP/2.0 200 OK
SIP/1.0 403 Forbidden

func ParseUri

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

ParseUri converts a string representation of a URI into a Uri object. Following https://datatracker.ietf.org/doc/html/rfc3261#section-19.1.1 sip:user:password@host:port;uri-parameters?headers

func SplitByWhitespace

func SplitByWhitespace(text string) []string

Splits the given string into sections, separated by one or more characters from c_ABNF_WS.

func UnmarshalParams

func UnmarshalParams(s string, seperator rune, ending rune, p sip.HeaderParams) (n int, err error)

Types

type HeaderParser

type HeaderParser func(headerName string, headerData string) (sip.Header, error)

A HeaderParser is any function that turns raw header data into one or more Header objects.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser is implementation of sip.SIPParser It is optimized with faster header parsing

func NewParser

func NewParser(options ...ParserOption) *Parser

Create a new Parser.

func (*Parser) ParseSIP

func (p *Parser) ParseSIP(data []byte) (msg sip.Message, err error)

ParseSIP converts data to sip message. Buffer must contain full sip message

type ParserOption

type ParserOption func(p *Parser)

ParserOption are addition option for NewParser. Check WithParser...

func WithHeadersParsers

func WithHeadersParsers(m map[string]HeaderParser) ParserOption

WithHeadersParsers allows customizing parser headers parsers Consider performance when adding custom parser. Add only if it will appear in almost every message

Check DefaultHeadersParser as starting point

func WithParserLogger

func WithParserLogger(logger zerolog.Logger) ParserOption

WithServerLogger allows customizing parser logger

Jump to

Keyboard shortcuts

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