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

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.0.1/pjlib/include/pj/compat/socket.h

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: socket.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 __PJ_COMPAT_SOCKET_H__
21
 
#define __PJ_COMPAT_SOCKET_H__
22
 
 
23
 
/**
24
 
 * @file socket.h
25
 
 * @brief Provides all socket related functions,data types, error codes, etc.
26
 
 */
27
 
 
28
 
#if defined(PJ_HAS_WINSOCK2_H) && PJ_HAS_WINSOCK2_H != 0
29
 
#  include <winsock2.h>
30
 
#endif
31
 
 
32
 
#if defined(PJ_HAS_WINSOCK_H) && PJ_HAS_WINSOCK_H != 0
33
 
#  include <winsock.h>
34
 
#endif
35
 
 
36
 
#if defined(PJ_HAS_WS2TCPIP_H) && PJ_HAS_WS2TCPIP_H != 0
37
 
#   include <ws2tcpip.h>
38
 
#endif
39
 
 
40
 
 
41
 
/*
42
 
 * IPv6 for Visual Studio's
43
 
 *
44
 
 * = Visual Studio 6 =
45
 
 *
46
 
 * Visual Studio 6 does not ship with IPv6 support, so you MUST
47
 
 * download and install IPv6 Tehnology Preview (IPv6Kit) from:
48
 
 *    http://msdn.microsoft.com/downloads/sdks/platform/tpipv6/ReadMe.asp
49
 
 * Then put IPv6Kit\inc in your Visual Studio include path.
50
 
 *
51
 
 * In addition, by default IPv6Kit does not want to install on
52
 
 * Windows 2000 SP4. Please see:
53
 
 *    http://msdn.microsoft.com/downloads/sdks/platform/tpipv6/faq.asp
54
 
 * on  how to install IPv6Kit on Win2K SP4.
55
 
 *
56
 
 *
57
 
 * = Visual Studio 2003, 2005 (including Express) =
58
 
 *
59
 
 * These VS uses Microsoft Platform SDK for Windows Server 2003 SP1, and
60
 
 * it has built-in IPv6 support.
61
 
 */
62
 
#if defined(_MSC_VER) && defined(PJ_HAS_IPV6) && PJ_HAS_IPV6!=0
63
 
#   ifndef s_addr
64
 
#       define s_addr  S_un.S_addr
65
 
#   endif
66
 
 
67
 
#   if !defined(IPPROTO_IPV6)
68
 
        /* Need to download and install IPv6Kit for this platform.
69
 
         * Please see the comments above about Visual Studio 6.
70
 
         */
71
 
#       include <tpipv6.h>
72
 
#   endif
73
 
 
74
 
#   define PJ_SOCK_HAS_GETADDRINFO  1
75
 
#endif  /* _MSC_VER */
76
 
 
77
 
#if defined(PJ_HAS_SYS_TYPES_H) && PJ_HAS_SYS_TYPES_H != 0
78
 
#  include <sys/types.h>
79
 
#endif
80
 
 
81
 
#if defined(PJ_HAS_SYS_SOCKET_H) && PJ_HAS_SYS_SOCKET_H != 0
82
 
#  include <sys/socket.h>
83
 
#endif
84
 
 
85
 
#if defined(PJ_HAS_LINUX_SOCKET_H) && PJ_HAS_LINUX_SOCKET_H != 0
86
 
#  include <linux/socket.h>
87
 
#endif
88
 
 
89
 
#if defined(PJ_HAS_SYS_SELECT_H) && PJ_HAS_SYS_SELECT_H != 0
90
 
#  include <sys/select.h>
91
 
#endif
92
 
 
93
 
#if defined(PJ_HAS_NETINET_IN_H) && PJ_HAS_NETINET_IN_H != 0
94
 
#  include <netinet/in.h>
95
 
#endif
96
 
 
97
 
#if defined(PJ_HAS_NETINET_IN_SYSTM_H) && PJ_HAS_NETINET_IN_SYSTM_H != 0
98
 
/* Required to include netinet/ip.h in FreeBSD 7.0 */
99
 
#  include <netinet/in_systm.h>
100
 
#endif
101
 
 
102
 
#if defined(PJ_HAS_NETINET_IP_H) && PJ_HAS_NETINET_IP_H != 0
103
 
/* To pull in IPTOS_* constants */
104
 
#  include <netinet/ip.h>
105
 
#endif
106
 
 
107
 
#if defined(PJ_HAS_NETINET_TCP_H) && PJ_HAS_NETINET_TCP_H != 0
108
 
/* To pull in TCP_NODELAY constants */
109
 
#  include <netinet/tcp.h>
110
 
#endif
111
 
 
112
 
#if defined(PJ_HAS_NET_IF_H) && PJ_HAS_NET_IF_H != 0
113
 
/* For interface enumeration in ip_helper */
114
 
#   include <net/if.h>
115
 
#endif
116
 
 
117
 
#if defined(PJ_HAS_IFADDRS_H) && PJ_HAS_IFADDRS_H != 0
118
 
/* Interface enum with getifaddrs() which works with IPv6 */
119
 
#   include <ifaddrs.h>
120
 
#endif
121
 
 
122
 
#if defined(PJ_HAS_ARPA_INET_H) && PJ_HAS_ARPA_INET_H != 0
123
 
#  include <arpa/inet.h>
124
 
#endif
125
 
 
126
 
#if defined(PJ_HAS_SYS_IOCTL_H) && PJ_HAS_SYS_IOCTL_H != 0
127
 
#  include <sys/ioctl.h>        /* FBIONBIO */
128
 
#endif
129
 
 
130
 
#if defined(PJ_HAS_ERRNO_H) && PJ_HAS_ERRNO_H != 0
131
 
#  include <errno.h>
132
 
#endif
133
 
 
134
 
#if defined(PJ_HAS_NETDB_H) && PJ_HAS_NETDB_H != 0
135
 
#  include <netdb.h>
136
 
#endif
137
 
 
138
 
#if defined(PJ_HAS_UNISTD_H) && PJ_HAS_UNISTD_H != 0
139
 
#  include <unistd.h>
140
 
#endif
141
 
 
142
 
#if defined(PJ_HAS_SYS_FILIO_H) && PJ_HAS_SYS_FILIO_H != 0
143
 
#   include <sys/filio.h>
144
 
#endif
145
 
 
146
 
#if defined(PJ_HAS_SYS_SOCKIO_H) && PJ_HAS_SYS_SOCKIO_H != 0
147
 
#   include <sys/sockio.h>
148
 
#endif
149
 
 
150
 
 
151
 
/*
152
 
 * Define common errors.
153
 
 */
154
 
#if (defined(PJ_WIN32) && PJ_WIN32!=0) || \
155
 
    (defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0)
156
 
#  define OSERR_EWOULDBLOCK    WSAEWOULDBLOCK
157
 
#  define OSERR_EINPROGRESS    WSAEINPROGRESS
158
 
#  define OSERR_ECONNRESET     WSAECONNRESET
159
 
#  define OSERR_ENOTCONN       WSAENOTCONN
160
 
#elif defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0
161
 
#  define OSERR_EWOULDBLOCK    -1
162
 
#  define OSERR_EINPROGRESS    -1
163
 
#  define OSERR_ECONNRESET     -1
164
 
#  define OSERR_ENOTCONN       -1
165
 
#else
166
 
#  define OSERR_EWOULDBLOCK    EWOULDBLOCK
167
 
#  define OSERR_EINPROGRESS    EINPROGRESS
168
 
#  define OSERR_ECONNRESET     ECONNRESET
169
 
#  define OSERR_ENOTCONN       ENOTCONN
170
 
#endif
171
 
 
172
 
 
173
 
/*
174
 
 * And undefine these..
175
 
 */
176
 
#undef s_addr
177
 
#undef s6_addr
178
 
 
179
 
/*
180
 
 * Linux kernel specifics
181
 
 */
182
 
#if defined(PJ_LINUX_KERNEL)
183
 
#   include <linux/net.h>
184
 
#   include <asm/ioctls.h>              /* FIONBIO      */
185
 
#   include <linux/syscalls.h>  /* sys_select() */
186
 
#   include <asm/uaccess.h>     /* set/get_fs() */
187
 
 
188
 
    typedef int socklen_t;
189
 
#   define getsockopt  sys_getsockopt
190
 
 
191
 
    /*
192
 
     * Wrapper for select() in Linux kernel.
193
 
     */
194
 
    PJ_INLINE(int) select(int n, fd_set *inp, fd_set *outp, fd_set *exp,
195
 
                          struct timeval *tvp)
196
 
    {
197
 
        int count;
198
 
        mm_segment_t oldfs = get_fs();
199
 
        set_fs(KERNEL_DS);
200
 
        count = sys_select(n, inp, outp, exp, tvp);
201
 
        set_fs(oldfs);
202
 
        return count;
203
 
    }
204
 
#endif  /* PJ_LINUX_KERNEL */
205
 
 
206
 
 
207
 
/*
208
 
 * This will finally be obsoleted, since it should be declared in
209
 
 * os_auto.h
210
 
 */
211
 
#if !defined(PJ_HAS_SOCKLEN_T) || PJ_HAS_SOCKLEN_T==0
212
 
    typedef int socklen_t;
213
 
#endif
214
 
 
215
 
/* Regarding sin_len member of sockaddr_in:
216
 
 *  BSD systems (including MacOS X requires that the sin_len member of
217
 
 *  sockaddr_in be set to sizeof(sockaddr_in), while other systems (Windows
218
 
 *  and Linux included) do not.
219
 
 *
220
 
 *  To maintain compatibility between systems, PJLIB will automatically
221
 
 *  set this field before invoking native OS socket API, and it will
222
 
 *  always reset the field to zero before returning pj_sockaddr_in to
223
 
 *  application (such as in pj_getsockname() and pj_recvfrom()).
224
 
 *
225
 
 *  Application MUST always set this field to zero.
226
 
 *
227
 
 *  This way we can avoid hard to find problem such as when the socket
228
 
 *  address is used as hash table key.
229
 
 */
230
 
#if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0
231
 
#   define PJ_SOCKADDR_SET_LEN(addr,len) (((pj_addr_hdr*)(addr))->sa_zero_len=(len))
232
 
#   define PJ_SOCKADDR_RESET_LEN(addr)   (((pj_addr_hdr*)(addr))->sa_zero_len=0)
233
 
#else
234
 
#   define PJ_SOCKADDR_SET_LEN(addr,len)
235
 
#   define PJ_SOCKADDR_RESET_LEN(addr)
236
 
#endif
237
 
 
238
 
#endif  /* __PJ_COMPAT_SOCKET_H__ */