Changeset 4728 for pjproject/trunk/pjnath/src/pjnath-test/ice_test.c
- Timestamp:
- Feb 4, 2014 10:13:56 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjnath-test/ice_test.c
r4412 r4728 1 1 /* $Id$ */ 2 /* 2 /* 3 3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) 4 4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> … … 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 #include "test.h" … … 113 113 114 114 static void ice_on_rx_data(pj_ice_strans *ice_st, 115 unsigned comp_id, 115 unsigned comp_id, 116 116 void *pkt, pj_size_t size, 117 117 const pj_sockaddr_t *src_addr, 118 118 unsigned src_addr_len); 119 static void ice_on_ice_complete(pj_ice_strans *ice_st, 119 static void ice_on_ice_complete(pj_ice_strans *ice_st, 120 120 pj_ice_strans_op op, 121 121 pj_status_t status); … … 202 202 return PJ_SUCCESS; 203 203 } 204 204 205 205 /* Create test session */ 206 206 static int create_sess(pj_stun_config *stun_cfg, … … 239 239 return -10; 240 240 } 241 sess->server->turn_respond_allocate = 241 sess->server->turn_respond_allocate = 242 242 sess->server->turn_respond_refresh = PJ_TRUE; 243 243 … … 319 319 320 320 static void ice_on_rx_data(pj_ice_strans *ice_st, 321 unsigned comp_id, 321 unsigned comp_id, 322 322 void *pkt, pj_size_t size, 323 323 const pj_sockaddr_t *src_addr, … … 336 336 337 337 338 static void ice_on_ice_complete(pj_ice_strans *ice_st, 338 static void ice_on_ice_complete(pj_ice_strans *ice_st, 339 339 pj_ice_strans_op op, 340 340 pj_status_t status) … … 437 437 for (; i<max_cnt; ++i) { 438 438 if (ept1->cfg.comp_cnt>i && 439 pj_ice_strans_get_valid_pair(ept1->ice, i+1) != NULL) 439 pj_ice_strans_get_valid_pair(ept1->ice, i+1) != NULL) 440 440 { 441 441 PJ_LOG(3,(THIS_FILE, INDENT "err: ice1 shouldn't have valid pair " … … 444 444 } 445 445 if (ept2->cfg.comp_cnt>i && 446 pj_ice_strans_get_valid_pair(ept2->ice, i+1) != NULL) 446 pj_ice_strans_get_valid_pair(ept2->ice, i+1) != NULL) 447 447 { 448 448 PJ_LOG(3,(THIS_FILE, INDENT "err: ice2 shouldn't have valid pair " … … 464 464 pj_gettimeofday(&t); \ 465 465 if (expr) { \ 466 rc= PJ_SUCCESS; \466 RC = PJ_SUCCESS; \ 467 467 break; \ 468 468 } \ … … 478 478 struct test_sess *sess = (struct test_sess *) data; 479 479 pj_stun_config *stun_cfg = sess->stun_cfg; 480 480 481 481 /* Wait until negotiation is complete on both endpoints */ 482 482 #define ALL_DONE (sess->param->worker_quit || \ … … 484 484 sess->callee.result.nego_status!=PJ_EPENDING)) 485 485 WAIT_UNTIL(sess->param->worker_timeout, ALL_DONE, rc); 486 486 PJ_UNUSED_ARG(rc); 487 487 return 0; 488 488 } … … 539 539 } 540 540 /* Init ICE on caller */ 541 rc = pj_ice_strans_init_ice(sess->caller.ice, sess->caller.cfg.role, 541 rc = pj_ice_strans_init_ice(sess->caller.ice, sess->caller.cfg.role, 542 542 &sess->caller.ufrag, &sess->caller.pass); 543 543 if (rc != PJ_SUCCESS) { … … 548 548 549 549 /* Init ICE on callee */ 550 rc = pj_ice_strans_init_ice(sess->callee.ice, sess->callee.cfg.role, 550 rc = pj_ice_strans_init_ice(sess->callee.ice, sess->callee.cfg.role, 551 551 &sess->callee.ufrag, &sess->callee.pass); 552 552 if (rc != PJ_SUCCESS) { … … 597 597 goto on_destroy; 598 598 } 599 599 600 600 WAIT_UNTIL(30000, ALL_DONE, rc); 601 601 if (!ALL_DONE) { … … 691 691 struct test_cfg ua1; 692 692 struct test_cfg ua2; 693 } sess_cfg[] = 693 } sess_cfg[] = 694 694 { 695 695 /* Role comp# host? stun? turn? flag? ans_del snd_del des_del */ … … 741 741 /* Simple test first with host candidate */ 742 742 if (1) { 743 struct sess_cfg_t cfg = 743 struct sess_cfg_t cfg = 744 744 { 745 745 "Basic with host candidates", … … 750 750 }; 751 751 752 rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag, 752 rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag, 753 753 &cfg.ua1, &cfg.ua2); 754 754 if (rc != 0) … … 757 757 cfg.ua1.comp_cnt = 2; 758 758 cfg.ua2.comp_cnt = 2; 759 rc = perform_test("Basic with host candidates, 2 components", 760 &stun_cfg, cfg.server_flag, 761 &cfg.ua1, &cfg.ua2); 762 if (rc != 0) 763 goto on_return; 764 } 765 759 rc = perform_test("Basic with host candidates, 2 components", 760 &stun_cfg, cfg.server_flag, 761 &cfg.ua1, &cfg.ua2); 762 if (rc != 0) 763 goto on_return; 764 } 765 766 766 /* Simple test first with srflx candidate */ 767 767 if (1) { 768 struct sess_cfg_t cfg = 768 struct sess_cfg_t cfg = 769 769 { 770 770 "Basic with srflx candidates", … … 775 775 }; 776 776 777 rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag, 777 rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag, 778 778 &cfg.ua1, &cfg.ua2); 779 779 if (rc != 0) … … 783 783 cfg.ua2.comp_cnt = 2; 784 784 785 rc = perform_test("Basic with srflx candidates, 2 components", 786 &stun_cfg, cfg.server_flag, 785 rc = perform_test("Basic with srflx candidates, 2 components", 786 &stun_cfg, cfg.server_flag, 787 787 &cfg.ua1, &cfg.ua2); 788 788 if (rc != 0) … … 792 792 /* Simple test with relay candidate */ 793 793 if (1) { 794 struct sess_cfg_t cfg = 794 struct sess_cfg_t cfg = 795 795 { 796 796 "Basic with relay candidates", … … 801 801 }; 802 802 803 rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag, 803 rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag, 804 804 &cfg.ua1, &cfg.ua2); 805 805 if (rc != 0) … … 809 809 cfg.ua2.comp_cnt = 2; 810 810 811 rc = perform_test("Basic with relay candidates, 2 components", 812 &stun_cfg, cfg.server_flag, 811 rc = perform_test("Basic with relay candidates, 2 components", 812 &stun_cfg, cfg.server_flag, 813 813 &cfg.ua1, &cfg.ua2); 814 814 if (rc != 0) … … 818 818 /* Failure test with STUN resolution */ 819 819 if (1) { 820 struct sess_cfg_t cfg = 820 struct sess_cfg_t cfg = 821 821 { 822 822 "STUN resolution failure", … … 835 835 cfg.ua2.client_flag |= DEL_ON_ERR; 836 836 837 rc = perform_test("STUN resolution failure with destroy on callback", 838 &stun_cfg, cfg.server_flag, 837 rc = perform_test("STUN resolution failure with destroy on callback", 838 &stun_cfg, cfg.server_flag, 839 839 &cfg.ua1, &cfg.ua2); 840 840 if (rc != 0) … … 844 844 /* Failure test with TURN resolution */ 845 845 if (1) { 846 struct sess_cfg_t cfg = 846 struct sess_cfg_t cfg = 847 847 { 848 848 "TURN allocation failure", … … 853 853 }; 854 854 855 rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag, 855 rc = perform_test(cfg.title, &stun_cfg, cfg.server_flag, 856 856 &cfg.ua1, &cfg.ua2); 857 857 if (rc != 0) … … 861 861 cfg.ua2.client_flag |= DEL_ON_ERR; 862 862 863 rc = perform_test("TURN allocation failure with destroy on callback", 864 &stun_cfg, cfg.server_flag, 863 rc = perform_test("TURN allocation failure with destroy on callback", 864 &stun_cfg, cfg.server_flag, 865 865 &cfg.ua1, &cfg.ua2); 866 866 if (rc != 0) … … 871 871 /* STUN failure, testing TURN deallocation */ 872 872 if (1) { 873 struct sess_cfg_t cfg = 873 struct sess_cfg_t cfg = 874 874 { 875 875 "STUN failure, testing TURN deallocation", … … 888 888 cfg.ua2.client_flag |= DEL_ON_ERR; 889 889 890 rc = perform_test("STUN failure, testing TURN deallocation (cb)", 891 &stun_cfg, cfg.server_flag, 890 rc = perform_test("STUN failure, testing TURN deallocation (cb)", 891 &stun_cfg, cfg.server_flag, 892 892 &cfg.ua1, &cfg.ua2); 893 893 if (rc != 0) … … 909 909 pj_ice_sess_role ua1; 910 910 pj_ice_sess_role ua2; 911 } role[] = 911 } role[] = 912 912 { 913 913 { ROLE1, ROLE2}, … … 937 937 char title[120]; 938 938 939 sprintf(title, 940 "%s/%s, %dms answer delay, %d vs %d components", 939 sprintf(title, 940 "%s/%s, %dms answer delay, %d vs %d components", 941 941 pj_ice_sess_role_name(role[j].ua1), 942 942 pj_ice_sess_role_name(role[j].ua2), … … 944 944 945 945 cfg->ua2.comp_cnt = k2; 946 rc = perform_test(title, &stun_cfg, cfg->server_flag, 946 rc = perform_test(title, &stun_cfg, cfg->server_flag, 947 947 &cfg->ua1, &cfg->ua2); 948 948 if (rc != 0) … … 1022 1022 unsigned i; 1023 1023 int rc; 1024 1024 1025 1025 pool = pj_pool_create(mem, NULL, 512, 512, NULL); 1026 1026 rc = create_stun_config(pool, &stun_cfg); … … 1029 1029 return -7; 1030 1030 } 1031 1031 1032 1032 for (i = 0; i < LOOP; i++) { 1033 1033 PJ_LOG(3,(THIS_FILE, INDENT "Test %d of %d", i+1, LOOP)); … … 1039 1039 /* Avoid compiler warning */ 1040 1040 goto on_return; 1041 1041 1042 1042 on_return: 1043 1043 destroy_stun_config(&stun_cfg);
Note: See TracChangeset
for help on using the changeset viewer.