Skip to content

Commit f3792d4

Browse files
author
Marcel Hecko
committed
Fix issue #205: Update SBCCallRegistry with actual B-leg Call-ID
When Call-ID is rewritten via call profile (Call-ID=$ci_mo-b2b) or when transparent_dlg_id is enabled, the registry now stores the actual Call-ID used in SIP messages instead of the auto-generated one. This fixes REFER with Replaces header failures where lookupCall would return an auto-generated Call-ID that doesn't match any active dialog. Changes: - Added SBCCallRegistry::updateCallId() method - Update A->B registry mapping after Call-ID changes in: * transparent_dlg_id mode (SBCCallLeg constructor) * call_profile.callid rewrite (applyBProfile)
1 parent 6e113db commit f3792d4

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

apps/sbc/SBCCallLeg.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ SBCCallLeg::SBCCallLeg(SBCCallLeg* caller, AmSipDialog* p_dlg,
182182
dlg->setCallid(caller->dlg->getCallid());
183183
dlg->setExtLocalTag(caller->dlg->getRemoteTag());
184184
dlg->cseq = caller->dlg->r_cseq;
185+
// Update registry with the actual Call-ID that will be used in SIP messages
186+
// The A->B mapping uses the caller's (A-leg's) local tag as the key
187+
SBCCallRegistry::updateCallId(caller->dlg->getLocalTag(), caller->dlg->getCallid());
185188
}
186189

187190
// copy RTP rate limit from caller leg
@@ -411,8 +414,12 @@ void SBCCallLeg::applyBProfile()
411414
}
412415

413416
// was read from caller but reading directly from profile now
414-
if (!call_profile.callid.empty())
417+
if (!call_profile.callid.empty()) {
415418
dlg->setCallid(call_profile.callid);
419+
// Update registry with the actual Call-ID that will be used in SIP messages
420+
// The A->B mapping uses the other leg's (A-leg's) local tag as the key
421+
SBCCallRegistry::updateCallId(getOtherId(), call_profile.callid);
422+
}
416423

417424
dlg->setContact(call_profile.bleg_contact);
418425
}

apps/sbc/SBCCallRegistry.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ void SBCCallRegistry::updateCall(const string& ltag, const string& other_rtag) {
5050
DBG("SBCCallRegistry: Updated call '%s' - rtag to: '%s'\n", ltag.c_str(), other_rtag.c_str());
5151
}
5252

53+
void SBCCallRegistry::updateCallId(const string& ltag, const string& new_callid) {
54+
registry_mutex.lock();
55+
56+
std::map<string, SBCCallRegistryEntry>::iterator it = registry.find(ltag);
57+
if (it != registry.end()) {
58+
it->second.callid = new_callid;
59+
}
60+
61+
registry_mutex.unlock();
62+
63+
DBG("SBCCallRegistry: Updated call '%s' - callid to: '%s'\n", ltag.c_str(), new_callid.c_str());
64+
}
65+
5366
bool SBCCallRegistry::lookupCall(const string& ltag, SBCCallRegistryEntry& other_dlg) {
5467
bool res = false;
5568

apps/sbc/SBCCallRegistry.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class SBCCallRegistry
5454

5555
static void addCall(const string& ltag, const SBCCallRegistryEntry& other_dlg);
5656
static void updateCall(const string& ltag, const string& other_rtag);
57+
static void updateCallId(const string& ltag, const string& new_callid);
5758
static bool lookupCall(const string& ltag, SBCCallRegistryEntry& other_dlg);
5859
static void removeCall(const string& ltag);
5960
};

0 commit comments

Comments
 (0)