| 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) |
| 36 |
#include <sys/types.h> |
| 37 |
#include <sys/socket.h> /* AF_INET */ |
| 38 |
#include <netinet/in.h> /* INADDR_ANY, ..., ntohl(), ... */ |
| 39 |
#ifdef XP_UNIX |
| 40 |
#ifdef AIX |
| 41 |
/* |
| 42 |
* On AIX 4.3, the header <arpa/inet.h> refers to struct |
| 43 |
* ether_addr and struct sockaddr_dl that are not declared. |
| 44 |
* The following struct declarations eliminate the compiler |
| 45 |
* warnings. |
| 46 |
*/ |
| 47 |
struct ether_addr; |
| 48 |
struct sockaddr_dl; |
| 49 |
#endif /* AIX */ |
| 50 |
#include <arpa/inet.h> |
| 51 |
#endif /* XP_UNIX */ |
| 52 |
#include <netdb.h> |
| 53 |
|
| 54 |
#if defined(QNX) |
| 55 |
#include <rpc/types.h> /* the only place that defines INADDR_LOOPBACK */ |
| 56 |
#endif |
| 57 |
|
| 58 |
/* |
| 59 |
* OS/2 hack. For some reason INADDR_LOOPBACK is not defined in the |
| 60 |
* socket headers. |
| 61 |
*/ |
| 62 |
#if !defined(INADDR_LOOPBACK) |
| 63 |
#define INADDR_LOOPBACK 0x7f000001 |
| 64 |
#endif |
| 65 |
|
| 66 |
/* On Android, ntohl() etc. are declared in <sys/endian.h>. */ |
| 67 |
#ifdef __ANDROID__ |
| 68 |
#include <sys/endian.h> |
| 69 |
#endif |
| 70 |
|
| 71 |
#elif defined(WIN32) |
| 72 |
|
| 73 |
/* |
| 74 |
* Do not include any system header files. |
| 75 |
* |
| 76 |
* Originally we were including <windows.h>. It slowed down the |
| 77 |
* compilation of files that included NSPR headers, so we removed |
| 78 |
* the <windows.h> inclusion at customer's request, which created |
| 79 |
* an unfortunate inconsistency with other platforms. |
| 80 |
*/ |
| 81 |
|
| 82 |
#else |
| 83 |
|
| 84 |
#error Unknown platform |
| 85 |
|
| 86 |
#endif |
| 87 |
|
| 88 |
#endif /* prinet_h__ */ |