messages, imsd: P-Access-Network-Info in responses and in requests within a dialog

imsd named the serving cell in its REGISTERs, the reg-event SUBSCRIBE,
an INVITE and a MESSAGE. TS 24.229 5.1.2A.1.1 and 5.1.2A.2 have a UE
insert the header into a request within a dialog as well, and into a
response within a dialog, to a request for a dialog and to a standalone
method: not into a CANCEL nor into a response to one, and into an ACK
at its choice. A PRACK and a BYE carry it now, and every response imsd
builds but a 100 Trying, the 200 to a CANCEL and the transport's 400 to
a request cut short.

The server ports (the protected ports' TCP listeners and UDP sockets)
take a request from any source (AGENTS.md §12), and the header is the
phone's cell. What they send in answer keeps it only on the two paths
of the SA pair the shell has on record, and loses it anywhere else.

Tested: the suites, and the daemon of this commit on the workstation
against a stand-in network that asks it from both sides of those paths
(the fp6 journal's 2026-12-04-pani-in-dialog capture, bench/), and on
the dev phone on KPN, where its answers to a text's two requests and a
call's 180 and 200 carried the header inside the SA pair (the
journal's 2026-12-04-imsd-1.2.7-range-on-dev-phone capture).
This commit is contained in:
Jorijn van der Graaf 2026-12-04 23:20:38 +01:00
commit a65724a252
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
11 changed files with 460 additions and 38 deletions

View file

@ -25,7 +25,8 @@ rules select — the policies carrying imsd's fingerprint and the reqid-1/2
transport-mode ESP states in their direction or on the UE's ims-PDN address,
whoever installed them (§12); and `FileNamesAnotherPair`, whether a state
file's spi_uc/spi_us name the pair the kernel holds (unknown on either side
decides nothing).
decides nothing). And `SaPaths` with `OnSaPath`: whether a packet runs on one
of the two paths the outbound policies of an SA pair select (§12).
Pure std C++ (the shell runs the commands and captures the text). Command
shapes and the parser are pinned by tests/Ipsec.
@ -180,6 +181,29 @@ export namespace imsd::ipsec {
return cmds;
}
// The two paths the outbound policies of an SA pair select
// (BuildSetupCommands: reqid 1 from the UE's protected client port to
// the P-CSCF's server port, reqid 2 from its protected server port to the
// P-CSCF's client port), between the pair's two addresses. The shell
// keeps one of the pair it set up without an error or resumed; with no
// ports, none.
struct SaPaths {
std::string local; // the UE's address the pair is on
std::string pcscf; // the P-CSCF's
int portPs = 0;
int portPc = 0;
};
// Whether a packet from [fromHost]:fromPort to [toHost]:toPort runs on
// one of the two paths of `p`. Addresses are compared as
// imsd::util::CanonicalAddr writes them (an IPv6 address in its RFC 5952
// form).
inline bool OnSaPath(const SaPaths& p, std::string_view fromHost, int fromPort, std::string_view toHost, int toPort) {
const int theirs = fromPort == imsd::util::PortUc ? p.portPs : fromPort == imsd::util::PortUs ? p.portPc : 0;
return theirs != 0 && toPort == theirs && imsd::util::CanonicalAddr(fromHost) == imsd::util::CanonicalAddr(p.local) &&
imsd::util::CanonicalAddr(toHost) == imsd::util::CanonicalAddr(p.pcscf);
}
// ---- Security-Server (RFC 3329 §2.2) -----------------------------------
//
// The P-CSCF answers the challenge with the mechanisms it supports, each