nsprpub/pr/include/prinet.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /*
michael@0 7 * File: prinet.h
michael@0 8 * Description:
michael@0 9 * Header file used to find the system header files for socket support[1].
michael@0 10 * This file serves the following purposes:
michael@0 11 * - A cross-platform, "get-everything" socket header file. On
michael@0 12 * Unix, socket support is scattered in several header files,
michael@0 13 * while Windows has a "get-everything" socket header file[2].
michael@0 14 * - NSPR needs the following macro definitions and function
michael@0 15 * prototype declarations from these header files:
michael@0 16 * AF_INET
michael@0 17 * INADDR_ANY, INADDR_LOOPBACK, INADDR_BROADCAST
michael@0 18 * ntohl(), ntohs(), htonl(), ntons().
michael@0 19 * NSPR does not define its own versions of these macros and
michael@0 20 * functions. It simply uses the native versions, which have
michael@0 21 * the same names on all supported platforms.
michael@0 22 * This file is intended to be included by NSPR public header
michael@0 23 * files, such as prio.h. One should not include this file directly.
michael@0 24 *
michael@0 25 * Notes:
michael@0 26 * 1. This file should have been an internal header. Please do not
michael@0 27 * depend on it to pull in the system header files you need.
michael@0 28 * 2. WARNING: This file is no longer cross-platform as it is a no-op
michael@0 29 * for WIN32! See the comment in the WIN32 section for details.
michael@0 30 */
michael@0 31
michael@0 32 #ifndef prinet_h__
michael@0 33 #define prinet_h__
michael@0 34
michael@0 35 #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
michael@0 36 #include <sys/types.h>
michael@0 37 #include <sys/socket.h> /* AF_INET */
michael@0 38 #include <netinet/in.h> /* INADDR_ANY, ..., ntohl(), ... */
michael@0 39 #ifdef XP_OS2
michael@0 40 #include <sys/ioctl.h>
michael@0 41 #endif
michael@0 42 #ifdef XP_UNIX
michael@0 43 #ifdef AIX
michael@0 44 /*
michael@0 45 * On AIX 4.3, the header <arpa/inet.h> refers to struct
michael@0 46 * ether_addr and struct sockaddr_dl that are not declared.
michael@0 47 * The following struct declarations eliminate the compiler
michael@0 48 * warnings.
michael@0 49 */
michael@0 50 struct ether_addr;
michael@0 51 struct sockaddr_dl;
michael@0 52 #endif /* AIX */
michael@0 53 #include <arpa/inet.h>
michael@0 54 #endif /* XP_UNIX */
michael@0 55 #include <netdb.h>
michael@0 56
michael@0 57 #if defined(FREEBSD) || defined(BSDI) || defined(QNX)
michael@0 58 #include <rpc/types.h> /* the only place that defines INADDR_LOOPBACK */
michael@0 59 #endif
michael@0 60
michael@0 61 /*
michael@0 62 * OS/2 hack. For some reason INADDR_LOOPBACK is not defined in the
michael@0 63 * socket headers.
michael@0 64 */
michael@0 65 #if defined(OS2) && !defined(INADDR_LOOPBACK)
michael@0 66 #define INADDR_LOOPBACK 0x7f000001
michael@0 67 #endif
michael@0 68
michael@0 69 /*
michael@0 70 * Prototypes of ntohl() etc. are declared in <machine/endian.h>
michael@0 71 * on these platforms.
michael@0 72 */
michael@0 73 #if defined(BSDI) || defined(OSF1)
michael@0 74 #include <machine/endian.h>
michael@0 75 #endif
michael@0 76
michael@0 77 /* On Android, ntohl() etc. are declared in <sys/endian.h>. */
michael@0 78 #ifdef __ANDROID__
michael@0 79 #include <sys/endian.h>
michael@0 80 #endif
michael@0 81
michael@0 82 #elif defined(WIN32)
michael@0 83
michael@0 84 /*
michael@0 85 * Do not include any system header files.
michael@0 86 *
michael@0 87 * Originally we were including <windows.h>. It slowed down the
michael@0 88 * compilation of files that included NSPR headers, so we removed
michael@0 89 * the <windows.h> inclusion at customer's request, which created
michael@0 90 * an unfortunate inconsistency with other platforms.
michael@0 91 */
michael@0 92
michael@0 93 #else
michael@0 94
michael@0 95 #error Unknown platform
michael@0 96
michael@0 97 #endif
michael@0 98
michael@0 99 #endif /* prinet_h__ */

mercurial