in.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #ifndef _NETINET_IN_H_
  2. /*
  3. * Copyright (C) 2001-2005 by egnite Software GmbH. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the copyright holders nor the names of
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  19. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  21. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  22. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  23. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  24. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  25. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  26. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  27. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  28. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. * SUCH DAMAGE.
  30. *
  31. * For additional information see http://www.ethernut.de/
  32. *
  33. * -
  34. * Portions Copyright (C) 2000 David J. Hudson <dave@humbug.demon.co.uk>
  35. *
  36. * This file is distributed in the hope that it will be useful, but WITHOUT
  37. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  38. * FITNESS FOR A PARTICULAR PURPOSE.
  39. *
  40. * You can redistribute this file and/or modify it under the terms of the GNU
  41. * General Public License (GPL) as published by the Free Software Foundation;
  42. * either version 2 of the License, or (at your discretion) any later version.
  43. * See the accompanying file "copying-gpl.txt" for more details.
  44. *
  45. * As a special exception to the GPL, permission is granted for additional
  46. * uses of the text contained in this file. See the accompanying file
  47. * "copying-liquorice.txt" for details.
  48. * -
  49. * Portions Copyright (c) 1983, 1993 by
  50. * The Regents of the University of California. All rights reserved.
  51. *
  52. * Redistribution and use in source and binary forms, with or without
  53. * modification, are permitted provided that the following conditions
  54. * are met:
  55. * 1. Redistributions of source code must retain the above copyright
  56. * notice, this list of conditions and the following disclaimer.
  57. * 2. Redistributions in binary form must reproduce the above copyright
  58. * notice, this list of conditions and the following disclaimer in the
  59. * documentation and/or other materials provided with the distribution.
  60. * 3. Neither the name of the University nor the names of its contributors
  61. * may be used to endorse or promote products derived from this software
  62. * without specific prior written permission.
  63. *
  64. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  65. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  66. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  67. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  68. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  69. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  70. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  71. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  72. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  73. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  74. * SUCH DAMAGE.
  75. */
  76. /*
  77. * $Log: in.h,v $
  78. * Revision 1.4 2007/05/02 11:18:32 haraldkipp
  79. * IGMP support added. Incomplete.
  80. *
  81. * Revision 1.3 2005/07/26 15:49:59 haraldkipp
  82. * Cygwin support added.
  83. *
  84. * Revision 1.2 2005/04/04 19:33:55 freckle
  85. * added creation of include/netdb_orig.h, include/sys/socket_orig.h and
  86. * include/netinet/in_orig.h to allow unix emulation to use tcp/ip sockets
  87. *
  88. * Revision 1.1.1.1 2003/05/09 14:41:14 haraldkipp
  89. * Initial using 3.2.1
  90. *
  91. * Revision 1.5 2003/02/04 18:00:45 harald
  92. * Version 3 released
  93. *
  94. * Revision 1.4 2002/06/26 17:29:21 harald
  95. * First pre-release with 2.4 stack
  96. *
  97. */
  98. #include <sys/types.h>
  99. /* use native version on unix emulation */
  100. #if defined(__linux__) || defined(__APPLE__) || defined(__CYGWIN__)
  101. #include <netinet/in_orig.h>
  102. /* assure _NETINET_IN_H_ is set */
  103. #undef _NETINET_IN_H_
  104. #define _NETINET_IN_H_
  105. #else /* unix emulation */
  106. #define _NETINET_IN_H_
  107. /*!
  108. * \file netinet/in.h
  109. * \brief Internet definitions.
  110. *
  111. * Constants and structures defined by the internet system.
  112. */
  113. /*
  114. * Protocols
  115. */
  116. #define IPPROTO_IP 0 /*!< \brief Dummy for IP. */
  117. #define IPPROTO_ICMP 1 /*!< \brief Control message protocol. */
  118. #define IPPROTO_IGMP 2 /*!< \brief Group management protocol. */
  119. #define IPPROTO_TCP 6 /*!< \brief Transmission control protocol. */
  120. #define IPPROTO_UDP 17 /*!< \brief User datagram protocol. */
  121. #define IPPROTO_RAW 255 /*!< \brief Raw IP packet. */
  122. #define IPPROTO_MAX 256 /*!< \brief Maximum protocol identifier. */
  123. #define IPPORT_RESERVED 1024 /*!< \brief Last reserved port number. */
  124. #define IPPORT_USERRESERVED 5000 /*!< \brief User reserved port number. */
  125. /*!
  126. * \brief Any IP address.
  127. */
  128. #define INADDR_ANY (u_long)0x00000000
  129. /*!
  130. * \brief Broadcast IP address.
  131. */
  132. #define INADDR_BROADCAST (u_long)0xffffffff
  133. /*
  134. * Definitions of bits in internet address integers.
  135. */
  136. #ifdef __BIG_ENDIAN__
  137. #define IN_CLASSA(i) (((u_long)(i) & 0x80000000) == 0)
  138. #define IN_CLASSA_NET 0xff000000
  139. #define IN_CLASSB(i) (((u_long)(i) & 0xc0000000) == 0x80000000)
  140. #define IN_CLASSB_NET 0xffff0000
  141. #define IN_CLASSC(i) (((u_long)(i) & 0xe0000000) == 0xc0000000)
  142. #define IN_CLASSC_NET 0xffffff00
  143. #define IN_CLASSD(i) (((u_long)(i) & 0xf0000000) == 0xe0000000)
  144. #define IN_CLASSD_NET 0xf0000000
  145. #else /* __BIG_ENDIAN__ */
  146. #define IN_CLASSA(i) (((u_long)(i) & 0x00000080) == 0)
  147. #define IN_CLASSA_NET 0x000000ff
  148. #define IN_CLASSB(i) (((u_long)(i) & 0x000000c0) == 0x00000080)
  149. #define IN_CLASSB_NET 0x0000ffff
  150. #define IN_CLASSC(i) (((u_long)(i) & 0x000000e0) == 0x000000c0)
  151. #define IN_CLASSC_NET 0x00ffffff
  152. #define IN_CLASSD(i) (((u_long)(i) & 0x000000f0) == 0x000000e0)
  153. #define IN_CLASSD_NET 0x0000000f
  154. #endif /* __BIG_ENDIAN__ */
  155. #define IN_MULTICAST(i) IN_CLASSD(i)
  156. #ifdef __BIG_ENDIAN__
  157. #define INADDR_UNSPEC_GROUP (u_long)0xe0000000 /* 224.0.0.0 */
  158. #define INADDR_ALLHOSTS_GROUP (u_long)0xe0000001 /* 224.0.0.1 */
  159. #define INADDR_ALLRTRS_GROUP (u_long)0xe0000002 /* 224.0.0.2 */
  160. #define INADDR_ALLRPTS_GROUP (u_long)0xe0000016 /* 224.0.0.22, IGMPv3 */
  161. #define INADDR_CARP_GROUP (u_long)0xe0000012 /* 224.0.0.18 */
  162. #define INADDR_PFSYNC_GROUP (u_long)0xe00000f0 /* 224.0.0.240 */
  163. #define INADDR_ALLMDNS_GROUP (u_long)0xe00000fb /* 224.0.0.251 */
  164. #define INADDR_MAX_LOCAL_GROUP (u_long)0xe00000ff /* 224.0.0.255 */
  165. #else /* __BIG_ENDIAN__ */
  166. #define INADDR_UNSPEC_GROUP (u_long)0x000000e0 /* 224.0.0.0 */
  167. #define INADDR_ALLHOSTS_GROUP (u_long)0x010000e0 /* 224.0.0.1 */
  168. #define INADDR_ALLRTRS_GROUP (u_long)0x020000e0 /* 224.0.0.2 */
  169. #define INADDR_ALLRPTS_GROUP (u_long)0x160000e0 /* 224.0.0.22, IGMPv3 */
  170. #define INADDR_CARP_GROUP (u_long)0x120000e0 /* 224.0.0.18 */
  171. #define INADDR_PFSYNC_GROUP (u_long)0xf00000e0 /* 224.0.0.240 */
  172. #define INADDR_ALLMDNS_GROUP (u_long)0xfb0000e0 /* 224.0.0.251 */
  173. #define INADDR_MAX_LOCAL_GROUP (u_long)0xff0000e0 /* 224.0.0.255 */
  174. #endif /* __BIG_ENDIAN__ */
  175. #ifdef __BIG_ENDIAN__
  176. #define INADDR_LOOPBACK (u_long)0x7f000001
  177. #else /* __BIG_ENDIAN__ */
  178. #define INADDR_LOOPBACK (u_long)0x0100007f
  179. #endif /* __BIG_ENDIAN__ */
  180. /*!
  181. * \brief Official loopback net address.
  182. */
  183. #define IN_LOOPBACKNET 127
  184. #endif /* unix emulation */
  185. #endif