Documentation
¶
Index ¶
- Constants
- func ASCIIToLower(s string) string
- func ASCIIToLowerInPlace(s []byte)
- func CopyHeaders(name string, from, to Message)
- func DefaultPort(protocol string) int
- func DialogStateString(state int) string
- func GenerateBranch() string
- func HeaderToLower(s string) string
- func MakeDialogID(callID, innerID, externalID string) string
- func MakeDialogIDFromMessage(msg Message) (string, error)
- func ParseAddr(addr string) (host string, port int, err error)
- func RandString(n int) string
- func ResolveSelfIP() (net.IP, error)
- func SplitByWhitespace(text string) []string
- func UriIsSIP(s string) bool
- func UriIsSIPS(s string) bool
- type CSeqHeader
- type CallIDHeader
- type ClientTransaction
- type ContactHeader
- type ContactUri
- type ContentLengthHeader
- type ContentTypeHeader
- type CopyHeader
- type Dialog
- type ExpiresHeader
- type FromHeader
- type GenericHeader
- type Header
- type HeaderKV
- type HeaderParams
- func (hp HeaderParams) Add(key string, val string) Params
- func (hp HeaderParams) Clone() Params
- func (hp HeaderParams) Equals(other interface{}) bool
- func (hp HeaderParams) Get(key string) (string, bool)
- func (hp HeaderParams) Has(key string) bool
- func (hp HeaderParams) Items() map[string]string
- func (hp HeaderParams) Keys() []string
- func (hp HeaderParams) Length() int
- func (hp HeaderParams) Remove(key string) Params
- func (hp HeaderParams) String() string
- func (hp HeaderParams) ToString(sep uint8) string
- func (hp HeaderParams) ToStringWrite(sep uint8, buffer io.StringWriter)
- type MaxForwardsHeader
- type Message
- type MessageData
- func (hs *MessageData) AppendHeader(header Header)
- func (hs *MessageData) AppendHeaderAfter(header Header, name string)
- func (msg *MessageData) Body() []byte
- func (hs *MessageData) CSeq() (*CSeqHeader, bool)
- func (hs *MessageData) CallID() (*CallIDHeader, bool)
- func (hs *MessageData) CloneHeaders() []Header
- func (hs *MessageData) Contact() (*ContactHeader, bool)
- func (hs *MessageData) ContentLength() (*ContentLengthHeader, bool)
- func (hs *MessageData) ContentType() (*ContentTypeHeader, bool)
- func (msg *MessageData) Destination() string
- func (hs *MessageData) From() (*FromHeader, bool)
- func (hs *MessageData) GetHeader(name string) Header
- func (hs *MessageData) GetHeaders(name string) []Header
- func (hs *MessageData) Headers() []Header
- func (hs *MessageData) PrependHeader(headers ...Header)
- func (hs *MessageData) RecordRoute() (*RecordRouteHeader, bool)
- func (hs *MessageData) RemoveHeader(name string)
- func (hs *MessageData) ReplaceHeader(header Header)
- func (hs *MessageData) Route() (*RouteHeader, bool)
- func (msg *MessageData) SetBody(body []byte)
- func (msg *MessageData) SetDestination(dest string)
- func (msg *MessageData) SetSource(src string)
- func (msg *MessageData) SetTransport(tp string)
- func (msg *MessageData) Source() string
- func (hs *MessageData) String() string
- func (hs *MessageData) StringWrite(buffer io.StringWriter)
- func (hs *MessageData) To() (*ToHeader, bool)
- func (msg *MessageData) Transport() string
- func (hs *MessageData) Via() (*ViaHeader, bool)
- type MessageHandler
- type MessageID
- type Params
- type RecordRouteHeader
- func (h *RecordRouteHeader) Clone() *RecordRouteHeader
- func (h *RecordRouteHeader) Name() string
- func (h *RecordRouteHeader) String() string
- func (h *RecordRouteHeader) StringWrite(buffer io.StringWriter)
- func (h *RecordRouteHeader) Value() string
- func (h *RecordRouteHeader) ValueStringWrite(buffer io.StringWriter)
- type Request
- func (hs *Request) AppendHeader(header Header)
- func (hs *Request) AppendHeaderAfter(header Header, name string)
- func (hs *Request) CSeq() (*CSeqHeader, bool)
- func (hs *Request) CallID() (*CallIDHeader, bool)
- func (req *Request) Clone() *Request
- func (hs *Request) CloneHeaders() []Header
- func (hs *Request) Contact() (*ContactHeader, bool)
- func (hs *Request) ContentLength() (*ContentLengthHeader, bool)
- func (hs *Request) ContentType() (*ContentTypeHeader, bool)
- func (req *Request) Destination() string
- func (hs *Request) From() (*FromHeader, bool)
- func (hs *Request) GetHeader(name string) Header
- func (hs *Request) GetHeaders(name string) []Header
- func (hs *Request) Headers() []Header
- func (req *Request) IsAck() bool
- func (req *Request) IsCancel() bool
- func (req *Request) IsInvite() bool
- func (req *Request) Method() RequestMethod
- func (hs *Request) PrependHeader(headers ...Header)
- func (req *Request) Recipient() *Uri
- func (hs *Request) RecordRoute() (*RecordRouteHeader, bool)
- func (hs *Request) RemoveHeader(name string)
- func (hs *Request) ReplaceHeader(header Header)
- func (hs *Request) Route() (*RouteHeader, bool)
- func (req *Request) SetMethod(method RequestMethod)
- func (req *Request) SetRecipient(recipient *Uri)
- func (req *Request) Short() string
- func (req *Request) Source() string
- func (req *Request) StartLine() string
- func (req *Request) StartLineWrite(buffer io.StringWriter)
- func (req *Request) String() string
- func (req *Request) StringWrite(buffer io.StringWriter)
- func (hs *Request) To() (*ToHeader, bool)
- func (req *Request) Transport() string
- func (hs *Request) Via() (*ViaHeader, bool)
- type RequestMethod
- type Response
- func (hs *Response) AppendHeader(header Header)
- func (hs *Response) AppendHeaderAfter(header Header, name string)
- func (hs *Response) CSeq() (*CSeqHeader, bool)
- func (hs *Response) CallID() (*CallIDHeader, bool)
- func (res *Response) Clone() *Response
- func (hs *Response) CloneHeaders() []Header
- func (hs *Response) Contact() (*ContactHeader, bool)
- func (hs *Response) ContentLength() (*ContentLengthHeader, bool)
- func (hs *Response) ContentType() (*ContentTypeHeader, bool)
- func (res *Response) Destination() string
- func (hs *Response) From() (*FromHeader, bool)
- func (hs *Response) GetHeader(name string) Header
- func (hs *Response) GetHeaders(name string) []Header
- func (hs *Response) Headers() []Header
- func (res *Response) IsAck() bool
- func (res *Response) IsCancel() bool
- func (res *Response) IsClientError() bool
- func (res *Response) IsGlobalError() bool
- func (res *Response) IsProvisional() bool
- func (res *Response) IsRedirection() bool
- func (res *Response) IsServerError() bool
- func (res *Response) IsSuccess() bool
- func (hs *Response) PrependHeader(headers ...Header)
- func (res *Response) Previous() []Response
- func (res *Response) Reason() string
- func (hs *Response) RecordRoute() (*RecordRouteHeader, bool)
- func (hs *Response) RemoveHeader(name string)
- func (hs *Response) ReplaceHeader(header Header)
- func (hs *Response) Route() (*RouteHeader, bool)
- func (res *Response) SetPrevious(responses []Response)
- func (res *Response) SetReason(reason string)
- func (res *Response) SetStatusCode(code StatusCode)
- func (res *Response) Short() string
- func (res *Response) StartLine() string
- func (res *Response) StartLineWrite(buffer io.StringWriter)
- func (res *Response) StatusCode() StatusCode
- func (res *Response) String() string
- func (res *Response) StringWrite(buffer io.StringWriter)
- func (hs *Response) To() (*ToHeader, bool)
- func (res *Response) Transport() string
- func (hs *Response) Via() (*ViaHeader, bool)
- type RouteHeader
- type SIPUri
- type ServerTransaction
- type StatusCode
- type ToHeader
- type Transaction
- type Transport
- type Uri
- type ViaHeader
- func (h *ViaHeader) Clone() *ViaHeader
- func (h *ViaHeader) Name() string
- func (h *ViaHeader) Remove()
- func (hop *ViaHeader) SentBy() string
- func (h *ViaHeader) String() string
- func (h *ViaHeader) StringWrite(buffer io.StringWriter)
- func (h *ViaHeader) Value() string
- func (h *ViaHeader) ValueStringWrite(buffer io.StringWriter)
Constants ¶
const ( // Dialog received 200 response DialogStateEstablished = iota // Dialog received ACK DialogStateConfirmed // Dialog received BYE DialogStateEnded )
Variables ¶
This section is empty.
Functions ¶
func ASCIIToLower ¶
ASCIIToLower is faster than go version. It avoids one more loop
func ASCIIToLowerInPlace ¶
func ASCIIToLowerInPlace(s []byte)
func CopyHeaders ¶
Copy all headers of one type from one message to another. Appending to any headers that were already there.
func DefaultPort ¶
DefaultPort returns protocol default port by network.
func DialogStateString ¶
DialogStateString maps state to string
func MakeDialogID ¶
func MakeDialogIDFromMessage ¶
MakeDialogIDFromMessage creates dialog ID of message. returns error if callid or to tag or from tag does not exists
func ResolveSelfIP ¶
Forked from github.com/StefanKopieczek/gossip by @StefanKopieczek
func SplitByWhitespace ¶
Splits the given string into sections, separated by one or more characters from c_ABNF_WS.
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 ¶
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 ¶
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 ¶
HeaderClone is generic function for cloning header
type HeaderParams ¶
HeaderParams are key value params. They do not provide order by default due to performance reasons
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) 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) 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 (*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 ¶
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 ¶
GetHeaders returns list of headers with same name
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) StringWrite ¶
func (hs *MessageData) StringWrite(buffer io.StringWriter)
func (*MessageData) Transport ¶
func (msg *MessageData) Transport() string
type MessageHandler ¶
type MessageHandler func(msg Message)
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 (h *RecordRouteHeader) Clone() *RecordRouteHeader
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 NewAckRequest ¶
NewAckRequest creates ACK request for 2xx INVITE https://tools.ietf.org/html/rfc3261#section-13.2.2.4
func NewCancelRequest ¶
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) AppendHeaderAfter ¶
func (*Request) CSeq ¶
func (hs *Request) CSeq() (*CSeqHeader, bool)
func (*Request) CallID ¶
func (hs *Request) CallID() (*CallIDHeader, bool)
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 (*Request) From ¶
func (hs *Request) From() (*FromHeader, bool)
func (*Request) GetHeader ¶
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 ¶
GetHeaders returns list of headers with same name
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) 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 (*Request) StartLineWrite ¶
func (req *Request) StartLineWrite(buffer io.StringWriter)
func (*Request) StringWrite ¶
func (req *Request) StringWrite(buffer io.StringWriter)
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 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 (*Response) CSeq ¶
func (hs *Response) CSeq() (*CSeqHeader, bool)
func (*Response) CallID ¶
func (hs *Response) CallID() (*CallIDHeader, bool)
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 (*Response) From ¶
func (hs *Response) From() (*FromHeader, bool)
func (*Response) GetHeader ¶
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 ¶
GetHeaders returns list of headers with same name
func (*Response) IsClientError ¶
func (*Response) IsGlobalError ¶
func (*Response) IsProvisional ¶
func (*Response) IsRedirection ¶
func (*Response) IsServerError ¶
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) 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 (*Response) SetStatusCode ¶
func (res *Response) SetStatusCode(code StatusCode)
func (*Response) StartLineWrite ¶
func (res *Response) StartLineWrite(buffer io.StringWriter)
func (*Response) StatusCode ¶
func (res *Response) StatusCode() StatusCode
func (*Response) StringWrite ¶
func (res *Response) StringWrite(buffer io.StringWriter)
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 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) StringWrite ¶
func (h *ToHeader) StringWrite(buffer io.StringWriter)
func (*ToHeader) ValueStringWrite ¶
func (h *ToHeader) ValueStringWrite(buffer io.StringWriter)
type Transaction ¶
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) IsEncrypted ¶
IsEncrypted returns true if uri is SIPS uri
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) StringWrite ¶
func (h *ViaHeader) StringWrite(buffer io.StringWriter)
func (*ViaHeader) ValueStringWrite ¶
func (h *ViaHeader) ValueStringWrite(buffer io.StringWriter)