sip

package module
v0.0.0-...-9c31f88 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: MIT Imports: 12 Imported by: 0

README

sip

. SIP simulator in go

Unfortunately I don't have time to work on this code in the near future for various reasons.

As stated by the license - very few strings are attached for anyone who may find it useful.

Documentation

Index

Constants

View Source
const (
	REQUEST  = "request"
	RESPONSE = "response"
)

REQUEST is used for processing SIP requests RESPONSE is used for processing SIP responses

Variables

This section is empty.

Functions

func CheckConnError

func CheckConnError(err error)

CheckConnError is used to check for errors encountered during connection establishment

func GenerateBranch

func GenerateBranch() string

GenerateBranch generates branch for via header

func GenerateCallID

func GenerateCallID() string

GenerateCallID generates call-id

func GenerateTag

func GenerateTag() string

GenerateTag generates tags for To/From headers

func ParseFirstLine

func ParseFirstLine(incomingFirstLine string) (string, []string, error)

func StartSIP

func StartSIP(lAddr string, rAddr string, transport string) (chan SipMessage, chan SipMessage)

func StartTCPClient

func StartTCPClient(lAddr string, rAddr string) (chan SipMessage, chan SipMessage)

StartTCPClient prepares TCP connection and returns inbound/outbound channels

func StartUDP

func StartUDP(lAddr string, rAddr string) (chan SipMessage, chan SipMessage)

StartUDP prepares and returns UDP connection

func TransactionLayerHandler

func TransactionLayerHandler(outboundT chan SipMessage, outbound chan SipMessage, inboundT chan SipMessage, inbound chan SipMessage)

Types

type ActiveClientTransactions

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

func (*ActiveClientTransactions) DeleteTransaction

func (act *ActiveClientTransactions) DeleteTransaction(id string)

func (*ActiveClientTransactions) GetState

func (*ActiveClientTransactions) NewTransaction

func (act *ActiveClientTransactions) NewTransaction(id string, outgoingMessage SipMessage)

func (*ActiveClientTransactions) UpdateState

func (act *ActiveClientTransactions) UpdateState(id string, newState InviteClientState)

type ClientTransaction

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

ClientTransaction describes client transaction

type Dialog

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

type InviteClientState

type InviteClientState uint8
const (
	InviteClientCalling InviteClientState = iota + 1
	InviteClientProceeding
	InviteClientCompleted
	InviteClientTerminated
)

FSM states for Invite Client Transactions

type MessageType

type MessageType uint8
const (
	TypeRequest MessageType = iota
	TypeResponse
)

type Packet

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

Packet stores UDP connection data and payload

type Request

type Request struct {
	Method     string
	RUri       string
	SipVersion string
	Headers    map[string]string
	Body       string
}

func (Request) AddHeader

func (req Request) AddHeader(name string, value string)

func (Request) GetBody

func (req Request) GetBody() string

func (Request) GetFirstLine

func (req Request) GetFirstLine() string

func (Request) GetHeaders

func (req Request) GetHeaders() map[string]string

func (Request) Serialize

func (req Request) Serialize() []byte

func (Request) SetBody

func (req Request) SetBody(b string)

func (Request) Type

func (req Request) Type() MessageType

type Response

type Response struct {
	SipVersion   string
	StatusCode   int
	ReasonPhrase string
	Headers      map[string]string
	Body         string
}

func (Response) AddHeader

func (res Response) AddHeader(name string, value string)

func (Response) GetBody

func (res Response) GetBody() string

func (Response) GetFirstLine

func (res Response) GetFirstLine() string

func (Response) GetHeaders

func (res Response) GetHeaders() map[string]string

func (Response) Serialize

func (res Response) Serialize() []byte

func (Response) SetBody

func (res Response) SetBody(b string)

func (Response) Type

func (res Response) Type() MessageType

type SipMessage

type SipMessage interface {
	Type() MessageType
	GetBody() string
	GetHeaders() map[string]string
	GetFirstLine() string
	SetBody(string)
	AddHeader(string, string)
	Serialize() []byte
}

func DeserializeSipMessage

func DeserializeSipMessage(payload []byte, streamed bool) (SipMessage, error)

DeserializeSipMessage transforms bytes comprising a sip message into SIP message

func NewDialog

func NewDialog(fromUri string, toUri string, transport string) SipMessage

NewDialog prepares INVITE for initiation of a new dialog

func PrepareInDialogRequest

func PrepareInDialogRequest(method string, cseq string, sipHeaders map[string]string) SipMessage

PrepareInDialogRequest prepares in-dialog requests

func PrepareResponse

func PrepareResponse(sipHeaders map[string]string, code int, reasonPhrase string) SipMessage

PrepareResponse builds basic structure for a response to an incoming request

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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