Documentation
¶
Index ¶
- Variables
- func DefaultHeadersParser() map[string]HeaderParser
- func ParseAddressValue(addressText string, uri *sip.Uri, headerParams sip.HeaderParams) (displayName string, err error)
- func ParseLine(startLine string) (msg sip.Message, err error)
- func ParseMessage(msgData []byte) (sip.Message, error)
- func ParseRequestLine(requestLine string, recipient *sip.Uri) (method sip.RequestMethod, sipVersion string, err error)
- func ParseStatusLine(statusLine string) (sipVersion string, statusCode sip.StatusCode, reasonPhrase string, err error)
- func ParseUri(uriStr string, uri *sip.Uri) (err error)
- func SplitByWhitespace(text string) []string
- func UnmarshalParams(s string, seperator rune, ending rune, p sip.HeaderParams) (n int, err error)
- type HeaderParser
- type Parser
- type ParserOption
- type ParserStream
Constants ¶
This section is empty.
Variables ¶
var ( ErrParseLineNoCRLF = errors.New("line has no CRLF") ErrParseInvalidMessage = errors.New("invalid SIP message") // Stream parse errors ErrParseSipPartial = errors.New("SIP partial data") ErrParseReadBodyIncomplete = errors.New("reading body incomplete") ErrParseMoreMessages = errors.New("Stream has more message") )
Functions ¶
func DefaultHeadersParser ¶ added in v0.8.0
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.
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 ¶
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 ¶
Splits the given string into sections, separated by one or more characters from c_ABNF_WS.
func UnmarshalParams ¶
Types ¶
type HeaderParser ¶
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 (*Parser) NewSIPStream ¶ added in v0.13.0
func (p *Parser) NewSIPStream() *ParserStream
NewSIPStream implements SIP parsing contructor for stream should be called per single stream
type ParserOption ¶ added in v0.8.0
type ParserOption func(p *Parser)
ParserOption are addition option for NewParser. Check WithParser...
func WithHeadersParsers ¶ added in v0.8.0
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 ¶ added in v0.8.0
func WithParserLogger(logger zerolog.Logger) ParserOption
WithServerLogger allows customizing parser logger
type ParserStream ¶ added in v0.13.0
type ParserStream struct {
// contains filtered or unexported fields
}
func (*ParserStream) ParseSIPStream ¶ added in v0.13.0
func (p *ParserStream) ParseSIPStream(data []byte) (msgs []sip.Message, err error)
ParseSIPStream parsing messages comming in stream It has slight overhead vs parsing full message