⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testsipmessage.cxx

📁 这是国外的resip协议栈
💻 CXX
📖 第 1 页 / 共 5 页
字号:
      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() << endl;      assert(inv.header(h_ContentType).type() == "text");      assert(inv.header(h_ContentType).subType() == "plain");      assert(!inv.exists(h_ContentLength));      assert(inv.getContents());      assert(dynamic_cast<PlainContents*>(inv.getContents()));      assert(dynamic_cast<PlainContents*>(inv.getContents())->text() == "here is some plain ol' contents");      const Data d(Data::from(inv));            cerr << "!! " << d;      assert(d == ("INVITE sip:bob@biloxi.com SIP/2.0\r\n"                   "To: <sip:bob@biloxi.com>\r\n"                   "From: \"Alice\"<sip:alice@atlanta.com>;tag=1928301774\r\n"                   "Call-ID: 314159\r\n"                   "CSeq: 14 INVITE\r\n"                   "Content-Type: text/plain\r\n"                   "Content-Length: 31\r\n"                   "bar: bar1\r\n"                   "bar: bar2\r\n"                   "\r\n"                   "here is some plain ol' contents"));   }   {      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"));      //i

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -