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:
parent
6d05aaed0d
commit
a65724a252
11 changed files with 460 additions and 38 deletions
|
|
@ -215,8 +215,7 @@ int main() {
|
|||
{
|
||||
// P-Access-Network-Info from `mmcli --location-get` (real-device
|
||||
// output shape; TAC/CI zero-padded wider than the 4/7 hex digits
|
||||
// PANI uses). The mcc+mnc+TAC+ECI concatenation was validated
|
||||
// against a stock modem's on-wire PANI; values here are synthetic.
|
||||
// PANI uses). Values here are synthetic.
|
||||
constexpr std::string_view Loc =
|
||||
" --------------------------\n"
|
||||
" 3GPP | operator mcc: 001\n"
|
||||
|
|
|
|||
|
|
@ -14,7 +14,11 @@
|
|||
// ring and are answered at the offer's own payload types, ring timeout ->
|
||||
// 480, BYE both ways; an incoming call from an INVITE, and an outgoing
|
||||
// call from responses, whose header names come in compact form (RFC 3261
|
||||
// 7.3.3). DTMF: the tones reach the media leg on an active
|
||||
// 7.3.3); which of a call's messages carry P-Access-Network-Info where
|
||||
// the cell is known (its 180, its 200s but the one to a CANCEL, a 486
|
||||
// and a 487, PRACK and BYE) and which do not (the 100 Trying, the 200 to
|
||||
// a CANCEL, the ACKs, the CANCEL). DTMF: the tones reach the media leg
|
||||
// on an active
|
||||
// call that negotiated telephone-event, and are dropped — with the reason
|
||||
// — before the answer, after the call, without the negotiation or with a
|
||||
// character that is no tone. Then RegRecovery, the registration recovery policy:
|
||||
|
|
@ -917,6 +921,67 @@ int main() {
|
|||
Check(m.Terminated(), "terminated");
|
||||
}
|
||||
|
||||
// ---- P-Access-Network-Info through a call's life, where the cell is
|
||||
// known: in the 180, the 200s but a CANCEL's, a 486 and a 487, and
|
||||
// in PRACK and BYE; in no 100 Trying, no ACK and no CANCEL
|
||||
{
|
||||
Context k = MakeCtx();
|
||||
k.panInfo = "3GPP-E-UTRAN-FDD;utran-cell-id-3gpp=0010112340ABCDE0";
|
||||
const auto with = [](const Action* a) { return a && a->text.contains("\r\nP-Access-Network-Info: 3GPP-E-UTRAN-FDD;utran-cell-id-3gpp=0010112340ABCDE0\r\n"); };
|
||||
const auto without = [](const Action* a) { return a && !a->text.contains("P-Access-Network-Info"); };
|
||||
const auto inDialog = [](std::string_view method, std::string_view callid, std::string_view extra = "") {
|
||||
return std::format(
|
||||
"{} sip:001010123456789@[2001:db8::db43]:45061 SIP/2.0\r\n"
|
||||
"Via: SIP/2.0/UDP [2001:db8::105]:5100;branch=z9hG4bKpcscf9\r\n"
|
||||
"From: <sip:+31612345678@ims;user=phone>;tag=caller1\r\n"
|
||||
"To: <sip:+31611111111@ims;user=phone>;tag=ours\r\n"
|
||||
"Call-ID: {}\r\nCSeq: 2 {}\r\n{}Content-Length: 0\r\n\r\n", method, callid, method, extra);
|
||||
};
|
||||
{
|
||||
// an incoming call its caller cancels
|
||||
imsd::util::Rng rng(71);
|
||||
CallMachine m(k, rng, "ims-call-80", IncomingInvite{MtInvite("Require: 100rel\r\n")}, 50004);
|
||||
auto ai = m.OnInvite();
|
||||
Check(with(Responded(ai, "SIP/2.0 180 Ringing")) && without(Responded(ai, "SIP/2.0 100 Trying")), "a cell known: the 180 to an incoming INVITE carries P-Access-Network-Info, its 100 Trying does not");
|
||||
Check(with(Responded(m.OnRequest(inDialog("PRACK", m.CallId(), "RAck: 1 1 INVITE\r\n")), "SIP/2.0 200 OK")), "... and the 200 to the PRACK of that 180");
|
||||
auto ac = m.OnRequest(inDialog("CANCEL", m.CallId()));
|
||||
Check(without(Responded(ac, "SIP/2.0 200 OK")) && with(Responded(ac, "SIP/2.0 487 Request Terminated")), "... the 200 to a CANCEL does not, the INVITE's 487 does");
|
||||
}
|
||||
{
|
||||
// an incoming call answered, then refreshed and ended from the far side
|
||||
imsd::util::Rng rng(72);
|
||||
CallMachine m(k, rng, "ims-call-81", IncomingInvite{MtInvite()}, 50004);
|
||||
m.OnInvite();
|
||||
Check(with(Responded(m.OnAccept(), "SIP/2.0 200 OK")), "... the 200 that answers the call");
|
||||
Check(with(Responded(m.OnRequest(inDialog("UPDATE", m.CallId(), "Session-Expires: 1800;refresher=uac\r\n")), "SIP/2.0 200 OK")), "... the 200 to a session refresh");
|
||||
Check(with(Responded(m.OnRequest(inDialog("BYE", m.CallId())), "SIP/2.0 200 OK")), "... and the 200 to the far side's BYE");
|
||||
}
|
||||
{
|
||||
// an incoming call refused, and one answered and ended here
|
||||
imsd::util::Rng rng(73);
|
||||
CallMachine m(k, rng, "ims-call-82", IncomingInvite{MtInvite()}, 50004);
|
||||
m.OnInvite();
|
||||
Check(with(Responded(m.OnHangup(), "SIP/2.0 486 Busy Here")), "... a 486");
|
||||
CallMachine n(k, rng, "ims-call-83", IncomingInvite{MtInvite()}, 50004);
|
||||
n.OnInvite();
|
||||
n.OnAccept();
|
||||
Check(with(Sent(n.OnHangup(), "BYE ")), "... our BYE on a call that came in");
|
||||
}
|
||||
{
|
||||
// a call we place: its PRACK and its BYE carry it, its ACKs and its CANCEL do not
|
||||
imsd::util::Rng rng(74);
|
||||
CallMachine m(k, rng, "ims-call-84", "1233", 50004, false);
|
||||
m.Start();
|
||||
Check(with(Sent(m.OnInviteResponse(R183(m.CallId())), "PRACK ")), "... the PRACK of a call we place");
|
||||
Check(without(Sent(m.OnInviteResponse(R200(m.CallId())), "ACK ")), "... not the ACK of its 200");
|
||||
Check(with(Sent(m.OnHangup(), "BYE ")), "... its BYE");
|
||||
CallMachine n(k, rng, "ims-call-85", "1233", 50004, false);
|
||||
n.Start();
|
||||
Check(without(Sent(n.OnHangup(), "CANCEL ")), "... not a CANCEL");
|
||||
Check(without(Sent(n.OnInviteResponse(Final(n.CallId(), 487, "Request Terminated")), "ACK ")), "... and not the ACK of a refusal");
|
||||
}
|
||||
}
|
||||
|
||||
// ================= emergency (stage 1) ================================
|
||||
|
||||
// ---- emergency dial: the INVITE targets the sos URN over the normal
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
// prints, with its line for each algorithm imsd installs, and
|
||||
// the Security-Server parser, fed the operator lines as captured (O2 UK's
|
||||
// six-mechanism Mavenir shape verbatim, under a null and under an aes-cbc
|
||||
// offer; KPN's single mechanism; Odido's), and the EALG list.
|
||||
// offer; KPN's single mechanism; Odido's), the EALG list, and the two
|
||||
// paths an SA pair's outbound policies select (OnSaPath).
|
||||
import std;
|
||||
import Imsd;
|
||||
|
||||
|
|
@ -476,6 +477,22 @@ int main() {
|
|||
Check(NormalizeEalg("") == "null" && NormalizeEalg("3des") == "des-ede3-cbc" && NormalizeEalg("aes-cbc") == "aes-cbc", "NormalizeEalg");
|
||||
}
|
||||
|
||||
// ---- OnSaPath: the two paths an SA pair's outbound policies select
|
||||
{
|
||||
const SaPaths p{"2001:db8::db43", "2001:db8::105", 6000, 33421};
|
||||
Check(OnSaPath(p, "2001:db8::db43", 45061, "2001:db8::105", 6000), "OnSaPath: the client port to the P-CSCF's server port");
|
||||
Check(OnSaPath(p, "2001:db8::db43", 45062, "2001:db8::105", 33421), "OnSaPath: the server port to the P-CSCF's client port");
|
||||
Check(!OnSaPath(p, "2001:db8::db43", 45061, "2001:db8::105", 33421) && !OnSaPath(p, "2001:db8::db43", 45062, "2001:db8::105", 6000), "OnSaPath: not the client port to its client port, nor the server port to its server port");
|
||||
Check(!OnSaPath(p, "2001:db8::db43", 45062, "2001:db8::105", 33422), "OnSaPath: not another port of the P-CSCF");
|
||||
Check(!OnSaPath(p, "2001:db8::db43", 45062, "2001:db8::106", 33421), "OnSaPath: not another host on the P-CSCF's port");
|
||||
Check(!OnSaPath(p, "2001:db8::db44", 45062, "2001:db8::105", 33421), "OnSaPath: not from another address of ours");
|
||||
Check(!OnSaPath(p, "2001:db8::db43", 5060, "2001:db8::105", 6000) && !OnSaPath(p, "2001:db8::db43", 5060, "2001:db8::105", 33421), "OnSaPath: not from a port that is neither protected port");
|
||||
Check(OnSaPath(p, "2001:DB8:0:0:0:0:0:DB43", 45061, "2001:0db8::0105", 6000) && OnSaPath(SaPaths{"2001:DB8:0:0:0:0:0:DB43", "2001:0db8::0105", 6000, 33421}, "2001:db8::db43", 45061, "2001:db8::105", 6000), "OnSaPath: an IPv6 address in another spelling is the same address, the packet's or the record's");
|
||||
Check(!OnSaPath(SaPaths{}, "2001:db8::db43", 45061, "2001:db8::105", 6000) && !OnSaPath(SaPaths{}, "", 45061, "", 0), "OnSaPath: no pair on record, no path");
|
||||
const SaPaths four{"192.0.2.2", "192.0.2.1", 6000, 33421};
|
||||
Check(OnSaPath(four, "192.0.2.2", 45062, "192.0.2.1", 33421) && !OnSaPath(four, "192.0.2.2", 45062, "192.0.2.3", 33421), "OnSaPath: over IPv4 a path of the pair, and not another host on its port");
|
||||
}
|
||||
|
||||
if (Failures == 0) std::println("Ipsec: all tests passed");
|
||||
return Failures != 0; // not the count: `crafter-build test` takes an exit status of 77 for a skipped suite, and an exit status keeps 8 bits
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,10 @@
|
|||
// 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. 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
|
||||
// session interval and Min-SE than the pinned 1, 1800 and 90. Which
|
||||
// messages carry P-Access-Network-Info where the cell is known, and that the
|
||||
// PRACK, the BYE and the responses that carry it carry none where it is not.
|
||||
// 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
|
||||
|
|
@ -423,11 +426,11 @@ int main() {
|
|||
Check(prack.contains("To: <sip:1233@x>;tag=remote99\r\n"), "PRACK To has remote tag");
|
||||
Check(prack.contains("CSeq: 2 PRACK\r\n"), "PRACK CSeq");
|
||||
Check(prack.contains("RAck: 42 1 INVITE\r\n"), "PRACK RAck");
|
||||
Check(prack.ends_with("Content-Length: 0\r\n\r\n"), "PRACK empty body");
|
||||
Check(prack.ends_with("RAck: 42 1 INVITE\r\nP-Access-Network-Info: 3GPP-E-UTRAN-FDD;utran-cell-id-3gpp=0010112340ABCDE0\r\nContent-Length: 0\r\n\r\n"), "PRACK: P-Access-Network-Info after its RAck, an empty body");
|
||||
|
||||
std::string bye = BuildInDialog(c, d, "BYE", 3, "byebranch");
|
||||
Check(bye.starts_with("BYE sip:termgw@2001:db8::9 SIP/2.0\r\n"), "BYE line");
|
||||
Check(bye.contains("CSeq: 3 BYE\r\n"), "BYE CSeq");
|
||||
Check(bye.ends_with("CSeq: 3 BYE\r\nP-Access-Network-Info: 3GPP-E-UTRAN-FDD;utran-cell-id-3gpp=0010112340ABCDE0\r\nContent-Length: 0\r\n\r\n"), "BYE: its CSeq, then P-Access-Network-Info");
|
||||
|
||||
std::string ack = BuildAck2xx(c, d, "ackbranch", "<ignored>");
|
||||
Check(ack.starts_with("ACK sip:termgw@2001:db8::9 SIP/2.0\r\n"), "ACK 2xx target");
|
||||
|
|
@ -438,6 +441,12 @@ int main() {
|
|||
Check(cancel.starts_with(std::format("CANCEL {} SIP/2.0\r\n", d.ruri)), "CANCEL request-URI = ruri");
|
||||
Check(cancel.contains("branch=z9hG4bKib;rport\r\n"), "CANCEL reuses INVITE branch");
|
||||
Check(cancel.contains("CSeq: 1 CANCEL\r\n"), "CANCEL CSeq copies INVITE");
|
||||
// RFC 7315 5.7: the header appears in no ACK and no CANCEL
|
||||
Check(!ack.contains("P-Access-Network-Info") && !cancel.contains("P-Access-Network-Info") && !BuildAckNon2xx(c, d, "<sip:x@y>;tag=z").contains("P-Access-Network-Info"), "neither ACK nor the CANCEL carries P-Access-Network-Info");
|
||||
// where the cell is not known the in-dialog requests carry none either
|
||||
Context n = MakeCtx();
|
||||
n.panInfo.clear();
|
||||
Check(BuildInDialog(n, d, "PRACK", 2, "prbranch", rack).ends_with("RAck: 42 1 INVITE\r\nContent-Length: 0\r\n\r\n") && BuildInDialog(n, d, "BYE", 3, "byebranch").ends_with("CSeq: 3 BYE\r\nContent-Length: 0\r\n\r\n"), "no cell known: PRACK and BYE without the header");
|
||||
}
|
||||
{
|
||||
// non-2xx ACK uses the INVITE branch + registration route + resp To
|
||||
|
|
@ -478,12 +487,21 @@ int main() {
|
|||
Check(r.contains("Via: SIP/2.0/TCP [a::1]:45061;branch=z9hG4bKother\r\n"), "200 echoes Via");
|
||||
Check(r.contains("Call-ID: xyz@far\r\n"), "200 echoes Call-ID");
|
||||
Check(r.contains("CSeq: 7 BYE\r\n"), "200 echoes CSeq");
|
||||
Check(r.ends_with("Content-Length: 0\r\n\r\n"), "200 empty body");
|
||||
Check(r.ends_with("CSeq: 7 BYE\r\nP-Access-Network-Info: 3GPP-E-UTRAN-FDD;utran-cell-id-3gpp=0010112340ABCDE0\r\nContent-Length: 0\r\n\r\n"), "200 to a BYE: P-Access-Network-Info after the echoed five, an empty body");
|
||||
// with an SDP answer: our Contact + application/sdp appear
|
||||
std::string r2 = BuildResponse200(c, req, Sdp);
|
||||
Check(r2.contains("Content-Type: application/sdp\r\n"), "200 w/ SDP content-type");
|
||||
Check(r2.contains("Contact: <sip:001010123456789@[2001:db8::db43]:45062>\r\n"), "200 w/ SDP includes our Contact");
|
||||
Check(r2.ends_with(Sdp), "200 w/ SDP body");
|
||||
Check(r2.contains("CSeq: 7 BYE\r\nP-Access-Network-Info: 3GPP-E-UTRAN-FDD;utran-cell-id-3gpp=0010112340ABCDE0\r\nContact: "), "200 w/ SDP: P-Access-Network-Info before our Contact");
|
||||
// TS 24.229 5.1.2A.1.1, 5.1.2A.2: "(except CANCEL responses)"
|
||||
std::string cancelReq = req;
|
||||
cancelReq.replace(0, 3, "CANCEL");
|
||||
cancelReq.replace(cancelReq.find("CSeq: 7 BYE"), 11, "CSeq: 7 CANCEL");
|
||||
Check(BuildResponse200(c, cancelReq).ends_with("CSeq: 7 CANCEL\r\nContent-Length: 0\r\n\r\n"), "200 to a CANCEL: no P-Access-Network-Info");
|
||||
Context n = MakeCtx();
|
||||
n.panInfo.clear();
|
||||
Check(BuildResponse200(n, req).ends_with("CSeq: 7 BYE\r\nContent-Length: 0\r\n\r\n") && !BuildResponse200(n, req, Sdp).contains("P-Access-Network-Info"), "no cell known: the 200 without the header");
|
||||
}
|
||||
|
||||
// ---- s53 oracle diff: UUID Contact user-part + User-Agent ------------
|
||||
|
|
@ -569,7 +587,9 @@ int main() {
|
|||
"Call-ID: in1@net\r\n"
|
||||
"CSeq: 9 MESSAGE\r\n"
|
||||
"Content-Length: 0\r\n\r\n";
|
||||
Eq(BuildResponse(c, inbound, 488, "Not Acceptable Here", "T488"),
|
||||
Context noCell = MakeCtx();
|
||||
noCell.panInfo.clear();
|
||||
Eq(BuildResponse(noCell, inbound, 488, "Not Acceptable Here", "T488"),
|
||||
"SIP/2.0 488 Not Acceptable Here\r\n"
|
||||
"Via: SIP/2.0/UDP [2001:db8::105]:6000;branch=z9hG4bKnet1\r\n"
|
||||
"Via: SIP/2.0/UDP [2001:db8::77]:5060;branch=z9hG4bKgw0\r\n"
|
||||
|
|
@ -578,6 +598,16 @@ int main() {
|
|||
"Call-ID: in1@net\r\n"
|
||||
"CSeq: 9 MESSAGE\r\n"
|
||||
"Content-Length: 0\r\n\r\n", "a 488 for an inbound MESSAGE echoes every Via and tags To");
|
||||
Eq(BuildResponse(c, inbound, 488, "Not Acceptable Here", "T488"),
|
||||
"SIP/2.0 488 Not Acceptable Here\r\n"
|
||||
"Via: SIP/2.0/UDP [2001:db8::105]:6000;branch=z9hG4bKnet1\r\n"
|
||||
"Via: SIP/2.0/UDP [2001:db8::77]:5060;branch=z9hG4bKgw0\r\n"
|
||||
"From: <sip:ipsmgw@ims>;tag=N1\r\n"
|
||||
"To: <sip:me@ims>;tag=T488\r\n"
|
||||
"Call-ID: in1@net\r\n"
|
||||
"CSeq: 9 MESSAGE\r\n"
|
||||
"P-Access-Network-Info: 3GPP-E-UTRAN-FDD;utran-cell-id-3gpp=0010112340ABCDE0\r\n"
|
||||
"Content-Length: 0\r\n\r\n", "and where the cell is known, P-Access-Network-Info after its CSeq");
|
||||
const std::string tagged = "MESSAGE sip:me@ims SIP/2.0\r\nVia: SIP/2.0/UDP [2001:db8::105]:6000;branch=z9hG4bKnet2\r\nFrom: <sip:ipsmgw@ims>;tag=N2\r\nTo: <sip:me@ims>;tag=had\r\nCall-ID: in2@net\r\nCSeq: 1 MESSAGE\r\nContent-Length: 0\r\n\r\n";
|
||||
Check(BuildResponse(c, tagged, 200, "OK", "unused").contains("\r\nTo: <sip:me@ims>;tag=had\r\n"), "a To that already carries a tag is echoed as it is");
|
||||
// the 400 to a request whose datagram ended before its body did (RFC 3261 18.3), built from what imsd::sip::CutShortRequest gives of it
|
||||
|
|
@ -598,6 +628,7 @@ int main() {
|
|||
"CSeq: 9 MESSAGE\r\n"
|
||||
"Content-Length: 0\r\n\r\n", "its 400 echoes every Via and tags To with sixteen hex digits of the MD5 of the secret and the header section");
|
||||
Eq(BuildBadRequest(imsd::sip::CutShortRequest(cut + "s").value_or(""), secret), BuildBadRequest(head, secret), "the same request cut short elsewhere draws the same 400, tag and all");
|
||||
Check(!BuildBadRequest(head, secret).contains("P-Access-Network-Info"), "the 400 is built without the registration's context: no P-Access-Network-Info");
|
||||
const auto toTag = [](std::string_view r) { const std::size_t at = r.find(";tag=", r.find("\r\nTo: ")); return r.substr(at, r.find("\r\n", at) - at); };
|
||||
const std::string r1 = BuildBadRequest(head, secret);
|
||||
std::string other = cut;
|
||||
|
|
@ -644,6 +675,18 @@ int main() {
|
|||
"i: call3@net\r\n"
|
||||
"CSeq: 1 INVITE\r\n"
|
||||
"l: 0\r\n\r\n";
|
||||
Eq(BuildInviteResponse(noCell, invite, 180, "Ringing", "T180"),
|
||||
"SIP/2.0 180 Ringing\r\n"
|
||||
"Via: SIP/2.0/TCP [2001:db8::105]:6000;branch=z9hG4bKnet3\r\n"
|
||||
"Via: SIP/2.0/UDP [2001:db8::77]:5060;branch=z9hG4bKgw3\r\n"
|
||||
"Record-Route: <sip:[2001:db8::105]:6000;lr>\r\n"
|
||||
"From: <sip:caller@ims>;tag=N3\r\n"
|
||||
"To: <sip:me@ims>;tag=T180\r\n"
|
||||
"Call-ID: call3@net\r\n"
|
||||
"CSeq: 1 INVITE\r\n"
|
||||
"Contact: <sip:001010123456789@[2001:db8::db43]:45062>\r\n"
|
||||
"Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, PRACK, UPDATE, MESSAGE, REFER\r\n"
|
||||
"Content-Length: 0\r\n\r\n", "a 180 for an INVITE echoes every Via and the Record-Route, tags To and carries our Contact and Allow");
|
||||
const std::string ringing = BuildInviteResponse(c, invite, 180, "Ringing", "T180");
|
||||
Eq(ringing,
|
||||
"SIP/2.0 180 Ringing\r\n"
|
||||
|
|
@ -656,7 +699,21 @@ int main() {
|
|||
"CSeq: 1 INVITE\r\n"
|
||||
"Contact: <sip:001010123456789@[2001:db8::db43]:45062>\r\n"
|
||||
"Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, PRACK, UPDATE, MESSAGE, REFER\r\n"
|
||||
"Content-Length: 0\r\n\r\n", "a 180 for an INVITE echoes every Via and the Record-Route, tags To and carries our Contact and Allow");
|
||||
"P-Access-Network-Info: 3GPP-E-UTRAN-FDD;utran-cell-id-3gpp=0010112340ABCDE0\r\n"
|
||||
"Content-Length: 0\r\n\r\n", "and where the cell is known, P-Access-Network-Info after them");
|
||||
{
|
||||
const std::array<std::string, 2> reliable = {"Require: 100rel", "RSeq: 1"};
|
||||
Check(BuildInviteResponse(c, invite, 180, "Ringing", "T180", std::nullopt, reliable).ends_with("Require: 100rel\r\nRSeq: 1\r\nP-Access-Network-Info: 3GPP-E-UTRAN-FDD;utran-cell-id-3gpp=0010112340ABCDE0\r\nContent-Length: 0\r\n\r\n"), "a reliable 180: P-Access-Network-Info after its Require and RSeq");
|
||||
Check(BuildInviteResponse(c, invite, 100, "Trying", "unused").ends_with("CSeq: 1 INVITE\r\nContent-Length: 0\r\n\r\n"), "a 100 Trying carries none");
|
||||
Check(BuildInviteResponse(c, invite, 486, "Busy Here", "T486").ends_with("CSeq: 1 INVITE\r\nP-Access-Network-Info: 3GPP-E-UTRAN-FDD;utran-cell-id-3gpp=0010112340ABCDE0\r\nContent-Length: 0\r\n\r\n"), "and a 486");
|
||||
Check(BuildInviteResponse(c, invite, 200, "OK", "T200", "v=0\r\n").ends_with("P-Access-Network-Info: 3GPP-E-UTRAN-FDD;utran-cell-id-3gpp=0010112340ABCDE0\r\nContent-Type: application/sdp\r\nContent-Length: 5\r\n\r\nv=0\r\n"), "and a 200 with its answer, before the Content-Type");
|
||||
Check(!BuildInviteResponse(noCell, invite, 100, "Trying", "unused").contains("P-Access-Network-Info") && !BuildInviteResponse(noCell, invite, 200, "OK", "T200", "v=0\r\n").contains("P-Access-Network-Info"), "no cell known: a 100 and a 200 without the header");
|
||||
Check(BuildInviteResponse(noCell, invite, 180, "Ringing", "T180", std::nullopt, reliable).ends_with("Require: 100rel\r\nRSeq: 1\r\nContent-Length: 0\r\n\r\n") && BuildInviteResponse(noCell, invite, 486, "Busy Here", "T486").ends_with("CSeq: 1 INVITE\r\nContent-Length: 0\r\n\r\n"), "no cell known: a reliable 180 and a 486 without it");
|
||||
// the exception is for a response to a CANCEL, not for one to a request that names the method
|
||||
std::string allowing = invite;
|
||||
allowing.insert(allowing.find("Content-Length:"), "Allow: INVITE, ACK, CANCEL, BYE\r\n");
|
||||
Check(BuildInviteResponse(c, allowing, 180, "Ringing", "T180") == ringing, "an INVITE whose Allow names CANCEL is answered like any other");
|
||||
}
|
||||
Eq(BuildInviteResponse(c, compactInvite, 180, "Ringing", "T180"), ringing, "a 180 for an INVITE in compact form is the one for its long form");
|
||||
Eq(BuildInviteResponse(c, compactInvite, 486, "Busy Here", "T486"), BuildInviteResponse(c, invite, 486, "Busy Here", "T486"), "and so is a 486");
|
||||
Check(BuildInviteResponse(c, invite, 486, "Busy Here", "T486").contains("\r\nTo: <sip:me@ims>;tag=T486\r\n") && !BuildInviteResponse(c, invite, 486, "Busy Here", "T486").contains("Record-Route"), "a 486 tags To and returns no Record-Route");
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@
|
|||
// (CutShortRequest), a refused final's Retry-After and summary (RetryAfter,
|
||||
// RefusalSummary), the interval a 422's Min-SE names (MinSe), transaction
|
||||
// matching (ResponseOf), our binding in a
|
||||
// reg-event document (RegInfoContactState), and HeaderUri and Body. These pin
|
||||
// the module's edge-case behavior; see the module header before "fixing" one.
|
||||
// reg-event document (RegInfoContactState), HeaderUri and Body, and a
|
||||
// message less every line on which one header is found (WithoutHeader).
|
||||
// These pin the module's edge-case behavior; see the module header before
|
||||
// "fixing" one.
|
||||
import std;
|
||||
import Imsd;
|
||||
|
||||
|
|
@ -569,6 +571,34 @@ int main() {
|
|||
Check(imsd::sip::Body("OPTIONS sip:x SIP/2.0\r\nCSeq: 1 OPTIONS\r\n").empty(), "Body: none without a terminator");
|
||||
}
|
||||
|
||||
// ---- WithoutHeader: a message less every line on which one header is
|
||||
// found
|
||||
{
|
||||
const std::string r =
|
||||
"SIP/2.0 200 OK\r\n"
|
||||
"Via: SIP/2.0/UDP [2001:db8::105]:6000;branch=z9hG4bKnet1\r\n"
|
||||
"P-Access-Network-Info: 3GPP-E-UTRAN-FDD;utran-cell-id-3gpp=0010112340ABCDE0\r\n"
|
||||
"Content-Type: text/plain\r\n"
|
||||
"Content-Length: 31\r\n"
|
||||
"\r\n"
|
||||
"P-Access-Network-Info: a body\r\n";
|
||||
const std::string bare =
|
||||
"SIP/2.0 200 OK\r\n"
|
||||
"Via: SIP/2.0/UDP [2001:db8::105]:6000;branch=z9hG4bKnet1\r\n"
|
||||
"Content-Type: text/plain\r\n"
|
||||
"Content-Length: 31\r\n"
|
||||
"\r\n"
|
||||
"P-Access-Network-Info: a body\r\n";
|
||||
Check(WithoutHeader(r, "P-Access-Network-Info") == bare, "WithoutHeader: the header's line is gone, the other lines and a body line that spells its name stay");
|
||||
Check(WithoutHeader(bare, "P-Access-Network-Info") == bare, "WithoutHeader: a message without the header comes back as it is");
|
||||
Check(WithoutHeader(r, "p-access-network-info") == bare, "WithoutHeader: the name in another letter case");
|
||||
Check(WithoutHeader(r, "P-Access-Network") == r && WithoutHeader(r, "Access-Network-Info") == r, "WithoutHeader: a name that is only part of a header's name takes nothing");
|
||||
const std::string twice = "BYE sip:a@b SIP/2.0\r\nP-Access-Network-Info: one\r\nCSeq: 2 BYE\r\nP-Access-Network-Info: two\r\n\r\n";
|
||||
Check(WithoutHeader(twice, "P-Access-Network-Info") == "BYE sip:a@b SIP/2.0\r\nCSeq: 2 BYE\r\n\r\n", "WithoutHeader: every line of the name, the last before the empty line too");
|
||||
Check(WithoutHeader("SIP/2.0 200 OK\r\nVia: x\r\nP-Access-Network-Info: v", "P-Access-Network-Info") == "SIP/2.0 200 OK\r\nVia: x\r\n", "WithoutHeader: a last line without its line end");
|
||||
Check(WithoutHeader("SIP/2.0 200 OK\r\nv: x\r\nTo: y\r\nVia: z\r\n\r\n", "Via") == "SIP/2.0 200 OK\r\nTo: y\r\n\r\n", "WithoutHeader: a header under its compact form goes as under its long one");
|
||||
}
|
||||
|
||||
if (Failures == 0) std::println("Sip: all tests passed");
|
||||
return Failures != 0; // not the count: `crafter-build test` takes an exit status of 77 for a skipped suite, and this suite has more checks than that
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue