base

package
v0.0.0-...-bf923f8 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2016 License: LGPL-2.1 Imports: 6 Imported by: 28

Documentation

Index

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 CSeq

type CSeq struct {
	SeqNo      uint32
	MethodName Method
}

func (*CSeq) Copy

func (h *CSeq) Copy() SipHeader

func (*CSeq) Name

func (h *CSeq) Name() string

func (*CSeq) String

func (cseq *CSeq) String() string

type CallId

type CallId string

func (*CallId) Copy

func (h *CallId) Copy() SipHeader

func (*CallId) Name

func (h *CallId) Name() string

func (CallId) String

func (callId CallId) String() string

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) Copy

func (h *ContactHeader) Copy() SipHeader

Copy the header.

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) Copy

func (h *FromHeader) Copy() SipHeader

Copy the header.

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) Copy

func (h *GenericHeader) Copy() SipHeader

Copy the header.

func (*GenericHeader) Name

func (h *GenericHeader) Name() string

Pull out the header name.

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.

func (*Method) Equals

func (method *Method) Equals(other *Method) bool

Determine if the given method equals some other given method. This is syntactic sugar for case insensitive equality checking.

type NoString

type NoString struct{}

NoString represents the absence of a string.

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.

func NewParams

func NewParams() Params

Create an empty set of parameters.

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 NewRequest(method Method, recipient Uri, sipVersion string, headers []SipHeader, body string) (request *Request)

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) AddHeader

func (hs *Request) AddHeader(h SipHeader)

Add the given header.

func (*Request) AllHeaders

func (request *Request) AllHeaders() []SipHeader

func (*Request) GetBody

func (request *Request) GetBody() string

func (*Request) Headers

func (hs *Request) Headers(name string) []SipHeader

Gets some headers.

func (*Request) RemoveHeader

func (request *Request) RemoveHeader(header SipHeader) error

func (*Request) SetBody

func (request *Request) SetBody(body string)

func (*Request) Short

func (request *Request) Short() string

func (*Request) String

func (request *Request) String() string

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 NewResponse(sipVersion string, statusCode uint16, reason string, headers []SipHeader, body string) (response *Response)

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) AddHeader

func (hs *Response) AddHeader(h SipHeader)

Add the given header.

func (*Response) AllHeaders

func (response *Response) AllHeaders() []SipHeader

func (*Response) GetBody

func (response *Response) GetBody() string

func (*Response) Headers

func (hs *Response) Headers(name string) []SipHeader

Gets some headers.

func (*Response) RemoveHeader

func (response *Response) RemoveHeader(header SipHeader) error

func (*Response) SetBody

func (response *Response) SetBody(body string)

func (*Response) Short

func (response *Response) Short() string

func (*Response) String

func (response *Response) String() string

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) Copy

func (uri *SipUri) Copy() Uri

Copy the Sip URI.

func (*SipUri) Equals

func (uri *SipUri) Equals(otherUri Uri) bool

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

func (uri *SipUri) IsWildcard() bool

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.

func (*SipUri) String

func (uri *SipUri) String() string

Generates the string representation of a SipUri struct.

type String

type String struct {
	S string
}

String represents an actual string.

func (String) String

func (s String) String() string

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
}

func (*ToHeader) Copy

func (h *ToHeader) Copy() SipHeader

Copy the header.

func (*ToHeader) Name

func (h *ToHeader) Name() string

func (*ToHeader) String

func (to *ToHeader) String() string

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 ViaHeader

type ViaHeader []*ViaHop

func (ViaHeader) Copy

func (h ViaHeader) Copy() SipHeader

func (ViaHeader) Name

func (h ViaHeader) Name() string

func (ViaHeader) String

func (via ViaHeader) String() string

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.

func (*ViaHop) Copy

func (hop *ViaHop) Copy() *ViaHop

Return an exact copy of this ViaHop.

func (*ViaHop) String

func (hop *ViaHop) String() string

type WildcardUri

type WildcardUri struct{}

The special wildcard URI used in Contact: headers in REGISTER requests when expiring all registrations.

func (WildcardUri) Copy

func (uri WildcardUri) Copy() Uri

Copy the wildcard URI. Not hard!

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) IsWildcard

func (uri WildcardUri) IsWildcard() bool

Always returns 'true'.

func (WildcardUri) String

func (uri WildcardUri) String() string

Always returns '*' - the representation of a wildcard URI in a SIP message.

Jump to

Keyboard shortcuts

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