On a heavily loaded CI host the SIP T1 retransmit timer (500 ms) fires
before the test framework processes responses, leaving extra datagrams
in the shared _uas_sock that survive tearDown. Additionally, SEMS
generates its own Call-ID for B-leg dialogs, so messages from different
tests mix on the same socket.
Changes:
t/sems_tester.py:
recvB2BINVITE(): new helper — reads from shared UAS socket skipping
any non-INVITE datagrams (stale BYE/ACK from previous tests)
recvSIPForCall(sock, b2b_cid): new helper — reads from shared UAS
socket discarding messages whose Call-ID doesn't match the current
B2B dialog
t/test-b2b.py:
tearDown: increase drain timeout 0.5 s → 1.5 s (covers up to 3×T1)
All recvFromSIP(_uas_sock) INVITE reads replaced with
recvB2BINVITE() + b2b_cid = _hdr(…, "Call-ID")
All subsequent recvSIP(_uas_sock) reads replaced with
recvSIPForCall(_uas_sock, b2b_cid) to discard stale datagrams
testInviteRetransmission: "must NOT forward" block filters by Call-ID
testEarlyCancelRace / testRtpDirectionHold: BYE/CANCEL acceptance
conditions extended with `and b2b_cid in msg`
testConcurrentCalls: setup_call() uses recvB2BINVITE +
recvSIPForCall, BYE waits keyed on per-call b2b_call_id
Change-Id: Id8987d3594c487d8b78c38ed3b9f580544a83693
add B2B SBC integration test suite (port from sems-pbx)
Port the 20-test B2B suite from sems-pbx. CE-specific differences:
- sip_port=5062 (avoids conflict with orphaned sockets on :5060)
- default_bl_ttl=0 in t/b2b.conf (disables destination blacklisting
so a 503 response in one test does not block subsequent tests)
- no g729 in load_plugins (codec not present in CE)
- plugin_config_path requires trailing slash
- 100 response matched as "100 [^\r]+" (CE sends "100 Connecting"
instead of "100 Trying")
sems_tester.py: add makeUACSocket/makeUASSocket, recvSIP, recvFromSIP,
sendToSIP, assertSIP helpers; create t/run/ in setUpClass; clean up
PID file in tearDownClass; skip testPreload when rtpe-preload.so is
not loaded.
testEarlyCancelRace: use 10 s socket timeout with inner try/except
so the test passes on loaded CI machines where BYE may arrive late.
Change-Id: Iecb563dee6a27cf46b9883c42154a4486b3f6429
Internally the parsing still happens on pointers, but the externally
visible function will be using string_view eventually, when all other
users are converted.
Change-Id: I87d3be9e41fd96f656ce242edc1c403425f3eb65
If the `postDtmfEvent()` doesn't acquire the ownershop
over the allocated event, then no one actually takes care
to release it.
Modify func to return true/false, and react accordingly
on the caller's side.
Change-Id: If683eeba275d71850f67d961e9a1cdefe3fe6619
In case the override func of virtual `onStop()`
anyhow reaches the AmSession again, and falls into
the scope where the same mutex lock is used (snapshot_lock)
this will be a dead-lock.
Hence preserve such, but manually managing the lock,
and release it, when calling the virtual func.
Change-Id: I7c7c4700767dd3aed1c482559be02e3a97cca407
No need to do local copy operations, because:
- local copy on stack created
- then another copy on stack created when returning
So this does two copy operations.
Instead just do one during return, this is still covered
with the lock guard.
Additionally: split `getMaxSessionNum()` into getter
and setter, because the name is misleading now.
Hence those callers, who want to get the max session number,
are obligated to also update to the new value.
Change-Id: Icc775d9236d5c80de829c55638e1da47ae095289
In some of the usages of manual lock/unlock,
an exception can leave the mutex locked.
So the guard should fit this better.
Change-Id: I3541abe7a0ec63edffe1e180c691531cabb3fccd
If stop bookkeeping is ever called twice or
without a successful start, it wraps to a huge value,
because the `session_num` is `unsigned int`.
Just a guard and throw a warning accordingly,
when 0 is reached.
Change-Id: Ic9cef4aa7ae827fc8ce68808a2e6f5753697ebbb
Out of the `SESSION_THREADPOOL` def block,
because actually used not only with it
(see implementation .cpp file).
Change-Id: I84549ea185b660cdde7619de3ddf5c5034bccfd1
Automatic memory management and less error prone as it avoids manual
pointer manipulations.
No functional change.
Change-Id: Id35f4e4dc8918436589001db4acdf55ff9c60e5f
Update the usage of the `getParameter()` through
the modules, whereas the default value isn't given.
Change-Id: I4c725639f56b70e5548fa3da321c8452675cdf99
Rework plug-ins parser so that it supports
the multi-line parsing.
E.g.:
load_plugins=wav;\
gsm;\
g729;\
opus;\
g722;\
di_dial;\
...
Change-Id: Ic672ff72db73279d9fd3d52ba9a60fa5f6d7eb25
uac_auth: fix 407 auth retry failing due to stuck OA state
When SEMS sent an INVITE with SDP to a peer requiring proxy
authentication, the 407 response was forwarded to the caller
instead of being handled transparently with a retry.
Root cause: AmOfferAnswer::onReplyIn() did not reset the OA state
for error replies (>= 300). After the initial INVITE, OA state
was OA_OfferSent. When the 407 arrived (no SDP body), the state
remained OA_OfferSent. UACAuth then tried to retry the INVITE
with the original SDP body, but onTxSdp() rejected it:
"There is already a pending offer".
Fix: add early return with clearTransitionalState() at the top of
AmOfferAnswer::onReplyIn() for replies with code >= 300, matching
the behavior already present in sems-pbx. This ensures the OA
state is reset to OA_None before UACAuth attempts the retry.
Additionally, store req.r_uri in SIPRequestInfo and use it for
digest URI computation instead of dlg->getRemoteUri(). This
ensures the Authorization uri field always matches the original
Request-URI, as required by RFC 2617, regardless of any dialog
state changes between the initial request and the 407 handler.
Change-Id: I780bc98f193421481156de3f69497d26b893c49d
Fixes:
AmUtils.cpp: In function ‘bool str2int(const std::string&, double&)’:
AmUtils.cpp:286:21: warning: catching polymorphic type ‘const class std::invalid_argument’ by value [-Wcatch-value=]
286 | catch (const std::invalid_argument)
| ^~~~~~~~~~~~~~~~
AmUtils.cpp:290:21: warning: catching polymorphic type ‘const class std::out_of_range’ by value [-Wcatch-value=]
290 | catch (const std::out_of_range)
| ^~~~~~~~~~~~
Change-Id: I3d112aff65ea6e90803b6be7c138227a36975d9f
Use references instead of pointers.
Use object operators instead of memcpy and memset.
Remove redundant ctors.
Change-Id: I04440450070af17909efbd957f42a3c561e658ab
- Add pyproject.toml and tox.ini with consistent black and pycodestyle
settings.
+ Fix all errors >= E300.
- Place unconditional imports at the beginning of the file.
- Do not import more than one module at the same time.
- Do not use blackslash at EOL within brackets.
- Do not use bare except.
- Do not end statement with semicolon.
- Do not place multiple statements in the same line.
- Use «is» and «is not» instead of «==» and «!=» for None.
- Disambiguate short variable name by giving it a better longer name.
- Remove trailing whitespace.
- Fix expected number of blank lines.
Change-Id: I02a29887a1267f5b843822e0ff05b7dca4416554
The code had not been converted to Python 3.x, and was not even
compiling there, with something like:
$ find -name '*.py' | xargs -n1 python3 -m py_compute
Change-Id: I795f931123d1bccb85670fe0dc6b06c46a9f22c2