transfer

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package transfer implements B2BUA-style call transfer signaling (RFC 3515 REFER + NOTIFY).

Signaling only:

  • Inbound REFER → 202 Accepted + NOTIFY sipfrag
  • Outbound second leg via protocol/sip/outbound.Manager.Dial
  • RFC 7044 / RFC 5806 retarget headers (ApplyRetargetHeaders)

Media bridging after transfer is in protocol/sipmedia/transferbridge. Business hooks (ACD, TTS brief, CRM) stay outside this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyRetargetHeaders

func ApplyRetargetHeaders(
	req *outbound.DialRequest,
	rawTo, rawHistoryInfo, rawDiversion string,
	historyReason, diversionReason string,
)

ApplyRetargetHeaders mutates req to include History-Info and Diversion chains for B2BUA retarget.

Types

type Config

type Config struct {
	Dialogs  *DialogStore
	LocalIP  string
	SIPPort  int
	Dial     func(ctx context.Context, req outbound.DialRequest) (string, error)
	SendSIP  func(msg *stack.Message, addr *net.UDPAddr) error
	Retarget RetargetSource
}

Config initializes a signaling-only transfer coordinator.

type Coordinator

type Coordinator struct {
	Dialogs  *DialogStore
	LocalIP  string
	SIPPort  int
	Dial     func(ctx context.Context, req outbound.DialRequest) (string, error)
	SendSIP  func(msg *stack.Message, addr *net.UDPAddr) error
	Retarget RetargetSource
	// contains filtered or unexported fields
}

Coordinator wires REFER signaling and outbound transfer dial (signaling only). Media bridging lives in protocol/sipmedia/transferbridge.

func NewCoordinator

func NewCoordinator(cfg Config) *Coordinator

NewCoordinator builds a transfer coordinator.

func (*Coordinator) HandleDialEvent

func (c *Coordinator) HandleDialEvent(evt outbound.DialEvent)

HandleDialEvent should be wired to outbound.ManagerConfig.OnEvent. Fires pending REFER NOTIFY on established/failed. Media bridge is handled by sipmedia/transferbridge.

func (*Coordinator) HandleDialogCallIDAdopted

func (c *Coordinator) HandleDialogCallIDAdopted(oldID, newID, _ string)

HandleDialogCallIDAdopted rekeys pending REFER NOTIFY when SBC rewrites outbound Call-ID.

func (*Coordinator) HandleRefer

func (c *Coordinator) HandleRefer(req *stack.Message, addr *net.UDPAddr) (*stack.Message, error)

HandleRefer answers inbound REFER with 202 and starts outbound transfer asynchronously.

func (*Coordinator) SendInboundBye

func (c *Coordinator) SendInboundBye(callID string) error

SendInboundBye sends BYE on the inbound dialog and forgets dialog state.

func (*Coordinator) TriggerFromReferTo

func (c *Coordinator) TriggerFromReferTo(ctx context.Context, inboundCallID, referToHeader string, onTerminalNotify func(sipfrag, subState string))

TriggerFromReferTo dials Refer-To target (signaling); bridge separately via sipmedia.

func (*Coordinator) TriggerToAgent

func (c *Coordinator) TriggerToAgent(ctx context.Context, inboundCallID string, tgt outbound.DialTarget, onTerminalNotify func(sipfrag, subState string))

TriggerToAgent dials an agent/trunk target for AI or ACD-driven transfer.

type DialogState

type DialogState struct {
	Remote     *net.UDPAddr
	From       string // our To from 200 OK (local tag)
	To         string // remote From from INVITE
	RequestURI string
	NextCSeq   int
}

DialogState holds in-dialog routing data for NOTIFY/BYE on an inbound UAS leg.

type DialogStore

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

DialogStore tracks confirmed inbound dialogs keyed by Call-ID.

func NewDialogStore

func NewDialogStore() *DialogStore

NewDialogStore creates an empty dialog map.

func (*DialogStore) BuildBye

func (s *DialogStore) BuildBye(callID, localIP string, localPort int) (*stack.Message, *net.UDPAddr, error)

BuildBye builds an in-dialog BYE for the inbound leg.

func (*DialogStore) BuildNotify

func (s *DialogStore) BuildNotify(callID, localIP string, localPort int, sipfragBody, subscriptionState string) (*stack.Message, *net.UDPAddr, error)

BuildNotify builds an in-dialog NOTIFY (Event: refer) with message/sipfrag body.

func (*DialogStore) Forget

func (s *DialogStore) Forget(callID string)

Forget removes dialog state (after BYE or teardown).

func (*DialogStore) Get

func (s *DialogStore) Get(callID string) *DialogState

Get returns dialog state for callID.

func (*DialogStore) Remember

func (s *DialogStore) Remember(callID string, remote *net.UDPAddr, inv *stack.Message, ourToWithTag string)

Remember records dialog state after answering INVITE (pass the To header from 200 OK).

type RetargetSource

type RetargetSource func(inboundCallID string) (toHdr, historyInfo, diversion string)

RetargetSource supplies inbound History-Info / Diversion context for outbound retarget INVITEs. Implementations typically read from protocol/sipmedia/session.CallSession metadata.

Jump to

Keyboard shortcuts

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