message

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateBranchID

func GenerateBranchID() string

GenerateBranchID generates a new branch ID

func GenerateNewCallID

func GenerateNewCallID() string

GenerateNewCallID generates new Call ID

func MessageDetails

func MessageDetails(data *SipMsg) string

MessageDetails prints all we know about the struct in a readable format

func ParseSipAuth

func ParseSipAuth(v []byte, out *SipAuth)

ParseSipAuth parse's WWW-Authenticate/Authorization headers

func ParseSipContact

func ParseSipContact(v []byte, out *SipContact)

ParseSipContact parses SIP contact header

func ParseSipCseq

func ParseSipCseq(v []byte, out *SipCseq)

ParseSipCseq parses CSeq Header

func ParseSipFrom

func ParseSipFrom(v []byte, out *SipFrom)

ParseSipFrom parser for SIP from Header

func ParseSipReq

func ParseSipReq(v []byte, out *SipReq)

ParseSipReq parse initial request line

func ParseSipTo

func ParseSipTo(v []byte, out *SipTo)

ParseSipTo parses SIP To Header

func ParseSipVia

func ParseSipVia(v []byte, out *SipVia)

ParseSipVia parses SIP Via Header

Types

type SipAuth

type SipAuth struct {
	Username  []byte
	Realm     []byte
	Nonce     []byte
	CNonce    []byte
	QoP       []byte
	Algorithm []byte
	Nc        []byte
	URI       []byte
	Response  []byte
	Src       []byte
}

SipAuth SIP Authorization Header

func (*SipAuth) GetAlgorithm

func (sa *SipAuth) GetAlgorithm() string

GetAlgorithm returns algorithm

func (*SipAuth) GetCNonce

func (sa *SipAuth) GetCNonce() string

GetCNonce returns cnonce

func (*SipAuth) GetNc

func (sa *SipAuth) GetNc() string

GetNc returns nc

func (*SipAuth) GetNonce

func (sa *SipAuth) GetNonce() string

GetNonce returns nonce

func (*SipAuth) GetQoP

func (sa *SipAuth) GetQoP() string

GetQoP returns qop

func (*SipAuth) GetRealm

func (sa *SipAuth) GetRealm() string

GetRealm returns realm

func (*SipAuth) GetResponse

func (sa *SipAuth) GetResponse() string

GetResponse returns response

func (*SipAuth) GetURI

func (sa *SipAuth) GetURI() string

GetURI returns nc

func (*SipAuth) GetUsername

func (sa *SipAuth) GetUsername() string

GetUsername returns username

func (*SipAuth) SetAlgorithm

func (sa *SipAuth) SetAlgorithm(value string)

SetAlgorithm sets algorithm

func (*SipAuth) SetCNonce

func (sa *SipAuth) SetCNonce(value string)

SetCNonce sets cnonce

func (*SipAuth) SetNc

func (sa *SipAuth) SetNc(value string)

SetNc sets nc

func (*SipAuth) SetNonce

func (sa *SipAuth) SetNonce(value string)

SetNonce sets nonce

func (*SipAuth) SetQoP

func (sa *SipAuth) SetQoP(value string)

SetQoP sets qop

func (*SipAuth) SetRealm

func (sa *SipAuth) SetRealm(value string)

SetRealm sets realm

func (*SipAuth) SetResponse

func (sa *SipAuth) SetResponse(value string)

SetResponse sets response

func (*SipAuth) SetURI

func (sa *SipAuth) SetURI(value string)

SetURI sets nc

func (*SipAuth) SetUsername

func (sa *SipAuth) SetUsername(value string)

SetUsername sets username

func (*SipAuth) String

func (sa *SipAuth) String() string

type SipContact

type SipContact struct {
	UriType string // Type of URI sip, sips, tel etc
	Name    []byte // Named portion of URI
	User    []byte // User part
	Host    []byte // Host part
	Port    []byte // Port number
	Tran    []byte // Transport
	Qval    []byte // Q Value
	Expires []byte // Expires
	Src     []byte // Full source if needed
}

SipContact SIP Contact Header

func NewContactHeader

func NewContactHeader(uriType string, user string, host string) *SipContact

NewContactHeader creates new Contact Header

func (*SipContact) SetHost

func (sc *SipContact) SetHost(host string)

SetHost sets host part of uri

func (*SipContact) SetName

func (sc *SipContact) SetName(name string)

SetName stes name portion of header

func (*SipContact) SetPort

func (sc *SipContact) SetPort(port string)

SetPort sets port of uri

func (*SipContact) SetUriType

func (sc *SipContact) SetUriType(uriType string)

SetUriType sets the uri type e.g. sip , sips

func (*SipContact) SetUser

func (sc *SipContact) SetUser(user string)

SetUser sets user part of the uri

func (*SipContact) String

func (sc *SipContact) String() string

String returns Header as String

type SipCseq

type SipCseq struct {
	ID     []byte // Cseq ID
	Method []byte // Cseq Method
	Src    []byte // Full source if needed
}

SipCseq SIP CSeq Header

func NewCSeq

func NewCSeq(id string, method string) *SipCseq

NewCSeq creates new CSeq header

func (*SipCseq) SetID

func (sc *SipCseq) SetID(id string)

SetID sets CSeq ID

func (*SipCseq) SetMethod

func (sc *SipCseq) SetMethod(method string)

SetMethod sets method

func (*SipCseq) String

func (sc *SipCseq) String() string

String returns Header as String

type SipFrom

type SipFrom struct {
	UriType  string // Type of URI sip, sips, tel etc
	Name     []byte // Named portion of URI
	User     []byte // User part
	Host     []byte // Host part
	Port     []byte // Port number
	Tag      []byte // Tag
	UserType []byte // User Type
	Src      []byte // Full source if needed
}

SipFrom SIP From Header

func NewFromHeader

func NewFromHeader(user string, uriType string, host string, port string) *SipFrom

NewFromHeader creates new From header

func (*SipFrom) SetHost

func (sf *SipFrom) SetHost(host string)

SetHost sets host part of uri

func (*SipFrom) SetPort

func (sf *SipFrom) SetPort(port string)

SetPort sets port of uri

func (*SipFrom) SetTag

func (sf *SipFrom) SetTag(tag string)

SetTag sets From Tag

func (*SipFrom) SetUriType

func (sf *SipFrom) SetUriType(uriType string)

SetUriType sets the uri type e.g. sip , sips

func (*SipFrom) SetUser

func (sf *SipFrom) SetUser(user string)

SetUser sets user part of the uri

func (*SipFrom) SetUserType

func (sf *SipFrom) SetUserType(userType string)

SetUserType sets UserType

func (*SipFrom) String

func (sf *SipFrom) String() string

String returns Header as String

type SipMsg

type SipMsg struct {
	Req      SipReq
	From     SipFrom
	To       SipTo
	Contact  SipContact
	Via      []SipVia
	Cseq     SipCseq
	Auth     SipAuth
	Ua       SipVal
	Exp      SipVal
	MaxFwd   SipVal
	CallID   SipVal
	ContType SipVal
	ContLen  SipVal
	Src      []byte
	Body     []byte
	Sdp      sdp.SdpMsg
}

SipMsg is a representation of a SIP message

func NewRequest

func NewRequest(request *SipReq, via *SipVia, to *SipTo, from *SipFrom, contact *SipContact, callID *SipVal, cseq *SipCseq, maxfor *SipVal, contlen *SipVal) *SipMsg

NewRequest creates new SIP request

func NewResponse

func NewResponse(request SipReq, via []SipVia, to SipTo, from SipFrom, callID SipVal, maxfor SipVal) *SipMsg

NewResponse creates new SIP Response

func Parse

func Parse(v []byte) (output SipMsg)

Parse routine, passes by value

func (*SipMsg) CopyHeaders

func (sm *SipMsg) CopyHeaders(msg *SipMsg)

CopyHeaders copys headers from one SIP message to another

func (*SipMsg) CopySdp

func (sm *SipMsg) CopySdp(msg *SipMsg)

CopySdp copys SDP from one SIP message to another

func (*SipMsg) GetStatusCode

func (sm *SipMsg) GetStatusCode() int

GetStatusCode returns responses status code

func (*SipMsg) SetAuthHeader

func (sm *SipMsg) SetAuthHeader(auth *SipAuth)

SetAuthHeader sets auth header

func (*SipMsg) String

func (sm *SipMsg) String() string

Export returns SIP message as string

type SipReq

type SipReq struct {
	Method     []byte // Sip Method eg INVITE etc
	UriType    string // Type of URI sip, sips, tel etc
	StatusCode []byte // Status Code eg 100
	StatusDesc []byte // Status Code Description eg trying
	User       []byte // User part
	Host       []byte // Host part
	Port       []byte // Port number
	UserType   []byte // User Type
	Src        []byte // Full source if needed
}

SipReq is the initial line of a SIP message

func NewRequestLine

func NewRequestLine(method string, uriType string, user string, host string, port string) *SipReq

NewRequestLine creates new request line

func NewResponseLine

func NewResponseLine(statuscode int, statusdesc string) *SipReq

NewResponseLine creates new request line

func (*SipReq) SetHost

func (sr *SipReq) SetHost(host string)

SetHost set host protion of uri

func (*SipReq) SetMethod

func (sr *SipReq) SetMethod(method string)

SetMethod gives the ability to set method e.g INVITE, REGISTER

func (*SipReq) SetPort

func (sr *SipReq) SetPort(port string)

SetPort set port portion of uri

func (*SipReq) SetStatusCode

func (sr *SipReq) SetStatusCode(code int)

SetStatusCode gives the ability to set SIP status codes e.g. 200, 100, 302

func (*SipReq) SetStatusDesc

func (sr *SipReq) SetStatusDesc(desc string)

SetStatusDesc gives the ability to set status descriptions e.g. OK, Trying, Moved Temporarily

func (*SipReq) SetUriType

func (sr *SipReq) SetUriType(uriType string)

SetUriType gives the ability to set URI type e.g. sip:, sips:

func (*SipReq) SetUser

func (sr *SipReq) SetUser(user string)

SetUser set user portion of uri

func (*SipReq) SetUserType

func (sr *SipReq) SetUserType(userType string)

SetUserType sets user type

func (*SipReq) String

func (sr *SipReq) String() string

String returns header as string

type SipTo

type SipTo struct {
	UriType  string // Type of URI sip, sips, tel etc
	Name     []byte // Named portion of URI
	User     []byte // User part
	Host     []byte // Host part
	Port     []byte // Port number
	Tag      []byte // Tag
	UserType []byte // User Type
	Src      []byte // Full source if needed
}

SipTo SIP To Header

func NewToHeader

func NewToHeader(user string, uriType string, host string, port string) *SipTo

NewToHeader creates new To header

func (*SipTo) SetHost

func (sf *SipTo) SetHost(host string)

SetHost set host protion of uri

func (*SipTo) SetPort

func (sf *SipTo) SetPort(port string)

SetPort set port portion of uri

func (*SipTo) SetTag

func (sf *SipTo) SetTag(tag string)

SetTag sets To Tag

func (*SipTo) SetUriType

func (sf *SipTo) SetUriType(uriType string)

SetUriType gives the ability to set URI type e.g. sip:, sips:

func (*SipTo) SetUser

func (sf *SipTo) SetUser(user string)

SetUser set user portion of uri

func (*SipTo) SetUserType

func (sf *SipTo) SetUserType(userType string)

SetUserType sets user type

func (*SipTo) String

func (sf *SipTo) String() string

String returns header as string

type SipVal

type SipVal struct {
	Value []byte // Sip Value
	Src   []byte // Full source if needed
}

SipVal is the value of a simple SIP Header e.g. Max Forwards

func NewCallID

func NewCallID(value string) *SipVal

NewCallID creates new CallID Header

func NewContentLength

func NewContentLength(value string) *SipVal

NewContentLength creates new Content Length Header

func NewMaxForwards

func NewMaxForwards(value string) *SipVal

NewMaxForwards creates new Max Forwards header

func (*SipVal) SetValue

func (sv *SipVal) SetValue(value string)

SetValue sets the value of a simple SIP Header e.g. Max Forwards

func (*SipVal) String

func (sv *SipVal) String() string

Export returns SIP value as string

type SipVia

type SipVia struct {
	Trans  string // Type of Transport udp, tcp, tls, sctp etc
	Host   []byte // Host part
	Port   []byte // Port number
	Branch []byte //
	Rport  []byte //
	Maddr  []byte //
	Ttl    []byte //
	Rcvd   []byte //
	Src    []byte // Full source if needed
}

SipVia SIP Via Header

func NewViaHeader

func NewViaHeader(transport string, host string, port string) *SipVia

NewViaHeader creates new Via Header

func (*SipVia) SetBranch

func (sv *SipVia) SetBranch(value string)

SetBranch sets branch

func (*SipVia) SetHost

func (sv *SipVia) SetHost(value string)

SetHost set host portion of uri

func (*SipVia) SetPort

func (sv *SipVia) SetPort(value string)

SetPort sets port portion of uri

func (*SipVia) SetTransport

func (sv *SipVia) SetTransport(trans string)

SetTransport sets transport in via header

func (*SipVia) String

func (sv *SipVia) String() string

String returns Header as String

Jump to

Keyboard shortcuts

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