Debian Codegraph @

Xpjproject/pjnath/src/pjnath-test/server.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #ifndef __PJNATH_TEST_SERVER_H__
20 #define __PJNATH_TEST_SERVER_H__
21
22 #include <pjnath.h>
23 #include <pjlib-util.h>
24 #include <pjlib.h>
25
26 #define TURN_USERNAME "auser"
27 #define TURN_PASSWD "apass"
28
29 #define MAX_TURN_ALLOC 16
30 #define MAX_TURN_PERM 16
31
32 enum test_server_flags
33 {
34 CREATE_DNS_SERVER = (1 << 0),
35 CREATE_A_RECORD_FOR_DOMAIN = (1 << 1),
36
37 CREATE_STUN_SERVER = (1 << 4),
38 CREATE_STUN_SERVER_DNS_SRV = (1 << 5),
39
40 CREATE_TURN_SERVER = (1 << 8),
41 CREATE_TURN_SERVER_DNS_SRV = (1 << 9),
42
43 SERVER_IPV4 = (1 << 12),
44 SERVER_IPV6 = (1 << 13),
45
46 TURN_UDP = (1 << 16),
47 TURN_TCP = (1 << 17),
48 TURN_TLS = (1 << 18)
49 };
50
51 typedef struct test_server test_server;
52
53 /* TURN allocation */
54 typedef struct turn_allocation
55 {
56 test_server *test_srv;
57 pj_pool_t *pool;
58 pj_activesock_t *sock;
59 pj_ioqueue_op_key_t send_key;
60 pj_sockaddr client_addr;
61 pj_sockaddr alloc_addr;
62 unsigned perm_cnt;
63 pj_sockaddr perm[MAX_TURN_PERM];
64 unsigned chnum[MAX_TURN_PERM];
65 pj_stun_msg *data_ind;
66 } turn_allocation;
67
68 /*
69 * Server installation for testing.
70 * This comprises of DNS server, STUN server, and TURN server.
71 */
72 struct test_server
73 {
74 pj_pool_t *pool;
75 pj_uint32_t flags;
76 pj_stun_config *stun_cfg;
77 pj_ioqueue_op_key_t send_key;
78
79 pj_dns_server *dns_server;
80 pj_uint16_t dns_server_port;
81
82 pj_activesock_t *stun_sock;
83 pj_uint16_t stun_server_port;
84
85 pj_activesock_t *turn_sock;
86 pj_uint16_t turn_server_port;
87
88 pj_ssl_sock_t *ssl_srv_sock;
89
90 pj_ssl_sock_t *ssl_cl_sock;
91
92 pj_activesock_t *cl_turn_sock;
93
94 pj_sockaddr remote_addr;
95 unsigned turn_alloc_cnt;
96 turn_allocation turn_alloc[MAX_TURN_ALLOC];
97 pj_bool_t turn_respond_allocate;
98 pj_bool_t turn_respond_refresh;
99
100 struct turn_stat {
101 unsigned rx_allocate_cnt;
102 unsigned rx_refresh_cnt;
103 unsigned rx_send_ind_cnt;
104 } turn_stat;
105
106 pj_str_t domain;
107 pj_str_t username;
108 pj_str_t passwd;
109
110 };
111
112
113 pj_status_t create_test_server(pj_stun_config *stun_cfg,
114 pj_uint32_t flags,
115 const char *domain,
116 test_server **p_test_srv);
117 void destroy_test_server(test_server *test_srv);
118 void test_server_poll_events(test_server *test_srv);
119
120
121 #endif /* __PJNATH_TEST_SERVER_H__ */
122