2
0

route.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #ifndef _NET_ROUTE_H
  2. #define _NET_ROUTE_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdint.h>
  7. #include <sys/socket.h>
  8. #include <sys/types.h>
  9. #include <netinet/in.h>
  10. struct rtentry {
  11. unsigned long int rt_pad1;
  12. struct sockaddr rt_dst;
  13. struct sockaddr rt_gateway;
  14. struct sockaddr rt_genmask;
  15. unsigned short int rt_flags;
  16. short int rt_pad2;
  17. unsigned long int rt_pad3;
  18. unsigned char rt_tos;
  19. unsigned char rt_class;
  20. short int rt_pad4[sizeof(long)/2-1];
  21. short int rt_metric;
  22. char *rt_dev;
  23. unsigned long int rt_mtu;
  24. unsigned long int rt_window;
  25. unsigned short int rt_irtt;
  26. };
  27. #define rt_mss rt_mtu
  28. struct in6_rtmsg {
  29. struct in6_addr rtmsg_dst;
  30. struct in6_addr rtmsg_src;
  31. struct in6_addr rtmsg_gateway;
  32. uint32_t rtmsg_type;
  33. uint16_t rtmsg_dst_len;
  34. uint16_t rtmsg_src_len;
  35. uint32_t rtmsg_metric;
  36. unsigned long int rtmsg_info;
  37. uint32_t rtmsg_flags;
  38. int rtmsg_ifindex;
  39. };
  40. #define RTF_UP 0x0001
  41. #define RTF_GATEWAY 0x0002
  42. #define RTF_HOST 0x0004
  43. #define RTF_REINSTATE 0x0008
  44. #define RTF_DYNAMIC 0x0010
  45. #define RTF_MODIFIED 0x0020
  46. #define RTF_MTU 0x0040
  47. #define RTF_MSS RTF_MTU
  48. #define RTF_WINDOW 0x0080
  49. #define RTF_IRTT 0x0100
  50. #define RTF_REJECT 0x0200
  51. #define RTF_STATIC 0x0400
  52. #define RTF_XRESOLVE 0x0800
  53. #define RTF_NOFORWARD 0x1000
  54. #define RTF_THROW 0x2000
  55. #define RTF_NOPMTUDISC 0x4000
  56. #define RTF_DEFAULT 0x00010000
  57. #define RTF_ALLONLINK 0x00020000
  58. #define RTF_ADDRCONF 0x00040000
  59. #define RTF_LINKRT 0x00100000
  60. #define RTF_NONEXTHOP 0x00200000
  61. #define RTF_CACHE 0x01000000
  62. #define RTF_FLOW 0x02000000
  63. #define RTF_POLICY 0x04000000
  64. #define RTCF_VALVE 0x00200000
  65. #define RTCF_MASQ 0x00400000
  66. #define RTCF_NAT 0x00800000
  67. #define RTCF_DOREDIRECT 0x01000000
  68. #define RTCF_LOG 0x02000000
  69. #define RTCF_DIRECTSRC 0x04000000
  70. #define RTF_LOCAL 0x80000000
  71. #define RTF_INTERFACE 0x40000000
  72. #define RTF_MULTICAST 0x20000000
  73. #define RTF_BROADCAST 0x10000000
  74. #define RTF_NAT 0x08000000
  75. #define RTF_ADDRCLASSMASK 0xF8000000
  76. #define RT_ADDRCLASS(flags) ((uint32_t) flags >> 23)
  77. #define RT_TOS(tos) ((tos) & IPTOS_TOS_MASK)
  78. #define RT_LOCALADDR(flags) ((flags & RTF_ADDRCLASSMASK) \
  79. == (RTF_LOCAL|RTF_INTERFACE))
  80. #define RT_CLASS_UNSPEC 0
  81. #define RT_CLASS_DEFAULT 253
  82. #define RT_CLASS_MAIN 254
  83. #define RT_CLASS_LOCAL 255
  84. #define RT_CLASS_MAX 255
  85. #define RTMSG_ACK NLMSG_ACK
  86. #define RTMSG_OVERRUN NLMSG_OVERRUN
  87. #define RTMSG_NEWDEVICE 0x11
  88. #define RTMSG_DELDEVICE 0x12
  89. #define RTMSG_NEWROUTE 0x21
  90. #define RTMSG_DELROUTE 0x22
  91. #define RTMSG_NEWRULE 0x31
  92. #define RTMSG_DELRULE 0x32
  93. #define RTMSG_CONTROL 0x40
  94. #define RTMSG_AR_FAILED 0x51
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif