~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject/pjnath/src/pjnath-test/server.h

  • Committer: Package Import Robot
  • Author(s): Francois Marier
  • Date: 2011-11-25 13:24:12 UTC
  • mfrom: (4.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20111125132412-dc4qvhyosk74cd42
Tags: 1.0.1-4
Don't assume that arch:all packages will get built (closes: #649726)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: server.h 3553 2011-05-05 06:14:19Z nanang $ */
 
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
#ifndef __PJNATH_TEST_SERVER_H__
 
21
#define __PJNATH_TEST_SERVER_H__
 
22
 
 
23
#include <pjnath.h>
 
24
#include <pjlib-util.h>
 
25
#include <pjlib.h>
 
26
 
 
27
#define DNS_SERVER_PORT     55533
 
28
#define STUN_SERVER_PORT    33478
 
29
#define TURN_SERVER_PORT    33479
 
30
 
 
31
#define TURN_USERNAME   "auser"
 
32
#define TURN_PASSWD     "apass"
 
33
 
 
34
#define MAX_TURN_ALLOC      16
 
35
#define MAX_TURN_PERM       16
 
36
 
 
37
enum test_server_flags
 
38
{
 
39
    CREATE_DNS_SERVER           = (1 << 0),
 
40
    CREATE_A_RECORD_FOR_DOMAIN  = (1 << 1),
 
41
 
 
42
    CREATE_STUN_SERVER          = (1 << 5),
 
43
    CREATE_STUN_SERVER_DNS_SRV  = (1 << 6),
 
44
 
 
45
    CREATE_TURN_SERVER          = (1 << 10),
 
46
    CREATE_TURN_SERVER_DNS_SRV  = (1 << 11),
 
47
 
 
48
};
 
49
 
 
50
typedef struct test_server test_server;
 
51
 
 
52
/* TURN allocation */
 
53
typedef struct turn_allocation
 
54
{
 
55
    test_server         *test_srv;
 
56
    pj_pool_t           *pool;
 
57
    pj_activesock_t     *sock;
 
58
    pj_ioqueue_op_key_t  send_key;
 
59
    pj_sockaddr          client_addr;
 
60
    pj_sockaddr          alloc_addr;
 
61
    unsigned             perm_cnt;
 
62
    pj_sockaddr          perm[MAX_TURN_PERM];
 
63
    unsigned             chnum[MAX_TURN_PERM];
 
64
    pj_stun_msg         *data_ind;
 
65
} turn_allocation;
 
66
 
 
67
/*
 
68
 * Server installation for testing.
 
69
 * This comprises of DNS server, STUN server, and TURN server.
 
70
 */
 
71
struct test_server
 
72
{
 
73
    pj_pool_t           *pool;
 
74
    pj_uint32_t          flags;
 
75
    pj_stun_config      *stun_cfg;
 
76
    pj_ioqueue_op_key_t  send_key;
 
77
 
 
78
    pj_dns_server       *dns_server;
 
79
 
 
80
    pj_activesock_t     *stun_sock;
 
81
 
 
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;
 
87
 
 
88
    struct turn_stat {
 
89
        unsigned         rx_allocate_cnt;
 
90
        unsigned         rx_refresh_cnt;
 
91
        unsigned         rx_send_ind_cnt;
 
92
    } turn_stat;
 
93
 
 
94
    pj_str_t             domain;
 
95
    pj_str_t             username;
 
96
    pj_str_t             passwd;
 
97
 
 
98
};
 
99
 
 
100
 
 
101
pj_status_t create_test_server(pj_stun_config *stun_cfg,
 
102
                               pj_uint32_t flags,
 
103
                               const char *domain,
 
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);
 
107
 
 
108
 
 
109
#endif  /* __PJNATH_TEST_SERVER_H__ */
 
110