| [2] | 1 | #ifndef __LINUX_RTNETLINK_H |
|---|
| 2 | #define __LINUX_RTNETLINK_H |
|---|
| 3 | |
|---|
| 4 | #include <linux/netlink.h> |
|---|
| 5 | |
|---|
| 6 | /**** |
|---|
| 7 | * Routing/neighbour discovery messages. |
|---|
| 8 | ****/ |
|---|
| 9 | |
|---|
| 10 | /* Types of messages */ |
|---|
| 11 | |
|---|
| 12 | enum { |
|---|
| 13 | RTM_BASE = 16, |
|---|
| 14 | #define RTM_BASE RTM_BASE |
|---|
| 15 | |
|---|
| 16 | RTM_NEWLINK = 16, |
|---|
| 17 | #define RTM_NEWLINK RTM_NEWLINK |
|---|
| 18 | RTM_DELLINK, |
|---|
| 19 | #define RTM_DELLINK RTM_DELLINK |
|---|
| 20 | RTM_GETLINK, |
|---|
| 21 | #define RTM_GETLINK RTM_GETLINK |
|---|
| 22 | RTM_SETLINK, |
|---|
| 23 | #define RTM_SETLINK RTM_SETLINK |
|---|
| 24 | |
|---|
| 25 | RTM_NEWADDR = 20, |
|---|
| 26 | #define RTM_NEWADDR RTM_NEWADDR |
|---|
| 27 | RTM_DELADDR, |
|---|
| 28 | #define RTM_DELADDR RTM_DELADDR |
|---|
| 29 | RTM_GETADDR, |
|---|
| 30 | #define RTM_GETADDR RTM_GETADDR |
|---|
| 31 | |
|---|
| 32 | RTM_NEWROUTE = 24, |
|---|
| 33 | #define RTM_NEWROUTE RTM_NEWROUTE |
|---|
| 34 | RTM_DELROUTE, |
|---|
| 35 | #define RTM_DELROUTE RTM_DELROUTE |
|---|
| 36 | RTM_GETROUTE, |
|---|
| 37 | #define RTM_GETROUTE RTM_GETROUTE |
|---|
| 38 | |
|---|
| 39 | RTM_NEWNEIGH = 28, |
|---|
| 40 | #define RTM_NEWNEIGH RTM_NEWNEIGH |
|---|
| 41 | RTM_DELNEIGH, |
|---|
| 42 | #define RTM_DELNEIGH RTM_DELNEIGH |
|---|
| 43 | RTM_GETNEIGH, |
|---|
| 44 | #define RTM_GETNEIGH RTM_GETNEIGH |
|---|
| 45 | |
|---|
| 46 | RTM_NEWRULE = 32, |
|---|
| 47 | #define RTM_NEWRULE RTM_NEWRULE |
|---|
| 48 | RTM_DELRULE, |
|---|
| 49 | #define RTM_DELRULE RTM_DELRULE |
|---|
| 50 | RTM_GETRULE, |
|---|
| 51 | #define RTM_GETRULE RTM_GETRULE |
|---|
| 52 | |
|---|
| 53 | RTM_NEWQDISC = 36, |
|---|
| 54 | #define RTM_NEWQDISC RTM_NEWQDISC |
|---|
| 55 | RTM_DELQDISC, |
|---|
| 56 | #define RTM_DELQDISC RTM_DELQDISC |
|---|
| 57 | RTM_GETQDISC, |
|---|
| 58 | #define RTM_GETQDISC RTM_GETQDISC |
|---|
| 59 | |
|---|
| 60 | RTM_NEWTCLASS = 40, |
|---|
| 61 | #define RTM_NEWTCLASS RTM_NEWTCLASS |
|---|
| 62 | RTM_DELTCLASS, |
|---|
| 63 | #define RTM_DELTCLASS RTM_DELTCLASS |
|---|
| 64 | RTM_GETTCLASS, |
|---|
| 65 | #define RTM_GETTCLASS RTM_GETTCLASS |
|---|
| 66 | |
|---|
| 67 | RTM_NEWTFILTER = 44, |
|---|
| 68 | #define RTM_NEWTFILTER RTM_NEWTFILTER |
|---|
| 69 | RTM_DELTFILTER, |
|---|
| 70 | #define RTM_DELTFILTER RTM_DELTFILTER |
|---|
| 71 | RTM_GETTFILTER, |
|---|
| 72 | #define RTM_GETTFILTER RTM_GETTFILTER |
|---|
| 73 | |
|---|
| 74 | RTM_NEWACTION = 48, |
|---|
| 75 | #define RTM_NEWACTION RTM_NEWACTION |
|---|
| 76 | RTM_DELACTION, |
|---|
| 77 | #define RTM_DELACTION RTM_DELACTION |
|---|
| 78 | RTM_GETACTION, |
|---|
| 79 | #define RTM_GETACTION RTM_GETACTION |
|---|
| 80 | |
|---|
| 81 | RTM_NEWPREFIX = 52, |
|---|
| 82 | #define RTM_NEWPREFIX RTM_NEWPREFIX |
|---|
| 83 | RTM_GETPREFIX = 54, |
|---|
| 84 | #define RTM_GETPREFIX RTM_GETPREFIX |
|---|
| 85 | |
|---|
| 86 | RTM_GETMULTICAST = 58, |
|---|
| 87 | #define RTM_GETMULTICAST RTM_GETMULTICAST |
|---|
| 88 | |
|---|
| 89 | RTM_GETANYCAST = 62, |
|---|
| 90 | #define RTM_GETANYCAST RTM_GETANYCAST |
|---|
| 91 | |
|---|
| 92 | __RTM_MAX, |
|---|
| 93 | #define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) |
|---|
| 94 | }; |
|---|
| 95 | |
|---|
| 96 | #define RTM_NR_MSGTYPES (RTM_MAX + 1 - RTM_BASE) |
|---|
| 97 | #define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2) |
|---|
| 98 | #define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2) |
|---|
| 99 | |
|---|
| 100 | /* |
|---|
| 101 | Generic structure for encapsulation of optional route information. |
|---|
| 102 | It is reminiscent of sockaddr, but with sa_family replaced |
|---|
| 103 | with attribute type. |
|---|
| 104 | */ |
|---|
| 105 | |
|---|
| 106 | struct rtattr |
|---|
| 107 | { |
|---|
| 108 | unsigned short rta_len; |
|---|
| 109 | unsigned short rta_type; |
|---|
| 110 | }; |
|---|
| 111 | |
|---|
| 112 | /* Macros to handle rtattributes */ |
|---|
| 113 | |
|---|
| 114 | #define RTA_ALIGNTO 4 |
|---|
| 115 | #define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) ) |
|---|
| 116 | #define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \ |
|---|
| 117 | (rta)->rta_len >= sizeof(struct rtattr) && \ |
|---|
| 118 | (rta)->rta_len <= (len)) |
|---|
| 119 | #define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \ |
|---|
| 120 | (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len))) |
|---|
| 121 | #define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len)) |
|---|
| 122 | #define RTA_SPACE(len) RTA_ALIGN(RTA_LENGTH(len)) |
|---|
| 123 | #define RTA_DATA(rta) ((void*)(((char*)(rta)) + RTA_LENGTH(0))) |
|---|
| 124 | #define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0)) |
|---|
| 125 | |
|---|
| 126 | |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | /****************************************************************************** |
|---|
| 130 | * Definitions used in routing table administration. |
|---|
| 131 | ****/ |
|---|
| 132 | |
|---|
| 133 | struct rtmsg |
|---|
| 134 | { |
|---|
| 135 | unsigned char rtm_family; |
|---|
| 136 | unsigned char rtm_dst_len; |
|---|
| 137 | unsigned char rtm_src_len; |
|---|
| 138 | unsigned char rtm_tos; |
|---|
| 139 | |
|---|
| 140 | unsigned char rtm_table; /* Routing table id */ |
|---|
| 141 | unsigned char rtm_protocol; /* Routing protocol; see below */ |
|---|
| 142 | unsigned char rtm_scope; /* See below */ |
|---|
| 143 | unsigned char rtm_type; /* See below */ |
|---|
| 144 | |
|---|
| 145 | unsigned rtm_flags; |
|---|
| 146 | }; |
|---|
| 147 | |
|---|
| 148 | /* rtm_type */ |
|---|
| 149 | |
|---|
| 150 | enum |
|---|
| 151 | { |
|---|
| 152 | RTN_UNSPEC, |
|---|
| 153 | RTN_UNICAST, /* Gateway or direct route */ |
|---|
| 154 | RTN_LOCAL, /* Accept locally */ |
|---|
| 155 | RTN_BROADCAST, /* Accept locally as broadcast, |
|---|
| 156 | send as broadcast */ |
|---|
| 157 | RTN_ANYCAST, /* Accept locally as broadcast, |
|---|
| 158 | but send as unicast */ |
|---|
| 159 | RTN_MULTICAST, /* Multicast route */ |
|---|
| 160 | RTN_BLACKHOLE, /* Drop */ |
|---|
| 161 | RTN_UNREACHABLE, /* Destination is unreachable */ |
|---|
| 162 | RTN_PROHIBIT, /* Administratively prohibited */ |
|---|
| 163 | RTN_THROW, /* Not in this table */ |
|---|
| 164 | RTN_NAT, /* Translate this address */ |
|---|
| 165 | RTN_XRESOLVE, /* Use external resolver */ |
|---|
| 166 | __RTN_MAX |
|---|
| 167 | }; |
|---|
| 168 | |
|---|
| 169 | #define RTN_MAX (__RTN_MAX - 1) |
|---|
| 170 | |
|---|
| 171 | |
|---|
| 172 | /* rtm_protocol */ |
|---|
| 173 | |
|---|
| 174 | #define RTPROT_UNSPEC 0 |
|---|
| 175 | #define RTPROT_REDIRECT 1 /* Route installed by ICMP redirects; |
|---|
| 176 | not used by current IPv4 */ |
|---|
| 177 | #define RTPROT_KERNEL 2 /* Route installed by kernel */ |
|---|
| 178 | #define RTPROT_BOOT 3 /* Route installed during boot */ |
|---|
| 179 | #define RTPROT_STATIC 4 /* Route installed by administrator */ |
|---|
| 180 | |
|---|
| 181 | /* Values of protocol >= RTPROT_STATIC are not interpreted by kernel; |
|---|
| 182 | they are just passed from user and back as is. |
|---|
| 183 | It will be used by hypothetical multiple routing daemons. |
|---|
| 184 | Note that protocol values should be standardized in order to |
|---|
| 185 | avoid conflicts. |
|---|
| 186 | */ |
|---|
| 187 | |
|---|
| 188 | #define RTPROT_GATED 8 /* Apparently, GateD */ |
|---|
| 189 | #define RTPROT_RA 9 /* RDISC/ND router advertisements */ |
|---|
| 190 | #define RTPROT_MRT 10 /* Merit MRT */ |
|---|
| 191 | #define RTPROT_ZEBRA 11 /* Zebra */ |
|---|
| 192 | #define RTPROT_BIRD 12 /* BIRD */ |
|---|
| 193 | #define RTPROT_DNROUTED 13 /* DECnet routing daemon */ |
|---|
| 194 | |
|---|
| 195 | /* rtm_scope |
|---|
| 196 | |
|---|
| 197 | Really it is not scope, but sort of distance to the destination. |
|---|
| 198 | NOWHERE are reserved for not existing destinations, HOST is our |
|---|
| 199 | local addresses, LINK are destinations, located on directly attached |
|---|
| 200 | link and UNIVERSE is everywhere in the Universe. |
|---|
| 201 | |
|---|
| 202 | Intermediate values are also possible f.e. interior routes |
|---|
| 203 | could be assigned a value between UNIVERSE and LINK. |
|---|
| 204 | */ |
|---|
| 205 | |
|---|
| 206 | enum rt_scope_t |
|---|
| 207 | { |
|---|
| 208 | RT_SCOPE_UNIVERSE=0, |
|---|
| 209 | /* User defined values */ |
|---|
| 210 | RT_SCOPE_SITE=200, |
|---|
| 211 | RT_SCOPE_LINK=253, |
|---|
| 212 | RT_SCOPE_HOST=254, |
|---|
| 213 | RT_SCOPE_NOWHERE=255 |
|---|
| 214 | }; |
|---|
| 215 | |
|---|
| 216 | /* rtm_flags */ |
|---|
| 217 | |
|---|
| 218 | #define RTM_F_NOTIFY 0x100 /* Notify user of route change */ |
|---|
| 219 | #define RTM_F_CLONED 0x200 /* This route is cloned */ |
|---|
| 220 | #define RTM_F_EQUALIZE 0x400 /* Multipath equalizer: NI */ |
|---|
| 221 | #define RTM_F_PREFIX 0x800 /* Prefix addresses */ |
|---|
| 222 | |
|---|
| 223 | /* Reserved table identifiers */ |
|---|
| 224 | |
|---|
| 225 | enum rt_class_t |
|---|
| 226 | { |
|---|
| 227 | RT_TABLE_UNSPEC=0, |
|---|
| 228 | /* User defined values */ |
|---|
| 229 | RT_TABLE_DEFAULT=253, |
|---|
| 230 | RT_TABLE_MAIN=254, |
|---|
| 231 | RT_TABLE_LOCAL=255, |
|---|
| 232 | __RT_TABLE_MAX |
|---|
| 233 | }; |
|---|
| 234 | #define RT_TABLE_MAX (__RT_TABLE_MAX - 1) |
|---|
| 235 | |
|---|
| 236 | |
|---|
| 237 | |
|---|
| 238 | /* Routing message attributes */ |
|---|
| 239 | |
|---|
| 240 | enum rtattr_type_t |
|---|
| 241 | { |
|---|
| 242 | RTA_UNSPEC, |
|---|
| 243 | RTA_DST, |
|---|
| 244 | RTA_SRC, |
|---|
| 245 | RTA_IIF, |
|---|
| 246 | RTA_OIF, |
|---|
| 247 | RTA_GATEWAY, |
|---|
| 248 | RTA_PRIORITY, |
|---|
| 249 | RTA_PREFSRC, |
|---|
| 250 | RTA_METRICS, |
|---|
| 251 | RTA_MULTIPATH, |
|---|
| 252 | RTA_PROTOINFO, |
|---|
| 253 | RTA_FLOW, |
|---|
| 254 | RTA_CACHEINFO, |
|---|
| 255 | RTA_SESSION, |
|---|
| 256 | RTA_MP_ALGO, |
|---|
| 257 | __RTA_MAX |
|---|
| 258 | }; |
|---|
| 259 | |
|---|
| 260 | #define RTA_MAX (__RTA_MAX - 1) |
|---|
| 261 | |
|---|
| 262 | #define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg)))) |
|---|
| 263 | #define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg)) |
|---|
| 264 | |
|---|
| 265 | /* RTM_MULTIPATH --- array of struct rtnexthop. |
|---|
| 266 | * |
|---|
| 267 | * "struct rtnexthop" describes all necessary nexthop information, |
|---|
| 268 | * i.e. parameters of path to a destination via this nexthop. |
|---|
| 269 | * |
|---|
| 270 | * At the moment it is impossible to set different prefsrc, mtu, window |
|---|
| 271 | * and rtt for different paths from multipath. |
|---|
| 272 | */ |
|---|
| 273 | |
|---|
| 274 | struct rtnexthop |
|---|
| 275 | { |
|---|
| 276 | unsigned short rtnh_len; |
|---|
| 277 | unsigned char rtnh_flags; |
|---|
| 278 | unsigned char rtnh_hops; |
|---|
| 279 | int rtnh_ifindex; |
|---|
| 280 | }; |
|---|
| 281 | |
|---|
| 282 | /* rtnh_flags */ |
|---|
| 283 | |
|---|
| 284 | #define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */ |
|---|
| 285 | #define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */ |
|---|
| 286 | #define RTNH_F_ONLINK 4 /* Gateway is forced on link */ |
|---|
| 287 | |
|---|
| 288 | /* Macros to handle hexthops */ |
|---|
| 289 | |
|---|
| 290 | #define RTNH_ALIGNTO 4 |
|---|
| 291 | #define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) ) |
|---|
| 292 | #define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \ |
|---|
| 293 | ((int)(rtnh)->rtnh_len) <= (len)) |
|---|
| 294 | #define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len))) |
|---|
| 295 | #define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len)) |
|---|
| 296 | #define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len)) |
|---|
| 297 | #define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0))) |
|---|
| 298 | |
|---|
| 299 | /* RTM_CACHEINFO */ |
|---|
| 300 | |
|---|
| 301 | struct rta_cacheinfo |
|---|
| 302 | { |
|---|
| 303 | __u32 rta_clntref; |
|---|
| 304 | __u32 rta_lastuse; |
|---|
| 305 | __s32 rta_expires; |
|---|
| 306 | __u32 rta_error; |
|---|
| 307 | __u32 rta_used; |
|---|
| 308 | |
|---|
| 309 | #define RTNETLINK_HAVE_PEERINFO 1 |
|---|
| 310 | __u32 rta_id; |
|---|
| 311 | __u32 rta_ts; |
|---|
| 312 | __u32 rta_tsage; |
|---|
| 313 | }; |
|---|
| 314 | |
|---|
| 315 | /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */ |
|---|
| 316 | |
|---|
| 317 | enum |
|---|
| 318 | { |
|---|
| 319 | RTAX_UNSPEC, |
|---|
| 320 | #define RTAX_UNSPEC RTAX_UNSPEC |
|---|
| 321 | RTAX_LOCK, |
|---|
| 322 | #define RTAX_LOCK RTAX_LOCK |
|---|
| 323 | RTAX_MTU, |
|---|
| 324 | #define RTAX_MTU RTAX_MTU |
|---|
| 325 | RTAX_WINDOW, |
|---|
| 326 | #define RTAX_WINDOW RTAX_WINDOW |
|---|
| 327 | RTAX_RTT, |
|---|
| 328 | #define RTAX_RTT RTAX_RTT |
|---|
| 329 | RTAX_RTTVAR, |
|---|
| 330 | #define RTAX_RTTVAR RTAX_RTTVAR |
|---|
| 331 | RTAX_SSTHRESH, |
|---|
| 332 | #define RTAX_SSTHRESH RTAX_SSTHRESH |
|---|
| 333 | RTAX_CWND, |
|---|
| 334 | #define RTAX_CWND RTAX_CWND |
|---|
| 335 | RTAX_ADVMSS, |
|---|
| 336 | #define RTAX_ADVMSS RTAX_ADVMSS |
|---|
| 337 | RTAX_REORDERING, |
|---|
| 338 | #define RTAX_REORDERING RTAX_REORDERING |
|---|
| 339 | RTAX_HOPLIMIT, |
|---|
| 340 | #define RTAX_HOPLIMIT RTAX_HOPLIMIT |
|---|
| 341 | RTAX_INITCWND, |
|---|
| 342 | #define RTAX_INITCWND RTAX_INITCWND |
|---|
| 343 | RTAX_FEATURES, |
|---|
| 344 | #define RTAX_FEATURES RTAX_FEATURES |
|---|
| 345 | __RTAX_MAX |
|---|
| 346 | }; |
|---|
| 347 | |
|---|
| 348 | #define RTAX_MAX (__RTAX_MAX - 1) |
|---|
| 349 | |
|---|
| 350 | #define RTAX_FEATURE_ECN 0x00000001 |
|---|
| 351 | #define RTAX_FEATURE_SACK 0x00000002 |
|---|
| 352 | #define RTAX_FEATURE_TIMESTAMP 0x00000004 |
|---|
| 353 | #define RTAX_FEATURE_ALLFRAG 0x00000008 |
|---|
| 354 | |
|---|
| 355 | struct rta_session |
|---|
| 356 | { |
|---|
| 357 | __u8 proto; |
|---|
| 358 | |
|---|
| 359 | union { |
|---|
| 360 | struct { |
|---|
| 361 | __u16 sport; |
|---|
| 362 | __u16 dport; |
|---|
| 363 | } ports; |
|---|
| 364 | |
|---|
| 365 | struct { |
|---|
| 366 | __u8 type; |
|---|
| 367 | __u8 code; |
|---|
| 368 | __u16 ident; |
|---|
| 369 | } icmpt; |
|---|
| 370 | |
|---|
| 371 | __u32 spi; |
|---|
| 372 | } u; |
|---|
| 373 | }; |
|---|
| 374 | |
|---|
| 375 | |
|---|
| 376 | /********************************************************* |
|---|
| 377 | * Interface address. |
|---|
| 378 | ****/ |
|---|
| 379 | |
|---|
| 380 | struct ifaddrmsg |
|---|
| 381 | { |
|---|
| 382 | unsigned char ifa_family; |
|---|
| 383 | unsigned char ifa_prefixlen; /* The prefix length */ |
|---|
| 384 | unsigned char ifa_flags; /* Flags */ |
|---|
| 385 | unsigned char ifa_scope; /* See above */ |
|---|
| 386 | int ifa_index; /* Link index */ |
|---|
| 387 | }; |
|---|
| 388 | |
|---|
| 389 | enum |
|---|
| 390 | { |
|---|
| 391 | IFA_UNSPEC, |
|---|
| 392 | IFA_ADDRESS, |
|---|
| 393 | IFA_LOCAL, |
|---|
| 394 | IFA_LABEL, |
|---|
| 395 | IFA_BROADCAST, |
|---|
| 396 | IFA_ANYCAST, |
|---|
| 397 | IFA_CACHEINFO, |
|---|
| 398 | IFA_MULTICAST, |
|---|
| 399 | __IFA_MAX |
|---|
| 400 | }; |
|---|
| 401 | |
|---|
| 402 | #define IFA_MAX (__IFA_MAX - 1) |
|---|
| 403 | |
|---|
| 404 | /* ifa_flags */ |
|---|
| 405 | |
|---|
| 406 | #define IFA_F_SECONDARY 0x01 |
|---|
| 407 | #define IFA_F_TEMPORARY IFA_F_SECONDARY |
|---|
| 408 | |
|---|
| 409 | #define IFA_F_DEPRECATED 0x20 |
|---|
| 410 | #define IFA_F_TENTATIVE 0x40 |
|---|
| 411 | #define IFA_F_PERMANENT 0x80 |
|---|
| 412 | |
|---|
| 413 | struct ifa_cacheinfo |
|---|
| 414 | { |
|---|
| 415 | __u32 ifa_prefered; |
|---|
| 416 | __u32 ifa_valid; |
|---|
| 417 | __u32 cstamp; /* created timestamp, hundredths of seconds */ |
|---|
| 418 | __u32 tstamp; /* updated timestamp, hundredths of seconds */ |
|---|
| 419 | }; |
|---|
| 420 | |
|---|
| 421 | |
|---|
| 422 | #define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg)))) |
|---|
| 423 | #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg)) |
|---|
| 424 | |
|---|
| 425 | /* |
|---|
| 426 | Important comment: |
|---|
| 427 | IFA_ADDRESS is prefix address, rather than local interface address. |
|---|
| 428 | It makes no difference for normally configured broadcast interfaces, |
|---|
| 429 | but for point-to-point IFA_ADDRESS is DESTINATION address, |
|---|
| 430 | local address is supplied in IFA_LOCAL attribute. |
|---|
| 431 | */ |
|---|
| 432 | |
|---|
| 433 | /************************************************************** |
|---|
| 434 | * Neighbour discovery. |
|---|
| 435 | ****/ |
|---|
| 436 | |
|---|
| 437 | struct ndmsg |
|---|
| 438 | { |
|---|
| 439 | unsigned char ndm_family; |
|---|
| 440 | unsigned char ndm_pad1; |
|---|
| 441 | unsigned short ndm_pad2; |
|---|
| 442 | int ndm_ifindex; /* Link index */ |
|---|
| 443 | __u16 ndm_state; |
|---|
| 444 | __u8 ndm_flags; |
|---|
| 445 | __u8 ndm_type; |
|---|
| 446 | }; |
|---|
| 447 | |
|---|
| 448 | enum |
|---|
| 449 | { |
|---|
| 450 | NDA_UNSPEC, |
|---|
| 451 | NDA_DST, |
|---|
| 452 | NDA_LLADDR, |
|---|
| 453 | NDA_CACHEINFO, |
|---|
| 454 | NDA_PROBES, |
|---|
| 455 | __NDA_MAX |
|---|
| 456 | }; |
|---|
| 457 | |
|---|
| 458 | #define NDA_MAX (__NDA_MAX - 1) |
|---|
| 459 | |
|---|
| 460 | #define NDA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg)))) |
|---|
| 461 | #define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg)) |
|---|
| 462 | |
|---|
| 463 | /* |
|---|
| 464 | * Neighbor Cache Entry Flags |
|---|
| 465 | */ |
|---|
| 466 | |
|---|
| 467 | #define NTF_PROXY 0x08 /* == ATF_PUBL */ |
|---|
| 468 | #define NTF_ROUTER 0x80 |
|---|
| 469 | |
|---|
| 470 | /* |
|---|
| 471 | * Neighbor Cache Entry States. |
|---|
| 472 | */ |
|---|
| 473 | |
|---|
| 474 | #define NUD_INCOMPLETE 0x01 |
|---|
| 475 | #define NUD_REACHABLE 0x02 |
|---|
| 476 | #define NUD_STALE 0x04 |
|---|
| 477 | #define NUD_DELAY 0x08 |
|---|
| 478 | #define NUD_PROBE 0x10 |
|---|
| 479 | #define NUD_FAILED 0x20 |
|---|
| 480 | |
|---|
| 481 | /* Dummy states */ |
|---|
| 482 | #define NUD_NOARP 0x40 |
|---|
| 483 | #define NUD_PERMANENT 0x80 |
|---|
| 484 | #define NUD_NONE 0x00 |
|---|
| 485 | |
|---|
| 486 | |
|---|
| 487 | struct nda_cacheinfo |
|---|
| 488 | { |
|---|
| 489 | __u32 ndm_confirmed; |
|---|
| 490 | __u32 ndm_used; |
|---|
| 491 | __u32 ndm_updated; |
|---|
| 492 | __u32 ndm_refcnt; |
|---|
| 493 | }; |
|---|
| 494 | |
|---|
| 495 | /**** |
|---|
| 496 | * General form of address family dependent message. |
|---|
| 497 | ****/ |
|---|
| 498 | |
|---|
| 499 | struct rtgenmsg |
|---|
| 500 | { |
|---|
| 501 | unsigned char rtgen_family; |
|---|
| 502 | }; |
|---|
| 503 | |
|---|
| 504 | /***************************************************************** |
|---|
| 505 | * Link layer specific messages. |
|---|
| 506 | ****/ |
|---|
| 507 | |
|---|
| 508 | /* struct ifinfomsg |
|---|
| 509 | * passes link level specific information, not dependent |
|---|
| 510 | * on network protocol. |
|---|
| 511 | */ |
|---|
| 512 | |
|---|
| 513 | struct ifinfomsg |
|---|
| 514 | { |
|---|
| 515 | unsigned char ifi_family; |
|---|
| 516 | unsigned char __ifi_pad; |
|---|
| 517 | unsigned short ifi_type; /* ARPHRD_* */ |
|---|
| 518 | int ifi_index; /* Link index */ |
|---|
| 519 | unsigned ifi_flags; /* IFF_* flags */ |
|---|
| 520 | unsigned ifi_change; /* IFF_* change mask */ |
|---|
| 521 | }; |
|---|
| 522 | |
|---|
| 523 | /******************************************************************** |
|---|
| 524 | * prefix information |
|---|
| 525 | ****/ |
|---|
| 526 | |
|---|
| 527 | struct prefixmsg |
|---|
| 528 | { |
|---|
| 529 | unsigned char prefix_family; |
|---|
| 530 | int prefix_ifindex; |
|---|
| 531 | unsigned char prefix_type; |
|---|
| 532 | unsigned char prefix_len; |
|---|
| 533 | unsigned char prefix_flags; |
|---|
| 534 | }; |
|---|
| 535 | |
|---|
| 536 | enum |
|---|
| 537 | { |
|---|
| 538 | PREFIX_UNSPEC, |
|---|
| 539 | PREFIX_ADDRESS, |
|---|
| 540 | PREFIX_CACHEINFO, |
|---|
| 541 | __PREFIX_MAX |
|---|
| 542 | }; |
|---|
| 543 | |
|---|
| 544 | #define PREFIX_MAX (__PREFIX_MAX - 1) |
|---|
| 545 | |
|---|
| 546 | struct prefix_cacheinfo |
|---|
| 547 | { |
|---|
| 548 | __u32 preferred_time; |
|---|
| 549 | __u32 valid_time; |
|---|
| 550 | }; |
|---|
| 551 | |
|---|
| 552 | /* The struct should be in sync with struct net_device_stats */ |
|---|
| 553 | struct rtnl_link_stats |
|---|
| 554 | { |
|---|
| 555 | __u32 rx_packets; /* total packets received */ |
|---|
| 556 | __u32 tx_packets; /* total packets transmitted */ |
|---|
| 557 | __u32 rx_bytes; /* total bytes received */ |
|---|
| 558 | __u32 tx_bytes; /* total bytes transmitted */ |
|---|
| 559 | __u32 rx_errors; /* bad packets received */ |
|---|
| 560 | __u32 tx_errors; /* packet transmit problems */ |
|---|
| 561 | __u32 rx_dropped; /* no space in linux buffers */ |
|---|
| 562 | __u32 tx_dropped; /* no space available in linux */ |
|---|
| 563 | __u32 multicast; /* multicast packets received */ |
|---|
| 564 | __u32 collisions; |
|---|
| 565 | |
|---|
| 566 | /* detailed rx_errors: */ |
|---|
| 567 | __u32 rx_length_errors; |
|---|
| 568 | __u32 rx_over_errors; /* receiver ring buff overflow */ |
|---|
| 569 | __u32 rx_crc_errors; /* recved pkt with crc error */ |
|---|
| 570 | __u32 rx_frame_errors; /* recv'd frame alignment error */ |
|---|
| 571 | __u32 rx_fifo_errors; /* recv'r fifo overrun */ |
|---|
| 572 | __u32 rx_missed_errors; /* receiver missed packet */ |
|---|
| 573 | |
|---|
| 574 | /* detailed tx_errors */ |
|---|
| 575 | __u32 tx_aborted_errors; |
|---|
| 576 | __u32 tx_carrier_errors; |
|---|
| 577 | __u32 tx_fifo_errors; |
|---|
| 578 | __u32 tx_heartbeat_errors; |
|---|
| 579 | __u32 tx_window_errors; |
|---|
| 580 | |
|---|
| 581 | /* for cslip etc */ |
|---|
| 582 | __u32 rx_compressed; |
|---|
| 583 | __u32 tx_compressed; |
|---|
| 584 | }; |
|---|
| 585 | |
|---|
| 586 | /* The struct should be in sync with struct ifmap */ |
|---|
| 587 | struct rtnl_link_ifmap |
|---|
| 588 | { |
|---|
| 589 | __u64 mem_start; |
|---|
| 590 | __u64 mem_end; |
|---|
| 591 | __u64 base_addr; |
|---|
| 592 | __u16 irq; |
|---|
| 593 | __u8 dma; |
|---|
| 594 | __u8 port; |
|---|
| 595 | }; |
|---|
| 596 | |
|---|
| 597 | enum |
|---|
| 598 | { |
|---|
| 599 | IFLA_UNSPEC, |
|---|
| 600 | IFLA_ADDRESS, |
|---|
| 601 | IFLA_BROADCAST, |
|---|
| 602 | IFLA_IFNAME, |
|---|
| 603 | IFLA_MTU, |
|---|
| 604 | IFLA_LINK, |
|---|
| 605 | IFLA_QDISC, |
|---|
| 606 | IFLA_STATS, |
|---|
| 607 | IFLA_COST, |
|---|
| 608 | #define IFLA_COST IFLA_COST |
|---|
| 609 | IFLA_PRIORITY, |
|---|
| 610 | #define IFLA_PRIORITY IFLA_PRIORITY |
|---|
| 611 | IFLA_MASTER, |
|---|
| 612 | #define IFLA_MASTER IFLA_MASTER |
|---|
| 613 | IFLA_WIRELESS, /* Wireless Extension event - see wireless.h */ |
|---|
| 614 | #define IFLA_WIRELESS IFLA_WIRELESS |
|---|
| 615 | IFLA_PROTINFO, /* Protocol specific information for a link */ |
|---|
| 616 | #define IFLA_PROTINFO IFLA_PROTINFO |
|---|
| 617 | IFLA_TXQLEN, |
|---|
| 618 | #define IFLA_TXQLEN IFLA_TXQLEN |
|---|
| 619 | IFLA_MAP, |
|---|
| 620 | #define IFLA_MAP IFLA_MAP |
|---|
| 621 | IFLA_WEIGHT, |
|---|
| 622 | #define IFLA_WEIGHT IFLA_WEIGHT |
|---|
| 623 | __IFLA_MAX |
|---|
| 624 | }; |
|---|
| 625 | |
|---|
| 626 | |
|---|
| 627 | #define IFLA_MAX (__IFLA_MAX - 1) |
|---|
| 628 | |
|---|
| 629 | #define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg)))) |
|---|
| 630 | #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg)) |
|---|
| 631 | |
|---|
| 632 | /* ifi_flags. |
|---|
| 633 | |
|---|
| 634 | IFF_* flags. |
|---|
| 635 | |
|---|
| 636 | The only change is: |
|---|
| 637 | IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are |
|---|
| 638 | more not changeable by user. They describe link media |
|---|
| 639 | characteristics and set by device driver. |
|---|
| 640 | |
|---|
| 641 | Comments: |
|---|
| 642 | - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid |
|---|
| 643 | - If neither of these three flags are set; |
|---|
| 644 | the interface is NBMA. |
|---|
| 645 | |
|---|
| 646 | - IFF_MULTICAST does not mean anything special: |
|---|
| 647 | multicasts can be used on all not-NBMA links. |
|---|
| 648 | IFF_MULTICAST means that this media uses special encapsulation |
|---|
| 649 | for multicast frames. Apparently, all IFF_POINTOPOINT and |
|---|
| 650 | IFF_BROADCAST devices are able to use multicasts too. |
|---|
| 651 | */ |
|---|
| 652 | |
|---|
| 653 | /* IFLA_LINK. |
|---|
| 654 | For usual devices it is equal ifi_index. |
|---|
| 655 | If it is a "virtual interface" (f.e. tunnel), ifi_link |
|---|
| 656 | can point to real physical interface (f.e. for bandwidth calculations), |
|---|
| 657 | or maybe 0, what means, that real media is unknown (usual |
|---|
| 658 | for IPIP tunnels, when route to endpoint is allowed to change) |
|---|
| 659 | */ |
|---|
| 660 | |
|---|
| 661 | /* Subtype attributes for IFLA_PROTINFO */ |
|---|
| 662 | enum |
|---|
| 663 | { |
|---|
| 664 | IFLA_INET6_UNSPEC, |
|---|
| 665 | IFLA_INET6_FLAGS, /* link flags */ |
|---|
| 666 | IFLA_INET6_CONF, /* sysctl parameters */ |
|---|
| 667 | IFLA_INET6_STATS, /* statistics */ |
|---|
| 668 | IFLA_INET6_MCAST, /* MC things. What of them? */ |
|---|
| 669 | IFLA_INET6_CACHEINFO, /* time values and max reasm size */ |
|---|
| 670 | __IFLA_INET6_MAX |
|---|
| 671 | }; |
|---|
| 672 | |
|---|
| 673 | #define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1) |
|---|
| 674 | |
|---|
| 675 | struct ifla_cacheinfo |
|---|
| 676 | { |
|---|
| 677 | __u32 max_reasm_len; |
|---|
| 678 | __u32 tstamp; /* ipv6InterfaceTable updated timestamp */ |
|---|
| 679 | __u32 reachable_time; |
|---|
| 680 | __u32 retrans_time; |
|---|
| 681 | }; |
|---|
| 682 | |
|---|
| 683 | /***************************************************************** |
|---|
| 684 | * Traffic control messages. |
|---|
| 685 | ****/ |
|---|
| 686 | |
|---|
| 687 | struct tcmsg |
|---|
| 688 | { |
|---|
| 689 | unsigned char tcm_family; |
|---|
| 690 | unsigned char tcm__pad1; |
|---|
| 691 | unsigned short tcm__pad2; |
|---|
| 692 | int tcm_ifindex; |
|---|
| 693 | __u32 tcm_handle; |
|---|
| 694 | __u32 tcm_parent; |
|---|
| 695 | __u32 tcm_info; |
|---|
| 696 | }; |
|---|
| 697 | |
|---|
| 698 | enum |
|---|
| 699 | { |
|---|
| 700 | TCA_UNSPEC, |
|---|
| 701 | TCA_KIND, |
|---|
| 702 | TCA_OPTIONS, |
|---|
| 703 | TCA_STATS, |
|---|
| 704 | TCA_XSTATS, |
|---|
| 705 | TCA_RATE, |
|---|
| 706 | TCA_FCNT, |
|---|
| 707 | TCA_STATS2, |
|---|
| 708 | __TCA_MAX |
|---|
| 709 | }; |
|---|
| 710 | |
|---|
| 711 | #define TCA_MAX (__TCA_MAX - 1) |
|---|
| 712 | |
|---|
| 713 | #define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg)))) |
|---|
| 714 | #define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg)) |
|---|
| 715 | |
|---|
| 716 | |
|---|
| 717 | /* RTnetlink multicast groups */ |
|---|
| 718 | |
|---|
| 719 | #define RTMGRP_LINK 1 |
|---|
| 720 | #define RTMGRP_NOTIFY 2 |
|---|
| 721 | #define RTMGRP_NEIGH 4 |
|---|
| 722 | #define RTMGRP_TC 8 |
|---|
| 723 | |
|---|
| 724 | #define RTMGRP_IPV4_IFADDR 0x10 |
|---|
| 725 | #define RTMGRP_IPV4_MROUTE 0x20 |
|---|
| 726 | #define RTMGRP_IPV4_ROUTE 0x40 |
|---|
| 727 | |
|---|
| 728 | #define RTMGRP_IPV6_IFADDR 0x100 |
|---|
| 729 | #define RTMGRP_IPV6_MROUTE 0x200 |
|---|
| 730 | #define RTMGRP_IPV6_ROUTE 0x400 |
|---|
| 731 | #define RTMGRP_IPV6_IFINFO 0x800 |
|---|
| 732 | |
|---|
| 733 | #define RTMGRP_DECnet_IFADDR 0x1000 |
|---|
| 734 | #define RTMGRP_DECnet_ROUTE 0x4000 |
|---|
| 735 | |
|---|
| 736 | #define RTMGRP_IPV6_PREFIX 0x20000 |
|---|
| 737 | |
|---|
| 738 | /* TC action piece */ |
|---|
| 739 | struct tcamsg |
|---|
| 740 | { |
|---|
| 741 | unsigned char tca_family; |
|---|
| 742 | unsigned char tca__pad1; |
|---|
| 743 | unsigned short tca__pad2; |
|---|
| 744 | }; |
|---|
| 745 | #define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg)))) |
|---|
| 746 | #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg)) |
|---|
| 747 | #define TCA_ACT_TAB 1 /* attr type must be >=1 */ |
|---|
| 748 | #define TCAA_MAX 1 |
|---|
| 749 | |
|---|
| 750 | #endif /* __LINUX_RTNETLINK_H */ |
|---|