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

📄 testsipmessage.cxx

📁 这是国外的resip协议栈
💻 CXX
📖 第 1 页 / 共 5 页
字号:
                   "Via: SIP/2.0/UDP RjS.localdomain:5070;branch=z9hG4bK-c87542-899769382-1--c87542-" CRLF                   "CSeq: " CRLF                   "Call-ID:  f354ce714fb8a95c" CRLF                   "From:  <sip:RjS@127.0.0.1:5070>;tag=59e7dd57" CRLF                   "To:  <sip:RjS@127.0.0.1:5060>" CRLF                   CRLF);     TestSupport::prettyPrint(txt,strlen(txt));     auto_ptr<SipMessage> response(TestSupport::makeMessage(txt,true));     try     {        response->header(h_CSeq).method();        assert(false);     }     catch (ParseException& e)     {        cerr << e << endl;     }   }   {     char * txt = ("SIP/2.0 489 Bad Event" CRLF                   "Via: SIP/2.0/UDP RjS.localdomain:5070;branch=z9hG4bK" RESIP_COOKIE "899769382-1--" RESIP_COOKIE "" CRLF                   "CSeq: 1 SUBSCRIBE" CRLF                   "Allow-Events: " CRLF                   "Call-ID:  f354ce714fb8a95c" CRLF                   "From:  <sip:RjS@127.0.0.1:5070>;tag=59e7dd57" CRLF                   "To:  <sip:RjS@127.0.0.1:5060>" CRLF                   CRLF);     TestSupport::prettyPrint(txt,strlen(txt));     auto_ptr<SipMessage> response(TestSupport::makeMessage(txt,true));     assert(response->exists(h_AllowEvents));     assert(response->header(h_AllowEvents).size() == 0);     cerr << response->brief() << endl;     assert(Data::from(response->brief()) == "SipResp: 489 tid=899769382 cseq=SUBSCRIBE / 1 from(wire)");          char * txt2 = ("SIP/2.0 489 Bad Event" CRLF                    "Via: SIP/2.0/UDP RjS.localdomain:5070;branch=z9hG4bK" RESIP_COOKIE "899769382-1--" RESIP_COOKIE "" CRLF                    "CSeq: 1 SUBSCRIBE" CRLF                    "Call-ID:  f354ce714fb8a95c" CRLF                    "From:  <sip:RjS@127.0.0.1:5070>;tag=59e7dd57" CRLF                    "To:  <sip:RjS@127.0.0.1:5060>" CRLF                    "Allow-Events:" CRLF                    CRLF);     TestSupport::prettyPrint(txt2,strlen(txt2));     auto_ptr<SipMessage> r2(TestSupport::makeMessage(txt2,true));     assert(r2->exists(h_AllowEvents));     assert(r2->header(h_AllowEvents).size() == 0);     char * txt3 =("SIP/2.0 489 Bad Event" CRLF                   "Via: SIP/2.0/UDP RjS.localdomain:5070;branch=z9hG4bK" RESIP_COOKIE "899769382-1--" RESIP_COOKIE "" CRLF                   "CSeq: 1 SUBSCRIBE" CRLF                   "Call-ID:  f354ce714fb8a95c" CRLF                   "From:  <sip:RjS@127.0.0.1:5070>;tag=59e7dd57" CRLF                   "To:  <sip:RjS@127.0.0.1:5060>" CRLF                   "Allow-Events: foo" CRLF                   "Allow-Events: bar" CRLF                   "Allow-Events: " CRLF                   CRLF);     auto_ptr<SipMessage> r3(TestSupport::makeMessage(txt3,false));     assert(r3->exists(h_AllowEvents));     assert(r3->header(h_AllowEvents).size() == 2);     assert(r3->header(h_AllowEvents).front().value() == "foo");     cerr << r3->brief() << endl;     assert(Data::from(r3->brief()) == "SipResp: 489 tid=899769382 cseq=SUBSCRIBE / 1 from(tu)");     char * txt4 = ("SIP/2.0 489 Bad Event" CRLF                    "Via: SIP/2.0/UDP RjS.localdomain:5070;branch=z9hG4bK" RESIP_COOKIE "899769382-1--" RESIP_COOKIE "" CRLF                    "CSeq: 1 SUBSCRIBE" CRLF                    "Call-ID:  f354ce714fb8a95c" CRLF                    "From:  <sip:RjS@127.0.0.1:5070>;tag=59e7dd57" CRLF                    "To:  <sip:RjS@127.0.0.1:5060>" CRLF                    "Allow-Events: foo,foobar" CRLF                    "Allow-Events: bar,gak" CRLF                    "Allow-Events: " CRLF                    CRLF);     auto_ptr<SipMessage> r4(TestSupport::makeMessage(txt4,true));     assert(r4->exists(h_AllowEvents) );     cerr << r4->header(h_AllowEvents).size() << endl;     cerr << r4->header(h_AllowEvents).front().value() << endl;     assert(r4->header(h_AllowEvents).size() == 4);     assert(r4->header(h_AllowEvents).front().value() == "foo");     char * txt5 = ("SIP/2.0 489 Bad Event" CRLF                    "Via: SIP/2.0/UDP RjS.localdomain:5070;branch=z9hG4bK" RESIP_COOKIE "899769382-1--" RESIP_COOKIE "" CRLF                    "CSeq: 1 SUBSCRIBE" CRLF                    "Call-ID:  f354ce714fb8a95c" CRLF                    "From:  <sip:RjS@127.0.0.1:5070>;tag=59e7dd57" CRLF                    "To:  <sip:RjS@127.0.0.1:5060>" CRLF                    "Allow-Events:      " CRLF                    "Allow-Events:   	     " CRLF                    "Allow-Events: " CRLF                    CRLF);     auto_ptr<SipMessage> r5(TestSupport::makeMessage(txt5,true));     assert(r5->exists(h_AllowEvents) );     assert(r5->header(h_AllowEvents).size() == 0);   }   {      // Test just in time parsing with comparison: NameAddr;      char* txt = ("INVITE sip:ext101@192.168.2.220:5064;transport=UDP SIP/2.0\r\n"                   "To: <sip:ext101@whistler.gloo.net:5061>\r\n"                   "From: <sip:ext103@whistler.gloo.net:5061>;tag=a731\r\n"                   "Via: SIP/2.0/UDP whistler.gloo.net:5061;branch=z9hG4bK" RESIP_COOKIE "11111-1-client_data-" RESIP_COOKIE ";stid=489573115\r\n"                   "Call-ID: 643f2f06\r\n"                   "CSeq: 1 INVITE\r\n"                   "Record-Route: <sip:proxy@whistler.gloo.net:5061;lr>\r\n"                   "Contact: <sip:ext103@192.168.2.220:5068;transport=UDP>\r\n"                   "Max-Forwards: 69\r\n"                   "Accept: foo/bar\r\n"                   "Content-Type: bar/foo\r\n"                   "Content-Encoding: foo\r\n"                   "Content-Disposition: bar\r\n"                   "Content-Length: 0\r\n"                   "\r\n");      auto_ptr<SipMessage> message(TestSupport::makeMessage(txt));      assert(message->header(h_ContentDisposition) < message->header(h_ContentEncoding));      assert(message->header(h_ContentType) < message->header(h_Accepts).front());      assert(message->header(h_To) < message->header(h_From));      cerr << message->brief() << endl;      assert(Data::from(message->brief()) == "SipReq:  INVITE ext101@192.168.2.220:5064 tid=11111 cseq=INVITE contact=ext103@192.168.2.220:5068 / 1 from(tu)");   }      {      cerr << "!Proxy-Authorization params" << endl;      char* txt = ("INVITE sip:ext101@192.168.2.220:5064;transport=UDP SIP/2.0\r\n"                   "To: <sip:ext101@whistler.gloo.net:5061>\r\n"                   "From: <sip:ext103@whistler.gloo.net:5061>;tag=a731\r\n"                   "Via: SIP/2.0/UDP whistler.gloo.net:5061;branch=z9hG4bK" RESIP_COOKIE "563465-1--" RESIP_COOKIE ";stid=489573115\r\n"                   "Via: SIP/2.0/UDP whistler.gloo.net:5068;branch=z9hG4bK" RESIP_COOKIE "489573115-1--" RESIP_COOKIE ";received=192.168.2.220\r\n"                   "Call-ID: 643f2f06\r\n"                   "CSeq: 1 INVITE\r\n"                   "Proxy-Authorization: Digest username=\"Alice\",realm=\"atlanta.com\",nonce=\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\",response=\"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\"\r\n"                   "Proxy-Authorization: Digest username=\"Alice\", realm = \"atlanta.com\", nonce=\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\", response=\"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\"\r\n"                   "Record-Route: <sip:proxy@whistler.gloo.net:5061;lr>\r\n"                   "Contact: <sip:ext103@192.168.2.220:5068;transport=UDP>\r\n"                   "Max-Forwards: 69\r\n"                   "Content-Length: 0\r\n"                   "\r\n");      auto_ptr<SipMessage> message(TestSupport::makeMessage(txt));      assert(message->header(h_ProxyAuthorizations).size() == 2);      assert(message->header(h_ProxyAuthorizations).front().param(p_realm) == "atlanta.com");      assert(message->header(h_ProxyAuthorizations).front().param(p_response) == "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY");      cerr << *message << endl;   }   {      char* txt = ("INVITE sip:ext101@192.168.2.220:5064;transport=UDP SIP/2.0\r\n"                   "To: <sip:ext101@whistler.gloo.net:5061>\r\n"                   "From: <sip:ext103@whistler.gloo.net:5061>;tag=a731\r\n"                   "Via: SIP/2.0/UDP whistler.gloo.net:5061;branch=z9hG4bK" RESIP_COOKIE "21312-1--" RESIP_COOKIE ";stid=489573115\r\n"                   "Via: SIP/2.0/UDP whistler.gloo.net:5068;branch=z9hG4bK" RESIP_COOKIE "489573115-1--" RESIP_COOKIE ";received=192.168.2.220\r\n"                   "Call-ID: 643f2f06\r\n"                   "CSeq: 1 INVITE\r\n"                   "Record-Route: <sip:proxy@whistler.gloo.net:5061;lr>\r\n"                   "Contact: <sip:ext103@192.168.2.220:5068;transport=UDP>\r\n"                   "Max-Forwards: 69\r\n"                   "Content-Length: 0\r\n"                   "\r\n");      auto_ptr<SipMessage> message(TestSupport::makeMessage(txt));      cerr << *message << endl;      assert(message->header(h_Vias).front().param(UnknownParameterType("stid")) == "489573115");      message->header(h_Vias).front().param(p_received) = "received";      assert(message->header(h_Vias).front().param(UnknownParameterType("stid")) == "489573115");   }   {      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().param(p_branch).getTransactionId() << endl;      cerr << message->header(h_Vias).back().param(p_branch).getTransactionId() << 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));      assert(message.get());      for (Vias::iterator i = message->header(h_Vias).begin();           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;

⌨️ 快捷键说明

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