sip

package
v0.13.2-0...-862b5e0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Dialog received 200 response
	DialogStateEstablished = iota
	// Dialog received ACK
	DialogStateConfirmed
	// Dialog received BYE
	DialogStateEnded
)
View Source
const (
	INVITE    = sipgo.INVITE
	ACK       = sipgo.ACK
	CANCEL    = sipgo.CANCEL
	BYE       = sipgo.BYE
	REGISTER  = sipgo.REGISTER
	OPTIONS   = sipgo.OPTIONS
	SUBSCRIBE = sipgo.SUBSCRIBE
	NOTIFY    = sipgo.NOTIFY
	REFER     = sipgo.REFER
	INFO      = sipgo.INFO
	MESSAGE   = sipgo.MESSAGE
	PRACK     = sipgo.PRACK
	UPDATE    = sipgo.UPDATE
	PUBLISH   = sipgo.PUBLISH
)

method names are defined here as constants for convenience.

View Source
const (
	MTU uint = 1500

	DefaultHost     = "127.0.0.1"
	DefaultProtocol = "UDP"

	DefaultUdpPort int = 5060
	DefaultTcpPort int = 5060
	DefaultTlsPort int = 5061
	DefaultWsPort  int = 80
	DefaultWssPort int = 443

	RFC3261BranchMagicCookie = "z9hG4bK"
)

Variables

This section is empty.

Functions

func ASCIIToLower

func ASCIIToLower(s string) string

ASCIIToLower is faster than go version. It avoids one more loop

func ASCIIToLowerInPlace

func ASCIIToLowerInPlace(s []byte)

func CopyHeaders

func CopyHeaders(name string, from, to Message)

Copy all headers of one type from one message to another. Appending to any headers that were already there.

func CopyRoutingHeaders

func CopyRoutingHeaders(newReq *Request, inviteRequest *Request, inviteResponse *Response, isOriginalUAC bool)

inviteRequest is the original dialog-establishing INVITE request, inviteResponse is the 2xx INVITE response, which should contain a permanent routing set, if any. isOriginalUAC should be true if newReq is being generated by the UAC (og sender) to be sent to UAS (og receiver)

func DefaultPort

func DefaultPort(transport string) int

DefaultPort returns transport default port by network.

func DialogStateString

func DialogStateString(state int) string

DialogStateString maps state to string

func GenerateBranch

func GenerateBranch() string

GenerateBranch returns random unique branch ID.

func GenerateBranchN

func GenerateBranchN(n int) string

GenerateBranchN returns random unique branch ID in format MagicCookie.<n chars>

func GenerateTagN

func GenerateTagN(n int) string

func HeaderToLower

func HeaderToLower(s string) string

HeaderToLower is fast ASCII lower string

func MessageShortString

func MessageShortString(msg Message) string

MessageShortString dumps short version of msg. Used only for logging

func NonceWrite

func NonceWrite(buf []byte)

func ParseAddr

func ParseAddr(addr string) (host string, port int, err error)

func ResolveSelfIP

func ResolveSelfIP() (net.IP, error)

Forked from github.com/StefanKopieczek/gossip by @StefanKopieczek

Types

type CSeqHeader

type CSeqHeader = sipgo.CSeqHeader

CSeq is CSeq header

type CallIDHeader

type CallIDHeader = sipgo.CallIDHeader

CallIDHeader is a Call-ID header presentation

type ClientTransaction

type ClientTransaction interface {
	Transaction
	// Responses returns channel with all responses for transaction
	Responses() <-chan *Response
	// Cancel sends cancel request
	Cancel() error
}

type ContactHeader

type ContactHeader = sipgo.ContactHeader

ContactHeader is Contact header representation

type ContentLengthHeader

type ContentLengthHeader = sipgo.ContentLengthHeader

ContentLengthHeader is Content-Length header representation

type ContentTypeHeader

type ContentTypeHeader = sipgo.ContentTypeHeader

ContentTypeHeader is Content-Type header representation.

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

func (d *Dialog) StateString() string

StateString returns string version of state established, confirmed, ended

type ExpiresHeader

type ExpiresHeader = sipgo.ExpiresHeader

ExpiresHeader is Expires header representation

type FromHeader

type FromHeader = sipgo.FromHeader
type Header = sipgo.Header

Header is a single SIP header.

func HeaderClone

func HeaderClone(h Header) Header

HeaderClone is generic function for cloning header

func NewHeader

func NewHeader(name, value string) Header

NewHeader creates generic type of header. Use it for unknown type of header

type HeaderKV

type HeaderKV = sipgo.HeaderKV

type HeaderParams

type HeaderParams = sipgo.HeaderParams

HeaderParams are key value params. They do not provide order by default due to performance reasons

func NewParams

func NewParams() HeaderParams

type MaxForwardsHeader

type MaxForwardsHeader = sipgo.MaxForwardsHeader

MaxForwardsHeader is Max-Forwards header representation

type Message

type Message = sipgo.Message

type MessageHandler

type MessageHandler func(msg Message)

type Parser

type Parser interface {
	ParseSIP(data []byte) (Message, error)
}

The buffer size of the parser input channel. Parser is interface for decoding full message into sip message

type RecordRouteHeader

type RecordRouteHeader = sipgo.RecordRouteHeader

RecordRouteHeader is Record-Route header representation.

type Request

type Request = sipgo.Request

Request RFC 3261 - 7.1.

func NewAckRequest

func NewAckRequest(inviteRequest *Request, inviteResponse *Response, body []byte) *Request

NewAckRequest creates ACK request for an INVITE response For 2xx: https://tools.ietf.org/html/rfc3261#section-13.2.2.4 For non-2xx: https://datatracker.ietf.org/doc/html/rfc3261#section-17.1.1.3

func NewByeRequest

func NewByeRequest(inviteRequest *Request, inviteResponse *Response, body []byte) *Request

NewByeRequest creates bye request from invite TODO do some testing

func NewCancelRequest

func NewCancelRequest(requestForCancel *Request) *Request

func NewRequest

func NewRequest(method RequestMethod, recipient Uri) *Request

type RequestMethod

type RequestMethod = sipgo.RequestMethod

type Response

type Response = sipgo.Response

Response RFC 3261 - 7.2.

func CopyResponse

func CopyResponse(res *Response) *Response

func NewResponse

func NewResponse(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 NewSDPResponseFromRequest

func NewSDPResponseFromRequest(req *Request, body []byte) *Response

NewSDPResponseFromRequest is wrapper for 200 response with SDP body

type RouteHeader

type RouteHeader = sipgo.RouteHeader

RouteHeader is Route header representation.

type ServerTransaction

type ServerTransaction interface {
	Transaction
	Respond(res *Response) error
	Acks() <-chan *Request
	Cancels() <-chan *Request
}

type StatusCode

type StatusCode = int

StatusCode - response status code: 1xx - 6xx

const (
	// https://datatracker.ietf.org/doc/html/rfc3261#section-21
	StatusTrying            StatusCode = 100
	StatusRinging           StatusCode = 180
	StatusCallIsForwarded   StatusCode = 181
	StatusQueued            StatusCode = 182
	StatusSessionInProgress StatusCode = 183

	StatusOK StatusCode = 200

	StatusMovedPermanently StatusCode = 301
	StatusMovedTemporarily StatusCode = 302
	StatusUseProxy         StatusCode = 305

	StatusBadRequest                   StatusCode = 400
	StatusUnauthorized                 StatusCode = 401
	StatusPaymentRequired              StatusCode = 402
	StatusForbidden                    StatusCode = 403
	StatusNotFound                     StatusCode = 404
	StatusMethodNotAllowed             StatusCode = 405
	StatusNotAcceptable                StatusCode = 406
	StatusProxyAuthRequired            StatusCode = 407
	StatusRequestTimeout               StatusCode = 408
	StatusConflict                     StatusCode = 409
	StatusGone                         StatusCode = 410
	StatusRequestEntityTooLarge        StatusCode = 413
	StatusRequestURITooLong            StatusCode = 414
	StatusUnsupportedMediaType         StatusCode = 415
	StatusRequestedRangeNotSatisfiable StatusCode = 416
	StatusBadExtension                 StatusCode = 420
	StatusExtensionRequired            StatusCode = 421
	StatusIntervalToBrief              StatusCode = 423
	StatusTemporarilyUnavailable       StatusCode = 480
	StatusCallTransactionDoesNotExists StatusCode = 481
	StatusLoopDetected                 StatusCode = 482
	StatusTooManyHops                  StatusCode = 483
	StatusAddressIncomplete            StatusCode = 484
	StatusAmbiguous                    StatusCode = 485
	StatusBusyHere                     StatusCode = 486
	StatusRequestTerminated            StatusCode = 487
	StatusNotAcceptableHere            StatusCode = 488

	StatusInternalServerError StatusCode = 500
	StatusNotImplemented      StatusCode = 501
	StatusBadGateway          StatusCode = 502
	StatusServiceUnavailable  StatusCode = 503
	StatusGatewayTimeout      StatusCode = 504
	StatusVersionNotSupported StatusCode = 505
	StatusMessageTooLarge     StatusCode = 513

	StatusGlobalBusyEverywhere       StatusCode = 600
	StatusGlobalDecline              StatusCode = 603
	StatusGlobalDoesNotExistAnywhere StatusCode = 604
	StatusGlobalNotAcceptable        StatusCode = 606
)

type ToHeader

type ToHeader = sipgo.ToHeader

ToHeader introduces SIP 'To' header

type Transaction

type Transaction interface {
	// Terminate will terminate transaction
	Terminate()
	// Done when transaction fsm terminates. Can be called multiple times
	Done() <-chan struct{}
	// Last error. Useful to check when transaction terminates
	Err() error
}

type Transport

type Transport interface {
	WriteMsg(msg Message) error
}

type Uri

type Uri = sipgo.Uri

type ViaHeader

type ViaHeader = sipgo.ViaHeader

ViaHeader is Via header representation. It can be linked list of multiple via if they are part of one header

Jump to

Keyboard shortcuts

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