sip

package
v0.0.0-...-042ab85 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadRequest                  = NewError(BadRequest, "bad request")
	ErrUnauthorized                = NewError(Unauthorized, "unauthorized")
	ErrForbidden                   = NewError(Forbidden, "forbidden")
	ErrMethodNotAllowed            = NewError(MethodNotAllowed, "method not allowed")
	ErrNotAcceptable               = NewError(NotAcceptable, "not acceptable")
	ErrProxyAuthenticationRequired = NewError(ProxyAuthenticationRequired, "proxy authentication required")
	ErrGone                        = NewError(Gone, "gone")
	ErrRequestEntityTooLarge       = NewError(RequestEntityTooLarge, "request entity too large")
	ErrRequestURITooLong           = NewError(RequestURITooLong, "request URI too long")
	ErrUnsupportedMediaType        = NewError(UnsupportedMediaType, "unsupported media type")
	ErrUnsupportedURIScheme        = NewError(UnsupportedURIScheme, "bad unsupported URI scheme")
	ErrExtensionRequired           = NewError(ExtensionRequired, "extension required")
	ErrIntervalTooBrief            = NewError(IntervalTooBrief, "interval too brief")
	ErrTemporarilyUnavailable      = NewError(TemporarilyUnavailable, "temporarily unavailable")
	ErrCallTransactionDoesNotExist = NewError(CallTransactionDoesNotExist, "call/transaction does not exist")
	ErrLoopDetected                = NewError(LoopDetected, "loop detected")
	ErrTooManyHops                 = NewError(TooManyHops, "too many hops")
	ErrAddressIncomplete           = NewError(AddressIncomplete, "address incomplete")
	ErrAmbiguous                   = NewError(Ambiguous, "ambiguous")
	ErrBusyHere                    = NewError(BusyHere, "busy here")
	ErrRequestTerminated           = NewError(RequestTerminated, "request terminated")
	ErrNotAcceptableHere           = NewError(NotAcceptableHere, "not acceptable here")
	ErrRequestPending              = NewError(RequestPending, "request pending")
	ErrUndecipherable              = NewError(Undecipherable, "undecipherable")
	ErrServerInternalError         = NewError(ServerInternalError, "server internal error")
	ErrNotImplemented              = NewError(NotImplemented, "not implemented")
	ErrBadGateway                  = NewError(BadGateway, "bad gateway")
	ErrServiceUnavailable          = NewError(ServiceUnavailable, "service unavailable")
	ErrServerTimeout               = NewError(ServerTimeout, "server timeout")
	ErrVersionNotSupported         = NewError(VersionNotSupported, "version not supported")
	ErrMessageTooLarge             = NewError(MessageTooLarge, "message too large")
	ErrMethodNotImplemented        = NewError(MethodNotImplemented, "method not implemented")
	ErrURITooLong                  = NewError(URITooLong, "URI too long")
	ErrURIDecoding                 = NewError(URIDecoding, "URI decoding failed")
	ErrUnsupportedProtocol         = NewError(UnsupportedProtocol, "unsupported protocol")
	ErrTooManyHeaders              = NewError(TooManyHeaders, "too many headers")
	ErrHeaderFieldsTooLarge        = NewError(HeaderFieldsTooLarge, "header fields too large")
	ErrBusyEverywhere              = NewError(BusyEverywhere, "busy everywhere")
	ErrDecline                     = NewError(Decline, "decline")
	ErrDoesNotExistAnywhere        = NewError(DoesNotExistAnywhere, "does not exist anywhere")
	ErrGlobalNotAcceptable         = NewError(GlobalNotAcceptable, "not acceptable")
)

Functions

func CodeStatus

func CodeStatus(code Code) string

CodeStatus returns a pre-defined line with code and status text (including terminating CRLF sequence) in case code is known to server, otherwise empty line is returned

Types

type Code

type Code uint16
const (
	// Provisional 1xx codes
	Trying               Code = 100 // RFC 3261 21.1.1
	Ringing              Code = 180 // RFC 3261 21.1.2
	CallIsBeingForwarded Code = 181 // RFC 3261 21.1.3
	Queued               Code = 182 // RFC 3261 21.1.4
	SessionProgress      Code = 183 // RFC 3261 21.1.5

	// Successful 2xx codes
	OK       Code = 200 // RFC 3261 21.2.1
	Accepted Code = 201 // Not show in RFC but recently used as de-facto standard code

	// Redirection 3xx codes
	MultipleChoices    Code = 300 // RFC 3261 21.3.1
	MovedPermanently   Code = 301 // RFC 3261 21.3.2
	MovedTemporarily   Code = 302 // RFC 3261 21.3.3
	UseProxy           Code = 305 // RFC 3261 21.3.4
	AlternativeService Code = 380 // RFC 3261 21.3.5

	// Request Failure 4xx codes
	BadRequest                  Code = 400 // RFC 3261 21.4.1
	Unauthorized                Code = 401 // RFC 3261 21.4.2
	PaymentRequired             Code = 402 // RFC 3261 21.4.3
	Forbidden                   Code = 403 // RFC 3261 21.4.4
	NotFound                    Code = 404 // RFC 3261 21.4.5
	MethodNotAllowed            Code = 405 // RFC 3261 21.4.6
	NotAcceptable               Code = 406 // RFC 3261 21.4.7
	ProxyAuthenticationRequired Code = 407 // RFC 3261 21.4.8
	RequestTimeout              Code = 408 // RFC 3261 21.4.9
	Gone                        Code = 410 // RFC 3261 21.4.10
	RequestEntityTooLarge       Code = 413 // RFC 3261 21.4.11
	RequestURITooLong           Code = 414 // RFC 3261 21.4.12
	UnsupportedMediaType        Code = 415 // RFC 3261 21.4.13
	UnsupportedURIScheme        Code = 416 // RFC 3261 21.4.14
	BadExtension                Code = 420 // RFC 3261 21.4.15
	ExtensionRequired           Code = 421 // RFC 3261 21.4.16
	IntervalTooBrief            Code = 423 // RFC 3261 21.4.17
	TemporarilyUnavailable      Code = 480 // RFC 3261 21.4.18
	CallTransactionDoesNotExist Code = 481 // RFC 3261 21.4.19
	LoopDetected                Code = 482 // RFC 3261 21.4.20
	TooManyHops                 Code = 483 // RFC 3261 21.4.21
	AddressIncomplete           Code = 484 // RFC 3261 21.4.22
	Ambiguous                   Code = 485 // RFC 3261 21.4.23
	BusyHere                    Code = 486 // RFC 3261 21.4.24
	RequestTerminated           Code = 487 // RFC 3261 21.4.25
	NotAcceptableHere           Code = 488 // RFC 3261 21.4.26
	RequestPending              Code = 491 // RFC 3261 21.4.27
	Undecipherable              Code = 493 // RFC 3261 21.4.28

	// Server Failure 5xx codes
	ServerInternalError  Code = 500 // RFC 3261 21.5.1
	NotImplemented       Code = 501 // RFC 3261 21.5.2
	BadGateway           Code = 502 // RFC 3261 21.5.3
	ServiceUnavailable   Code = 503 // RFC 3261 21.5.4
	ServerTimeout        Code = 504 // RFC 3261 21.5.5
	VersionNotSupported  Code = 505 // RFC 3261 21.5.6
	MessageTooLarge      Code = 513 // RFC 3261 21.5.7
	URITooLong           Code = 520 // Custom 52x code
	URIDecoding          Code = 521 // Custom 52x code
	UnsupportedProtocol  Code = 522 // Custom 52x code
	TooManyHeaders       Code = 523 // Custom 52x code
	HeaderFieldsTooLarge Code = 524 // Custom 52x code
	MethodNotImplemented Code = 525 // Custom 52x code

	// Global Failures 6xx codes
	BusyEverywhere       Code = 600 // RFC 3261 21.6.1
	Decline              Code = 603 // RFC 3261 21.6.2
	DoesNotExistAnywhere Code = 604 // RFC 3261 21.6.3
	GlobalNotAcceptable  Code = 606 // RFC 3261 21.6.4
)

SIP status codes as registered RFC 3261 See: https://www.rfc-editor.org/rfc/rfc3261

type Error

type Error struct {
	Message string
	Code    Code
}

func NewError

func NewError(code Code, message string) Error

func (Error) Error

func (e Error) Error() string

type Method

type Method string
const (
	INVITE   Method = "INVITE"
	REGISTER Method = "REGISTER"
	OPTIONS  Method = "OPTIONS"
	ACK      Method = "ACK"
	CANCEL   Method = "CANCEL"
	BYE      Method = "BYE"
)

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(
	request *Request, keyArena, valArena, requestLineArena arena.Arena[byte],
	valuesPool pool.ObjectPool[[]string], s settings.Settings,
) *Parser

func (*Parser) Parse

func (p *Parser) Parse(data []byte) (done bool, err error)

func (*Parser) Release

func (p *Parser) Release()

type Protocol

type Protocol string

func (Protocol) Scheme

func (p Protocol) Scheme() string

func (Protocol) Version

func (p Protocol) Version() string

type Request

type Request struct {
	Method        string
	URI           URI
	Proto         Protocol
	Headers       header.Headers
	ContentLength int
	Body          []byte
}

func NewRequest

func NewRequest() *Request

func (Request) HasBody

func (r Request) HasBody() bool

type Response

type Response struct{}

type Status

type Status string

func Text

func Text(code Code) Status

Text returns a text for the SIP status code. It returns the empty string if the code is unknown.

type URI

type URI struct {
	Scheme   string
	User     string
	Password string
	Host     string
	Port     int
	// TODO: give more generic name to header.Headers, as, how we can see here, it is used
	//  not only for headers, but as general key-value structure
	Params header.Headers
}

Jump to

Keyboard shortcuts

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