prinet.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is the Netscape Portable Runtime (NSPR).
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 1998-2000
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. /*
  38. * File: prinet.h
  39. * Description:
  40. * Header file used to find the system header files for socket support.
  41. * This file serves the following purposes:
  42. * - A cross-platform, "get-everything" socket header file. On
  43. * Unix, socket support is scattered in several header files,
  44. * while Windows and Mac have a "get-everything" socket header
  45. * file.
  46. * - NSPR needs the following macro definitions and function
  47. * prototype declarations from these header files:
  48. * AF_INET
  49. * INADDR_ANY, INADDR_LOOPBACK, INADDR_BROADCAST
  50. * ntohl(), ntohs(), htonl(), ntons().
  51. * NSPR does not define its own versions of these macros and
  52. * functions. It simply uses the native versions, which have
  53. * the same names on all supported platforms.
  54. * This file is intended to be included by nspr20 public header
  55. * files, such as prio.h. One should not include this file directly.
  56. */
  57. #ifndef prinet_h__
  58. #define prinet_h__
  59. #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
  60. #ifdef LINUX
  61. #undef __STRICT_ANSI__
  62. #define __STRICT_ANSI__
  63. #endif
  64. #include <sys/types.h>
  65. #include <sys/socket.h> /* AF_INET */
  66. #include <netinet/in.h> /* INADDR_ANY, ..., ntohl(), ... */
  67. #ifdef XP_OS2
  68. #include <sys/ioctl.h>
  69. #endif
  70. #ifdef XP_UNIX
  71. #ifdef AIX
  72. /*
  73. * On AIX 4.3, the header <arpa/inet.h> refers to struct
  74. * ether_addr and struct sockaddr_dl that are not declared.
  75. * The following struct declarations eliminate the compiler
  76. * warnings.
  77. */
  78. struct ether_addr;
  79. struct sockaddr_dl;
  80. #endif /* AIX */
  81. #include <arpa/inet.h>
  82. #endif /* XP_UNIX */
  83. #include <netdb.h>
  84. #if defined(FREEBSD) || defined(BSDI) || defined(QNX)
  85. #include <rpc/types.h> /* the only place that defines INADDR_LOOPBACK */
  86. #endif
  87. /*
  88. * OS/2 hack. For some reason INADDR_LOOPBACK is not defined in the
  89. * socket headers.
  90. */
  91. #if defined(OS2) && !defined(INADDR_LOOPBACK)
  92. #define INADDR_LOOPBACK 0x7f000001
  93. #endif
  94. /*
  95. * Prototypes of ntohl() etc. are declared in <machine/endian.h>
  96. * on these platforms.
  97. */
  98. #if defined(BSDI) || defined(OSF1)
  99. #include <machine/endian.h>
  100. #endif
  101. #elif defined(WIN32)
  102. /* Do not include any system header files. */
  103. #elif defined(WIN16)
  104. #include <winsock.h>
  105. #elif defined(XP_MAC)
  106. #include "macsocket.h"
  107. #else
  108. #error Unknown platform
  109. #endif
  110. #endif /* prinet_h__ */