if.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #ifndef _NET_IF_H_
  2. #define _NET_IF_H_
  3. /*
  4. * Copyright (C) 2007 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. *
  34. * -
  35. * Copyright (c) 1982, 1986, 1989, 1993
  36. * The Regents of the University of California. All rights reserved.
  37. *
  38. * Redistribution and use in source and binary forms, with or without
  39. * modification, are permitted provided that the following conditions
  40. * are met:
  41. * 1. Redistributions of source code must retain the above copyright
  42. * notice, this list of conditions and the following disclaimer.
  43. * 2. Redistributions in binary form must reproduce the above copyright
  44. * notice, this list of conditions and the following disclaimer in the
  45. * documentation and/or other materials provided with the distribution.
  46. * 3. Neither the name of the University nor the names of its contributors
  47. * may be used to endorse or promote products derived from this software
  48. * without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  51. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  52. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  53. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  54. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  55. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  56. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  57. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  58. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  59. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  60. * SUCH DAMAGE.
  61. */
  62. /*!
  63. * \file net/if.h
  64. * \brief Network interface header file.
  65. *
  66. * \verbatim
  67. *
  68. * $Log$
  69. * Revision 1.2 2008/08/11 07:00:19 haraldkipp
  70. * BSD types replaced by stdint types (feature request #1282721).
  71. *
  72. * Revision 1.1 2007/05/02 11:15:31 haraldkipp
  73. * Socket ioctl functions added. Untested.
  74. *
  75. *
  76. * \endverbatim
  77. */
  78. #include <stdint.h>
  79. /*!
  80. * \brief Length of interface name, including terminating zero character.
  81. */
  82. #define IF_NAMESIZE 8
  83. /*!
  84. * \name Interface Flags
  85. */
  86. /*@{*/
  87. #define IFF_UP 0x00000001 /*!< \brief Interface is up. */
  88. #define IFF_BROADCAST 0x00000002 /*!< \brief Broadcast address valid. */
  89. #define IFF_DEBUG 0x00000004 /*!< \brief Turn on debugging. */
  90. #define IFF_LOOPBACK 0x00000008 /*!< \brief Is a loopback net. */
  91. #define IFF_POINTOPOINT 0x00000010 /*!< \brief Is a point-to-point link. */
  92. #define IFF_NOARP 0x00000080 /*!< \brief No address resolution protocol. */
  93. #define IFF_PROMISC 0x00000100 /*!< \brief Receive all packets. */
  94. #define IFF_ALLMULTI 0x00000200 /*!< \brief Receive all multicast packets. */
  95. #define IFF_DRV_OACTIVE 0x00000400 /*!< \brief Transmit hardware queue is full. */
  96. #define IFF_SIMPLEX 0x00000800 /*!< \brief Can't hear own transmissions. */
  97. #define IFF_LINK0 0x00001000 /*!< \brief Per link layer defined bit. */
  98. #define IFF_LINK1 0x00002000 /*!< \brief Per link layer defined bit. */
  99. #define IFF_LINK2 0x00004000 /*!< \brief Per link layer defined bit. */
  100. #define IFF_MULTICAST 0x00008000 /*!< \brief Supports multicast. */
  101. #define IFF_PPROMISC 0x00020000 /*!< \brief User-requested promisc mode. */
  102. #define IFF_MONITOR 0x00040000 /*!< \brief User-requested monitor mode. */
  103. #define IFF_STATICARP 0x00080000 /*!< \brief Static ARP. */
  104. /*@}*/
  105. /*!
  106. * \name Interface Link State
  107. */
  108. /*@{*/
  109. #define LINK_STATE_UNKNOWN 0 /* Link invalid/unknown. */
  110. #define LINK_STATE_DOWN 1 /* Link is down. */
  111. #define LINK_STATE_UP 2 /* Link is up. */
  112. /*@}*/
  113. /*!
  114. * \brief Interface request structure used for socket ioctl's.
  115. */
  116. struct ifreq {
  117. char ifr_name[IF_NAMESIZE];
  118. union {
  119. uint32_t ifru_addr;
  120. uint32_t ifru_dstaddr;
  121. uint32_t ifru_broadaddr;
  122. uint16_t ifru_flags[2];
  123. uint16_t ifru_index;
  124. int ifru_metric;
  125. int ifru_mtu;
  126. int ifru_phys;
  127. int ifru_media;
  128. int ifru_cap[2];
  129. } ifr_ifru;
  130. };
  131. #endif