route.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* Copyright (C) 1997, 2002 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. /* Based on the 4.4BSD and Linux version of this file. */
  16. #ifndef _NET_ROUTE_H
  17. #define _NET_ROUTE_H 1
  18. #include <features.h>
  19. #include <sys/socket.h>
  20. #include <sys/types.h>
  21. #include <netinet/in.h>
  22. #include <bits/wordsize.h>
  23. /* This structure gets passed by the SIOCADDRT and SIOCDELRT calls. */
  24. struct rtentry
  25. {
  26. unsigned long int rt_pad1;
  27. struct sockaddr rt_dst; /* Target address. */
  28. struct sockaddr rt_gateway; /* Gateway addr (RTF_GATEWAY). */
  29. struct sockaddr rt_genmask; /* Target network mask (IP). */
  30. unsigned short int rt_flags;
  31. short int rt_pad2;
  32. unsigned long int rt_pad3;
  33. unsigned char rt_tos;
  34. unsigned char rt_class;
  35. #if __WORDSIZE == 64
  36. short int rt_pad4[3];
  37. #else
  38. short int rt_pad4;
  39. #endif
  40. short int rt_metric; /* +1 for binary compatibility! */
  41. char *rt_dev; /* Forcing the device at add. */
  42. unsigned long int rt_mtu; /* Per route MTU/Window. */
  43. unsigned long int rt_window; /* Window clamping. */
  44. unsigned short int rt_irtt; /* Initial RTT. */
  45. };
  46. /* Compatibility hack. */
  47. #define rt_mss rt_mtu
  48. #if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
  49. struct in6_rtmsg
  50. {
  51. struct in6_addr rtmsg_dst;
  52. struct in6_addr rtmsg_src;
  53. struct in6_addr rtmsg_gateway;
  54. u_int32_t rtmsg_type;
  55. u_int16_t rtmsg_dst_len;
  56. u_int16_t rtmsg_src_len;
  57. u_int32_t rtmsg_metric;
  58. unsigned long int rtmsg_info;
  59. u_int32_t rtmsg_flags;
  60. int rtmsg_ifindex;
  61. };
  62. #endif
  63. #define RTF_UP 0x0001 /* Route usable. */
  64. #define RTF_GATEWAY 0x0002 /* Destination is a gateway. */
  65. #define RTF_HOST 0x0004 /* Host entry (net otherwise). */
  66. #define RTF_REINSTATE 0x0008 /* Reinstate route after timeout. */
  67. #define RTF_DYNAMIC 0x0010 /* Created dyn. (by redirect). */
  68. #define RTF_MODIFIED 0x0020 /* Modified dyn. (by redirect). */
  69. #define RTF_MTU 0x0040 /* Specific MTU for this route. */
  70. #define RTF_MSS RTF_MTU /* Compatibility. */
  71. #define RTF_WINDOW 0x0080 /* Per route window clamping. */
  72. #define RTF_IRTT 0x0100 /* Initial round trip time. */
  73. #define RTF_REJECT 0x0200 /* Reject route. */
  74. #define RTF_STATIC 0x0400 /* Manually injected route. */
  75. #define RTF_XRESOLVE 0x0800 /* External resolver. */
  76. #define RTF_NOFORWARD 0x1000 /* Forwarding inhibited. */
  77. #define RTF_THROW 0x2000 /* Go to next class. */
  78. #define RTF_NOPMTUDISC 0x4000 /* Do not send packets with DF. */
  79. /* for IPv6 */
  80. #define RTF_DEFAULT 0x00010000 /* default - learned via ND */
  81. #define RTF_ALLONLINK 0x00020000 /* fallback, no routers on link */
  82. #define RTF_ADDRCONF 0x00040000 /* addrconf route - RA */
  83. #define RTF_LINKRT 0x00100000 /* link specific - device match */
  84. #define RTF_NONEXTHOP 0x00200000 /* route with no nexthop */
  85. #define RTF_CACHE 0x01000000 /* cache entry */
  86. #define RTF_FLOW 0x02000000 /* flow significant route */
  87. #define RTF_POLICY 0x04000000 /* policy route */
  88. #define RTCF_VALVE 0x00200000
  89. #define RTCF_MASQ 0x00400000
  90. #define RTCF_NAT 0x00800000
  91. #define RTCF_DOREDIRECT 0x01000000
  92. #define RTCF_LOG 0x02000000
  93. #define RTCF_DIRECTSRC 0x04000000
  94. #define RTF_LOCAL 0x80000000
  95. #define RTF_INTERFACE 0x40000000
  96. #define RTF_MULTICAST 0x20000000
  97. #define RTF_BROADCAST 0x10000000
  98. #define RTF_NAT 0x08000000
  99. #define RTF_ADDRCLASSMASK 0xF8000000
  100. #define RT_ADDRCLASS(flags) ((__u_int32_t) flags >> 23)
  101. #define RT_TOS(tos) ((tos) & IPTOS_TOS_MASK)
  102. #define RT_LOCALADDR(flags) ((flags & RTF_ADDRCLASSMASK) \
  103. == (RTF_LOCAL|RTF_INTERFACE))
  104. #define RT_CLASS_UNSPEC 0
  105. #define RT_CLASS_DEFAULT 253
  106. #define RT_CLASS_MAIN 254
  107. #define RT_CLASS_LOCAL 255
  108. #define RT_CLASS_MAX 255
  109. #if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
  110. #define RTMSG_ACK NLMSG_ACK
  111. #define RTMSG_OVERRUN NLMSG_OVERRUN
  112. #define RTMSG_NEWDEVICE 0x11
  113. #define RTMSG_DELDEVICE 0x12
  114. #define RTMSG_NEWROUTE 0x21
  115. #define RTMSG_DELROUTE 0x22
  116. #define RTMSG_NEWRULE 0x31
  117. #define RTMSG_DELRULE 0x32
  118. #define RTMSG_CONTROL 0x40
  119. #define RTMSG_AR_FAILED 0x51 /* Address Resolution failed. */
  120. #endif
  121. #endif /* net/route.h */