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

📄 siptorturetests.cxx

📁 这是国外的resip协议栈
💻 CXX
📖 第 1 页 / 共 3 页
字号:
      tassert(message->header(h_CSeq).method() == REGISTER);      tassert(message->exists(h_Vias));      tassert(message->header(h_Vias).empty() == false);      tassert(message->header(h_Vias).front().protocolName() == "SIP");      tassert(message->header(h_Vias).front().protocolVersion() == "2.0");      tassert(message->header(h_Vias).front().transport() == "UDP");      tassert(message->header(h_Vias).front().sentHost() == "135.180.130.133");      tassert(message->header(h_Vias).front().sentPort() == 0);      tassert(message->header(h_Vias).front().exists(p_branch));      tassert(message->header(h_Vias).front().param(p_branch).getTransactionId() == "kdjuw");      tassert(message->exists(h_Expires));      /*        * Quoted from RFC 3261        * The "expires" parameter of a Contact header field value indicates how       * long the URI is valid.  The value of the parameter is a number       * indicating seconds.  If this parameter is not provided, the value of       * the Expires header field determines how long the URI is valid.       * Malformed values SHOULD be treated as equivalent to 3600.       * This provides a modest level of backwards compatibility with RFC       * 2543, which allowed absolute times in this header field.  If an       * absolute time is received, it will be treated as malformed, and       * then default to 3600.       */      tassert(message->header(h_Expires).value() == 3600);      // Asking for something when it doesnt exist      tassert(message->exists(h_ContentLength) == false);            message->header(h_ContentLength).value();      tassert_verify(4);   }void test5()   {      CritLog( << "2.5    INVITE with inconsistent Accept and message body");            const char *txt = ("INVITE sip:user@company.com SIP/2.0 \r\n"                   "To: sip:j_user@company.com \r\n"                   "From: sip:caller@university.edu;tag=234 \r\n"                   "Max-Forwards: 5 \r\n"                   "Call-ID: 0ha0isndaksdj@10.0.0.1 \r\n"                   "Accept: text/newformat \r\n"                   "CSeq: 8 INVITE \r\n"                   "Via: SIP/2.0/UDP 135.180.130.133;branch=z9hG4bKkdjuw \r\n"                   "Content-Type: application/sdp \r\n"                   "\r\n"                   "v=0 \r\n"                   "c=IN IP4 135.180.130.88 \r\n"                   "m=audio 492170 RTP/AVP 0 12 \r\n"                   "m=video 3227 RTP/AVP 31 \r\n"                   "a=rtpmap:31 LPC "                   "\r\n");      auto_ptr<SipMessage> message(TestSupport::makeMessage(txt));      tassert_reset();      tassert(message->isRequest());      tassert(!message->isResponse());      tassert(message->header(h_RequestLine).getMethod() == INVITE);      tassert(message->header(h_RequestLine).getSipVersion() == "SIP/2.0");      tassert(message->header(h_RequestLine).uri().host() == "company.com");      tassert(message->header(h_RequestLine).uri().user() == "user");      tassert(message->header(h_RequestLine).uri().scheme() == "sip");      tassert(message->header(h_RequestLine).uri().port() == 0);      tassert(message->header(h_RequestLine).uri().password() == "");      tassert(message->header(h_To).uri().host() == "company.com");      tassert(message->header(h_To).uri().user() == "j_user");      tassert(message->header(h_To).uri().scheme() == "sip");      tassert(message->header(h_To).uri().port() == 0);      tassert(message->header(h_To).uri().password() == "");      tassert(message->header(h_From).uri().host() == "university.edu");      tassert(message->header(h_From).uri().user() == "caller");      tassert(message->header(h_From).uri().scheme() == "sip");      tassert(message->header(h_From).uri().port() == 0);      tassert(message->header(h_From).uri().password() == "");      // The tag is a tag on From: not the uri...      tassert(message->header(h_From).param(p_tag) == "234");      tassert(message->header(h_MaxForwards).value() == 5);      tassert(message->header(h_CallId).value() == "0ha0isndaksdj@10.0.0.1");      tassert(message->header(h_Accepts).size() == 1);      tassert(message->header(h_Accepts).front().type() == "text");      tassert(message->header(h_Accepts).front().subType() == "newformat");      tassert(message->header(h_CSeq).sequence() == 8);      tassert(message->header(h_CSeq).method() == INVITE);      tassert(message->header(h_Vias).size() == 1);      tassert(message->header(h_Vias).front().protocolName() == "SIP");      tassert(message->header(h_Vias).front().protocolVersion() == "2.0");      tassert(message->header(h_Vias).front().transport() == "UDP");      tassert(message->header(h_Vias).front().sentHost() == "135.180.130.133");      tassert(message->header(h_Vias).front().sentPort() == 0);      tassert(message->header(h_Vias).front().param(p_branch).hasMagicCookie());      // !ah! this should go away when parser fixed.      tassert(message->header(h_Vias).front().param(p_branch).getTransactionId() == "kdjuw");      tassert(message->header(h_ContentType).type() == "application");      tassert(message->header(h_ContentType).subType() == "sdp");      tassert_verify(5);      // .dlb. someday the body will gack on parse   }void test6(){      CritLog( << "2.6    INVITE with non-SDP message body ");            const char *txt = ("INVITE sip:user@company.com SIP/2.0\r\n"                   "To: sip:j.user@company.com\r\n"                   "From: sip:caller@university.edu;tag=8\r\n"                   "Max-Forwards: 70 \r\n"                   "Call-ID: 0ha0isndaksdj@10.0.0.1 \r\n"                   "CSeq: 8 INVITE \r\n"                   "Via: SIP/2.0/UDP 135.180.130.133;branch=z9hG4bKkdjuw \r\n"                   "Content-Type: application/newformat \r\n"                   "\r\n"                   "<audio> <pcmu port=\"443\"/> </audio> \r\n"                   "\r\n");      auto_ptr<SipMessage> message(TestSupport::makeMessage(txt));      tassert_reset();      tassert(message->isRequest());      tassert(!message->isResponse());      tassert(message->header(h_RequestLine).getMethod() == INVITE);      tassert(message->header(h_RequestLine).getSipVersion() == "SIP/2.0");      tassert(message->header(h_RequestLine).uri().host() == "company.com");      tassert(message->header(h_RequestLine).uri().user() == "user");      tassert(message->header(h_RequestLine).uri().scheme() == "sip");      tassert(message->header(h_RequestLine).uri().port() == 0);      tassert(message->header(h_RequestLine).uri().password() == "");      tassert(message->header(h_To).uri().host() == "company.com");      tassert(message->header(h_To).uri().user() == "j.user");      tassert(message->header(h_To).uri().scheme() == "sip");      tassert(message->header(h_To).uri().port() == 0);      tassert(message->header(h_From).uri().host() == "university.edu");      tassert(message->header(h_From).uri().user() == "caller");      tassert(message->header(h_From).uri().scheme() == "sip");      tassert(message->header(h_From).uri().port() == 0);      tassert(message->header(h_ContentType).type() == "application");      tassert(message->header(h_ContentType).subType() == "newformat");      // !jf! should send this to a UAS and it should be rejected (don't      // understand why) - says because it is not SDP      tassert_verify(6);}void test7(){      CritLog( << "2.7    Unknown Method Message");            const char *txt = ("NEWMETHOD sip:user@company.com SIP/2.0 \r\n"                   "To: sip:j.user@company.com \r\n"                   "From: sip:caller@university.edu;tag=34525 \r\n"                   "Max-Forwards: 6 \r\n"                   "Call-ID: 0ha0isndaksdj@10.0.0.1 \r\n"                   "CSeq: 8 NEWMETHOD \r\n"                   "Via: SIP/2.0/UDP 135.180.130.133;branch=z9hG4bKkdjuw \r\n"                   "Content-Type: application/sdp \r\n"                   "\r\n"                   "v=0\r\n"                   "o=mhandley 29739 7272939 IN IP4 126.5.4.3 \r\n"                   "s=-\r\n"                   "c=IN IP4 135.180.130.88\r\n"                   "m=audio 492170 RTP/AVP 0 12\r\n"                   "m=video 3227 RTP/AVP 31\r\n"                   "a=rtpmap:31 LPC \r\n"                   "\r\n");      auto_ptr<SipMessage> message(TestSupport::makeMessage(txt));      tassert_reset();      tassert(message->isRequest());      tassert(!message->isResponse());      tassert(message->header(h_RequestLine).getMethod() == UNKNOWN);      tassert(message->header(h_RequestLine).unknownMethodName() == "NEWMETHOD");      tassert(message->header(h_RequestLine).getSipVersion() == "SIP/2.0");      tassert(message->header(h_RequestLine).uri().host() == "company.com");      tassert(message->header(h_RequestLine).uri().user() == "user");      tassert(message->header(h_RequestLine).uri().scheme() == "sip");      tassert(message->header(h_RequestLine).uri().port() == 0);      tassert(message->header(h_RequestLine).uri().password() == "");      tassert(message->header(h_To).uri().host() == "company.com");      tassert(message->header(h_To).uri().user() == "j.user");      tassert(message->header(h_To).uri().scheme() == "sip");      tassert(message->header(h_To).uri().port() == 0);      tassert(message->header(h_From).uri().host() == "university.edu");      tassert(message->header(h_From).uri().user() == "caller");      tassert(message->header(h_From).uri().scheme() == "sip");      tassert(message->header(h_From).uri().port() == 0);      tassert(message->header(h_ContentType).type() == "application");      tassert(message->header(h_ContentType).subType() == "sdp");            DebugLog( << "start map dump" );      HashMap<Mime, ContentsFactoryBase*>& m = ContentsFactoryBase::getFactoryMap();      HashMap<Mime, ContentsFactoryBase*>::iterator i;      i = m.begin();      while ( i != m.end() )      {         DebugLog( << "first=" << i->first );         i++;      }      DebugLog( << "done map dump" );      Contents* c = message->getContents();              SdpContents* sdp = dynamic_cast<SdpContents*>(c);            sdp->session();            DebugLog( << "got contents of type" << c->getType() );            // A proxy should forward this using the same retransmission rules as       // BYE. A UAS should reject it with an error, and list the available       // methods in the response.       tassert_verify(7);}void test8(){   CritLog( << "2.8   Unknown Method with CSeq Error ");      const char *txt = ("NEWMETHOD sip:user@comapny.com SIP/2.0\r\n"                "To: sip:j.user@company.com\r\n"                "From: sip:caller@university.edu;tag=23411413\r\n"                "Max-Forwards: 3\r\n"                "Call-ID: 0ha0isndaksdj@10.0.1.1\r\n"                "CSeq: 8 INVITE\r\n"                "Via: SIP/2.0/UDP 135.180.130.133;branch=z9hG4bKkdjuw\r\n"                "Content-Type: application/sdp\r\n"                "\r\n"                "v=0\r\n"                "o=mhandley 29739 7272939 IN IP4 126.5.4.3\r\n"                "s=-\r\n"                "c=IN IP4 135.180.130.88\r\n"                "t=0 0\r\n"                "m=audio 492170 RTP/AVP 0 12\r\n"                "m=video 3227 RTP/AVP 31\r\n"                "a=rtpmap:31 LPC\r\n");   auto_ptr<SipMessage> message(TestSupport::makeMessage(txt));   tassert_reset();   tassert(message->isRequest());   tassert(!message->isResponse());   tassert(message->header(h_RequestLine).getMethod() == UNKNOWN);   tassert(message->header(h_RequestLine).unknownMethodName() == "NEWMETHOD");   tassert(message->header(h_CSeq).method() == INVITE);   tassert(message->header(h_CSeq).method() != message->header(h_RequestLine).getMethod());   tassert_verify(8);}void test9(){   CritLog( << "2.9    REGISTER with Unknown Authorization Scheme" );      const char* txt = ("REGISTER sip:company.com SIP/2.0\r\n"                "To: sip:j.user@company.com\r\n"                "From: sip:j.user@company.com;tag=87321hj23128\r\n"                "Max-Forwards: 8\r\n"                "Call-ID: 0ha0isndaksdj@10.0.1.1\r\n"                "CSeq: 8 REGISTER\r\n"                "Via: SIP/2.0/UDP 135.180.130.133;branch=z9hG4bKkdjuw\r\n"                "Authorization: Super-PGP foo=ajsohdaosdh0asyhdaind08yasdknasd09asidhas0d8\r\n\r\n");   auto_ptr<SipMessage> message(TestSupport::makeMessage(txt));   tassert_reset();   tassert(message->isRequest());   tassert(!message->isResponse());      tassert(message->header(h_RequestLine).getMethod() == REGISTER);   tassert(message->header(h_Authorizations).front().scheme() == "Super-PGP");   tassert_verify(9);}void test10(){   CritLog( << "2.10 Multiple SIP Request in a Single Message");      const char* txt = ("REGISTER sip:company.com SIP/2.0\r\n"                "To: sip:j.user@company.com\r\n"                "From: sip:j.user@company.com;tag=43251j3j324\r\n"                "Max-Forwards: 8\r\n"                "Call-ID: 0ha0isndaksdj@10.0.2.2\r\n"                "Contact: sip:j.user@host.company.com\r\n"                "CSeq: 8 REGISTER\r\n"                "Via: SIP/2.0/UDP 135.180.130.133;branch=z9hG4bKkdjuw\r\n"                "Content-Length: 0\r\n\r\n"                "INVITE sip:joe@company.com SIP/2.0\r\n"                "To: sip:joe@company.com\r\n"                "From: sip:caller@university.edu;tag=141334\r\n"                "Max-Forwards: 8\r\n"                "Call-ID: 0ha0isnda977644900765@10.0.0.1\r\n"                "CSeq: 8 INVITE\r\n"                "Via: SIP/2.0/UDP 135.180.130.133;branch=z9hG4bKkdjuw\r\n"                "Content-Type: application/sdp\r\n"                "\r\n"                "v=0\r\n"                "o=mhandley 29739 7272939 IN IP4 126.5.4.3\r\n"                "s=-\r\n"                "c=IN IP4 135.180.130.88\r\n"                "t=0 0\r\n"                "m=audio 492170 RTP/AVP 0 12\r\n"                "m =video 3227 RTP/AVP 31\r\n"                "a=rtpmap:31 LPC\r\n"                "\r\n");   tassert_reset();   try   {

⌨️ 快捷键说明

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