Documentation
¶
Index ¶
- Constants
- Variables
- func WriteHeader(b *bytes.Buffer, h Header)
- func WriteKVPs(b *bytes.Buffer, kvps []KVP, KVPsSep byte, sep byte)
- type CSeq
- type CallID
- type Contact
- type ContentLength
- type From
- type Header
- func NewContact(displayName string, sipuri *SIPURI, params []KVP) (Header, error)
- func NewFrom(displayName string, sipuri *SIPURI, params []KVP) (Header, error)
- func NewTo(displayName string, sipuri *SIPURI, params []KVP) (Header, error)
- func ParseContact(value string, new NewContactHeaderFunc) (Header, error)
- func ParseHeader(b []byte) (Header, error)
- func ParseHeaders(line string) ([]Header, error)
- type KVP
- type MaxForwards
- type Method
- type NewContactHeaderFunc
- type Request
- type Response
- type SIPURI
- type To
- type Transport
- type URIScheme
- type Via
Constants ¶
const ( REGISTER = Method("REGISTER") INVITE = Method("INVITE") ACK = Method("ACK") CANCEL = Method("CANCEL") BYE = Method("BYE") OPTIONS = Method("OPTIONS") SUBSCRIBE = Method("SUBSCRIBE") NOTIFY = Method("NOTIFY") REFER = Method("REFER") INFO = Method("INFO") )
https://tools.ietf.org/html/rfc3261 7.1 - Method: This specification defines six methods: REGISTER for registering contact information, INVITE, ACK, and CANCEL for setting up sessions, BYE for terminating sessions, and OPTIONS for querying servers about their capabilities. SIP extensions, documented in standards track RFCs, may define additional methods.
const Version = "SIP/2.0"
Version hold the SIP version string used on Request Lines
Variables ¶
var ( //Methods holds the list of All Request Methods Methods = []Method{REGISTER, INVITE, ACK, CANCEL, BYE, OPTIONS, SUBSCRIBE, NOTIFY, REFER, INFO} //SP means space. This is the separator between the Request Line fields. SP = byte(' ') )
var ( SIPScheme = URIScheme("sip:") SIPSScheme = URIScheme("sips:") SIPSchemeStr = string(SIPScheme) SIPSSchemeStr = string(SIPSScheme) )
Define the URIScheme values
var ( ErrInvalidTransport = errors.New("message.Via: Invalid Transport") ErrInvalidViaHeaderFormat = errors.New("message.Via: Invalid Via Header Format") )
Defining errors
var ( //CRLF defines the end of line. CRLF = []byte{'\r', '\n'} )
var (
ErrUnknownHeader = errors.New("message.Header: Unknown header")
)
Defining errors
Transports holds a list of valid Transports
Functions ¶
func WriteHeader ¶
WriteHeader method writes the HeaderField following the section 7.3.1
Types ¶
type CSeq ¶
CSeq represents the CSeq SIP Header
type CallID ¶
type CallID string
CallID represents the Call-ID SIP header
func ParseCallID ¶
ParseCallID receives a string and parses it to the CallID type
type ContentLength ¶
type ContentLength int
ContentLength represents the Content-Length SIP Header
func ParseContentLength ¶
func ParseContentLength(value string) (*ContentLength, error)
ParseContentLength parses a string value to a ContentLength instance and returns as a Header interface
func (ContentLength) CHeader ¶
func (ContentLength) CHeader() string
CHeader returns the compact header tag
func (ContentLength) String ¶
func (cl ContentLength) String() string
type Header ¶
type Header interface {
Header() string
CHeader() string // Tag in the compact form
String() string
}
Header is a type used by the SIP Headers. []byte is a convenient way to parse and write.
func NewContact ¶
NewContact is a constructor of the Contact Header
func ParseContact ¶
func ParseContact(value string, new NewContactHeaderFunc) (Header, error)
ParseContact parses a string value to a Contact instance and returns as a Header interface
func ParseHeader ¶
ParseHeader parses a byte slice value to a Header instance
func ParseHeaders ¶
ParseHeaders follows the section 7.3.1 Header Field Format It receives a string with one or more headers
type KVP ¶
KVP is a key value pair type used to define ordered Params in KPV slices.
func ParseKVP ¶
ParseKVP parses a byte slice to a KVP instance The second parameter sep is the separator between the key and the value
type MaxForwards ¶
type MaxForwards uint8
MaxForwards represents the Max-Forwards SIP Header
func ParseMaxForwards ¶
func ParseMaxForwards(value string) (*MaxForwards, error)
ParseMaxForwards a string value to a MaxForwards instance
func (MaxForwards) CHeader ¶
func (MaxForwards) CHeader() string
CHeader returns the compact header tag
func (MaxForwards) String ¶
func (f MaxForwards) String() string
type Method ¶
type Method = string
Method https://tools.ietf.org/html/rfc3261 The method is the primary function that a REQUEST is meant to invoke on a server. The method is carried in the request message itself. Example methods are INVITE and BYE.
type NewContactHeaderFunc ¶
NewContactHeaderFunc is a function type to be implemented by Constructors of Contact style types like From, To and Contact
type Request ¶
type Request struct {
Method Method
RequestURI string //RFC 3261 Section 8.1.1.1
Headers []Header
Body []byte
}
Request type holds the data that identifies a request from a User Agent Client(UAC). The mandatory headers are members of this type. The remaining headers and the body can be extracted from the RawContent attribute through helper methods. This approach avoids unnecessary parsing.
func ParseRequest ¶
ParseRequest parses a string to a Request instance
type Response ¶
Response type holds the data from a User Agent Server(UAS) in response of a Request.
func ParseResponse ¶
ParseResponse parses a string to a Response instance
type SIPURI ¶
SIPURI 19.1.1 SIP-URI components sip:user:password@host:port;uri-parameters?headers
func (*SIPURI) FormatedContainsSep ¶
FormatedContainsSep checks if the formated version includes separators. This function is primarily used by the Contact format.
type URIScheme ¶
type URIScheme []byte
URIScheme represents a Scheme type in the SIPURI specification - SIP: or SIPS: