Documentation ¶
Index ¶
- func CopyHeaders(name string, from, to SipMessage)
- type CSeq
- type CallId
- type ContactHeader
- type ContactUri
- type ContentLength
- type FromHeader
- type GenericHeader
- type MaxForwards
- type MaybeString
- type Method
- type NoString
- type Params
- type ProxyRequireHeader
- type Request
- func (hs *Request) AddFrontHeader(h SipHeader)
- func (hs *Request) AddHeader(h SipHeader)
- func (request *Request) AllHeaders() []SipHeader
- func (request *Request) GetBody() string
- func (hs *Request) Headers(name string) []SipHeader
- func (request *Request) RemoveHeader(header SipHeader) error
- func (request *Request) SetBody(body string)
- func (request *Request) Short() string
- func (request *Request) String() string
- type RequireHeader
- type Response
- func (hs *Response) AddFrontHeader(h SipHeader)
- func (hs *Response) AddHeader(h SipHeader)
- func (response *Response) AllHeaders() []SipHeader
- func (response *Response) GetBody() string
- func (hs *Response) Headers(name string) []SipHeader
- func (response *Response) RemoveHeader(header SipHeader) error
- func (response *Response) SetBody(body string)
- func (response *Response) Short() string
- func (response *Response) String() string
- type SipHeader
- type SipMessage
- type SipUri
- type String
- type SupportedHeader
- type ToHeader
- type UnsupportedHeader
- type Uri
- type ViaHeader
- type ViaHop
- type WildcardUri
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyHeaders ¶
func CopyHeaders(name string, from, to SipMessage)
Copy all headers of one type from one message to another. Appending to any headers that were already there.
Types ¶
type ContactHeader ¶
type ContactHeader struct { // The display name from the header, may be omitted. DisplayName MaybeString Address ContactUri // Any parameters present in the header. Params Params }
func (*ContactHeader) Name ¶
func (h *ContactHeader) Name() string
func (*ContactHeader) String ¶
func (contact *ContactHeader) String() string
type ContactUri ¶
type ContactUri interface { Uri // Return true if and only if the URI is the special wildcard URI '*'; that is, if it is // a WildcardUri struct. IsWildcard() bool }
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 '*'.
type ContentLength ¶
type ContentLength uint32
func (ContentLength) Copy ¶
func (h ContentLength) Copy() SipHeader
func (ContentLength) Name ¶
func (h ContentLength) Name() string
func (ContentLength) String ¶
func (contentLength ContentLength) String() string
type FromHeader ¶
type FromHeader struct { // The display name from the header, may be omitted. DisplayName MaybeString Address Uri // Any parameters present in the header. Params Params }
func (*FromHeader) Name ¶
func (h *FromHeader) Name() string
func (*FromHeader) String ¶
func (from *FromHeader) String() string
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 }
Encapsulates a header that gossip does not natively support. This allows header data that is not understood to be parsed by gossip and relayed to the parent application.
func (*GenericHeader) String ¶
func (header *GenericHeader) String() string
Convert the header to a flat string representation.
type MaxForwards ¶
type MaxForwards uint32
func (MaxForwards) Copy ¶
func (h MaxForwards) Copy() SipHeader
func (MaxForwards) Name ¶
func (h MaxForwards) Name() string
func (MaxForwards) String ¶
func (maxForwards MaxForwards) String() string
type MaybeString ¶
type MaybeString interface {
// contains filtered or unexported methods
}
Maybestring contains a string, or nil.
type Method ¶
type Method string
A representation of a SIP method. This is syntactic sugar around the string type, so make sure to use the Equals method rather than built-in equality, or you'll fall foul of case differences. If you're defining your own Method, uppercase is preferred but not compulsory.
const ( INVITE Method = "INVITE" ACK Method = "ACK" CANCEL Method = "CANCEL" BYE Method = "BYE" REGISTER Method = "REGISTER" OPTIONS Method = "OPTIONS" SUBSCRIBE Method = "SUBSCRIBE" NOTIFY Method = "NOTIFY" REFER Method = "REFER" )
It's nicer to avoid using raw strings to represent methods, so the following standard method names are defined here as constants for convenience.
type Params ¶
type Params interface { Get(k string) (MaybeString, bool) Add(k string, v MaybeString) Params Copy() Params Equals(p Params) bool ToString(sep uint8) string Length() int Items() map[string]MaybeString Keys() []string }
Generic list of parameters on a header.
type ProxyRequireHeader ¶
type ProxyRequireHeader struct {
Options []string
}
func (*ProxyRequireHeader) Copy ¶
func (h *ProxyRequireHeader) Copy() SipHeader
func (*ProxyRequireHeader) Name ¶
func (h *ProxyRequireHeader) Name() string
func (*ProxyRequireHeader) String ¶
func (header *ProxyRequireHeader) String() string
type Request ¶
type Request struct { // Which method this request is, e.g. an INVITE or a REGISTER. Method Method // The Request URI. This indicates the user to whom this request is being addressed. Recipient Uri // The version of SIP used in this message, e.g. "SIP/2.0". SipVersion string // The application data of the message. Body string // contains filtered or unexported fields }
A SIP request (c.f. RFC 3261 section 7.1).
func NewRequest ¶
func (*Request) AddFrontHeader ¶
func (hs *Request) AddFrontHeader(h SipHeader)
AddFrontHeader adds header to the front of header list if there is no header has h's name, add h to the tail of all headers if there are some headers have h's name, add h to front of the sublist
func (*Request) AllHeaders ¶
func (*Request) RemoveHeader ¶
type RequireHeader ¶
type RequireHeader struct {
Options []string
}
func (*RequireHeader) Copy ¶
func (h *RequireHeader) Copy() SipHeader
func (*RequireHeader) Name ¶
func (h *RequireHeader) Name() string
func (*RequireHeader) String ¶
func (header *RequireHeader) String() string
type Response ¶
type Response struct { // The version of SIP used in this message, e.g. "SIP/2.0". SipVersion string // The response code, e.g. 200, 401 or 500. // This indicates the outcome of the originating request. StatusCode uint16 // The reason string provides additional, human-readable information used to provide // clarification or explanation of the status code. // This will vary between different SIP UAs, and should not be interpreted by the receiving UA. Reason string // The application data of the message. Body string // contains filtered or unexported fields }
A SIP response object (c.f. RFC 3261 section 7.2).
func NewResponse ¶
func (*Response) AddFrontHeader ¶
func (hs *Response) AddFrontHeader(h SipHeader)
AddFrontHeader adds header to the front of header list if there is no header has h's name, add h to the tail of all headers if there are some headers have h's name, add h to front of the sublist
func (*Response) AllHeaders ¶
func (*Response) RemoveHeader ¶
type SipHeader ¶
type SipHeader interface { // Produce the string representation of the header. String() string // Produce the name of the header (e.g. "To", "Via") Name() string // Produce an exact copy of this header. Copy() SipHeader }
A single logical header from a SIP message.
type SipMessage ¶
type SipMessage interface { // Yields a flat, string representation of the SIP message suitable for sending out over the wire. String() string // Adds a header to this message. AddHeader(h SipHeader) // Returns a slice of all headers of the given type. // If there are no headers of the requested type, returns an empty slice. Headers(name string) []SipHeader // Return all headers attached to the message, as a slice. AllHeaders() []SipHeader // Yields a short string representation of the message useful for logging. Short() string // Remove the specified header from the message. RemoveHeader(header SipHeader) error // Get the body of the message, as a string. GetBody() string // Set the body of the message. SetBody(body string) }
Internal representation of a SIP message - either a Request or a Response.
type SipUri ¶
type SipUri struct { // True if and only if the URI is a SIPS URI. IsEncrypted 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 MaybeString // 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 MaybeString // 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 so is represented here as a pointer type. Port *uint16 // 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 Params // 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 MaybeStrings, 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 Params }
A SIP or SIPS URI, including all params and URI header params.
func (*SipUri) Equals ¶
Determine if the SIP URI is equal to the specified URI according to the rules laid down in RFC 3261 s. 19.1.4. TODO: The Equals method is not currently RFC-compliant; fix this!
func (*SipUri) IsWildcard ¶
IsWildcard() always returns 'false' for SIP URIs as they are not equal to the wildcard '*' URI. This method is required since SIP URIs are valid in Contact: headers.
type SupportedHeader ¶
type SupportedHeader struct {
Options []string
}
func (*SupportedHeader) Copy ¶
func (h *SupportedHeader) Copy() SipHeader
func (*SupportedHeader) Name ¶
func (h *SupportedHeader) Name() string
func (*SupportedHeader) String ¶
func (header *SupportedHeader) String() string
type ToHeader ¶
type ToHeader struct { // The display name from the header, may be omitted. DisplayName MaybeString Address Uri // Any parameters present in the header. Params Params }
type UnsupportedHeader ¶
type UnsupportedHeader struct {
Options []string
}
'Unsupported:' is a SIP header type - this doesn't indicate that the header itself is not supported by gossip!
func (*UnsupportedHeader) Copy ¶
func (h *UnsupportedHeader) Copy() SipHeader
func (*UnsupportedHeader) Name ¶
func (h *UnsupportedHeader) Name() string
func (*UnsupportedHeader) String ¶
func (header *UnsupportedHeader) String() string
type Uri ¶
type Uri interface { // Determine if the two URIs are equal according to the rules in RFC 3261 s. 19.1.4. Equals(other Uri) bool // Produce the string representation of the URI. String() string // Produce an exact copy of this URI. Copy() Uri }
A URI from any schema (e.g. sip:, tel:, callto:)
type ViaHop ¶
type ViaHop 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 *uint16 Params Params }
A single component in a Via header. Via headers are composed of several segments of the same structure, added by successive nodes in a routing chain.
type WildcardUri ¶
type WildcardUri struct{}
The special wildcard URI used in Contact: headers in REGISTER requests when expiring all registrations.
func (WildcardUri) Equals ¶
func (uri WildcardUri) Equals(other Uri) bool
Determines if this wildcard URI equals the specified other URI. This is true if and only if the other URI is also a wildcard URI.
func (WildcardUri) String ¶
func (uri WildcardUri) String() string
Always returns '*' - the representation of a wildcard URI in a SIP message.