1
/* $Id: sip_transport_tcp.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 __PJSIP_TRANSPORT_TCP_H__
21
#define __PJSIP_TRANSPORT_TCP_H__
24
* @file sip_transport_tcp.h
25
* @brief SIP TCP Transport.
28
#include <pjsip/sip_transport.h>
29
#include <pj/sock_qos.h>
32
/* Only declare the API if PJ_HAS_TCP is true */
33
#if defined(PJ_HAS_TCP) && PJ_HAS_TCP!=0
39
* @defgroup PJSIP_TRANSPORT_TCP TCP Transport
40
* @ingroup PJSIP_TRANSPORT
41
* @brief API to create and register TCP transport.
43
* The functions below are used to create TCP transport and register
44
* the transport to the framework.
48
* Settings to be specified when creating the TCP transport. Application
49
* should initialize this structure with its default values by calling
50
* pjsip_tcp_transport_cfg_default().
52
typedef struct pjsip_tcp_transport_cfg
55
* Address family to use. Valid values are pj_AF_INET() and
56
* pj_AF_INET6(). Default is pj_AF_INET().
61
* Optional address to bind the socket to. Default is to bind to
62
* PJ_INADDR_ANY and to any available port.
64
pj_sockaddr bind_addr;
67
* Optional published address, which is the address to be
68
* advertised as the address of this SIP transport.
69
* By default the bound address will be used as the published address.
71
pjsip_host_port addr_name;
74
* Number of simultaneous asynchronous accept() operations to be
75
* supported. It is recommended that the number here corresponds to
76
* the number of processors in the system (or the number of SIP
84
* QoS traffic type to be set on this transport. When application wants
85
* to apply QoS tagging to the transport, it's preferable to set this
86
* field rather than \a qos_param fields since this is more portable.
88
* Default is QoS not set.
93
* Set the low level QoS parameters to the transport. This is a lower
94
* level operation than setting the \a qos_type field and may not be
95
* supported on all platforms.
97
* Default is QoS not set.
99
pj_qos_params qos_params;
101
} pjsip_tcp_transport_cfg;
105
* Initialize pjsip_tcp_transport_cfg structure with default values for
106
* the specifed address family.
108
* @param cfg The structure to initialize.
109
* @param af Address family to be used.
111
PJ_DECL(void) pjsip_tcp_transport_cfg_default(pjsip_tcp_transport_cfg *cfg,
116
* Register support for SIP TCP transport by creating TCP listener on
117
* the specified address and port. This function will create an
118
* instance of SIP TCP transport factory and register it to the
121
* @param endpt The SIP endpoint.
122
* @param local Optional local address to bind, or specify the
123
* address to bind the server socket to. Both IP
124
* interface address and port fields are optional.
125
* If IP interface address is not specified, socket
126
* will be bound to PJ_INADDR_ANY. If port is not
127
* specified, socket will be bound to any port
128
* selected by the operating system.
129
* @param async_cnt Number of simultaneous asynchronous accept()
130
* operations to be supported. It is recommended that
131
* the number here corresponds to the number of
132
* processors in the system (or the number of SIP
134
* @param p_factory Optional pointer to receive the instance of the
135
* SIP TCP transport factory just created.
137
* @return PJ_SUCCESS when the transport has been successfully
138
* started and registered to transport manager, or
139
* the appropriate error code.
141
PJ_DECL(pj_status_t) pjsip_tcp_transport_start(pjsip_endpoint *endpt,
142
const pj_sockaddr_in *local,
144
pjsip_tpfactory **p_factory);
149
* A newer variant of #pjsip_tcp_transport_start(), which allows specifying
150
* the published/public address of the TCP transport.
152
* @param endpt The SIP endpoint.
153
* @param local Optional local address to bind, or specify the
154
* address to bind the server socket to. Both IP
155
* interface address and port fields are optional.
156
* If IP interface address is not specified, socket
157
* will be bound to PJ_INADDR_ANY. If port is not
158
* specified, socket will be bound to any port
159
* selected by the operating system.
160
* @param a_name Optional published address, which is the address to be
161
* advertised as the address of this SIP transport.
162
* If this argument is NULL, then the bound address
163
* will be used as the published address.
164
* @param async_cnt Number of simultaneous asynchronous accept()
165
* operations to be supported. It is recommended that
166
* the number here corresponds to the number of
167
* processors in the system (or the number of SIP
169
* @param p_factory Optional pointer to receive the instance of the
170
* SIP TCP transport factory just created.
172
* @return PJ_SUCCESS when the transport has been successfully
173
* started and registered to transport manager, or
174
* the appropriate error code.
176
PJ_DECL(pj_status_t) pjsip_tcp_transport_start2(pjsip_endpoint *endpt,
177
const pj_sockaddr_in *local,
178
const pjsip_host_port *a_name,
180
pjsip_tpfactory **p_factory);
183
* Another variant of #pjsip_tcp_transport_start().
185
* @param endpt The SIP endpoint.
186
* @param cfg TCP transport settings. Application should initialize
187
* this setting with #pjsip_tcp_transport_cfg_default().
188
* @param p_factory Optional pointer to receive the instance of the
189
* SIP TCP transport factory just created.
191
* @return PJ_SUCCESS when the transport has been successfully
192
* started and registered to transport manager, or
193
* the appropriate error code.
195
PJ_DECL(pj_status_t) pjsip_tcp_transport_start3(
196
pjsip_endpoint *endpt,
197
const pjsip_tcp_transport_cfg *cfg,
198
pjsip_tpfactory **p_factory
208
#endif /* PJ_HAS_TCP */
210
#endif /* __PJSIP_TRANSPORT_TCP_H__ */