route.h 2.5 KB

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