sip: ResponseOf compares a response's CSeq as its number and its method
ResponseOf matched a response to a request by its Call-ID and by its CSeq compared as text. RFC 3261 25.1 writes the CSeq as 1*DIGIT LWS Method, so a response may part the two by a tab or by more than one space, and one written so was no transaction's: a REGISTER's wait ran out without a reply. CSeqParts takes a CSeq value as its number and its method: the digits it begins with, the spaces or tabs after them, the method to the value's end. ResponseOf compares the two as 20.16 has two CSeqs equal, "if the sequence number and the request method are identical": the number as a number — zeros before it do not make it another — and the method to the letter. A value of another shape matches nothing. Tested by tests/Sip: a final whose CSeq has two spaces, a tab or both between its parts, or zeros before its number, is the transaction's, and so is its 100 Trying; another number, another method, a method in other letter case, and a CSeq without its number, its method or the white space between them are not.
This commit is contained in:
parent
1267fe1ada
commit
78c702546a
3 changed files with 50 additions and 4 deletions
|
|
@ -355,6 +355,25 @@ int main() {
|
|||
Check(!ResponseOf("NOTIFY sip:x SIP/2.0\r\nCall-ID: 12345@host\r\nCSeq: 2 REGISTER\r\n\r\n", "12345@host", "2 REGISTER"), "a request is never a response");
|
||||
Check(!ResponseOf("", "12345@host", "2 REGISTER"), "nothing is not it");
|
||||
Check(ResponseOf("SIP/2.0 202 Accepted\r\nv: SIP/2.0/TCP [2001:db8::db43]:45062;branch=z9hG4bKx\r\ni: 12345@host\r\nCSeq: 1 MESSAGE\r\nl: 0\r\n\r\n", "12345@host", "1 MESSAGE"), "a final whose Call-ID comes as `i:` is the transaction's");
|
||||
// a provisional of the transaction is its response too: both REGISTER waits start over on one
|
||||
Check(ResponseOf("SIP/2.0 100 Trying\r\nCall-ID: 12345@host\r\nCSeq: 2 REGISTER\r\nContent-Length: 0\r\n\r\n", "12345@host", "2 REGISTER"), "the transaction's 100 Trying is its response");
|
||||
// the CSeq as its number and its method (RFC 3261 20.16: equal "if the sequence number and the request method are identical"; 25.1: 1*DIGIT LWS Method), whatever spaces or tabs part them
|
||||
auto finalWith = [](std::string_view cseq) { return std::format("SIP/2.0 202 Accepted\r\nCall-ID: 12345@host\r\nCSeq: {}\r\nContent-Length: 0\r\n\r\n", cseq); };
|
||||
Check(ResponseOf(finalWith("1 MESSAGE"), "12345@host", "1 MESSAGE"), "two spaces between the CSeq's number and its method: the transaction's");
|
||||
Check(ResponseOf(finalWith("1\tMESSAGE"), "12345@host", "1 MESSAGE"), "a tab between them: the transaction's");
|
||||
Check(ResponseOf(finalWith("1 \t MESSAGE"), "12345@host", "1 MESSAGE"), "spaces and a tab between them: the transaction's");
|
||||
Check(ResponseOf(finalWith("01 MESSAGE"), "12345@host", "1 MESSAGE") && ResponseOf(finalWith("1 MESSAGE"), "12345@host", "001 MESSAGE"), "zeros before the number do not make it another");
|
||||
Check(ResponseOf(finalWith("0 MESSAGE"), "12345@host", "00 MESSAGE") && !ResponseOf(finalWith("10 MESSAGE"), "12345@host", "1 MESSAGE"), "zero is zero however long, and a zero after the number counts");
|
||||
Check(ResponseOf(finalWith("1 MESSAGE"), "12345@host", " 1 MESSAGE "), "white space around the CSeq asked for is no part of it");
|
||||
Check(!ResponseOf(finalWith("11 MESSAGE"), "12345@host", "1 MESSAGE") && !ResponseOf(finalWith("1 MESSAGE"), "12345@host", "11 MESSAGE"), "another number that begins alike is not it");
|
||||
Check(!ResponseOf(finalWith("1 MESSAGES"), "12345@host", "1 MESSAGE") && !ResponseOf(finalWith("1 MESSAG"), "12345@host", "1 MESSAGE"), "another method that begins alike is not it");
|
||||
Check(!ResponseOf(finalWith("1 message"), "12345@host", "1 MESSAGE"), "a method is a case-sensitive token");
|
||||
Check(!ResponseOf(finalWith("1MESSAGE"), "12345@host", "1 MESSAGE"), "no white space between number and method: not a CSeq");
|
||||
Check(!ResponseOf(finalWith("1 "), "12345@host", "1 MESSAGE") && !ResponseOf(finalWith("1"), "12345@host", "1 MESSAGE"), "a CSeq without a method is not it");
|
||||
Check(!ResponseOf(finalWith("MESSAGE"), "12345@host", "1 MESSAGE") && !ResponseOf(finalWith(" MESSAGE"), "12345@host", "1 MESSAGE"), "a CSeq without a number is not it");
|
||||
Check(!ResponseOf("SIP/2.0 202 Accepted\r\nCall-ID: 12345@host\r\nContent-Length: 0\r\n\r\n", "12345@host", "1 MESSAGE"), "a final without a CSeq is not it");
|
||||
Check(!ResponseOf(finalWith("1 MESSAGE"), "12345@host", "MESSAGE"), "asked with a CSeq of another shape: nothing is it");
|
||||
Check(!ResponseOf(finalWith("MESSAGE"), "12345@host", "MESSAGE") && !ResponseOf(finalWith("1MESSAGE"), "12345@host", "1MESSAGE"), "two CSeqs of another shape are no match, alike or not");
|
||||
}
|
||||
|
||||
// ---- RegInfoContactState: our binding in a reg-event NOTIFY (RFC 3680)
|
||||
|
|
|
|||
Loading…
Reference in a new issue