messages, engine: the INVITE's sequence number, session interval and Min-SE are the dialog's
BuildInvite wrote "CSeq: 1 INVITE", "Session-Expires: 1800;refresher=uac" and "Min-SE: 90" as fixed text, and the INVITE's CANCEL, its two ACKs and a PRACK's RAck wrote the 1 again. The three values are fields of the Dialog now, with those defaults, and nothing in the daemon sets them otherwise yet: every message it sends is byte for byte what it was. Tested: the suites (tests/Messages has an INVITE, its CANCEL and its ACKs for a dialog with other values).
This commit is contained in:
parent
e3b94a8415
commit
3d702ec1f1
4 changed files with 37 additions and 12 deletions
|
|
@ -358,7 +358,9 @@ What the suites pin:
|
|||
variants (a Security-Client for another offer among them; the two
|
||||
REGISTERs of an identity an ISIM holds, byte for byte the pinned ones
|
||||
with the card's names for the derived ones, and `RuriFor` at an
|
||||
ISIM's home domain), the in-dialog
|
||||
ISIM's home domain; the INVITE, its CANCEL and its two ACKs for a dialog
|
||||
whose sequence number, session interval and `Min-SE` are not 1, 1800
|
||||
and 90), the in-dialog
|
||||
requests, the ACKs, the CANCEL and
|
||||
`BuildResponse200` by their lines, `BuildInviteResponse` by the lines of
|
||||
one 180 and by a 486 without a Record-Route (`tests/Engine` checks the
|
||||
|
|
|
|||
|
|
@ -617,7 +617,7 @@ export namespace imsd::engine {
|
|||
if (rseq && require.contains("100rel") && !pracked_.contains(std::string(*rseq))) {
|
||||
pracked_.insert(std::string(*rseq));
|
||||
std::array<std::string, 1> extra = {
|
||||
std::format("RAck: {} 1 INVITE", *rseq)};
|
||||
std::format("RAck: {} {} INVITE", *rseq, d_.invCseq)};
|
||||
a.push_back(Send(imsd::msg::BuildInDialog(ctx_, d_, "PRACK", nextCseq_, rng_.Token(20), extra)));
|
||||
nextCseq_++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
Imsd:Messages — the SIP request/response text the engine puts on the wire.
|
||||
|
||||
Every VoLTE message the daemon sends is assembled here from an explicit
|
||||
context and the per-request variables (tags, branches, CSeq) so the builders
|
||||
context and the per-request variables so the builders
|
||||
are pure functions with no hidden state: the engine owns the dialog bookkeeping
|
||||
and the transport owns the socket, this module only formats bytes. That makes
|
||||
each message byte-pinnable — tests/Messages compares a REGISTER pair and an INVITE
|
||||
|
|
@ -333,7 +333,7 @@ export namespace imsd::msg {
|
|||
|
||||
// ---- call dialog ----------------------------------------------------
|
||||
|
||||
// The dialog identity + routing the engine accumulates for one call.
|
||||
// A dialog as the engine keeps it.
|
||||
// For an outgoing call itag is our From tag and dialogTo is learned from
|
||||
// the responses; for an incoming call itag is the To tag we mint,
|
||||
// dialogTo is the caller's From, and both feed BuildInDialog identically
|
||||
|
|
@ -348,6 +348,12 @@ export namespace imsd::msg {
|
|||
std::optional<std::string> remoteTarget; // remote Contact URI
|
||||
std::string localUri; // our URI in this dialog: the UAS takes the
|
||||
// INVITE's To URI; empty = CallerId(c) (UAC)
|
||||
int invCseq = 1; // our INVITE's sequence number: its CANCEL
|
||||
// and its ACK carry it, a PRACK's RAck
|
||||
// names it
|
||||
int sessionExpires = 1800; // the session interval our INVITE asks for
|
||||
// (RFC 4028 4), in seconds
|
||||
int minSe = 90; // the Min-SE our INVITE carries (RFC 4028 5)
|
||||
};
|
||||
|
||||
// The identity we sign our own requests with: the registered public
|
||||
|
|
@ -382,7 +388,8 @@ export namespace imsd::msg {
|
|||
}
|
||||
|
||||
// INVITE with an AMR-WB SDP offer (passed in, built by Imsd:Sdp). MMTEL
|
||||
// ICSI feature tags + sec-agree + session timers, exactly as imsd._send_invite.
|
||||
// ICSI feature tags + sec-agree + session timers, as imsd._send_invite; the
|
||||
// sequence number, the session interval and its minimum are the dialog's.
|
||||
std::string BuildInvite(const Context& c, const Dialog& d, std::string_view sdp, bool precond) {
|
||||
std::string supported = precond ? "100rel, timer, precondition"
|
||||
: "100rel, timer";
|
||||
|
|
@ -394,7 +401,7 @@ export namespace imsd::msg {
|
|||
std::format("From: <{}>;tag={}", FromUri(c, d), d.itag),
|
||||
std::format("To: <{}>", d.ruri),
|
||||
std::format("Call-ID: {}", d.callid),
|
||||
"CSeq: 1 INVITE",
|
||||
std::format("CSeq: {} INVITE", d.invCseq),
|
||||
std::format("Contact: <sip:{}@{}>;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"", ContactUser(c), imsd::util::HostPort(c.local, c.portUs)),
|
||||
"Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, PRACK, UPDATE, MESSAGE, REFER",
|
||||
std::format("Supported: {}", supported),
|
||||
|
|
@ -406,8 +413,8 @@ export namespace imsd::msg {
|
|||
l.push_back(std::format("Security-Verify: {}", c.securityServer));
|
||||
l.push_back("Proxy-Require: sec-agree");
|
||||
l.push_back("Require: sec-agree");
|
||||
l.push_back("Session-Expires: 1800;refresher=uac");
|
||||
l.push_back("Min-SE: 90");
|
||||
l.push_back(std::format("Session-Expires: {};refresher=uac", d.sessionExpires));
|
||||
l.push_back(std::format("Min-SE: {}", d.minSe));
|
||||
l.push_back("Content-Type: application/sdp");
|
||||
l.push_back(std::format("Content-Length: {}", sdp.size()));
|
||||
l.push_back("");
|
||||
|
|
@ -454,7 +461,7 @@ export namespace imsd::msg {
|
|||
std::format("From: <{}>;tag={}", FromUri(c, d), d.itag),
|
||||
std::format("To: {}", to),
|
||||
std::format("Call-ID: {}", d.callid),
|
||||
"CSeq: 1 ACK",
|
||||
std::format("CSeq: {} ACK", d.invCseq),
|
||||
"Content-Length: 0",
|
||||
};
|
||||
return std::format("{}\r\n", detail::Join(l));
|
||||
|
|
@ -471,7 +478,7 @@ export namespace imsd::msg {
|
|||
std::format("From: <{}>;tag={}", FromUri(c, d), d.itag),
|
||||
std::format("To: {}", toHeader),
|
||||
std::format("Call-ID: {}", d.callid),
|
||||
"CSeq: 1 ACK",
|
||||
std::format("CSeq: {} ACK", d.invCseq),
|
||||
"Content-Length: 0",
|
||||
};
|
||||
return std::format("{}\r\n", detail::Join(l));
|
||||
|
|
@ -487,7 +494,7 @@ export namespace imsd::msg {
|
|||
std::format("From: <{}>;tag={}", FromUri(c, d), d.itag),
|
||||
std::format("To: <{}>", d.ruri),
|
||||
std::format("Call-ID: {}", d.callid),
|
||||
"CSeq: 1 CANCEL",
|
||||
std::format("CSeq: {} CANCEL", d.invCseq),
|
||||
"Content-Length: 0",
|
||||
};
|
||||
return std::format("{}\r\n", detail::Join(l));
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@
|
|||
// CS fallback (observed live 2026-07-20); and the REGISTERs' Security-Client
|
||||
// carries the default offer's two mechanisms, where the Python stack offered
|
||||
// one cipher. The two REGISTERs once more on an identity an ISIM holds: the
|
||||
// pinned ones with the card's names in place of the derived ones. Then the
|
||||
// pinned ones with the card's names in place of the derived ones. The INVITE,
|
||||
// its CANCEL and its ACKs once more for a dialog with another sequence number,
|
||||
// session interval and Min-SE than the pinned 1, 1800 and 90. Then the
|
||||
// SMS over IP shapes: the
|
||||
// +g.3gpp.smsip Contact tag behind Context::smsOverIp, the MESSAGE carrying
|
||||
// an RP-DATA to the service centre and the one carrying an RP-ACK to the
|
||||
|
|
@ -446,6 +448,20 @@ int main() {
|
|||
Check(ack.contains(std::format("Route: {}\r\n", c.route)), "non-2xx ACK registration route");
|
||||
Check(ack.contains("To: <sip:x@y>;tag=z\r\n"), "non-2xx ACK echoes response To");
|
||||
}
|
||||
{
|
||||
// The INVITE's sequence number, session interval and Min-SE are the
|
||||
// dialog's (1, 1800 and 90 in the pinned INVITE above), and its CANCEL
|
||||
// and both ACKs carry the INVITE's number.
|
||||
Dialog d;
|
||||
d.ruri = "sip:x@y"; d.callid = "CID"; d.itag = "it"; d.invBranch = "ib9";
|
||||
d.invCseq = 2; d.sessionExpires = 3600; d.minSe = 2400;
|
||||
std::string inv = BuildInvite(c, d, "v=0\r\n", false);
|
||||
Check(inv.contains("\r\nCSeq: 2 INVITE\r\n"), "INVITE carries the dialog's sequence number");
|
||||
Check(inv.contains("\r\nSession-Expires: 3600;refresher=uac\r\nMin-SE: 2400\r\n"), "INVITE carries the dialog's session interval and Min-SE");
|
||||
Check(BuildCancel(c, d).contains("\r\nCSeq: 2 CANCEL\r\n"), "CANCEL copies the INVITE's number");
|
||||
Check(BuildAckNon2xx(c, d, "<sip:x@y>;tag=z").contains("\r\nCSeq: 2 ACK\r\n"), "non-2xx ACK copies the INVITE's number");
|
||||
Check(BuildAck2xx(c, d, "ab", "<sip:x@y>;tag=z").contains("\r\nCSeq: 2 ACK\r\n"), "2xx ACK copies the INVITE's number");
|
||||
}
|
||||
|
||||
// ---- 200 OK response echoes the request's dialog headers, in order
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue