parser

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Overview

Originaly forked from github.com/StefanKopieczek/gossip by @StefanKopieczek

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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)

Parse a SIP message by creating a parser on the fly.

func ParseParams

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

ParseKeyValParams method for parsing 'key=value' parameters.

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. 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 struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser() *Parser

Create a new Parser.

func (*Parser) Parse

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

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

func (*Parser) ParseHeader

func (p *Parser) ParseHeader(headerText string) (header sip.Header, err error)

func (*Parser) SetLogger

func (p *Parser) SetLogger(l zerolog.Logger)

type SIPParser

type SIPParser interface {
	Parse(data []byte) (sip.Message, error)
}

The buffer size of the parser input channel. SipParser is interface for decoding full message into sip message

type SIPParserStreamed

type SIPParserStreamed interface {
	Write(data []byte) (int, error)
	Output() chan sip.Message
}

SIPParserStreamed is parser that allows streamed data for parsing

Jump to

Keyboard shortcuts

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