prinet.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. * File: prinet.h
  7. * Description:
  8. * Header file used to find the system header files for socket support[1].
  9. * This file serves the following purposes:
  10. * - A cross-platform, "get-everything" socket header file. On
  11. * Unix, socket support is scattered in several header files,
  12. * while Windows has a "get-everything" socket header file[2].
  13. * - NSPR needs the following macro definitions and function
  14. * prototype declarations from these header files:
  15. * AF_INET
  16. * INADDR_ANY, INADDR_LOOPBACK, INADDR_BROADCAST
  17. * ntohl(), ntohs(), htonl(), ntons().
  18. * NSPR does not define its own versions of these macros and
  19. * functions. It simply uses the native versions, which have
  20. * the same names on all supported platforms.
  21. * This file is intended to be included by NSPR public header
  22. * files, such as prio.h. One should not include this file directly.
  23. *
  24. * Notes:
  25. * 1. This file should have been an internal header. Please do not
  26. * depend on it to pull in the system header files you need.
  27. * 2. WARNING: This file is no longer cross-platform as it is a no-op
  28. * for WIN32! See the comment in the WIN32 section for details.
  29. */
  30. #ifndef prinet_h__
  31. #define prinet_h__
  32. #if defined(XP_UNIX) || defined(XP_OS2)
  33. #include <sys/types.h>
  34. #include <sys/socket.h> /* AF_INET */
  35. #include <netinet/in.h> /* INADDR_ANY, ..., ntohl(), ... */
  36. #ifdef XP_OS2
  37. #include <sys/ioctl.h>
  38. #endif
  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. #if defined(BSDI) || defined(QNX)
  54. #include <rpc/types.h> /* the only place that defines INADDR_LOOPBACK */
  55. #endif
  56. /*
  57. * OS/2 hack. For some reason INADDR_LOOPBACK is not defined in the
  58. * socket headers.
  59. */
  60. #if defined(OS2) && !defined(INADDR_LOOPBACK)
  61. #define INADDR_LOOPBACK 0x7f000001
  62. #endif
  63. /*
  64. * Prototypes of ntohl() etc. are declared in <machine/endian.h>
  65. * on these platforms.
  66. */
  67. #if defined(BSDI)
  68. #include <machine/endian.h>
  69. #endif
  70. /* On Android, ntohl() etc. are declared in <sys/endian.h>. */
  71. #ifdef __ANDROID__
  72. #include <sys/endian.h>
  73. #endif
  74. #elif defined(WIN32)
  75. /*
  76. * Do not include any system header files.
  77. *
  78. * Originally we were including <windows.h>. It slowed down the
  79. * compilation of files that included NSPR headers, so we removed
  80. * the <windows.h> inclusion at customer's request, which created
  81. * an unfortunate inconsistency with other platforms.
  82. */
  83. #else
  84. #error Unknown platform
  85. #endif
  86. #endif /* prinet_h__ */