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

source code of include/nspr/prinet.h