Documentation

Index

Constants

View Source
const (
	Proceeding = iota
	Ringing
	Answered
	Hangup
)
View Source
const (
	GosipUA    = "slytherin/1.o"
	GosipAllow = "INVITE, ACK, CANCEL, BYE, OPTIONS"
)

Variables

View Source
var (
	// How often to check for shutdowns.
	DeathClock = 200 * time.Millisecond

	// SIP egress msg length must not exceed me. If you are brave and use jumbo
	// frames you can increase this value.
	MTU = 1450

	// Maximum number SRV/Redirects/Etc. to entertain. More accurately, this is
	// the maximum number of time's we're allowed to enter the "calling" state.
	MaxAttempts = 10

	// This is how long to wait (in nanoseconds) for a 100 trying response before
	// retransmitting the invite. Multiply this by RetransmitAttempts and that's
	// how long it'll be before we try another server. That might seem like a
	// very long time but happy networks facilitate fast failover by sending hard
	// errors (ICMP, 480, 500-599)
	TryingTimeout = 500 * time.Millisecond

	// How many times to attempt to retransmit before moving on.
	RetransmitAttempts = 2

	// Number of nanoseconds (across all attempts) before we give up trying to
	// connect a call. This doesn't mean the call has to have been answered but
	// rather has moved beyond the "calling" state and doesn't go back.
	GiveupTimeout = 3 * time.Second

	// TODO(jart): How long to wait before refreshing a call with a re-INVITE
	//             message.
	RefreshTimeout = 15 * time.Minute

	// How many times are proxies allowed to forward a message.
	MaxForwards int = 70

	// Approx. how long the transaction engine remembers old Call-IDs to prevent
	// a retransmit from accidentally opening a new dialog.
	CallIDBanDuration = 35 * time.Second

	// Approx. how often to sweep old transactions from ban list.
	CallIDBanSweepDuration = 5 * time.Second

	// Should the transport layer add timestamps to Via headers (µsi/µse = UTC
	// microseconds since unix epoch ingress/egress).
	ViaTimestampTagging = true

	// Use this feature to print out raw sip messages the moment they are
	// sent/received by the transport layer.
	TransportTrace = (os.Getenv("TPORT_LOG") == "true")
)

Functions

func AckMatch

func AckMatch(msg, ack *sip.Msg) bool

    Returns true if `ack` can be considered an appropriate response to `msg`. We don't enforce a matching Via because some VoIP software will generate a new branch for ACKs.

    func NewBye

    func NewBye(invite, remote *sip.Msg, lseq *int) *sip.Msg

    func NewCancel

    func NewCancel(invite *sip.Msg) *sip.Msg

    func NewRequest

    func NewRequest(tp *Transport, method string, to, from *sip.Addr) *sip.Msg

    func NewResponse

    func NewResponse(msg *sip.Msg, status int) *sip.Msg

    func PopulateMessage

    func PopulateMessage(via *sip.Via, contact *sip.Addr, msg *sip.Msg)

    func ReceiveMessages

    func ReceiveMessages(sock *net.UDPConn, c chan<- *sip.Msg, e chan<- error)

    func ResponseMatch

    func ResponseMatch(req, rsp *sip.Msg) bool

      Returns true if `resp` can be considered an appropriate response to `msg`. Do not use for ACKs.

      func RouteMessage

      func RouteMessage(via *sip.Via, contact *sip.Addr, msg *sip.Msg) (host string, port uint16, err error)

      Types

      type AddressRoute

      type AddressRoute struct {
      	Address string
      	Next    *AddressRoute
      }

      func RouteAddress

      func RouteAddress(host string, port uint16, wantSRV bool) (routes *AddressRoute, err error)

      type Dialog

      type Dialog struct {
      	OnErr   <-chan error
      	OnState <-chan int
      	OnPeer  <-chan *net.UDPAddr
      	Hangup  chan<- bool
      }

        Dialog represents an outbound SIP phone call.

        func NewDialog

        func NewDialog(invite *sip.Msg) (dl *Dialog, err error)

          NewDialog creates a phone call.

          type Transport

          type Transport struct {
          	C       <-chan *sip.Msg
          	E       <-chan error
          	Sock    *net.UDPConn
          	Via     *sip.Via
          	Contact *sip.Addr
          }

            Transport sends and receives SIP messages over UDP with stateless routing.

            func NewTransport

            func NewTransport(contact *sip.Addr) (tp *Transport, err error)

              Creates a new stateless network mechanism for transmitting and receiving SIP signalling messages.

              contact is a SIP address, e.g. "<sip:1.2.3.4>", that tells how to bind sockets. If contact.Uri.Port is 0, it'll be mutated with a randomly selected port. This value is also used for contact headers which tell other user-agents where to send responses and hence should only contain an IP or canonical address.

              func (*Transport) Send

              func (tp *Transport) Send(msg *sip.Msg) error

                Sends a SIP message.