Documentation
¶
Overview ¶
Package dialog tracks minimal SIP dialog identifiers for UAS-centric call legs.
A dialog is created by an INVITE and confirmed by ACK (RFC 3261 §12). This package stores the fields needed to match in-dialog requests and ACKs without parsing SDP:
- Call-ID — dialog identifier (same for the whole call leg)
- InviteBranch — top Via branch of the creating INVITE (transaction layer key)
- CSeqInvite — INVITE sequence number (ACK reuses it with method ACK)
- RemoteTag — typically ;tag= from the INVITE From (caller)
- LocalTag — ;tag= added by the UAS on To in 1xx/2xx
Example INVITE establishing a dialog:
INVITE sip:bob@example.com SIP/2.0 Via: SIP/2.0/UDP 192.0.2.1:5060;branch=z9hG4bK776asdhds From: Alice <sip:alice@example.com>;tag=1928301774 To: Bob <sip:bob@example.com> Call-ID: a84b4c76e66710@192.0.2.1 CSeq: 314159 INVITE
After 200 OK, To contains the UAS tag:
To: Bob <sip:bob@example.com>;tag=a6c85cf
Matching ACK:
ACK sip:bob@example.com SIP/2.0 Via: SIP/2.0/UDP 192.0.2.1:5060;branch=z9hG4bK776asdhds From: Alice <sip:alice@example.com>;tag=1928301774 To: Bob <sip:bob@example.com>;tag=a6c85cf Call-ID: a84b4c76e66710@192.0.2.1 CSeq: 314159 ACK
Usage ¶
d, err := dialog.NewUASFromINVITE(invite)
d.SetLocalTagFromToHeader(resp.GetHeader(stack.HeaderTo))
d.Confirm()
if d.MatchACK(ack) { ... }
Registry stores one Dialog per Call-ID for simple B2BUA/UAS apps.
Media and SDP negotiation live in protocol/sipmedia/session, not here.
Index ¶
- func AppendTagAfterNameAddr(header, tag string) string
- func TagFromHeader(header string) string
- type Dialog
- func (d *Dialog) Confirm()
- func (d *Dialog) GetLocalTag() string
- func (d *Dialog) GetRemoteTag() string
- func (d *Dialog) InviteCSeqNum() int
- func (d *Dialog) InviteTransactionKey() string
- func (d *Dialog) MatchACK(ack *stack.Message) bool
- func (d *Dialog) SetLocalTag(tag string)
- func (d *Dialog) SetLocalTagFromToHeader(toHeader string)
- func (d *Dialog) State() State
- func (d *Dialog) Terminate()
- type Registry
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendTagAfterNameAddr ¶
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 ¶
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 ¶
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 ¶
GetLocalTag returns the UAS tag for this dialog (empty before 2xx To is set).
func (*Dialog) GetRemoteTag ¶
GetRemoteTag returns the peer tag parsed from the INVITE From.
func (*Dialog) InviteCSeqNum ¶
InviteCSeqNum returns the CSeq number of the INVITE that created this dialog (ACK uses the same number).
func (*Dialog) InviteTransactionKey ¶
InviteTransactionKey returns the same key used by protocol/sip/transaction INVITE maps.
func (*Dialog) MatchACK ¶
MatchACK reports whether ack belongs to this dialog's INVITE (same Call-ID, CSeq number, ACK method, tags when present).
func (*Dialog) SetLocalTag ¶
SetLocalTag records the UAS tag (usually parsed from the To header you generated on 1xx/2xx).
func (*Dialog) SetLocalTagFromToHeader ¶
SetLocalTagFromToHeader extracts ;tag= from a To header value (e.g. your generated 200 OK To).
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).