slurp

package module
v0.0.0-...-e015cb7 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

README

slurp

Extensible, Customizable SIP UA Library for Go

This library is still in its very early stages. Please check back in a couple months!

The goal is to provide a simple but flexible API for SIP UAC and UAS functionality in Golang, in compliance with RFC 3261.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SupportedMethods = [5]string{
	"INVITE", "REGISTER", "NOTIFY", "SUBSCRIBE", "ACK",
}

SupportedMethods is a list of all request types currently supported by Slurp

View Source
var SupportedResponses = map[int]string{
	200: "OK",
	100: "Trying",
	180: "Ringing",
	183: "Session Progress",
	401: "Unauthorized",
	404: "Not Found",
	486: "Busy Here",
}

SupportedResponses is a mapping of support response codes and their text values

Functions

This section is empty.

Types

type CallControlHeaders

type CallControlHeaders struct {
	// A slice of Via headers
	// the format is an array[2] of strings, where:
	// [0] = The transport (UDP, TCP)
	// [1] = The URI
	Via [][2]string
	// The branch of the most recent via, or ours if we added it
	ViaBranch    string
	CallId       string
	Sequence     int
	Authenticate string
}

CallControlHeaders are common headers that are usually only set by the system, not by users

type CommonHeaders

type CommonHeaders struct {
	To            Header
	From          Header
	Contacts      []Header
	Forward       int //MaxForwards
	UserAgent     string
	ContentType   string
	ContentLength int
}

Contains header information common across all messages

type Contact

type Contact map[string]string

The Contact header, which is repeatable

func (*Contact) Init

func (h *Contact) Init() Header

func (*Contact) Param

func (h *Contact) Param(name string) string

func (*Contact) ParamString

func (h *Contact) ParamString() (result string)

func (*Contact) SetParam

func (h *Contact) SetParam(name, value string) Header

func (*Contact) SetUri

func (h *Contact) SetUri(uri string) Header

func (*Contact) SetValue

func (h *Contact) SetValue(value string) Header

func (*Contact) Uri

func (h *Contact) Uri() string

func (*Contact) Value

func (h *Contact) Value() string
type Header interface {
	Value() string
	Param(string) string
	Uri() string
	SetValue(string) Header
	SetParam(string, string) Header
	SetUri(string) Header
	ParamString() string
	// Do we want to do Init() here or move Render() to each header impl?
	Init() Header
}

Header represents "complicated" headers in the SIP RFC Not all headers are Headers. For instance, MaxForwards is fundamentally too simple to merit so much overhead

func NewHeader

func NewHeader(h Header) Header

type Invite

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

func (*Invite) Control

func (i *Invite) Control() *CallControlHeaders

func (*Invite) Headers

func (i *Invite) Headers() *CommonHeaders

func (*Invite) Method

func (i *Invite) Method() string

func (*Invite) Parse

func (i *Invite) Parse(message string) (err error)

Parse takes a string representation of a message and unmarshalls the data into the appropriate struct fields.

func (*Invite) Payload

func (i *Invite) Payload() []byte

func (*Invite) RawHeaders

func (i *Invite) RawHeaders() string

func (*Invite) Render

func (i *Invite) Render() string

func (*Invite) SetPayload

func (i *Invite) SetPayload(data []byte)

func (*Invite) StringPayload

func (i *Invite) StringPayload() string

func (*Invite) Uri

func (i *Invite) Uri() string

type Message

type Message interface {
	Render() string
	// given a string representation of a message, unmarshall into Message object
	Parse(string) error
	// Get the method/request type of the message
	Method() string
	Uri() string
	Headers() *CommonHeaders
	RawHeaders() string
	Control() *CallControlHeaders
	Payload() []byte
	StringPayload() string
	SetPayload([]byte)
}

Message is the golang model representing an entire SIP message

type Register

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

func (*Register) Control

func (r *Register) Control() *CallControlHeaders

func (*Register) Headers

func (r *Register) Headers() *CommonHeaders

func (*Register) Method

func (r *Register) Method() string

func (*Register) Parse

func (r *Register) Parse(message string) (err error)

Parse takes a string representation of a message and unmarshalls the data into the appropriate struct fields.

func (*Register) Payload

func (r *Register) Payload() []byte

func (*Register) Render

func (r *Register) Render() string

func (*Register) SetPayload

func (r *Register) SetPayload(data []byte)

func (*Register) StringPayload

func (r *Register) StringPayload() string

func (*Register) Uri

func (r *Register) Uri() string

type ToFrom

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

Used for both From an To headers as they have the same parameters

func (*ToFrom) Init

func (t *ToFrom) Init() Header

func (*ToFrom) Param

func (t *ToFrom) Param(name string) string

func (*ToFrom) ParamString

func (t *ToFrom) ParamString() string

func (*ToFrom) SetParam

func (t *ToFrom) SetParam(name, value string) Header

func (*ToFrom) SetUri

func (t *ToFrom) SetUri(uri string) Header

func (*ToFrom) SetValue

func (t *ToFrom) SetValue(value string) Header

func (*ToFrom) Uri

func (t *ToFrom) Uri() string

func (*ToFrom) Value

func (t *ToFrom) Value() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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