1 /* $Id$ */
2 /*
3  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
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
19  */
20 #include <pjlib.h>
21 #include <pjlib-util.h>
22 #include <pjnath.h>
23 
24 #if defined(PJ_EXCLUDE_BENCHMARK_TESTS) && (PJ_EXCLUDE_BENCHMARK_TESTS==1)
25 #   define WITH_BENCHMARK	    0
26 #else
27 #   define WITH_BENCHMARK	    1
28 #endif
29 
30 #define INCLUDE_STUN_TEST	    1
31 #define INCLUDE_ICE_TEST	    1
32 #define INCLUDE_TRICKLE_ICE_TEST    1
33 #define INCLUDE_STUN_SOCK_TEST	    1
34 #define INCLUDE_TURN_SOCK_TEST	    1
35 #define INCLUDE_CONCUR_TEST    	    1
36 
37 #define GET_AF(use_ipv6) (use_ipv6?pj_AF_INET6():pj_AF_INET())
38 
39 #if defined(PJ_HAS_IPV6) && PJ_HAS_IPV6
40 #   define USE_IPV6	1
41 #else
42 #   define USE_IPV6	0
43 #endif
44 
45 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK
46 #   define USE_TLS	1
47 #else
48 #   define USE_TLS	0
49 #endif
50 
51 int stun_test(void);
52 int sess_auth_test(void);
53 int stun_sock_test(void);
54 int turn_sock_test(void);
55 int ice_test(void);
56 int trickle_ice_test(void);
57 int concur_test(void);
58 int test_main(void);
59 
60 #define app_perror(msg, rc) app_perror_dbg(msg, rc, __FILE__, __LINE__)
61 extern void app_perror_dbg(const char *msg, pj_status_t rc,
62 			   const char *file, int line);
63 extern void app_set_sock_nb(pj_sock_t sock);
64 extern pj_pool_factory *mem;
65 
66 int ice_one_conc_test(pj_stun_config *stun_cfg, int err_quit);
67 
68 ////////////////////////////////////
69 /*
70  * Utilities
71  */
72 pj_status_t create_stun_config(pj_pool_t *pool, pj_stun_config *stun_cfg);
73 void destroy_stun_config(pj_stun_config *stun_cfg);
74 
75 void poll_events(pj_stun_config *stun_cfg, unsigned msec,
76 		 pj_bool_t first_event_only);
77 
78 typedef struct pjlib_state
79 {
80     unsigned	timer_cnt;	/* Number of timer entries */
81     unsigned	pool_used_cnt;	/* Number of app pools	    */
82 } pjlib_state;
83 
84 
85 void capture_pjlib_state(pj_stun_config *cfg, struct pjlib_state *st);
86 int check_pjlib_state(pj_stun_config *cfg,
87 		      const struct pjlib_state *initial_st);
88 
89 pj_turn_tp_type get_turn_tp_type(pj_uint32_t flag);
90 
91 #define ERR_MEMORY_LEAK	    1
92 #define ERR_TIMER_LEAK	    2
93 
94