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

📄 torture_sip.c

📁 Sofia SIP is an open-source SIP User-Agent library, compliant with the IETF RFC3261 specification.
💻 C
📖 第 1 页 / 共 5 页
字号:
  TEST_P(msg_header_offset(msg, sip, sip_in_reply_to), &sip->sip_in_reply_to);		           		  TEST_P(msg_header_offset(msg, sip, sip_accept), &sip->sip_accept);  TEST_P(msg_header_offset(msg, sip, sip_accept_encoding),	 &sip->sip_accept_encoding);  TEST_P(msg_header_offset(msg, sip, sip_accept_language),	 &sip->sip_accept_language);  TEST_P(msg_header_offset(msg, sip, sip_session_expires),	 &sip->sip_session_expires);  TEST_P(msg_header_offset(msg, sip, sip_min_se), &sip->sip_min_se);        TEST_P(msg_header_offset(msg, sip, sip_allow), &sip->sip_allow);  TEST_P(msg_header_offset(msg, sip, sip_require), &sip->sip_require);  TEST_P(msg_header_offset(msg, sip, sip_proxy_require),	 &sip->sip_proxy_require);  TEST_P(msg_header_offset(msg, sip, sip_supported), &sip->sip_supported);  TEST_P(msg_header_offset(msg, sip, sip_unsupported), &sip->sip_unsupported);#if SIP_HAVE_ENCRYPTION  TEST(msg_header_offset(msg, sip, sip_encryption), &sip->sip_encryption);#endif#if SIP_HAVE_RESPONSE_KEY  TEST(msg_header_offset(msg, sip, sip_response_key), &sip->sip_response_key);#endif  TEST_P(msg_header_offset(msg, sip, sip_proxy_authenticate),	 &sip->sip_proxy_authenticate);  TEST_P(msg_header_offset(msg, sip, sip_proxy_authorization),	 &sip->sip_proxy_authorization);  TEST_P(msg_header_offset(msg, sip, sip_authorization),	 &sip->sip_authorization);  TEST_P(msg_header_offset(msg, sip, sip_www_authenticate),	 &sip->sip_www_authenticate);  TEST_P(msg_header_offset(msg, sip, sip_error_info), &sip->sip_error_info);  TEST_P(msg_header_offset(msg, sip, sip_warning), &sip->sip_warning);		         TEST_P(msg_header_offset(msg, sip, sip_mime_version), &sip->sip_mime_version);  TEST_P(msg_header_offset(msg, sip, sip_content_type), &sip->sip_content_type);  TEST_P(msg_header_offset(msg, sip, sip_content_encoding),	 &sip->sip_content_encoding);  TEST_P(msg_header_offset(msg, sip, sip_content_disposition),	 &sip->sip_content_disposition);  TEST_P(msg_header_offset(msg, sip, sip_content_length),	 &sip->sip_content_length);  TEST_SIZE(sip_request_class->hc_params, 0);  TEST_SIZE(sip_status_class->hc_params, 0);  TEST_SIZE(sip_unknown_class->hc_params, 0);  TEST_SIZE(sip_separator_class->hc_params, 0);  TEST_SIZE(sip_payload_class->hc_params, 0);  TEST_SIZE(sip_via_class->hc_params, offsetof(sip_via_t, v_params));  TEST_SIZE(sip_route_class->hc_params, offsetof(sip_route_t, r_params));  TEST_SIZE(sip_record_route_class->hc_params, 	    offsetof(sip_record_route_t, r_params));  TEST_SIZE(sip_max_forwards_class->hc_params, 0);  TEST_SIZE(sip_from_class->hc_params, offsetof(sip_from_t, a_params));  TEST_SIZE(sip_to_class->hc_params, offsetof(sip_to_t, a_params));  TEST_SIZE(sip_call_id_class->hc_params, 0);  TEST_SIZE(sip_cseq_class->hc_params, 0);  TEST_SIZE(sip_contact_class->hc_params, offsetof(sip_contact_t, m_params));						  TEST_SIZE(sip_expires_class->hc_params, 0);  TEST_SIZE(sip_date_class->hc_params, 0);  TEST_SIZE(sip_retry_after_class->hc_params, 	    offsetof(sip_retry_after_t, af_params));  TEST_SIZE(sip_timestamp_class->hc_params, 0);  TEST_SIZE(sip_subject_class->hc_params, 0);  TEST_SIZE(sip_priority_class->hc_params, 0);		           		  TEST_SIZE(sip_call_info_class->hc_params, 	    offsetof(sip_call_info_t, ci_params));  TEST_SIZE(sip_organization_class->hc_params, 0);  TEST_SIZE(sip_server_class->hc_params, 0);  TEST_SIZE(sip_user_agent_class->hc_params, 0);  TEST_SIZE(sip_in_reply_to_class->hc_params, 	    offsetof(sip_in_reply_to_t, k_items));  TEST_SIZE(sip_accept_class->hc_params, offsetof(sip_accept_t, ac_params));  TEST_SIZE(sip_accept_encoding_class->hc_params, 	    offsetof(sip_accept_encoding_t, aa_params));  TEST_SIZE(sip_accept_language_class->hc_params, 	    offsetof(sip_accept_language_t, aa_params));     TEST_SIZE(sip_session_expires_class->hc_params,	    offsetof(sip_session_expires_t, x_params));  TEST_SIZE(sip_min_se_class->hc_params, offsetof(sip_min_se_t, min_params));  TEST_SIZE(sip_allow_class->hc_params, offsetof(sip_allow_t, k_items));  TEST_SIZE(sip_require_class->hc_params, offsetof(sip_require_t, k_items));  TEST_SIZE(sip_proxy_require_class->hc_params, 	    offsetof(sip_proxy_require_t, k_items));  TEST_SIZE(sip_supported_class->hc_params, 	    offsetof(sip_supported_t, k_items));  TEST_SIZE(sip_unsupported_class->hc_params, 	    offsetof(sip_unsupported_t, k_items));#if SIP_HAVE_ENCRYPTION  TEST_SIZE(sip_encryption_class->hc_params, 	    offsetof(sip_encryption_t, au_params));#endif#if SIP_HAVE_RESPONSE_KEY  TEST_SIZE(sip_response_key_class->hc_params, 	    offsetof(sip_response_key_t, au_params));#endif  TEST_SIZE(sip_proxy_authenticate_class->hc_params,  	    offsetof(sip_proxy_authenticate_t, au_params));  TEST_SIZE(sip_proxy_authorization_class->hc_params,  	    offsetof(sip_proxy_authorization_t, au_params));  TEST_SIZE(sip_authorization_class->hc_params,  	    offsetof(sip_authorization_t, au_params));  TEST_SIZE(sip_www_authenticate_class->hc_params,  	    offsetof(sip_www_authenticate_t, au_params));  TEST_SIZE(sip_error_info_class->hc_params, 	    offsetof(sip_error_info_t, ei_params));  TEST_SIZE(sip_alert_info_class->hc_params, 	    offsetof(sip_alert_info_t, ai_params));  TEST_SIZE(sip_reply_to_class->hc_params, 	    offsetof(sip_reply_to_t, rplyto_params));  TEST_SIZE(sip_warning_class->hc_params, 0);		         TEST_SIZE(sip_mime_version_class->hc_params, 0);  TEST_SIZE(sip_content_type_class->hc_params, 	    offsetof(sip_content_type_t, c_params));  TEST_SIZE(sip_content_encoding_class->hc_params, 	    offsetof(sip_content_encoding_t, k_items));  TEST_SIZE(sip_content_disposition_class->hc_params, 	    offsetof(sip_content_disposition_t, cd_params));  TEST_SIZE(sip_content_length_class->hc_params, 0);  msg_destroy(msg);  su_home_unref(home);  END();}static int count(sip_common_t *h){  sip_header_t *sh = (sip_header_t *)h;  unsigned n;    for (n = 0; sh; sh = sh->sh_next)    n++;    return n;}static int len(sip_common_t *h){  sip_header_t *sh = (sip_header_t *)h;  unsigned n;  for (n = 0; sh; sh = sh->sh_next) {    if (n) n +=2;    n += sip_header_field_e(NULL, 0, sh, 0);  }  return n;}static int sip_header_test(void){  msg_t *msg;  sip_t *sip;  su_home_t *home;  void const *x;  sip_via_t *v, *v0;  tagi_t const *tl;  tagi_t *tl0;  BEGIN();  home = su_home_new(sizeof *home);  TEST_1(msg = read_message(MSG_DO_EXTRACT_COPY,     "MESSAGE sip:John_Smith@tct.hut.fi SIP/2.0\r\n"    "To: John Smith <sip:John_Smith@tct.hut.fi:5066;user=ip;maddr=131.228.16.2>\r\n"    "  ; tag = deadbeef\r\n"    "From:h<http://www.cs.columbia.edu>\r\n"    "Call-ID: 0ha0isndaksdj@10.1.2.3\r\n"    "CSeq : 8 MESSAGE\r\n"    "Via: SIP/2.0/UDP 135.180.130.133;received=defa:daf::00:12\r\n"    "Via: SIP/2.0/TCP 135.180.130.131;branch=deadbeef.barf;ttl=3;hidden,,"    "SIP/2.0/UDP\r\n 135.180.130.131:5061;received=[defa::00:12]\r\n"    "Contact: Joe Bob Briggs <urn:ipaddr:122.1.2.3> ; bar=\042foo baa\042, <sip:kuik@foo.invalid>, sip:barf\r\n"    "Via: SIP/2.0/UDP [aa:bb::1]:5061\r\n"    "Record-Route: Test Element <sip:[defa::00:12]:5061>;param=12+1\r\n"    "Record-Route: sip:135.180.130.133,<sip:135.180.130.131;transport=tcp>,\r\n"    "\t,Test Element <sip:[defa::00:12]:5061>;param=12+1\r\n"    "Path: Test <sip:[defa::00:12]:5061>\r\n"    "Service-Route: Test <sip:[defa::00:12]:5061>\r\n"    "Route: ,\r\n"    "Unknown-Extension: hip\r\n"    "Hide: hop\r\n"    "Max-Forwards: 12\r\n"    "Min-Expires: 150\r\n"    "Timestamp: 10.010 0.000100\r\n"    "Suppress-Body-If-Match: humppa \t\r\n"    "Suppress-Notify-If-Match: zumppa\r\n"    " \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"    "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"));  TEST_1(sip = sip_object(msg));  TEST(count(sip->sip_request->rq_common), 1);  TEST(count(sip->sip_to->a_common), 1);  TEST(count(sip->sip_from->a_common), 1);  TEST(count(sip->sip_cseq->cs_common), 1);  TEST(count(sip->sip_call_id->i_common), 1);  TEST(count(sip->sip_via->v_common), 4);  TEST(count(sip->sip_contact->m_common), 3);  TEST(count(sip->sip_content_type->c_common), 1);  TEST(count(sip->sip_route->r_common), 0);  TEST(count(sip->sip_record_route->r_common), 4);#if SU_HAVE_EXPERIMENTAL  TEST(count(sip->sip_unknown->un_common), 2);#else  TEST(count(sip->sip_unknown->un_common), 4);#endif  TEST(count(sip->sip_error->er_common), 1);  TEST(count(sip->sip_max_forwards->mf_common), 1);  TEST(count(sip->sip_min_expires->me_common), 1);  TEST(count(sip->sip_timestamp->ts_common), 1);  TEST_S(sip->sip_contact->m_display, "Joe Bob Briggs");  TEST_1(sip->sip_contact->m_next->m_display != NULL);  TEST_S(sip->sip_contact->m_next->m_display, "");  TEST_1(sip->sip_contact->m_next->m_next->m_display == NULL);  TEST(sip->sip_max_forwards->mf_count, 12);  TEST(sip->sip_min_expires->me_delta, 150);#if SU_HAVE_EXPERIMENTAL  {    sip_suppress_body_if_match_t *sbim;    sip_suppress_notify_if_match_t *snim;    TEST_1(sbim = sip_suppress_body_if_match(sip));    TEST_S(sbim->sbim_tag, "humppa");    TEST_SIZE(offsetof(msg_generic_t, g_value),	      offsetof(sip_suppress_body_if_match_t, sbim_tag));    TEST_1(snim = sip_suppress_notify_if_match(sip));    TEST_S(snim->snim_tag, "zumppa");    TEST_SIZE(offsetof(msg_generic_t, g_value),	      offsetof(sip_suppress_notify_if_match_t, snim_tag));  }#endif  TEST_1(sip->sip_from->a_display);  TEST_S(sip->sip_from->a_display, "h");  v0 = sip->sip_via;  TEST_1(v = sip_via_copy(home, v0));  TEST(len(v->v_common), len(v0->v_common));  for (; v && v0; v = v->v_next, v0 = v0->v_next) {    if (v->v_params)      TEST_1(v->v_params != v0->v_params);    if (v->v_branch)      TEST_1(v->v_branch == v0->v_branch);  }  TEST_1(v == NULL && v0 == NULL);    v0 = sip->sip_via;    TEST_1(v = sip_via_dup(home, v0));  TEST(len(v->v_common), len(v0->v_common));  for (; v && v0; v = v->v_next, v0 = v0->v_next) {    if (v->v_params)      TEST_1(v->v_params != v0->v_params);    if (v->v_branch)      TEST_1(v->v_branch != v0->v_branch);  }  TEST_1(v == NULL && v0 == NULL);  TEST(sip_add_dup(msg, sip, (sip_header_t *)sip->sip_max_forwards), 0);  /* Max-Forwards is last header? */  TEST_P(sip->sip_max_forwards, sip->sip_content_type->c_common->h_succ);  TEST(sip_to_tag(home, sip->sip_to, sip->sip_to->a_tag), 0);  TEST(sip_to_tag(home, sip->sip_to, "tag=deadbeef"), 0);  TEST(sip_to_tag(home, sip->sip_to, "foofaa"), -1);  msg_header_remove(msg, (msg_pub_t *)sip, (msg_header_t *)sip->sip_payload);  TEST(sip_add_tl(msg, sip, 		  SIPTAG_FROM(SIP_NONE),		  SIPTAG_VIA(SIP_NONE),		  SIPTAG_VIA_STR("SIP/2.0/SCTP foo.bar.com:5060;branch=foo"),		  SIPTAG_TO_STR("<sip:foo@bar>"),		  SIPTAG_HEADER_STR("Authorization: Basic foobar\n"				    "Priority:\n urgent"),		  SIPTAG_HEADER_STR("Accept: foo/bar\n"				    "\n"				    "test payload\n"),		  SIPTAG_TIMESTAMP(sip->sip_timestamp),		  SIPTAG_END(),		  SIPTAG_REFER_TO_STR("<sip:foo@bar>"),		  TAG_END()), 0);  TEST_1(sip->sip_from == NULL);  TEST_1(sip->sip_via); TEST_1(sip->sip_via->v_next == NULL);  TEST_S(sip->sip_via->v_protocol, "SIP/2.0/SCTP");  TEST_1(sip->sip_authorization);  TEST_1(sip->sip_priority);  TEST_1(sip->sip_payload);  TEST_S(sip->sip_payload->pl_data, "test payload\n");  TEST_1(sip->sip_timestamp);  TEST_S(sip->sip_timestamp->ts_stamp, "10.010");  TEST_S(sip->sip_timestamp->ts_delay, "0.000100");  TEST_1(!sip->sip_refer_to);  TEST_1(tl = tl0 = tl_list(SIPTAG_TO_STR("<sip:foo@bar>"),			    SIPTAG_END(),			    SIPTAG_REFER_TO_STR("<sip:foo@bar>"),			    TAG_END()));  /* sip_add_tagis should stop after SIPTAG_END() */  TEST(sip_add_tagis(msg, sip, &tl), 0);  TEST_P(tl, tl0 + 2);  tl_free(tl0);  TEST_P(sip_timestamp_make(home, "+1"), NULL);  TEST_P(sip_timestamp_make(home, "1.0e6 13.0"), NULL);  TEST_1(sip_timestamp_make(home, "1.0 .001"));  TEST_P(sip_timestamp_make(home, ".0001 13.0"), NULL);  TEST_1(x = sip->sip_path);  TEST_1(sip_add_make(msg, sip, sip_path_class, "<sip:135.180.130.133>") == 0);  TEST_P(x, sip->sip_path->r_next);  TEST_1(x = sip->sip_service_route);  TEST_1(sip_add_make(msg, sip, sip_service_route_class, 		      "<sip:135.180.130.133>") == 0);  TEST_P(x, sip->sip_service_route);  TEST_1(sip->sip_service_route->r_next);  /* Detect parsing errors */  TEST_1(!sip_cseq_make(home, "21874624876976 INVITE"));  TEST_1(!sip_cseq_make(home, "218746INVITE"));    msg_destroy(msg), msg = NULL;  su_home_unref(home), home = NULL;  END();}static int test_bad_packet(void){  msg_t *msg;  sip_t *sip;  su_home_t *home;  BEGIN();  home = su_home_new(sizeof *home);  TEST_1(msg = read_message(MSG_DO_EXTRACT_COPY,     "MESSAGE <sip:John_Smith@tct.hut.fi> SIP/2.0\r\n"    "To: John Smith <sip:John_Smith@tct.hut.fi:5066;user=ip;maddr=131.228.16.2>\r\n"    "  ; tag = deadbeef\r\n"    "From:h<http://www.cs.columbia.edu>\r\n"    "Call-ID: 0ha0isndaksdj@10.1.2.3\r\n"    "CSeq : 8 MESSAGE\r\n"    "Via: SIP/2.0/UDP 135.180.130.133;received=defa:daf::00:12\r\n"    "Via: SIP/2.0/TCP 135.180.130.131;branch=deadbeef.barf;ttl=3;hidden,,"    "SIP/2.0/UDP\r\n 135.180.130.131:5061;received=[defa::00:12]\r\n"    "Contact: Joe Bob Briggs <urn:ipaddr:122.1.2.3> ; bar=\042foo baa\042, sip:kuik@foo.invalid\r\n"    "Via: SIP/2.0/UDP [aa:bb::1]:5061\0\0"));  TEST_1(sip = sip_object(msg));  TEST(count(sip->sip_request->rq_common), 1);  TEST(count(sip->sip_to->a_common), 1);  TEST(count(sip->sip_from->a_common), 1);  TEST(count(sip->sip_cseq->cs_common), 1);  TEST(count(sip->sip_call_id->i_common), 1);  TEST(count(sip->sip_via->v_common), 4);  TEST(count(sip->sip_route->r_common), 0);  TEST(sip->sip_request->rq_url->url_type, url_invalid);  su_home_unref(home), home = NULL;  msg_destroy(msg), msg = NULL;  END();}static int test_sip_list_header(void){  msg_t *msg;  sip_t *sip;  su_home_t *home;  sip_allow_t *a;  BEGIN();  home = su_ho

⌨️ 快捷键说明

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