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
(cherry picked from commit 6b0af315ee)
- 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
Improperly checked return value of `str2int()`
in the `setTimer()` DSM wrapper.
False is failed conversion, true is fine.
Change-Id: I2e2a10b9e25b660ec94322934043717edb4aebf3
It's been noticed actually no result is written
by the reference given to a funciton helper.
Also it's not convenient with a rest of other
helpers, which return either true/false
on successfull or failed conversion, but just
directly return the result of atof() as a bool,
which is a mistake.
Also add a comment to a function declaration.
Change-Id: I4f18ce527638a3575ef7446a549650a951a0b583
src/XmlRpcValue.cpp: In member function ‘std::ostream& XmlRpc::XmlRpcValue::write(std::ostream&) const’:
src/XmlRpcValue.cpp:483:44: warning: ‘%02d’ directive output may be truncated writing between 2 and 11 bytes into a region of size between 8 and 15 [-Wformat-truncation=]
483 | snprintf(buf, sizeof(buf)-1, "%4d%02d%02dT%02d:%02d:%02d",
| ^~~~
src/XmlRpcValue.cpp:483:40: note: directive argument in the range [-2147483647, 2147483647]
483 | snprintf(buf, sizeof(buf)-1, "%4d%02d%02dT%02d:%02d:%02d",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/XmlRpcValue.cpp:483:19: note: ‘snprintf’ output between 18 and 70 bytes into a destination of size 19
483 | snprintf(buf, sizeof(buf)-1, "%4d%02d%02dT%02d:%02d:%02d",
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
484 | (1900 + t.tm_year), (1 + t.tm_mon), t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Change-Id: I38edb330bc0d0ea17fc215f745fc51e66d56d41f
Use a template to cover all signed- and unsigned- int-to-string
conversions. Based on a quick benchmark, this is the fastest alternative
(faster than sprintf and faster than using div/abs).
Change existing wrapper functions to use this template and let the
compiler optimise.
Change-Id: Id0512d0777407c8be442de0920f45d0751132ced
To initialize `sessId` and `sessV` to 0
in case when they aren't given explicitly
during the construction
(e.g. via ther other concrete constructor).
Closes Coverity CID 642745.
Change-Id: I8abea03f079ed64a0a4127afaba61cad17473e82
Properly place the clear RTP receivers handler.
Instead of doing directly from the destructor,
do it on state change (onBeforeDestroy) via
the down to up virtual function realization search.
Is triggered by `AmSession::finalize()`.
Closes Coverity CID 642748.
Change-Id: I4c224425e9fbecedef3d29a6658f1723313b19c4
Instead of copying, move that.
And then later for the local socket assignment
operations use a copy connections map member used
as a destination shortly before.
Closes Coverity CID 642750.
Change-Id: Ief7891c1962251b33cd5960e74e4081685881dcf
All the subsequent code already relies on the fact
it's not NULL, so makes no sense to actually check
this later again.
Closes Coverity CID 642754.
Change-Id: I0de348d0deff6d36f4d0ecfdb2635c94d1101fb2
It's been noticed that the SDP body gets missing
after multipart body arrives with quoted boundaries.
The reason for that is the multi-part body,
which has boundaries quoted at both beginning and the end.
As a result 'AmMimeBody::findNextBoundary()' is not able
to parse/find next boundary, and the multi-part body
entirely gets stripped.
This commit fixes this misbehavior.
Change-Id: I73beab32ea97a8ed148180ab6b149f84fe8c0ac1
To determine whether a timer has been added to a list yet, use a
dedicated link object wrapped in an "optional" (empty state meaning not
added to a list), instead of a raw pointer and its NULL state.
Change-Id: I70ca342d8c9e4900140529977c99b3b0f61a5588
Introduce a config option to skip generating
the direction paramter in case when SEMS
generates local SDP offer or answer.
Change-Id: Ifcba27cd6ad0070bead182d60ad3dc5ee57b41bc
- Update Standards-Version to 4.7.2.
- Remove «Rules-Requires-Root: no» field, which is now the default.
- Remove «Priority: optional» field, which is now the default.
- Remove ancient conffile removal handling.
- Disable DH_VERBOSE by default, as is expected from a usual package.
- Terminate multi-lines with «# EOL» to make modifying them not cause
unnecessary diff damage.
Change-Id: I11399af5dbe8509ce31b3ae52b9ed559bbb9a2b3
This commit introduces a new RTP transport model,
based on the AmRtpTransport abstraction, providing a more modular and
efficient approach to RTP handling compared to the legacy model.
General things:
- Introduction of new RTP receiver and transport abstractions
- The new model coexists with the legacy RTP handling
to preserve backward compatibility
Architecture overview:
- A new AmRtpTransport layer is introduced to encapsulate RTP transport logic
and decouple it from AmRtpStream and session-level code
- Transport-specific functionality is implemented via dedicated classes:
- AmRtpTransport: base abstraction responsible for RTP/RTCP packet flow,
lifecycle management, and interaction with streams
- AmRtpUdpSocket: UDP-based RTP socket implementation
- AmRtpSocketPair: manages RTP/RTCP socket pairs and their coordination
- AmRtpStream is refactored to rely on the transport interface
instead of directly managing sockets and low-level I/O
Integration details:
- SIP session and dialog logic (AmSession, AmSipDialog) is updated to work with
the new transport model
- SBC call legs and call profiles are extended to support transport selection
and lifecycle handling
- SDP processing (AmSdp) is updated to reflect transport capabilities and
address handling changes
This refactoring improves separation of concerns, reduces coupling between RTP
streaming and transport mechanics, and provides a cleaner foundation for future
RTP extensions and optimizations.
Code provenance and license:
- part of the code was written by Fokus GmbH
- part of the code was written by Sipwise GmbH
- part of the code base copyrighted by Fokus GmbH was provided by them in
the form of backports under the GPL license.
- these changes are covered by the GPL, matching the existing project license
Change-Id: I313c4abd9b54f805c1e668c019cf6fb8c4a9e46d
Instead of using borrowed raw pointers (which is a big
risk when there are multiple users of the container)
give a possibility to operate on the AmObject as
a shared pointer, which at least ensures that
the object won't be gone if there are still some users.
In the next improvements the raw pointers usage for
`AmDynInvoke*` and `AmObject*` will be deprecated and
both of them will be replaced with shared pointers,
accordingly callers refactoring is required.
Change-Id: I576b0eca22f01b41473b0551b940452dc2515e19
If this is an SDP answer (provided by non-fwd 200OK),
don't hesitate to update the original leg originated this
INVITE transaction.
Originally this was prevented by the
56115ed5dd00f7ce9271e97e5933a9745eb31435
of the original (root) SEMS project, in order to fix
some of the Click2Dial scenarios of the according
Click2Dial app. Original message from it:
don't refresh for establishing transaction
fixes click2dial application.
In the B2BUA, usually a refresh is done if the established session
description has changed on the other leg (e.g. initiated by SST
refresh from the middle). This fix prevents that refresh for the
initial transaction, where the re-INVITE to caller is done explicitely.
It seems that this commit somehow introduces this logic also
for those legs, which aren't actually establishing but are in need
for the SDP media updates. So just remove it.
Change-Id: I3acf7d3d9ceaa3c8d7a8ba0f7a5c6973646bc2af