📄 testsipmessage.cxx
字号:
i != message->header(h_Vias).end(); i++)
{
i->param(p_branch).encode(cerr);
cerr << endl;
}
}
{
char* txt = ("SIP/2.0 200 OK""\r\n"
"From: 1245<sip:4000@193.12.63.124:5060>;tag=7c3f0cc1-13c4-3e5a380c-1ac5646-257e""\r\n"
"To: prolab<sip:5000@host2.sipdragon.sipit.net>;tag=7c3f0cc1-13c5-3e5a380d-1ac5827-618f""\r\n"
"Call-ID: 9e9017c-7c3f0cc1-13c4-3e5a380c-1ac5646-3700@193.12.63.124""\r\n"
"CSeq: 1 INVITE""\r\n"
"Via: SIP/2.0/UDP host2.sipdragon.sipit.net;received=193.12.62.209;branch=z9hG4bK" RESIP_COOKIE "-3e5a380c-1ac5646-adf" RESIP_COOKIE "1-1""\r\n"
"Via: SIP/2.0/UDP 193.12.63.124:5060;received=193.12.63.124;branch=z9hG4bK-3e5a380c-1ac5646-adf""\r\n"
"Contact: <sip:5000@193.12.63.124:5061>""\r\n"
"Record-Route: <sip:proxy@host2.sipdragon.sipit.net:5060;lr>""\r\n"
"Content-Length:0\r\n\r\n");
auto_ptr<SipMessage> message(TestSupport::makeMessage(txt));
cerr << *message << endl;
message->header(h_Vias).front();
message->header(h_From);
message->header(h_To);
cerr << message->header(h_Vias).front() << endl;
cerr << message->header(h_Vias).back() << endl;
cerr << message->header(h_Vias).front().param(p_branch).getTransactionId() << endl;
cerr << message->header(h_Vias).back().param(p_branch).getTransactionId() << endl;
}
{
char *txt = ("To: <sip:106@kelowna.gloo.net>"
"From: <sip:106@kelowna.gloo.net>;tag=18c7b33a-430c-429c-9f46-e5b509264519\r\n"
"Via: SIP/2.0/UDP 192.168.2.15:10276;received=192.168.2.15\r\n"
"Call-ID: cb15283c-6efb-452e-aef2-5e44e02e2440@192.168.2.15\r\n"
"CSeq: 2 REGISTER\r\n"
"Contact: <sip:192.168.2.15:10276>;xmethods=\"INVITE, MESSAGE, INFO, SUBSCRIBE, OPTIONS, BYE, CANCEL, NOTIFY, ACK\"\r\n"
"Expires: 0\r\n"
"User-Agent: Windows RTC/1.0\r\n"
"Content-Length: 0\r\n"
"\r\n");
auto_ptr<SipMessage> message(TestSupport::makeMessage(txt));
cerr << message->header(h_Contacts).front().param(UnknownParameterType("xmethods")) << endl;
cerr << *message << endl;
}
{
Data txt1("INVITE sip:bob@biloxi.com SIP/2.0\r\n"
"Via: SIP/2.0/UDP pc33.atlanta.com\r\n"
"To: Bob <sip:bob@biloxi.com>\r\n"
"From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
"Call-ID: a84b4c76e66710\r\n"
"CSeq: 314159 INVITE\r\n"
"Max-Forwards: 70\r\n"
"Foobie-Blech: it is not a glass paperweight\r\n"
"Contact: <sip:alice@pc33.atlanta.com>\r\n"
"Content-Length: 0\r\n"
"\r\n");
Data txt2("INVITE sip:joe@biloxi.com SIP/2.0\r\n"
"Via: SIP/2.0/UDP pc33.atlanta.com\r\n"
"To: Bob <sip:bob@biloxi.com>\r\n"
"From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
"Call-ID: a84b4c76e66710\r\n"
"CSeq: 314159 INVITE\r\n"
"Max-Forwards: 70\r\n"
"Foobie-Blech: it is not a glass paperweight\r\n"
"Contact: <sip:alice@pc33.atlanta.com>\r\n"
"Content-Length: 0\r\n"
"\r\n");
Data txt3("INVITE sip:bob@biloxi.com;user=phone SIP/2.0\r\n"
"Via: SIP/2.0/UDP pc33.atlanta.com\r\n"
"To: Bob <sip:bob@biloxi.com>\r\n"
"From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
"Call-ID: a84b4c76e66710\r\n"
"CSeq: 314159 INVITE\r\n"
"Max-Forwards: 70\r\n"
"Foobie-Blech: it is not a glass paperweight\r\n"
"Contact: <sip:alice@pc33.atlanta.com>\r\n"
"Content-Length: 0\r\n"
"\r\n");
Data txt4("INVITE sip:bob@biloxi.com;user=phone;lr SIP/2.0\r\n"
"Via: SIP/2.0/UDP pc33.atlanta.com\r\n"
"To: Bob <sip:bob@biloxi.com>\r\n"
"From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
"Call-ID: a84b4c76e66710\r\n"
"CSeq: 314159 INVITE\r\n"
"Max-Forwards: 70\r\n"
"Foobie-Blech: it is not a glass paperweight\r\n"
"Contact: <sip:alice@pc33.atlanta.com>\r\n"
"Content-Length: 0\r\n"
"\r\n");
Data txt5("INVITE sip:bob@biloxi.com;user=phone;lr;maddr=192.168.1.1 SIP/2.0\r\n"
"Via: SIP/2.0/UDP pc33.atlanta.com\r\n"
"To: Bob <sip:bob@biloxi.com>\r\n"
"From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
"Call-ID: a84b4c76e66710\r\n"
"CSeq: 314159 INVITE\r\n"
"Max-Forwards: 70\r\n"
"Foobie-Blech: it is not a glass paperweight\r\n"
"Contact: <sip:alice@pc33.atlanta.com>\r\n"
"Content-Length: 0\r\n"
"\r\n");
Data txt6("INVITE sip:bob@biloxi.com;maddr=192.168.1.1;user=phone SIP/2.0\r\n"
"Via: SIP/2.0/UDP pc33.atlanta.com\r\n"
"To: Bob <sip:bob@biloxi.com>\r\n"
"From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
"Call-ID: a84b4c76e66710\r\n"
"CSeq: 314159 INVITE\r\n"
"Max-Forwards: 70\r\n"
"Foobie-Blech: it is not a glass paperweight\r\n"
"Contact: <sip:alice@pc33.atlanta.com>\r\n"
"Content-Length: 0\r\n"
"\r\n");
Data txt7("INVITE sip:bob@biloxi.com;maddr=192.168.1.1;user=phone;jason=foo SIP/2.0\r\n"
"Via: SIP/2.0/UDP pc33.atlanta.com\r\n"
"To: Bob <sip:bob@biloxi.com>\r\n"
"From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
"Call-ID: a84b4c76e66710\r\n"
"CSeq: 314159 INVITE\r\n"
"Max-Forwards: 70\r\n"
"Foobie-Blech: it is not a glass paperweight\r\n"
"Contact: <sip:alice@pc33.atlanta.com>\r\n"
"Content-Length: 0\r\n"
"\r\n");
Data txt8("INVITE sip:bob@biloxi.com;maddr=192.168.1.1;lr;jason=foo;user=phone SIP/2.0\r\n"
"Via: SIP/2.0/UDP pc33.atlanta.com\r\n"
"To: Bob <sip:bob@biloxi.com>\r\n"
"From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
"Call-ID: a84b4c76e66710\r\n"
"CSeq: 314159 INVITE\r\n"
"Max-Forwards: 70\r\n"
"Foobie-Blech: it is not a glass paperweight\r\n"
"Contact: <sip:alice@pc33.atlanta.com>\r\n"
"Content-Length: 0\r\n"
"\r\n");
Data txt9("INVITE sip:bob@biloxi.com;maddr=192.168.1.1;lr;jason=foo;user=phone SIP/2.0\r\n"
"Via: SIP/2.0/UDP pc33.atlanta.com; branch=foobar\r\n"
"To: Bob <sip:bob@biloxi.com>\r\n"
"From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
"Call-ID: a84b4c76e66710\r\n"
"CSeq: 314159 INVITE\r\n"
"Max-Forwards: 70\r\n"
"Foobie-Blech: it is not a glass paperweight\r\n"
"Contact: <sip:alice@pc33.atlanta.com>\r\n"
"Content-Length: 0\r\n"
"\r\n");
Data txt10("INVITE sip:bob@biloxi.com;maddr=192.168.1.1;lr;jason=foo;user=phone SIP/2.0\r\n"
"Via: SIP/2.0/UDP pc33.atlanta.com; branch=foobar\r\n"
"To: Bob <sip:bob@biloxi.com>\r\n"
"From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
"Call-ID: a84b4c76e66710\r\n"
"CSeq: 314158 INVITE\r\n"
"Max-Forwards: 70\r\n"
"Foobie-Blech: it is not a glass paperweight\r\n"
"Contact: <sip:alice@pc33.atlanta.com>\r\n"
"Content-Length: 0\r\n"
"\r\n");
Data txt11("INVITE sip:bob@biloxi.com;maddr=192.168.1.1;lr;jason=foo;user=phone SIP/2.0\r\n"
"Via: SIP/2.0/UDP pc33.atlanta.com; branch=foobar\r\n"
"To: Bob <sip:bob@biloxi.com>\r\n"
"From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
"Call-ID: a84b4c76e66710\r\n"
"CSeq: 314158 INVITE\r\n"
"Max-Forwards: 73\r\n"
"Foobie-Blech: it is not a glass paperweight\r\n"
"Contact: <sip:alice@pc.atlanta.com>\r\n"
"Content-Length: 0\r\n"
"\r\n");
auto_ptr<SipMessage> msg1(TestSupport::makeMessage(txt1));
auto_ptr<SipMessage> msg2(TestSupport::makeMessage(txt2));
auto_ptr<SipMessage> msg3(TestSupport::makeMessage(txt3));
auto_ptr<SipMessage> msg4(TestSupport::makeMessage(txt4));
auto_ptr<SipMessage> msg5(TestSupport::makeMessage(txt5));
auto_ptr<SipMessage> msg6(TestSupport::makeMessage(txt6));
auto_ptr<SipMessage> msg7(TestSupport::makeMessage(txt7));
auto_ptr<SipMessage> msg8(TestSupport::makeMessage(txt8));
auto_ptr<SipMessage> msg9(TestSupport::makeMessage(txt9));
auto_ptr<SipMessage> msg10(TestSupport::makeMessage(txt10));
auto_ptr<SipMessage> msg11(TestSupport::makeMessage(txt11));
assert(msg1->getTransactionId() == msg1->getTransactionId());
cerr << "msg2=" << msg2->getTransactionId() << endl;
cerr << "msg3=" << msg3->getTransactionId() << endl;
assert(msg2->getTransactionId() != msg3->getTransactionId());
assert(msg3->getTransactionId() == msg4->getTransactionId());
assert(msg4->getTransactionId() != msg5->getTransactionId());
assert(msg4->getTransactionId() != msg6->getTransactionId());
cerr << "msg5=" << msg5->getTransactionId() << endl;
cerr << "msg6=" << msg6->getTransactionId() << endl;
assert(msg5->header(h_RequestLine).uri() == msg6->header(h_RequestLine).uri());
assert(msg5->header(h_RequestLine).uri().commutativeParameterHash() == msg6->header(h_RequestLine).uri().commutativeParameterHash());
assert(msg5->getTransactionId() == msg6->getTransactionId());
assert(msg7->getTransactionId() == msg8->getTransactionId());
assert(msg6->getTransactionId() != msg8->getTransactionId());
assert(msg8->getTransactionId() != msg9->getTransactionId());
assert(msg9->getTransactionId() != msg10->getTransactionId());
assert(msg10->getTransactionId() == msg11->getTransactionId());
}
{
SipMessage inv;
UnknownHeaderType h_Foo("foo");
UnknownHeaderType h_Bar("bar");
inv.header(h_Foo);
inv.header(h_Bar).push_back(StringCategory("bar1"));
inv.header(h_Bar).push_back(StringCategory("bar2"));
inv.header(h_To);
inv.header(h_RequestLine) = RequestLine(INVITE);
inv.header(h_RequestLine).uri() = Uri("sip:bob@biloxi.com");
inv.header(h_To) = NameAddr("sip:bob@biloxi.com");
inv.header(h_From) = NameAddr("Alice <sip:alice@atlanta.com>;tag=1928301774");
inv.header(h_CallId).value() = "314159";
inv.header(h_CSeq).sequence() = 14;
inv.header(h_CSeq).method() = INVITE;
PlainContents pc("here is some plain ol' contents");
inv.setContents(&pc);
cerr << inv.header(h_ContentType).type() << en
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -