1
/* $Id: server.h 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
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.
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.
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
20
#ifndef __PJNATH_TEST_SERVER_H__
21
#define __PJNATH_TEST_SERVER_H__
24
#include <pjlib-util.h>
27
#define DNS_SERVER_PORT 55533
28
#define STUN_SERVER_PORT 33478
29
#define TURN_SERVER_PORT 33479
31
#define TURN_USERNAME "auser"
32
#define TURN_PASSWD "apass"
34
#define MAX_TURN_ALLOC 16
35
#define MAX_TURN_PERM 16
37
enum test_server_flags
39
CREATE_DNS_SERVER = (1 << 0),
40
CREATE_A_RECORD_FOR_DOMAIN = (1 << 1),
42
CREATE_STUN_SERVER = (1 << 5),
43
CREATE_STUN_SERVER_DNS_SRV = (1 << 6),
45
CREATE_TURN_SERVER = (1 << 10),
46
CREATE_TURN_SERVER_DNS_SRV = (1 << 11),
50
typedef struct test_server test_server;
53
typedef struct turn_allocation
55
test_server *test_srv;
57
pj_activesock_t *sock;
58
pj_ioqueue_op_key_t send_key;
59
pj_sockaddr client_addr;
60
pj_sockaddr alloc_addr;
62
pj_sockaddr perm[MAX_TURN_PERM];
63
unsigned chnum[MAX_TURN_PERM];
64
pj_stun_msg *data_ind;
68
* Server installation for testing.
69
* This comprises of DNS server, STUN server, and TURN server.
75
pj_stun_config *stun_cfg;
76
pj_ioqueue_op_key_t send_key;
78
pj_dns_server *dns_server;
80
pj_activesock_t *stun_sock;
82
pj_activesock_t *turn_sock;
83
unsigned turn_alloc_cnt;
84
turn_allocation turn_alloc[MAX_TURN_ALLOC];
85
pj_bool_t turn_respond_allocate;
86
pj_bool_t turn_respond_refresh;
89
unsigned rx_allocate_cnt;
90
unsigned rx_refresh_cnt;
91
unsigned rx_send_ind_cnt;
101
pj_status_t create_test_server(pj_stun_config *stun_cfg,
104
test_server **p_test_srv);
105
void destroy_test_server(test_server *test_srv);
106
void test_server_poll_events(test_server *test_srv);
109
#endif /* __PJNATH_TEST_SERVER_H__ */