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