dialog

package
v1.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package dialog tracks minimal SIP dialog state for pkg/sip1 (Call-ID, tags, early/confirmed).

It aligns with transaction keys via InviteTransactionKey (branch + Call-ID from the INVITE). It does not parse SDP or touch RTP; use pkg/sip1/session for media.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendTagAfterNameAddr

func AppendTagAfterNameAddr(header, tag string) string

AppendTagAfterNameAddr inserts ;tag=tag immediately after the closing '>' of a name-addr, or appends ;tag=tag when no angle brackets are present. If a tag already exists, header is unchanged.

func TagFromHeader

func TagFromHeader(header string) string

TagFromHeader extracts the SIP tag parameter from a From or To header value.

Types

type Dialog

type Dialog struct {
	CallID       string
	InviteBranch string // top Via branch of the INVITE; matches transaction layer key
	CSeqInvite   int    // INVITE CSeq number (ACK uses same number with method ACK)

	// RemoteTag is typically the peer tag from the INVITE From (caller).
	RemoteTag string
	// LocalTag is the UAS tag added to To in 1xx/2xx responses.
	LocalTag string
	// contains filtered or unexported fields
}

Dialog holds minimal identifiers for one SIP dialog (UAS-centric helpers).

func NewUASFromINVITE

func NewUASFromINVITE(inv *stack.Message) (*Dialog, error)

NewUASFromINVITE builds dialog state from an inbound INVITE (early). Parses Call-ID, branch, INVITE CSeq, remote From tag.

func (*Dialog) Confirm

func (d *Dialog) Confirm()

Confirm marks the dialog confirmed (e.g. after stable 2xx/ACK path).

func (*Dialog) GetLocalTag

func (d *Dialog) GetLocalTag() string

GetLocalTag returns the UAS tag for this dialog (empty before 2xx To is set).

func (*Dialog) GetRemoteTag

func (d *Dialog) GetRemoteTag() string

GetRemoteTag returns the peer tag parsed from the INVITE From.

func (*Dialog) InviteCSeqNum

func (d *Dialog) InviteCSeqNum() int

InviteCSeqNum returns the CSeq number of the INVITE that created this dialog (ACK uses the same number).

func (*Dialog) InviteTransactionKey

func (d *Dialog) InviteTransactionKey() string

InviteTransactionKey returns the same key used by pkg/sip1/transaction for INVITE server/client maps.

func (*Dialog) MatchACK

func (d *Dialog) MatchACK(ack *stack.Message) bool

MatchACK reports whether ack belongs to this dialog's INVITE (same Call-ID, CSeq number, ACK method, tags when present).

func (*Dialog) SetLocalTag

func (d *Dialog) SetLocalTag(tag string)

SetLocalTag records the UAS tag (usually parsed from the To header you generated on 1xx/2xx).

func (*Dialog) SetLocalTagFromToHeader

func (d *Dialog) SetLocalTagFromToHeader(toHeader string)

SetLocalTagFromToHeader extracts ;tag= from a To header value (e.g. your generated 200 OK To).

func (*Dialog) State

func (d *Dialog) State() State

State returns the current dialog state.

func (*Dialog) Terminate

func (d *Dialog) Terminate()

Terminate marks the dialog terminated.

type Registry

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

Registry stores dialogs keyed by Call-ID (single dialog per Call-ID for this minimal registry).

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty registry.

func (*Registry) Delete

func (r *Registry) Delete(callID string)

Delete removes a dialog by Call-ID.

func (*Registry) Get

func (r *Registry) Get(callID string) *Dialog

Get returns the dialog for Call-ID or nil.

func (*Registry) Put

func (r *Registry) Put(d *Dialog) error

Put registers d under its Call-ID (must be non-empty).

type State

type State int

State is the dialog lifecycle for a UAS leg (inbound INVITE).

const (
	StateNone State = iota
	StateEarly
	StateConfirmed
	StateTerminated
)

Jump to

Keyboard shortcuts

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