engine, imsd: a submit report for a MESSAGE no longer in flight that this run sent in the last hour is answered 200
TS 24.341 5.3.1.2 has a submit report answered 200 when its In-Reply-To "indicates that the request corresponds to a short message submitted by the SM-over-IP sender" and 488 when it does not, and its NOTE 3 has the sender store the Call-ID for that. imsd knew only the Call-ID of the segment in flight (OwnsReport): a report that came once its message had ended — the 40 s wait run out — or once its segment was followed by the next was answered 488 like a stranger's, and its line said only "no MESSAGE of ours in flight" (issue #3, the first of its three cases). RecentSubmissions keeps the Call-ID of every MESSAGE a submission goes out in for an hour, with the message's id and the segment. A report In-Reply-To one of them that the message in flight does not take is answered 200, and the journal has `submit report (RP-ACK) In-Reply-To …: sms <id>'s segment i/n, no longer in flight; 200`, an RP-ERROR's with its cause. The 488 is left for an In-Reply-To that names no MESSAGE of ours on record, and its line says so ("on record" for "in flight"). A report without In-Reply-To that no message in flight takes by its RP-MR is answered 200 as before; its line ends `that no message in flight owns; 200` where it ended `for no message in flight; 200`. The bus is told nothing of a late report: the Messaging interface is frozen with `failed` as a message's last word (AGENTS.md §8.4), so a text the service centre took after its wait had run out stays `failed` there; the journal's line is the record of it. Tested by tests/Engine: the table (a Call-ID on record for 3600 s, the first of a list that is ours, each segment's MESSAGE put on record as it goes out) and OnSmsMessage (200 and the line for a report on a segment that was followed by the next, on a message that was sent and, with an RP-ERROR's cause, on one its wait had ended; 488 and its line for a stranger's). On the dev phone, with the binary of this range's last commit, no report came for a MESSAGE no longer in flight (the fp6 journal's 2026-11-20-issues-2-5 capture, phone-form6), so the 200 for one and its line have run in the suite alone.
This commit is contained in:
parent
710f884575
commit
ef04b473a7
4 changed files with 203 additions and 94 deletions
|
|
@ -37,7 +37,8 @@
|
|||
// delivery with no gateway for its report, a
|
||||
// delivered message to the bus and its RP-ACK to the IP-SM-GW with
|
||||
// In-Reply-To, a concatenated pair whole once, a status report, a submit
|
||||
// report routed to the message in flight, 488 for one that is not ours, an
|
||||
// report routed to the message in flight, 200 for one of ours no longer in
|
||||
// flight (RecentSubmissions), 488 for one that is not ours, an
|
||||
// unusable TPDU acknowledged with an RP-ERROR, a body that is no RP
|
||||
// message, a page-mode text 200'd and logged, a short message while SMS
|
||||
// over IP is off refused with 480, a delivered MESSAGE and a final whose
|
||||
|
|
@ -1331,11 +1332,12 @@ int main() {
|
|||
c.aor = "sip:+31611111111@ims.mnc001.mcc001.3gppnetwork.org";
|
||||
c.smsOverIp = true;
|
||||
const SmsOutbound::Params p{"+31612345678", "Hello", "sip:+31653131313@ims.mnc001.mcc001.3gppnetwork.org;user=phone", kpnSc, 10, 20, 0x2A, 0xA9, false};
|
||||
RecentSubmissions sub; // the MESSAGEs the messages below go out in; a check that needs an empty one makes its own
|
||||
|
||||
// a one-segment message: MESSAGE, 202, RP-ACK -> sent
|
||||
{
|
||||
imsd::util::Rng rng(71);
|
||||
SmsOutbound m(c, rng, "ims-sms-1", p);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-1", p);
|
||||
auto a = m.Start(100.0);
|
||||
const auto* sent = findSms(a, SmsAction::Type::SendClient);
|
||||
Check(sent && sent->text.starts_with("MESSAGE sip:+31653131313@ims.mnc001.mcc001.3gppnetwork.org;user=phone SIP/2.0\r\n"), "outbound: the MESSAGE goes to the SC's PSI");
|
||||
|
|
@ -1360,7 +1362,7 @@ int main() {
|
|||
// the final refuses it
|
||||
{
|
||||
imsd::util::Rng rng(72);
|
||||
SmsOutbound m(c, rng, "ims-sms-2", p);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-2", p);
|
||||
auto a = m.Start(0.0);
|
||||
const std::string callid(imsd::sip::Header(findSms(a, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
auto b = m.OnResponse(std::format("SIP/2.0 403 Forbidden\r\nCall-ID: {}\r\nCSeq: 1 MESSAGE\r\nWarning: 399 x \"no\"\r\nContent-Length: 0\r\n\r\n", callid), 403, 1.0);
|
||||
|
|
@ -1370,7 +1372,7 @@ int main() {
|
|||
// a provisional keeps it waiting; the RP-ERROR fails it with the cause
|
||||
{
|
||||
imsd::util::Rng rng(73);
|
||||
SmsOutbound m(c, rng, "ims-sms-3", p);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-3", p);
|
||||
auto a = m.Start(0.0);
|
||||
const std::string callid(imsd::sip::Header(findSms(a, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
m.OnResponse(final(callid, 100, "Trying"), 100, 5.0);
|
||||
|
|
@ -1384,13 +1386,13 @@ int main() {
|
|||
// timeouts and a failed send
|
||||
{
|
||||
imsd::util::Rng rng(74);
|
||||
SmsOutbound m(c, rng, "ims-sms-4", p);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-4", p);
|
||||
m.Start(0.0);
|
||||
auto a = m.OnDeadline();
|
||||
const auto* st = findSms(a, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason.contains("no answer to the MESSAGE"), "outbound: no final within the wait fails it");
|
||||
imsd::util::Rng rng2(75);
|
||||
SmsOutbound m2(c, rng2, "ims-sms-5", p);
|
||||
SmsOutbound m2(c, rng2, sub, "ims-sms-5", p);
|
||||
auto b = m2.Start(0.0);
|
||||
const std::string callid(imsd::sip::Header(findSms(b, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
m2.OnResponse(final(callid, 202, "Accepted"), 202, 1.0);
|
||||
|
|
@ -1398,7 +1400,7 @@ int main() {
|
|||
st = findSms(d, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason.contains("no submit report"), "outbound: no submit report within its wait fails it");
|
||||
imsd::util::Rng rng3(76);
|
||||
SmsOutbound m3(c, rng3, "ims-sms-6", p);
|
||||
SmsOutbound m3(c, rng3, sub, "ims-sms-6", p);
|
||||
m3.Start(0.0);
|
||||
auto e = m3.OnSendFailed();
|
||||
st = findSms(e, SmsAction::Type::State);
|
||||
|
|
@ -1409,7 +1411,7 @@ int main() {
|
|||
imsd::util::Rng rng(77);
|
||||
SmsOutbound::Params pl = p;
|
||||
pl.text = std::string(200, 'x');
|
||||
SmsOutbound m(c, rng, "ims-sms-7", pl);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-7", pl);
|
||||
auto a = m.Start(0.0);
|
||||
Check(m.Segments() == 2 && m.TpMrs() == std::vector<std::uint8_t>{10, 11}, "outbound: 200 characters are two segments with consecutive TP-MRs");
|
||||
const std::string callid(imsd::sip::Header(findSms(a, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
|
|
@ -1433,21 +1435,21 @@ int main() {
|
|||
imsd::util::Rng rng(78);
|
||||
SmsOutbound::Params bad = p;
|
||||
bad.number = "nobody";
|
||||
SmsOutbound m(c, rng, "ims-sms-8", bad);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-8", bad);
|
||||
auto a = m.Start(0.0);
|
||||
const auto* st = findSms(a, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason == "'nobody' is not a number" && m.Done() && !hasSms(a, SmsAction::Type::SendClient), "outbound: a destination that is no number fails at once");
|
||||
SmsOutbound::Params longNumber = p;
|
||||
longNumber.number = "+" + std::string(21, '3');
|
||||
imsd::util::Rng rngL(80);
|
||||
SmsOutbound mL(c, rngL, "ims-sms-10", longNumber);
|
||||
SmsOutbound mL(c, rngL, sub, "ims-sms-10", longNumber);
|
||||
auto l = mL.Start(0.0);
|
||||
st = findSms(l, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason.contains("is not a number") && !hasSms(l, SmsAction::Type::SendClient), "outbound: a destination of more than 20 digits is no number, not a text that does not fit");
|
||||
SmsOutbound::Params noSc = p;
|
||||
noSc.scAddress.clear();
|
||||
imsd::util::Rng rng2(79);
|
||||
SmsOutbound m2(c, rng2, "ims-sms-9", noSc);
|
||||
SmsOutbound m2(c, rng2, sub, "ims-sms-9", noSc);
|
||||
auto b = m2.Start(0.0);
|
||||
st = findSms(b, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason.contains("no service centre"), "outbound: no service centre fails at once");
|
||||
|
|
@ -1535,6 +1537,29 @@ int main() {
|
|||
Check(ReceivedSmsId("7f3a9c21", 42, 1) != ReceivedSmsId("0b1d2e3f", 42, 1) && SentSmsId("7f3a9c21", 42, 1) != SentSmsId("0b1d2e3f", 42, 1), "two runs with different tokens: their ids differ at the same second and counter");
|
||||
Check(ReceivedSmsId("ffffffff", std::numeric_limits<std::int64_t>::min(), std::numeric_limits<std::uint64_t>::max()).size() <= 64, "the longest received id is no longer than 64 bytes");
|
||||
}
|
||||
// the MESSAGEs our submissions went out in, on record for an hour each (the Call-ID TS 24.341 5.3.1.2 NOTE 3 has the sender store; the hour is imsd's)
|
||||
{
|
||||
RecentSubmissions book;
|
||||
Check(RecentSubmissions::Keep == 3600.0 && book.Size() == 0 && !book.Named("a@h", 0.0), "submissions: an empty table names nothing; a MESSAGE is kept 3600 s");
|
||||
book.Sent("a@h", "ims-sms-1", 1, 2, 100.0);
|
||||
book.Sent("b@h", "ims-sms-1", 2, 2, 105.0);
|
||||
const auto one = book.Named("a@h", 110.0);
|
||||
Check(one && one->id == "ims-sms-1" && one->segment == 1 && one->segments == 2 && book.Size() == 2, "submissions: a Call-ID on record gives its message and segment");
|
||||
const auto listed = book.Named(" x@y ,\tb@h , a@h", 110.0);
|
||||
Check(listed && listed->segment == 2, "submissions: of a list of Call-IDs, the first that is ours");
|
||||
Check(!book.Named("a@h2", 110.0) && !book.Named("", 110.0) && !book.Named("A@H", 110.0), "submissions: another Call-ID, an empty In-Reply-To and another letter case name none");
|
||||
Check(book.Named("a@h", 100.0 + 3600.0) && !book.Named("a@h", 100.0 + 3600.5) && book.Named("b@h", 100.0 + 3600.5) && book.Size() == 1, "submissions: on record 3600 s after the MESSAGE went out, no longer");
|
||||
book.Sent("c@h", "ims-sms-2", 1, 1, 105.0 + 3601.0);
|
||||
Check(book.Size() == 1 && !book.Named("b@h", 105.0 + 3601.0) && book.Named("c@h", 105.0 + 3601.0), "submissions: a new MESSAGE's entry clears those past their hour");
|
||||
// a message puts each MESSAGE it goes out in on record, with its segment
|
||||
imsd::util::Rng rng(93);
|
||||
SmsOutbound::Params two = p; two.text = std::string(200, 'A');
|
||||
SmsOutbound m(c, rng, book, "ims-sms-21", two);
|
||||
const std::string callid1(imsd::sip::Header(findSms(m.Start(4000.0), SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
const std::string callid2(imsd::sip::Header(findSms(m.OnReport(Rp{RpType::AckMt, 20, std::nullopt, {}, std::nullopt, std::nullopt}, 4001.0), SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
const auto first = book.Named(callid1, 4002.0), second = book.Named(callid2, 4002.0);
|
||||
Check(first && first->id == "ims-sms-21" && first->segment == 1 && first->segments == 2 && first->at == 4000.0 && second && second->segment == 2 && second->at == 4001.0, "submissions: each segment's MESSAGE goes on record as it goes out");
|
||||
}
|
||||
// inbound MESSAGEs, as the IP-SM-GW sends them
|
||||
auto inbound = [](std::string_view bodyHex, std::string_view extraHeaders = "") {
|
||||
auto b = *imsd::util::FromHex(bodyHex);
|
||||
|
|
@ -1544,7 +1569,7 @@ int main() {
|
|||
{
|
||||
imsd::util::Rng rng(80);
|
||||
Reassembler re;
|
||||
auto r = OnSmsMessage(c, rng, inbound("011107911356131313F3001E040B911346610089F60000208062917314080CC8F71D14969741F977FD07"), re, nullptr, 50.0);
|
||||
auto r = OnSmsMessage(c, rng, inbound("011107911356131313F3001E040B911346610089F60000208062917314080CC8F71D14969741F977FD07"), re, nullptr, sub, 50.0);
|
||||
Check(r.response.starts_with("SIP/2.0 200 OK\r\n") && r.response.contains("Call-ID: in-011107@net\r\n"), "inbound: the MESSAGE is answered 200");
|
||||
const auto* rec = findSms(r.actions, SmsAction::Type::Received);
|
||||
Check(rec && rec->received.from == "+31641600986" && rec->received.text == "How are you?" && rec->received.sc == "+31653131313" && rec->received.scts == "2002-08-26T19:37:41-00:00" && rec->received.segments == 1 && rec->received.tpdu.size() == 30, "inbound: the message reaches the bus");
|
||||
|
|
@ -1554,7 +1579,7 @@ int main() {
|
|||
Check(rep && imsd::sip::Body(rep->text) == std::string("\x02\x11\x41\x02\x00\x00", 6) && imsd::sip::Header(rep->text, "Call-ID") == r.reportCallId, "inbound: the report is an RP-ACK with the SMS-DELIVER-REPORT, RP-MR echoed");
|
||||
std::string other = inbound("011207911356131313F3001E040B911346610089F60000208062917314080CC8F71D14969741F977FD07");
|
||||
other.replace(other.find("From: <sip:ipsmgw@"), 18, "From: <sip:someone@");
|
||||
auto ro = OnSmsMessage(c, rng, other, re, nullptr, 51.0);
|
||||
auto ro = OnSmsMessage(c, rng, other, re, nullptr, sub, 51.0);
|
||||
const auto* repo = findSms(ro.actions, SmsAction::Type::SendClient);
|
||||
Check(repo && repo->text.starts_with("MESSAGE sip:ipsmgw@ims.mnc001.mcc001.3gppnetwork.org SIP/2.0\r\n"), "inbound: with a From that names another, the report still goes to the P-Asserted-Identity");
|
||||
}
|
||||
|
|
@ -1567,8 +1592,8 @@ int main() {
|
|||
Check(folded.contains("\r\nContent-Type:\r\n\tapplication/vnd.3gpp.sms\r\n") && framed == longForm, "folded MESSAGE: the datagram framer hands the long form's message on");
|
||||
imsd::util::Rng rng(80), rngLong(80);
|
||||
Reassembler re, reLong;
|
||||
auto r = OnSmsMessage(c, rng, framed.value_or(""), re, nullptr, 50.0);
|
||||
auto want = OnSmsMessage(c, rngLong, longForm, reLong, nullptr, 50.0);
|
||||
auto r = OnSmsMessage(c, rng, framed.value_or(""), re, nullptr, sub, 50.0);
|
||||
auto want = OnSmsMessage(c, rngLong, longForm, reLong, nullptr, sub, 50.0);
|
||||
const auto* rec = findSms(r.actions, SmsAction::Type::Received);
|
||||
Check(rec && rec->received.text == "How are you?" && r.response == want.response && hasSms(r.actions, SmsAction::Type::SendClient), "folded MESSAGE: taken for a short message, answered and reported on as its long form");
|
||||
}
|
||||
|
|
@ -1579,8 +1604,8 @@ int main() {
|
|||
Check(!compact.contains("Content-Type:") && !compact.contains("Call-ID:") && !compact.contains("Via:") && compact.contains("\r\nc: application/vnd.3gpp.sms\r\n") && compact.contains("\r\ni: in-011107@net\r\n") && compact.contains("\r\nv: SIP/2.0/TCP [2001:db8::105]:6000;branch=z9hG4bKn1\r\n") && compact.contains(std::format("\r\nl: {}\r\n", imsd::sip::Body(longForm).size())) && imsd::sip::Body(longForm).size() == 42 && imsd::sip::Body(compact) == imsd::sip::Body(longForm), "the compact MESSAGE carries `c:`, `i:`, `v:` and `l:`, the body of 42 bytes as it was");
|
||||
imsd::util::Rng rng(80), rngLong(80);
|
||||
Reassembler re, reLong;
|
||||
auto r = OnSmsMessage(c, rng, compact, re, nullptr, 50.0);
|
||||
auto want = OnSmsMessage(c, rngLong, longForm, reLong, nullptr, 50.0);
|
||||
auto r = OnSmsMessage(c, rng, compact, re, nullptr, sub, 50.0);
|
||||
auto want = OnSmsMessage(c, rngLong, longForm, reLong, nullptr, sub, 50.0);
|
||||
const auto* rec = findSms(r.actions, SmsAction::Type::Received);
|
||||
const auto* rep = findSms(r.actions, SmsAction::Type::SendClient);
|
||||
const auto* wantRep = findSms(want.actions, SmsAction::Type::SendClient);
|
||||
|
|
@ -1589,7 +1614,7 @@ int main() {
|
|||
Check(RecentTransactions::Key(compact) == "in-011107@net|1 MESSAGE|z9hG4bKn1" && RecentTransactions::Key(compact) == RecentTransactions::Key(longForm), "compact MESSAGE: the retransmission key from `i:` and `v:`");
|
||||
// the final to a MESSAGE of ours, its Call-ID as `i:`
|
||||
imsd::util::Rng rngOut(81);
|
||||
SmsOutbound m(c, rngOut, "ims-sms-20", p);
|
||||
SmsOutbound m(c, rngOut, sub, "ims-sms-20", p);
|
||||
const std::string callid(imsd::sip::Header(findSms(m.Start(0.0), SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
const std::string final202 = Compact(final(callid, 202, "Accepted"));
|
||||
Check(final202.contains(std::format("\r\ni: {}\r\n", callid)) && !final202.contains("Call-ID:") && m.OwnsResponse(final202), "outbound: a final whose Call-ID comes as `i:` is the message in flight's");
|
||||
|
|
@ -1601,7 +1626,7 @@ int main() {
|
|||
Reassembler re;
|
||||
std::string req = inbound("011107911356131313F3001E040B911346610089F60000208062917314080CC8F71D14969741F977FD07");
|
||||
req.replace(req.find("in-011107@net"), 13, std::string("in-0111") + static_cast<char>(b) + "Route:x@net");
|
||||
auto r = OnSmsMessage(c, rng, req, re, nullptr, 52.0);
|
||||
auto r = OnSmsMessage(c, rng, req, re, nullptr, sub, 52.0);
|
||||
const auto* rep = findSms(r.actions, SmsAction::Type::SendClient);
|
||||
Check(rep && hasSms(r.actions, SmsAction::Type::Received) && !rep->text.contains("In-Reply-To") && !rep->text.contains("Route:x") && imsd::sip::Body(rep->text) == std::string("\x02\x11\x41\x02\x00\x00", 6), std::format("inbound: a Call-ID with the byte 0x{:02x} in it is not written into the delivery report's In-Reply-To", b));
|
||||
}
|
||||
|
|
@ -1609,11 +1634,11 @@ int main() {
|
|||
for (bool first : {true, false}) {
|
||||
imsd::util::Rng rng(92);
|
||||
Reassembler re;
|
||||
SmsOutbound m(c, rng, "ims-sms-19", p);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-19", p);
|
||||
auto a = m.Start(0.0);
|
||||
const std::string callid(imsd::sip::Header(findSms(a, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
m.OnResponse(final(callid, 202, "Accepted"), 202, 1.0);
|
||||
auto r = OnSmsMessage(c, rng, inbound("0314", first ? std::format("In-Reply-To: {}\r\nIn-Reply-To: x@y\r\n", callid) : std::format("In-Reply-To: x@y\r\nIn-Reply-To: {}\r\n", callid)), re, &m, 2.0);
|
||||
auto r = OnSmsMessage(c, rng, inbound("0314", first ? std::format("In-Reply-To: {}\r\nIn-Reply-To: x@y\r\n", callid) : std::format("In-Reply-To: x@y\r\nIn-Reply-To: {}\r\n", callid)), re, &m, sub, 2.0);
|
||||
const auto* st = findSms(r.actions, SmsAction::Type::State);
|
||||
Check(r.response.starts_with("SIP/2.0 200 OK") && st && st->state == "sent" && m.Done(), std::format("inbound: a submit report whose In-Reply-To rows list ours in the {} reaches the message in flight", first ? "first" : "second"));
|
||||
}
|
||||
|
|
@ -1624,7 +1649,7 @@ int main() {
|
|||
std::string req = inbound("011107911356131313F30035040B911346610089F6000420806291731408220A502D41737365727465642D4964656E746974793A203C7369703A6576696C40783E");
|
||||
const auto pai = req.find("P-Asserted-Identity:"); // without the header, a body line would be the first match
|
||||
if (pai != std::string::npos) req.erase(pai, req.find("\r\n", pai) + 2 - pai);
|
||||
auto r = OnSmsMessage(c, rng, req, re, nullptr, 52.0);
|
||||
auto r = OnSmsMessage(c, rng, req, re, nullptr, sub, 52.0);
|
||||
const auto* rec = findSms(r.actions, SmsAction::Type::Received);
|
||||
const auto* rep = findSms(r.actions, SmsAction::Type::SendClient);
|
||||
Check(rec && rec->received.data.size() == 34 && rep && rep->text.starts_with("MESSAGE sip:ipsmgw@ims.mnc001.mcc001.3gppnetwork.org SIP/2.0\r\n") && !rep->text.contains("evil"), "inbound: a header name in the body picks neither the report's target nor anything else");
|
||||
|
|
@ -1633,10 +1658,10 @@ int main() {
|
|||
{
|
||||
imsd::util::Rng rng(81);
|
||||
Reassembler re;
|
||||
auto r2 = OnSmsMessage(c, rng, inbound("011207911356131313F3001E440B911316325476F80000620161220500800C0500037B02028442A15008"), re, nullptr, 60.0);
|
||||
auto r2 = OnSmsMessage(c, rng, inbound("011207911356131313F3001E440B911316325476F80000620161220500800C0500037B02028442A15008"), re, nullptr, sub, 60.0);
|
||||
Check(!hasSms(r2.actions, SmsAction::Type::Received) && hasSms(r2.actions, SmsAction::Type::SendClient) && re.Pending() == 1, "inbound: segment 2/2 first: acknowledged, nothing to the bus yet");
|
||||
const std::string seg1 = "440B911316325476F8000062016122050080A00500037B020182C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683C16030180C0683";
|
||||
auto r1 = OnSmsMessage(c, rng, inbound(std::format("011307911356131313F300{:02X}{}", seg1.size() / 2, seg1)), re, nullptr, 61.0);
|
||||
auto r1 = OnSmsMessage(c, rng, inbound(std::format("011307911356131313F300{:02X}{}", seg1.size() / 2, seg1)), re, nullptr, sub, 61.0);
|
||||
const auto* rec = findSms(r1.actions, SmsAction::Type::Received);
|
||||
Check(rec && rec->received.text == std::string(153, 'A') + "BBBBB" && rec->received.segments == 2 && re.Pending() == 0, "inbound: segment 1/2 completes the message");
|
||||
Check(hasSms(r1.actions, SmsAction::Type::SendClient), "inbound: segment 1/2 acknowledged too");
|
||||
|
|
@ -1648,8 +1673,8 @@ int main() {
|
|||
Reassembler re;
|
||||
const std::string u1 = "440B911316325476F80008620161220500808C0500032A0201" + rep("00FC", 66) + "D83D";
|
||||
const std::string u2 = "440B911316325476F8000862016122050080100500032A0202DE00" + rep("0078", 4);
|
||||
auto a1 = OnSmsMessage(c, rng, inbound(std::format("011407911356131313F300{:02X}{}", u1.size() / 2, u1)), re, nullptr, 62.0);
|
||||
auto a2 = OnSmsMessage(c, rng, inbound(std::format("011507911356131313F300{:02X}{}", u2.size() / 2, u2)), re, nullptr, 63.0);
|
||||
auto a1 = OnSmsMessage(c, rng, inbound(std::format("011407911356131313F300{:02X}{}", u1.size() / 2, u1)), re, nullptr, sub, 62.0);
|
||||
auto a2 = OnSmsMessage(c, rng, inbound(std::format("011507911356131313F300{:02X}{}", u2.size() / 2, u2)), re, nullptr, sub, 63.0);
|
||||
const auto* w = findSms(a2.actions, SmsAction::Type::Received);
|
||||
Check(!hasSms(a1.actions, SmsAction::Type::Received) && w && w->received.text == rep("ü", 66) + "😀xxxx" && w->received.segments == 2 && re.Pending() == 0, "inbound: a surrogate pair split across segments reaches the bus whole");
|
||||
}
|
||||
|
|
@ -1657,7 +1682,7 @@ int main() {
|
|||
{
|
||||
imsd::util::Rng rng(82);
|
||||
Reassembler re;
|
||||
auto r = OnSmsMessage(c, rng, inbound("011207911356131313F30019062A0B911316325476F8620161220500806201612205708000"), re, nullptr, 70.0);
|
||||
auto r = OnSmsMessage(c, rng, inbound("011207911356131313F30019062A0B911316325476F8620161220500806201612205708000"), re, nullptr, sub, 70.0);
|
||||
const auto* sr = findSms(r.actions, SmsAction::Type::StatusReport);
|
||||
Check(sr && sr->report.mr == 0x2A && sr->report.status == 0 && !hasSms(r.actions, SmsAction::Type::Received) && hasSms(r.actions, SmsAction::Type::SendClient), "inbound: a status report is handed over and acknowledged");
|
||||
}
|
||||
|
|
@ -1665,11 +1690,11 @@ int main() {
|
|||
{
|
||||
imsd::util::Rng rng(84);
|
||||
Reassembler re;
|
||||
SmsOutbound m(c, rng, "ims-sms-11", p);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-11", p);
|
||||
auto a = m.Start(0.0);
|
||||
const std::string callid(imsd::sip::Header(findSms(a, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
Check(m.State() == SmsOutbound::Phase::Sending && m.OwnsReport(callid, std::nullopt), "outbound: a report is owned while the MESSAGE's final is still due");
|
||||
auto r = OnSmsMessage(c, rng, inbound("0314", std::format("In-Reply-To: {}\r\n", callid)), re, &m, 1.0);
|
||||
auto r = OnSmsMessage(c, rng, inbound("0314", std::format("In-Reply-To: {}\r\n", callid)), re, &m, sub, 1.0);
|
||||
const auto* st = findSms(r.actions, SmsAction::Type::State);
|
||||
Check(r.response.starts_with("SIP/2.0 200 OK") && st && st->state == "sent" && m.Done() && !m.OwnsResponse(final(callid, 202, "Accepted")), "outbound: the early RP-ACK ends the message as sent; the late 202 is nobody's");
|
||||
}
|
||||
|
|
@ -1678,22 +1703,23 @@ int main() {
|
|||
imsd::util::Rng rng(85);
|
||||
Reassembler re;
|
||||
SmsOutbound::Params two = p; two.text = std::string(200, 'A');
|
||||
SmsOutbound m(c, rng, "ims-sms-12", two);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-12", two);
|
||||
auto a = m.Start(0.0);
|
||||
const std::string callid1(imsd::sip::Header(findSms(a, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
auto r = OnSmsMessage(c, rng, inbound("0314", std::format("In-Reply-To: {}\r\n", callid1)), re, &m, 1.0);
|
||||
auto r = OnSmsMessage(c, rng, inbound("0314", std::format("In-Reply-To: {}\r\n", callid1)), re, &m, sub, 1.0);
|
||||
const auto* seg2 = findSms(r.actions, SmsAction::Type::SendClient);
|
||||
const std::string callid2 = seg2 ? std::string(imsd::sip::Header(seg2->text, "Call-ID").value_or("")) : std::string();
|
||||
Check(seg2 && !callid2.empty() && callid2 != callid1 && m.State() == SmsOutbound::Phase::Sending && !m.OwnsResponse(final(callid1, 202, "Accepted")) && m.OwnsResponse(final(callid2, 202, "Accepted")), "outbound: segment 1's early RP-ACK sends segment 2 under its own Call-ID; segment 1's late 202 is nobody's");
|
||||
// a second report for segment 1 once segment 2 is out: 488, the message untouched
|
||||
auto rs = OnSmsMessage(c, rng, inbound("0314", std::format("In-Reply-To: {}\r\n", callid1)), re, &m, 2.0);
|
||||
Check(rs.response.starts_with("SIP/2.0 488 Not Acceptable Here\r\n") && m.State() == SmsOutbound::Phase::Sending && m.OwnsResponse(final(callid2, 202, "Accepted")), "inbound: a report for segment 1 after segment 2 went out: 488, the message untouched");
|
||||
// a second report for segment 1 once segment 2 is out: ours on record, so 200 and the journal, the message untouched
|
||||
auto rs = OnSmsMessage(c, rng, inbound("0314", std::format("In-Reply-To: {}\r\n", callid1)), re, &m, sub, 2.0);
|
||||
const auto* late = findSms(rs.actions, SmsAction::Type::Log);
|
||||
Check(rs.response.starts_with("SIP/2.0 200 OK\r\n") && rs.actions.size() == 1 && late && late->text == std::format("submit report (RP-ACK) In-Reply-To {}: sms ims-sms-12's segment 1/2, no longer in flight; 200", callid1) && m.State() == SmsOutbound::Phase::Sending && m.OwnsResponse(final(callid2, 202, "Accepted")), "inbound: a report for segment 1 after segment 2 went out: 200 and its line, the message untouched");
|
||||
}
|
||||
// a text past 255 segments to a valid number: failed at once, naming the fit
|
||||
{
|
||||
imsd::util::Rng rng(86);
|
||||
SmsOutbound::Params big = p; big.text = std::string(255 * 153 + 1, 'A');
|
||||
SmsOutbound m(c, rng, "ims-sms-13", big);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-13", big);
|
||||
auto a = m.Start(0.0);
|
||||
const auto* st = findSms(a, SmsAction::Type::State);
|
||||
Check(st && st->state == "failed" && st->reason.contains("does not fit 255 segments") && m.Done() && !hasSms(a, SmsAction::Type::SendClient), "outbound: a text past 255 segments fails at once, naming the fit");
|
||||
|
|
@ -1709,7 +1735,7 @@ int main() {
|
|||
if (i == std::string::npos || j == std::string::npos) return 1;
|
||||
msg.erase(i, pai.size());
|
||||
msg.replace(msg.find(from), from.size(), "From: anonymous;tag=N1");
|
||||
auto r = OnSmsMessage(c, rng, msg, re, nullptr, 51.0);
|
||||
auto r = OnSmsMessage(c, rng, msg, re, nullptr, sub, 51.0);
|
||||
bool said = false;
|
||||
for (const auto& x : r.actions) if (x.type == SmsAction::Type::Log && x.text.contains("no P-Asserted-Identity or From URI")) said = true;
|
||||
Check(r.response.starts_with("SIP/2.0 200 OK") && hasSms(r.actions, SmsAction::Type::Received) && !hasSms(r.actions, SmsAction::Type::SendClient) && r.reportCallId.empty() && said, "inbound: no gateway for the delivery report — the message handed over, the absence logged");
|
||||
|
|
@ -1718,11 +1744,11 @@ int main() {
|
|||
{
|
||||
imsd::util::Rng rng(88);
|
||||
Reassembler re;
|
||||
SmsOutbound m(c, rng, "ims-sms-14", p);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-14", p);
|
||||
auto a = m.Start(0.0);
|
||||
const std::string callid(imsd::sip::Header(findSms(a, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
m.OnResponse(final(callid, 202, "Accepted"), 202, 1.0);
|
||||
auto r = OnSmsMessage(c, rng, inbound("0314"), re, &m, 2.0);
|
||||
auto r = OnSmsMessage(c, rng, inbound("0314"), re, &m, sub, 2.0);
|
||||
const auto* st = findSms(r.actions, SmsAction::Type::State);
|
||||
Check(r.response.starts_with("SIP/2.0 200 OK") && st && st->state == "sent" && m.Done() && r.reportCallId.empty(), "inbound: a submit report without In-Reply-To reaches the message in flight by RP-MR");
|
||||
}
|
||||
|
|
@ -1730,46 +1756,48 @@ int main() {
|
|||
{
|
||||
imsd::util::Rng rng(83);
|
||||
Reassembler re;
|
||||
SmsOutbound m(c, rng, "ims-sms-10", p);
|
||||
SmsOutbound m(c, rng, sub, "ims-sms-10", p);
|
||||
auto a = m.Start(0.0);
|
||||
const std::string callid(imsd::sip::Header(findSms(a, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
m.OnResponse(final(callid, 202, "Accepted"), 202, 1.0);
|
||||
auto r = OnSmsMessage(c, rng, inbound("0314", std::format("In-Reply-To: {}\r\n", callid)), re, &m, 2.0);
|
||||
auto r = OnSmsMessage(c, rng, inbound("0314", std::format("In-Reply-To: {}\r\n", callid)), re, &m, sub, 2.0);
|
||||
const auto* st = findSms(r.actions, SmsAction::Type::State);
|
||||
Check(r.response.starts_with("SIP/2.0 200 OK") && st && st->state == "sent" && m.Done() && r.reportCallId.empty(), "inbound: the submit report reaches the message in flight and is answered 200");
|
||||
auto r2 = OnSmsMessage(c, rng, inbound("0314", "In-Reply-To: nobody@x\r\n"), re, &m, 3.0);
|
||||
Check(r2.response.starts_with("SIP/2.0 488 Not Acceptable Here\r\n") && hasSms(r2.actions, SmsAction::Type::Log), "inbound: a report In-Reply-To a MESSAGE that is not ours: 488");
|
||||
// a report for our own MESSAGE once the message has ended (here: sent): 488, as for a stranger's
|
||||
auto r4 = OnSmsMessage(c, rng, inbound("0314", std::format("In-Reply-To: {}\r\n", callid)), re, &m, 3.5);
|
||||
Check(r4.response.starts_with("SIP/2.0 488 Not Acceptable Here\r\n") && hasSms(r4.actions, SmsAction::Type::Log), "inbound: a report for our own MESSAGE after the message ended: 488");
|
||||
// and once the report's wait ended it (OnDeadline): 488 too
|
||||
SmsOutbound m3(c, rng, "ims-sms-13", p);
|
||||
auto r2 = OnSmsMessage(c, rng, inbound("0314", "In-Reply-To: nobody@x\r\n"), re, &m, sub, 3.0);
|
||||
Check(r2.response.starts_with("SIP/2.0 488 Not Acceptable Here\r\n") && r2.actions.size() == 1 && findSms(r2.actions, SmsAction::Type::Log) && findSms(r2.actions, SmsAction::Type::Log)->text == "submit report (RP-ACK) In-Reply-To nobody@x: no MESSAGE of ours on record; 488", "inbound: a report In-Reply-To a MESSAGE that is not ours: 488 and its line");
|
||||
// a report for our own MESSAGE once the message has ended (here: sent): 200, nothing but the journal's line — a stranger's got 488 above
|
||||
auto r4 = OnSmsMessage(c, rng, inbound("0314", std::format("In-Reply-To: {}\r\n", callid)), re, &m, sub, 3.5);
|
||||
const auto* l4 = findSms(r4.actions, SmsAction::Type::Log);
|
||||
Check(r4.response.starts_with("SIP/2.0 200 OK\r\n") && r4.actions.size() == 1 && l4 && l4->text == std::format("submit report (RP-ACK) In-Reply-To {}: sms ims-sms-10's segment 1/1, no longer in flight; 200", callid), "inbound: a report for our own MESSAGE after the message ended: 200 and its line, nothing to the bus");
|
||||
// and once the report's wait ended it (OnDeadline), an RP-ERROR that comes after: 200, its cause in the line
|
||||
SmsOutbound m3(c, rng, sub, "ims-sms-13", p);
|
||||
auto a3 = m3.Start(10.0);
|
||||
const std::string callid3(imsd::sip::Header(findSms(a3, SmsAction::Type::SendClient)->text, "Call-ID").value_or(""));
|
||||
m3.OnResponse(final(callid3, 202, "Accepted"), 202, 11.0);
|
||||
m3.OnDeadline();
|
||||
auto r5 = OnSmsMessage(c, rng, inbound("0314", std::format("In-Reply-To: {}\r\n", callid3)), re, &m3, 60.0);
|
||||
Check(m3.Done() && r5.response.starts_with("SIP/2.0 488 Not Acceptable Here\r\n"), "inbound: a report for our own MESSAGE after its wait ended it: 488");
|
||||
auto r3 = OnSmsMessage(c, rng, inbound("0314"), re, nullptr, 4.0);
|
||||
auto r5 = OnSmsMessage(c, rng, inbound("05140126410A01C30062016122050080", std::format("In-Reply-To: {}\r\n", callid3)), re, &m3, sub, 60.0);
|
||||
const auto* l5 = findSms(r5.actions, SmsAction::Type::Log);
|
||||
Check(m3.Done() && r5.response.starts_with("SIP/2.0 200 OK\r\n") && r5.actions.size() == 1 && l5 && l5->text == std::format("submit report (RP-ERROR, RP cause 38 (network out of order), TP-FCS 0xc3 (invalid SME address)) In-Reply-To {}: sms ims-sms-13's segment 1/1, no longer in flight; 200", callid3), "inbound: an RP-ERROR for our own MESSAGE after its wait ended the message: 200, its cause and TP-FCS in the line");
|
||||
auto r3 = OnSmsMessage(c, rng, inbound("0314"), re, nullptr, sub, 4.0);
|
||||
Check(r3.response.starts_with("SIP/2.0 200 OK") && hasSms(r3.actions, SmsAction::Type::Log) && !hasSms(r3.actions, SmsAction::Type::SendClient), "inbound: a report without In-Reply-To for no message: 200 and the log");
|
||||
}
|
||||
// an unusable TPDU, a body that is no RP message, another content type
|
||||
{
|
||||
imsd::util::Rng rng(84);
|
||||
Reassembler re;
|
||||
auto r = OnSmsMessage(c, rng, inbound("011507911356131313F30002FFFF"), re, nullptr, 5.0);
|
||||
auto r = OnSmsMessage(c, rng, inbound("011507911356131313F30002FFFF"), re, nullptr, sub, 5.0);
|
||||
const auto* rep = findSms(r.actions, SmsAction::Type::SendClient);
|
||||
Check(r.response.starts_with("SIP/2.0 200 OK") && rep && imsd::sip::Body(rep->text) == std::string("\x04\x15\x01\x60\x41\x03\x00\xB0\x00", 9) && !hasSms(r.actions, SmsAction::Type::Received), "inbound: an unusable TPDU is acknowledged with an RP-ERROR (cause 96, TP-FCS B0)");
|
||||
auto rs = OnSmsMessage(c, rng, inbound("011607911356131313F3000102"), re, nullptr, 5.2);
|
||||
auto rs = OnSmsMessage(c, rng, inbound("011607911356131313F3000102"), re, nullptr, sub, 5.2);
|
||||
const auto* reps = findSms(rs.actions, SmsAction::Type::SendClient);
|
||||
Check(rs.response.starts_with("SIP/2.0 200 OK") && reps && imsd::sip::Body(reps->text) == std::string("\x04\x16\x01\x60\x41\x03\x00\xB0\x00", 9) && !hasSms(rs.actions, SmsAction::Type::StatusReport), "inbound: a status report that does not parse gets the same RP-ERROR");
|
||||
auto rt = OnSmsMessage(c, rng, inbound("011707911356131313F300020100"), re, nullptr, 5.4);
|
||||
auto rt = OnSmsMessage(c, rng, inbound("011707911356131313F300020100"), re, nullptr, sub, 5.4);
|
||||
const auto* rept = findSms(rt.actions, SmsAction::Type::SendClient);
|
||||
Check(rt.response.starts_with("SIP/2.0 200 OK") && rept && imsd::sip::Body(rept->text) == std::string("\x04\x17\x01\x60\x41\x03\x00\xB0\x00", 9) && !hasSms(rt.actions, SmsAction::Type::Received), "inbound: a TPDU of the submit-report type gets the same RP-ERROR");
|
||||
auto r2 = OnSmsMessage(c, rng, inbound("07"), re, nullptr, 6.0);
|
||||
auto r2 = OnSmsMessage(c, rng, inbound("07"), re, nullptr, sub, 6.0);
|
||||
Check(r2.response.starts_with("SIP/2.0 200 OK") && !r2.rp && hasSms(r2.actions, SmsAction::Type::Log) && !hasSms(r2.actions, SmsAction::Type::SendClient), "inbound: a body that is no RP message: 200 and the log");
|
||||
const std::string plain = "MESSAGE sip:me@ims SIP/2.0\r\nVia: SIP/2.0/TCP [2001:db8::105]:6000;branch=z9hG4bKn2\r\nFrom: <sip:x@ims>;tag=1\r\nTo: <sip:me@ims>\r\nCall-ID: t1@net\r\nCSeq: 1 MESSAGE\r\nContent-Type: text/plain\r\nContent-Length: 2\r\n\r\nhi";
|
||||
auto r3 = OnSmsMessage(c, rng, plain, re, nullptr, 7.0);
|
||||
auto r3 = OnSmsMessage(c, rng, plain, re, nullptr, sub, 7.0);
|
||||
Check(r3.response.starts_with("SIP/2.0 200 OK") && !r3.rp && hasSms(r3.actions, SmsAction::Type::Log) && findSms(r3.actions, SmsAction::Type::Log)->text.contains("hi"), "inbound: a page-mode text is 200'd and logged with its body");
|
||||
}
|
||||
// the store's record codec
|
||||
|
|
@ -1831,15 +1859,15 @@ int main() {
|
|||
off.aor = c.aor;
|
||||
const std::string_view offeredHex = "011107911356131313F3001E040B911346610089F60000208062917314080CC8F71D14969741F977FD07";
|
||||
const std::string offered = inbound(offeredHex);
|
||||
auto r = OnSmsMessage(off, rng, offered, re, nullptr, 8.0);
|
||||
auto r = OnSmsMessage(off, rng, offered, re, nullptr, sub, 8.0);
|
||||
Check(r.response.starts_with("SIP/2.0 480 Temporarily Unavailable\r\n") && r.response.contains("Call-ID: in-011107@net\r\n"), "off: a short message is refused with 480");
|
||||
Check(!hasSms(r.actions, SmsAction::Type::Received) && !hasSms(r.actions, SmsAction::Type::SendClient) && r.reportCallId.empty() && !r.rp && re.Pending() == 0, "off: nothing to the bus, no delivery report, nothing parsed");
|
||||
const auto* log = findSms(r.actions, SmsAction::Type::Log);
|
||||
Check(log && log->text.ends_with("while SMS_OVER_IMS is off: 480") && !log->text.contains("How are you") && !log->text.contains(std::string_view(offered).substr(offered.find("\r\n\r\n") + 4)) && !log->text.contains(imsd::util::ToHex(*imsd::util::FromHex(offeredHex))), "off: logged with a line that ends at the 480, without the text, the body or its hex");
|
||||
const std::string plain = "MESSAGE sip:me@ims SIP/2.0\r\nVia: SIP/2.0/TCP [2001:db8::105]:6000;branch=z9hG4bKn3\r\nFrom: <sip:x@ims>;tag=1\r\nTo: <sip:me@ims>\r\nCall-ID: t2@net\r\nCSeq: 1 MESSAGE\r\nContent-Type: text/plain\r\nContent-Length: 2\r\n\r\nhi";
|
||||
auto r2 = OnSmsMessage(off, rng, plain, re, nullptr, 9.0);
|
||||
auto r2 = OnSmsMessage(off, rng, plain, re, nullptr, sub, 9.0);
|
||||
Check(r2.response.starts_with("SIP/2.0 200 OK") && hasSms(r2.actions, SmsAction::Type::Log), "off: a page-mode text is still 200'd and logged");
|
||||
auto r3 = OnSmsMessage(off, rng, Compact(offered), re, nullptr, 9.5);
|
||||
auto r3 = OnSmsMessage(off, rng, Compact(offered), re, nullptr, sub, 9.5);
|
||||
Check(r3.response.starts_with("SIP/2.0 480 Temporarily Unavailable\r\n") && r3.response.contains("\r\nCall-ID: in-011107@net\r\n") && !r3.rp, "off: a short message whose content type comes as `c:` is refused with 480 too");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue