sip

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: 79

Documentation

Index

Constants

View Source
const (
	// Dialog received 200 response
	DialogStateEstablished = iota
	// Dialog received ACK
	DialogStateConfirmed
	// Dialog received BYE
	DialogStateEnded
)
View Source
const (
	MTU uint = 1500

	DefaultHost     = "127.0.0.1"
	DefaultProtocol = "UDP"

	DefaultUdpPort int = 5060
	DefaultTcpPort int = 5060
	DefaultTlsPort int = 5061
	DefaultWsPort  int = 80
	DefaultWssPort int = 443

	RFC3261BranchMagicCookie = "z9hG4bK"
)

Variables

This section is empty.

Functions

func ASCIIToLower

func ASCIIToLower(s string) string

ASCIIToLower is faster than go version. It avoids one more loop

func ASCIIToLowerInPlace

func ASCIIToLowerInPlace(s []byte)

func CopyHeaders

func CopyHeaders(name string, from, to Message)

Copy all headers of one type from one message to another. Appending to any headers that were already there.

func DefaultPort

func DefaultPort(protocol string) int

DefaultPort returns protocol default port by network.

func DialogStateString

func DialogStateString(state int) string

DialogStateString maps state to string

func GenerateBranch

func GenerateBranch() string

GenerateBranch returns random unique branch ID.

func HeaderToLower

func HeaderToLower(s string) string

HeaderToLower is fast ASCII lower string

func MakeDialogID

func MakeDialogID(callID, innerID, externalID string) string

func MakeDialogIDFromMessage

func MakeDialogIDFromMessage(msg Message) (string, error)

MakeDialogIDFromMessage creates dialog ID of message. returns error if callid or to tag or from tag does not exists

func ParseAddr

func ParseAddr(addr string) (host string, port int, err error)

func ResolveSelfIP

func ResolveSelfIP() (net.IP, error)

Forked from github.com/StefanKopieczek/gossip by @StefanKopieczek

func SplitByWhitespace

func SplitByWhitespace(text string) []string

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

func UriIsSIP

func UriIsSIP(s string) bool

Check uri is SIP fast

func UriIsSIPS

func UriIsSIPS(s string) bool

Types

type CSeqHeader

type CSeqHeader struct {
	SeqNo      uint32
	MethodName RequestMethod
}

CSeq is CSeq header

func (*CSeqHeader) Name

func (h *CSeqHeader) Name() string

func (*CSeqHeader) String

func (h *CSeqHeader) String() string

func (*CSeqHeader) StringWrite

func (h *CSeqHeader) StringWrite(buffer io.StringWriter)

func (*CSeqHeader) Value

func (h *CSeqHeader) Value() string

func (*CSeqHeader) ValueStringWrite

func (h *CSeqHeader) ValueStringWrite(buffer io.StringWriter)

type CallIDHeader

type CallIDHeader string

CallIDHeader is a Call-ID header presentation

func (*CallIDHeader) Name

func (h *CallIDHeader) Name() string

func (*CallIDHeader) String

func (h *CallIDHeader) String() string

func (*CallIDHeader) StringWrite

func (h *CallIDHeader) StringWrite(buffer io.StringWriter)

func (*CallIDHeader) Value

func (h *CallIDHeader) Value() string

type ClientTransaction

type ClientTransaction interface {
	Transaction
	Receive(res *Response) error
	Responses() <-chan *Response
	Cancel() error
}

type ContactHeader

type ContactHeader struct {
	// The display name from the header, may be omitted.
	DisplayName string
	Address     Uri
	// Any parameters present in the header.
	Params HeaderParams
	// Next goes to next header if header has multi value
	Next *ContactHeader
}

ContactHeader is Contact header representation

func (*ContactHeader) Clone

func (h *ContactHeader) Clone() *ContactHeader

func (*ContactHeader) Name

func (h *ContactHeader) Name() string

func (*ContactHeader) String

func (h *ContactHeader) String() string

func (*ContactHeader) StringWrite

func (h *ContactHeader) StringWrite(buffer io.StringWriter)

func (*ContactHeader) Value

func (h *ContactHeader) Value() string

func (*ContactHeader) ValueStringWrite

func (h *ContactHeader) ValueStringWrite(buffer io.StringWriter)

type ContactUri

type ContactUri interface {
	SIPUri
}

A URI from a schema suitable for inclusion in a Contact: header. The only such URIs are sip/sips URIs and the special wildcard URI '*'. hold this interface to not break other code

type ContentLengthHeader

type ContentLengthHeader uint32

ContentLengthHeader is Content-Length header representation

func (*ContentLengthHeader) Name

func (h *ContentLengthHeader) Name() string

func (ContentLengthHeader) String

func (h ContentLengthHeader) String() string

func (ContentLengthHeader) StringWrite

func (h ContentLengthHeader) StringWrite(buffer io.StringWriter)

func (ContentLengthHeader) Value

func (h ContentLengthHeader) Value() string

type ContentTypeHeader

type ContentTypeHeader string

ContentTypeHeader is Content-Type header representation.

func (*ContentTypeHeader) Name

func (h *ContentTypeHeader) Name() string

func (*ContentTypeHeader) String

func (h *ContentTypeHeader) String() string

func (*ContentTypeHeader) StringWrite

func (h *ContentTypeHeader) StringWrite(buffer io.StringWriter)

func (ContentTypeHeader) Value

func (h ContentTypeHeader) Value() string

type CopyHeader

type CopyHeader interface {
	// contains filtered or unexported methods
}

CopyHeader is internal interface for cloning headers. Maybe it will be full exposed later

type Dialog

type Dialog struct {
	// ID created by FROM tag, TO tag and Callid
	ID string
	// State of dialog. Check more for DialogState... constants
	State int
}

Dialog is data structure represanting dialog

func (*Dialog) StateString

func (d *Dialog) StateString() string

StateString returns string version of state established, confirmed, ended

type ExpiresHeader

type ExpiresHeader uint32

ExpiresHeader is Expires header representation

func (*ExpiresHeader) Name

func (h *ExpiresHeader) Name() string

func (*ExpiresHeader) String

func (h *ExpiresHeader) String() string

func (*ExpiresHeader) StringWrite

func (h *ExpiresHeader) StringWrite(buffer io.StringWriter)

func (ExpiresHeader) Value

func (h ExpiresHeader) Value() string

type FromHeader

type FromHeader struct {
	// The display name from the header, may be omitted.
	DisplayName string

	Address Uri

	// Any parameters present in the header.
	Params HeaderParams
}

func (*FromHeader) Name

func (h *FromHeader) Name() string

func (*FromHeader) Next

func (header *FromHeader) Next() Header

func (*FromHeader) String

func (h *FromHeader) String() string

func (*FromHeader) StringWrite

func (h *FromHeader) StringWrite(buffer io.StringWriter)

func (*FromHeader) Value

func (h *FromHeader) Value() string

func (*FromHeader) ValueStringWrite

func (h *FromHeader) ValueStringWrite(buffer io.StringWriter)

type GenericHeader

type GenericHeader struct {
	// The name of the header.
	HeaderName string
	// The contents of the header, including any parameters.
	// This is transparent data that is not natively understood by gossip.
	Contents string
}

GenericHeader is generic struct for unknown headers

func (*GenericHeader) Name

func (h *GenericHeader) Name() string

func (*GenericHeader) String

func (h *GenericHeader) String() string

func (*GenericHeader) StringWrite

func (h *GenericHeader) StringWrite(buffer io.StringWriter)

func (*GenericHeader) Value

func (h *GenericHeader) Value() string
type Header interface {
	// Name returns header name.
	Name() string
	Value() string
	// Clone() Header
	String() string
	// StringWrite is better way to reuse single buffer
	StringWrite(w io.StringWriter)
	// contains filtered or unexported methods
}

Header is a single SIP header.

func HeaderClone

func HeaderClone(h Header) Header

HeaderClone is generic function for cloning header

type HeaderKV

type HeaderKV struct {
	K string
	V string
}

type HeaderParams

type HeaderParams map[string]string

HeaderParams are key value params. They do not provide order by default due to performance reasons

func NewParams

func NewParams() HeaderParams

Create an empty set of parameters.

func (HeaderParams) Add

func (hp HeaderParams) Add(key string, val string) Params

func (HeaderParams) Clone

func (hp HeaderParams) Clone() Params

Clone returns underneath map copied

func (HeaderParams) Equals

func (hp HeaderParams) Equals(other interface{}) bool

Equals check if two maps of parameters are equal in the sense of having the same keys with the same values. This does not rely on any ordering of the keys of the map in memory.

func (HeaderParams) Get

func (hp HeaderParams) Get(key string) (string, bool)

func (HeaderParams) Has

func (hp HeaderParams) Has(key string) bool

func (HeaderParams) Items

func (hp HeaderParams) Items() map[string]string

Items returns the entire parameter map.

func (HeaderParams) Keys

func (hp HeaderParams) Keys() []string

Keys return a slice of keys, in order.

func (HeaderParams) Length

func (hp HeaderParams) Length() int

Length returns number of params.

func (HeaderParams) Remove

func (hp HeaderParams) Remove(key string) Params

func (HeaderParams) String

func (hp HeaderParams) String() string

String returns params joined with '&' char.

func (HeaderParams) ToString

func (hp HeaderParams) ToString(sep uint8) string

ToString renders params to a string. Note that this does not escape special characters, this should already have been done before calling this method.

func (HeaderParams) ToStringWrite

func (hp HeaderParams) ToStringWrite(sep uint8, buffer io.StringWriter)

ToStringWrite is same as ToString but it stores to defined buffer instead returning string

type MaxForwardsHeader

type MaxForwardsHeader uint32

MaxForwardsHeader is Max-Forwards header representation

func (*MaxForwardsHeader) Name

func (h *MaxForwardsHeader) Name() string

func (*MaxForwardsHeader) String

func (h *MaxForwardsHeader) String() string

func (*MaxForwardsHeader) StringWrite

func (h *MaxForwardsHeader) StringWrite(buffer io.StringWriter)

func (*MaxForwardsHeader) Value

func (h *MaxForwardsHeader) Value() string

type Message

type Message interface {
	// Start line returns message start line.
	StartLine() string
	// Start line returns message start line.
	StartLineWrite(io.StringWriter)
	// 	// String returns string representation of SIP message in RFC 3261 form.
	String() string
	// String write is same as String but lets you to provide writter and reduce allocations
	StringWrite(io.StringWriter)
	// Short returns short string info about message.
	Short() string

	// Headers returns all message headers.
	Headers() []Header
	// GetHeaders returns slice of headers of the given type.
	GetHeaders(name string) []Header
	// GetHeader returns first header with same name
	GetHeader(name string) Header
	// PrependHeader prepends header to message.
	PrependHeader(header ...Header)
	// AppendHeader appends header to message.
	AppendHeader(header Header)
	// AppendHeaderAfter appends header to message.
	AppendHeaderAfter(header Header, name string)
	// RemoveHeader removes header from message.
	RemoveHeader(name string)
	ReplaceHeader(header Header)
	/* Helper getters for common headers */
	// CallID returns 'Call-ID' header.
	CallID() (*CallIDHeader, bool)
	// Via returns the top 'Via' header field.
	Via() (*ViaHeader, bool)
	// From returns 'From' header field.
	From() (*FromHeader, bool)
	// To returns 'To' header field.
	To() (*ToHeader, bool)
	// CSeq returns 'CSeq' header field.
	CSeq() (*CSeqHeader, bool)
	// ContentLength returns 'Content-Length' header field.
	ContentLength() (*ContentLengthHeader, bool)
	// ContentType returns 'Content-Type' header field.
	ContentType() (*ContentTypeHeader, bool)
	// Route returns 'Route' header field.
	Route() (*RouteHeader, bool)
	// RecordRoute returns 'Record-Route' header field.
	RecordRoute() (*RecordRouteHeader, bool)

	// Body returns message body.
	Body() []byte
	// SetBody sets message body.
	SetBody(body []byte)

	Transport() string
	SetTransport(tp string)
	Source() string
	SetSource(src string)
	Destination() string
	SetDestination(dest string)
}

type MessageData

type MessageData struct {
	SipVersion string
	// contains filtered or unexported fields
}

func (*MessageData) AppendHeader

func (hs *MessageData) AppendHeader(header Header)

Add the given header.

func (*MessageData) AppendHeaderAfter

func (hs *MessageData) AppendHeaderAfter(header Header, name string)

func (*MessageData) Body

func (msg *MessageData) Body() []byte

func (*MessageData) CSeq

func (hs *MessageData) CSeq() (*CSeqHeader, bool)

func (*MessageData) CallID

func (hs *MessageData) CallID() (*CallIDHeader, bool)

func (*MessageData) CloneHeaders

func (hs *MessageData) CloneHeaders() []Header

CloneHeaders returns all cloned headers in slice.

func (*MessageData) Contact

func (hs *MessageData) Contact() (*ContactHeader, bool)

func (*MessageData) ContentLength

func (hs *MessageData) ContentLength() (*ContentLengthHeader, bool)

func (*MessageData) ContentType

func (hs *MessageData) ContentType() (*ContentTypeHeader, bool)

func (*MessageData) Destination

func (msg *MessageData) Destination() string

func (*MessageData) From

func (hs *MessageData) From() (*FromHeader, bool)

func (*MessageData) GetHeader

func (hs *MessageData) GetHeader(name string) Header

Return Header if exists, otherwise nil is returned Use lower case to avoid allocs Headers are pointers, always Clone them for change

func (*MessageData) GetHeaders

func (hs *MessageData) GetHeaders(name string) []Header

GetHeaders returns list of headers with same name

func (*MessageData) Headers

func (hs *MessageData) Headers() []Header

Headers gets some headers.

func (*MessageData) PrependHeader

func (hs *MessageData) PrependHeader(headers ...Header)

PrependHeader adds header to the front of header list using as list reduces need of realloc underneath array

func (*MessageData) RecordRoute

func (hs *MessageData) RecordRoute() (*RecordRouteHeader, bool)

func (*MessageData) RemoveHeader

func (hs *MessageData) RemoveHeader(name string)

RemoveHeader removes header by name

func (*MessageData) ReplaceHeader

func (hs *MessageData) ReplaceHeader(header Header)

ReplaceHeader replaces first header with same name

func (*MessageData) Route

func (hs *MessageData) Route() (*RouteHeader, bool)

func (*MessageData) SetBody

func (msg *MessageData) SetBody(body []byte)

SetBody sets message body, calculates it length and add 'Content-Length' header.

func (*MessageData) SetDestination

func (msg *MessageData) SetDestination(dest string)

func (*MessageData) SetSource

func (msg *MessageData) SetSource(src string)

func (*MessageData) SetTransport

func (msg *MessageData) SetTransport(tp string)

func (*MessageData) Source

func (msg *MessageData) Source() string

func (*MessageData) String

func (hs *MessageData) String() string

func (*MessageData) StringWrite

func (hs *MessageData) StringWrite(buffer io.StringWriter)

func (*MessageData) To

func (hs *MessageData) To() (*ToHeader, bool)

func (*MessageData) Transport

func (msg *MessageData) Transport() string

func (*MessageData) Via

func (hs *MessageData) Via() (*ViaHeader, bool)

type MessageHandler

type MessageHandler func(msg Message)

type MessageID

type MessageID string

func NextMessageID

func NextMessageID() MessageID

type Params

type Params interface {
	Get(key string) (string, bool)
	Add(key string, val string) Params
	Remove(key string) Params
	Clone() Params
	Equals(params interface{}) bool
	ToString(sep uint8) string
	ToStringWrite(sep uint8, buffer io.StringWriter)
	String() string
	Length() int
	Items() map[string]string
	Keys() []string
	Has(key string) bool
}

type RecordRouteHeader

type RecordRouteHeader struct {
	Address Uri
	Next    *RecordRouteHeader
}

RecordRouteHeader is Record-Route header representation.

func (*RecordRouteHeader) Clone

func (*RecordRouteHeader) Name

func (h *RecordRouteHeader) Name() string

func (*RecordRouteHeader) String

func (h *RecordRouteHeader) String() string

func (*RecordRouteHeader) StringWrite

func (h *RecordRouteHeader) StringWrite(buffer io.StringWriter)

func (*RecordRouteHeader) Value

func (h *RecordRouteHeader) Value() string

func (*RecordRouteHeader) ValueStringWrite

func (h *RecordRouteHeader) ValueStringWrite(buffer io.StringWriter)

type Request

type Request struct {
	MessageData
	// contains filtered or unexported fields
}

Request RFC 3261 - 7.1.

func CopyRequest

func CopyRequest(req *Request) *Request

func NewAckRequest

func NewAckRequest(inviteRequest *Request, inviteResponse *Response, body []byte) *Request

NewAckRequest creates ACK request for 2xx INVITE https://tools.ietf.org/html/rfc3261#section-13.2.2.4

func NewCancelRequest

func NewCancelRequest(requestForCancel *Request) *Request

func NewRequest

func NewRequest(
	method RequestMethod,
	recipient *Uri,
	sipVersion string,
) *Request

NewRequest creates base for building sip Request No headers are added. AppendHeader should be called to add Headers. r.SetBody can be called to set proper ContentLength header

func (*Request) AppendHeader

func (hs *Request) AppendHeader(header Header)

Add the given header.

func (*Request) AppendHeaderAfter

func (hs *Request) AppendHeaderAfter(header Header, name string)

func (*Request) CSeq

func (hs *Request) CSeq() (*CSeqHeader, bool)

func (*Request) CallID

func (hs *Request) CallID() (*CallIDHeader, bool)

func (*Request) Clone

func (req *Request) Clone() *Request

func (*Request) CloneHeaders

func (hs *Request) CloneHeaders() []Header

CloneHeaders returns all cloned headers in slice.

func (*Request) Contact

func (hs *Request) Contact() (*ContactHeader, bool)

func (*Request) ContentLength

func (hs *Request) ContentLength() (*ContentLengthHeader, bool)

func (*Request) ContentType

func (hs *Request) ContentType() (*ContentTypeHeader, bool)

func (*Request) Destination

func (req *Request) Destination() string

func (*Request) From

func (hs *Request) From() (*FromHeader, bool)

func (*Request) GetHeader

func (hs *Request) GetHeader(name string) Header

Return Header if exists, otherwise nil is returned Use lower case to avoid allocs Headers are pointers, always Clone them for change

func (*Request) GetHeaders

func (hs *Request) GetHeaders(name string) []Header

GetHeaders returns list of headers with same name

func (*Request) Headers

func (hs *Request) Headers() []Header

Headers gets some headers.

func (*Request) IsAck

func (req *Request) IsAck() bool

func (*Request) IsCancel

func (req *Request) IsCancel() bool

func (*Request) IsInvite

func (req *Request) IsInvite() bool

func (*Request) Method

func (req *Request) Method() RequestMethod

func (*Request) PrependHeader

func (hs *Request) PrependHeader(headers ...Header)

PrependHeader adds header to the front of header list using as list reduces need of realloc underneath array

func (*Request) Recipient

func (req *Request) Recipient() *Uri

func (*Request) RecordRoute

func (hs *Request) RecordRoute() (*RecordRouteHeader, bool)

func (*Request) RemoveHeader

func (hs *Request) RemoveHeader(name string)

RemoveHeader removes header by name

func (*Request) ReplaceHeader

func (hs *Request) ReplaceHeader(header Header)

ReplaceHeader replaces first header with same name

func (*Request) Route

func (hs *Request) Route() (*RouteHeader, bool)

func (*Request) SetMethod

func (req *Request) SetMethod(method RequestMethod)

func (*Request) SetRecipient

func (req *Request) SetRecipient(recipient *Uri)

func (*Request) Short

func (req *Request) Short() string

func (*Request) Source

func (req *Request) Source() string

func (*Request) StartLine

func (req *Request) StartLine() string

StartLine returns Request Line - RFC 2361 7.1.

func (*Request) StartLineWrite

func (req *Request) StartLineWrite(buffer io.StringWriter)

func (*Request) String

func (req *Request) String() string

func (*Request) StringWrite

func (req *Request) StringWrite(buffer io.StringWriter)

func (*Request) To

func (hs *Request) To() (*ToHeader, bool)

func (*Request) Transport

func (req *Request) Transport() string

func (*Request) Via

func (hs *Request) Via() (*ViaHeader, bool)

type RequestMethod

type RequestMethod string
const (
	INVITE    RequestMethod = "INVITE"
	ACK       RequestMethod = "ACK"
	CANCEL    RequestMethod = "CANCEL"
	BYE       RequestMethod = "BYE"
	REGISTER  RequestMethod = "REGISTER"
	OPTIONS   RequestMethod = "OPTIONS"
	SUBSCRIBE RequestMethod = "SUBSCRIBE"
	NOTIFY    RequestMethod = "NOTIFY"
	REFER     RequestMethod = "REFER"
	INFO      RequestMethod = "INFO"
	MESSAGE   RequestMethod = "MESSAGE"
	PRACK     RequestMethod = "PRACK"
	UPDATE    RequestMethod = "UPDATE"
	PUBLISH   RequestMethod = "PUBLISH"
)

method names are defined here as constants for convenience.

func (RequestMethod) String

func (r RequestMethod) String() string

type Response

type Response struct {
	MessageData
	// contains filtered or unexported fields
}

Response RFC 3261 - 7.2.

func CopyResponse

func CopyResponse(res *Response) *Response

func NewResponse

func NewResponse(
	sipVersion string,
	statusCode StatusCode,
	reason string,
) *Response

NewResponse creates base structure of response.

func NewResponseFromRequest

func NewResponseFromRequest(
	req *Request,
	statusCode StatusCode,
	reason string,
	body []byte,
) *Response

RFC 3261 - 8.2.6

func (*Response) AppendHeader

func (hs *Response) AppendHeader(header Header)

Add the given header.

func (*Response) AppendHeaderAfter

func (hs *Response) AppendHeaderAfter(header Header, name string)

func (*Response) CSeq

func (hs *Response) CSeq() (*CSeqHeader, bool)

func (*Response) CallID

func (hs *Response) CallID() (*CallIDHeader, bool)

func (*Response) Clone

func (res *Response) Clone() *Response

func (*Response) CloneHeaders

func (hs *Response) CloneHeaders() []Header

CloneHeaders returns all cloned headers in slice.

func (*Response) Contact

func (hs *Response) Contact() (*ContactHeader, bool)

func (*Response) ContentLength

func (hs *Response) ContentLength() (*ContentLengthHeader, bool)

func (*Response) ContentType

func (hs *Response) ContentType() (*ContentTypeHeader, bool)

func (*Response) Destination

func (res *Response) Destination() string

func (*Response) From

func (hs *Response) From() (*FromHeader, bool)

func (*Response) GetHeader

func (hs *Response) GetHeader(name string) Header

Return Header if exists, otherwise nil is returned Use lower case to avoid allocs Headers are pointers, always Clone them for change

func (*Response) GetHeaders

func (hs *Response) GetHeaders(name string) []Header

GetHeaders returns list of headers with same name

func (*Response) Headers

func (hs *Response) Headers() []Header

Headers gets some headers.

func (*Response) IsAck

func (res *Response) IsAck() bool

func (*Response) IsCancel

func (res *Response) IsCancel() bool

func (*Response) IsClientError

func (res *Response) IsClientError() bool

func (*Response) IsGlobalError

func (res *Response) IsGlobalError() bool

func (*Response) IsProvisional

func (res *Response) IsProvisional() bool

func (*Response) IsRedirection

func (res *Response) IsRedirection() bool

func (*Response) IsServerError

func (res *Response) IsServerError() bool

func (*Response) IsSuccess

func (res *Response) IsSuccess() bool

func (*Response) PrependHeader

func (hs *Response) PrependHeader(headers ...Header)

PrependHeader adds header to the front of header list using as list reduces need of realloc underneath array

func (*Response) Previous

func (res *Response) Previous() []Response

func (*Response) Reason

func (res *Response) Reason() string

func (*Response) RecordRoute

func (hs *Response) RecordRoute() (*RecordRouteHeader, bool)

func (*Response) RemoveHeader

func (hs *Response) RemoveHeader(name string)

RemoveHeader removes header by name

func (*Response) ReplaceHeader

func (hs *Response) ReplaceHeader(header Header)

ReplaceHeader replaces first header with same name

func (*Response) Route

func (hs *Response) Route() (*RouteHeader, bool)

func (*Response) SetPrevious

func (res *Response) SetPrevious(responses []Response)

func (*Response) SetReason

func (res *Response) SetReason(reason string)

func (*Response) SetStatusCode

func (res *Response) SetStatusCode(code StatusCode)

func (*Response) Short

func (res *Response) Short() string

Short is textual short version of response

func (*Response) StartLine

func (res *Response) StartLine() string

StartLine returns Response Status Line - RFC 2361 7.2.

func (*Response) StartLineWrite

func (res *Response) StartLineWrite(buffer io.StringWriter)

func (*Response) StatusCode

func (res *Response) StatusCode() StatusCode

func (*Response) String

func (res *Response) String() string

func (*Response) StringWrite

func (res *Response) StringWrite(buffer io.StringWriter)

func (*Response) To

func (hs *Response) To() (*ToHeader, bool)

func (*Response) Transport

func (res *Response) Transport() string

func (*Response) Via

func (hs *Response) Via() (*ViaHeader, bool)

type RouteHeader

type RouteHeader struct {
	Address Uri
	Next    *RouteHeader
}

RouteHeader is Route header representation.

func (*RouteHeader) Clone

func (h *RouteHeader) Clone() *RouteHeader

func (*RouteHeader) Name

func (h *RouteHeader) Name() string

func (*RouteHeader) String

func (h *RouteHeader) String() string

func (*RouteHeader) StringWrite

func (h *RouteHeader) StringWrite(buffer io.StringWriter)

func (*RouteHeader) Value

func (h *RouteHeader) Value() string

func (*RouteHeader) ValueStringWrite

func (h *RouteHeader) ValueStringWrite(buffer io.StringWriter)

type SIPUri

type SIPUri interface {
	// Determine if the two URIs are equal according to the rules in RFC 3261 s. 19.1.4.
	// Equals(other interface{}) bool
	String() string

	IsEncrypted() bool
}

A URI from any schema (e.g. sip:, tel:, callto:)

type ServerTransaction

type ServerTransaction interface {
	Transaction
	Receive(req *Request) error
	Respond(res *Response) error
	Acks() <-chan *Request
	Cancels() <-chan *Request
}

type StatusCode

type StatusCode int

StatusCode - response status code: 1xx - 6xx

type ToHeader

type ToHeader struct {
	// The display name from the header, may be omitted.
	DisplayName string
	Address     Uri
	// Any parameters present in the header.
	Params HeaderParams
}

ToHeader introduces SIP 'To' header

func (*ToHeader) Name

func (h *ToHeader) Name() string

func (*ToHeader) Next

func (header *ToHeader) Next() Header

func (*ToHeader) String

func (h *ToHeader) String() string

func (*ToHeader) StringWrite

func (h *ToHeader) StringWrite(buffer io.StringWriter)

func (*ToHeader) Value

func (h *ToHeader) Value() string

func (*ToHeader) ValueStringWrite

func (h *ToHeader) ValueStringWrite(buffer io.StringWriter)

type Transaction

type Transaction interface {
	Init() error
	Key() string
	Origin() *Request
	String() string
	// Transport() Transport
	Terminate()
	Done() <-chan bool
	Errors() <-chan error
}

type Transport

type Transport interface {
	WriteMsg(msg Message) error
}

type Uri

type Uri struct {
	// True if and only if the URI is a SIPS URI.
	Encrypted bool
	Wildcard  bool

	// The user part of the URI: the 'joe' in sip:joe@bloggs.com
	// This is a pointer, so that URIs without a user part can have 'nil'.
	User string

	// The password field of the URI. This is represented in the URI as joe:hunter2@bloggs.com.
	// Note that if a URI has a password field, it *must* have a user field as well.
	// This is a pointer, so that URIs without a password field can have 'nil'.
	// Note that RFC 3261 strongly recommends against the use of password fields in SIP URIs,
	// as they are fundamentally insecure.
	Password string

	// The host part of the URI. This can be a domain, or a string representation of an IP address.
	Host string

	// The port part of the URI. This is optional, and can be empty.
	Port int

	// Any parameters associated with the URI.
	// These are used to provide information about requests that may be constructed from the URI.
	// (For more details, see RFC 3261 section 19.1.1).
	// These appear as a semicolon-separated list of key=value pairs following the host[:port] part.
	UriParams HeaderParams

	// Any headers to be included on requests constructed from this URI.
	// These appear as a '&'-separated list at the end of the URI, introduced by '?'.
	// Although the values of the map are sip.strings, they will never be NoString in practice as the parser
	// guarantees to not return blank values for header elements in SIP URIs.
	// You should not set the values of headers to NoString.
	Headers HeaderParams
}

func (*Uri) Clone

func (uri *Uri) Clone() *Uri

Clone

func (*Uri) IsEncrypted

func (uri *Uri) IsEncrypted() bool

IsEncrypted returns true if uri is SIPS uri

func (*Uri) String

func (uri *Uri) String() string

Generates the string representation of a SipUri struct.

func (*Uri) StringWrite

func (uri *Uri) StringWrite(buffer io.StringWriter)

StringWrite writes uri string to buffer

type ViaHeader

type ViaHeader struct {
	// E.g. 'SIP'.
	ProtocolName string
	// E.g. '2.0'.
	ProtocolVersion string
	Transport       string
	Host            string
	// The port for this via hop. This is stored as a pointer type, since it is an optional field.
	Port   int
	Params HeaderParams
	Next   *ViaHeader
}

ViaHeader is Via header representation. It can be linked list of multiple via if they are part of one header

func (*ViaHeader) Clone

func (h *ViaHeader) Clone() *ViaHeader

func (*ViaHeader) Name

func (h *ViaHeader) Name() string

func (*ViaHeader) Remove

func (h *ViaHeader) Remove()

func (*ViaHeader) SentBy

func (hop *ViaHeader) SentBy() string

func (*ViaHeader) String

func (h *ViaHeader) String() string

func (*ViaHeader) StringWrite

func (h *ViaHeader) StringWrite(buffer io.StringWriter)

func (*ViaHeader) Value

func (h *ViaHeader) Value() string

func (*ViaHeader) ValueStringWrite

func (h *ViaHeader) ValueStringWrite(buffer io.StringWriter)

Jump to

Keyboard shortcuts

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