| 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 |
|
| 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_NEWNEIGHTBL = 64,
|
| 93 | #define RTM_NEWNEIGHTBL RTM_NEWNEIGHTBL
|
| 94 | RTM_GETNEIGHTBL = 66,
|
| 95 | #define RTM_GETNEIGHTBL RTM_GETNEIGHTBL
|
| 96 | RTM_SETNEIGHTBL,
|
| 97 | #define RTM_SETNEIGHTBL RTM_SETNEIGHTBL
|
| 98 |
|
| 99 | __RTM_MAX,
|
| 100 | #define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
|
| 101 | };
|
| 102 |
|
| 103 | #define RTM_NR_MSGTYPES (RTM_MAX + 1 - RTM_BASE)
|
| 104 | #define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2)
|
| 105 | #define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2)
|
| 106 |
|
| 107 | |
| 108 | Generic structure for encapsulation of optional route information.
|
| 109 | It is reminiscent of sockaddr, but with sa_family replaced
|
| 110 | with attribute type.
|
| 111 |
|
| 112 |
|
| 113 | struct rtattr
|
| 114 | {
|
| 115 | unsigned short rta_len;
|
| 116 | unsigned short rta_type;
|
| 117 | };
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 | #define RTA_ALIGNTO 4
|
| 122 | #define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) )
|
| 123 | #define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \
|
| 124 | (rta)->rta_len >= sizeof(struct rtattr) && \
|
| 125 | (rta)->rta_len <= (len))
|
| 126 | #define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
|
| 127 | (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len)))
|
| 128 | #define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
|
| 129 | #define RTA_SPACE(len) RTA_ALIGN(RTA_LENGTH(len))
|
| 130 | #define RTA_DATA(rta) ((void*)(((char*)(rta)) + RTA_LENGTH(0)))
|
| 131 | #define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0))
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 | |
| 137 | * Definitions used in routing table administration.
|
| 138 | ***
|
| 139 |
|
| 140 | struct rtmsg
|
| 141 | {
|
| 142 | unsigned char rtm_family;
|
| 143 | unsigned char rtm_dst_len;
|
| 144 | unsigned char rtm_src_len;
|
| 145 | unsigned char rtm_tos;
|
| 146 |
|
| 147 | unsigned char rtm_table;
|
| 148 | unsigned char rtm_protocol;
|
| 149 | unsigned char rtm_scope;
|
| 150 | unsigned char rtm_type;
|
| 151 |
|
| 152 | unsigned rtm_flags;
|
| 153 | };
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 | enum
|
| 158 | {
|
| 159 | RTN_UNSPEC,
|
| 160 | RTN_UNICAST,
|
| 161 | RTN_LOCAL,
|
| 162 | RTN_BROADCAST, |
| 163 | send as broadcast
|
| 164 | RTN_ANYCAST, |
| 165 | but send as unicast
|
| 166 | RTN_MULTICAST,
|
| 167 | RTN_BLACKHOLE,
|
| 168 | RTN_UNREACHABLE,
|
| 169 | RTN_PROHIBIT,
|
| 170 | RTN_THROW,
|
| 171 | RTN_NAT,
|
| 172 | RTN_XRESOLVE,
|
| 173 | __RTN_MAX
|
| 174 | };
|
| 175 |
|
| 176 | #define RTN_MAX (__RTN_MAX - 1)
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 | #define RTPROT_UNSPEC 0
|
| 182 | #define RTPROT_REDIRECT 1 |
| 183 | not used by current IPv4
|
| 184 | #define RTPROT_KERNEL 2
|
| 185 | #define RTPROT_BOOT 3
|
| 186 | #define RTPROT_STATIC 4
|
| 187 |
|
| 188 | |
| 189 | they are just passed from user and back as is.
|
| 190 | It will be used by hypothetical multiple routing daemons.
|
| 191 | Note that protocol values should be standardized in order to
|
| 192 | avoid conflicts.
|
| 193 |
|
| 194 |
|
| 195 | #define RTPROT_GATED 8
|
| 196 | #define RTPROT_RA 9
|
| 197 | #define RTPROT_MRT 10
|
| 198 | #define RTPROT_ZEBRA 11
|
| 199 | #define RTPROT_BIRD 12
|
| 200 | #define RTPROT_DNROUTED 13
|
| 201 | #define RTPROT_XORP 14
|
| 202 |
|
| 203 | |
| 204 |
|
| 205 | Really it is not scope, but sort of distance to the destination.
|
| 206 | NOWHERE are reserved for not existing destinations, HOST is our
|
| 207 | local addresses, LINK are destinations, located on directly attached
|
| 208 | link and UNIVERSE is everywhere in the Universe.
|
| 209 |
|
| 210 | Intermediate values are also possible f.e. interior routes
|
| 211 | could be assigned a value between UNIVERSE and LINK.
|
| 212 |
|
| 213 |
|
| 214 | enum rt_scope_t
|
| 215 | {
|
| 216 | RT_SCOPE_UNIVERSE=0,
|
| 217 |
|
| 218 | RT_SCOPE_SITE=200,
|
| 219 | RT_SCOPE_LINK=253,
|
| 220 | RT_SCOPE_HOST=254,
|
| 221 | RT_SCOPE_NOWHERE=255
|
| 222 | };
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 | #define RTM_F_NOTIFY 0x100
|
| 227 | #define RTM_F_CLONED 0x200
|
| 228 | #define RTM_F_EQUALIZE 0x400
|
| 229 | #define RTM_F_PREFIX 0x800
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 | enum rt_class_t
|
| 234 | {
|
| 235 | RT_TABLE_UNSPEC=0,
|
| 236 |
|
| 237 | RT_TABLE_DEFAULT=253,
|
| 238 | RT_TABLE_MAIN=254,
|
| 239 | RT_TABLE_LOCAL=255,
|
| 240 | __RT_TABLE_MAX
|
| 241 | };
|
| 242 | #define RT_TABLE_MAX (__RT_TABLE_MAX - 1)
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 | enum rtattr_type_t
|
| 249 | {
|
| 250 | RTA_UNSPEC,
|
| 251 | RTA_DST,
|
| 252 | RTA_SRC,
|
| 253 | RTA_IIF,
|
| 254 | RTA_OIF,
|
| 255 | RTA_GATEWAY,
|
| 256 | RTA_PRIORITY,
|
| 257 | RTA_PREFSRC,
|
| 258 | RTA_METRICS,
|
| 259 | RTA_MULTIPATH,
|
| 260 | RTA_PROTOINFO,
|
| 261 | RTA_FLOW,
|
| 262 | RTA_CACHEINFO,
|
| 263 | RTA_SESSION,
|
| 264 | RTA_MP_ALGO,
|
| 265 | __RTA_MAX
|
| 266 | };
|
| 267 |
|
| 268 | #define RTA_MAX (__RTA_MAX - 1)
|
| 269 |
|
| 270 | #define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
|
| 271 | #define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
|
| 272 |
|
| 273 | |
| 274 | *
|
| 275 | * "struct rtnexthop" describes all necessary nexthop information,
|
| 276 | * i.e. parameters of path to a destination via this nexthop.
|
| 277 | *
|
| 278 | * At the moment it is impossible to set different prefsrc, mtu, window
|
| 279 | * and rtt for different paths from multipath.
|
| 280 |
|
| 281 |
|
| 282 | struct rtnexthop
|
| 283 | {
|
| 284 | unsigned short rtnh_len;
|
| 285 | unsigned char rtnh_flags;
|
| 286 | unsigned char rtnh_hops;
|
| 287 | int rtnh_ifindex;
|
| 288 | };
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 | #define RTNH_F_DEAD 1
|
| 293 | #define RTNH_F_PERVASIVE 2
|
| 294 | #define RTNH_F_ONLINK 4
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 | #define RTNH_ALIGNTO 4
|
| 299 | #define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
|
| 300 | #define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
|
| 301 | ((int)(rtnh)->rtnh_len) <= (len))
|
| 302 | #define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
|
| 303 | #define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
|
| 304 | #define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
|
| 305 | #define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 | struct rta_cacheinfo
|
| 310 | {
|
| 311 | __u32 rta_clntref;
|
| 312 | __u32 rta_lastuse;
|
| 313 | __s32 rta_expires;
|
| 314 | __u32 rta_error;
|
| 315 | __u32 rta_used;
|
| 316 |
|
| 317 | #define RTNETLINK_HAVE_PEERINFO 1
|
| 318 | __u32 rta_id;
|
| 319 | __u32 rta_ts;
|
| 320 | __u32 rta_tsage;
|
| 321 | };
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 | enum
|
| 326 | {
|
| 327 | RTAX_UNSPEC,
|
| 328 | #define RTAX_UNSPEC RTAX_UNSPEC
|
| 329 | RTAX_LOCK,
|
| 330 | #define RTAX_LOCK RTAX_LOCK
|
| 331 | RTAX_MTU,
|
| 332 | #define RTAX_MTU RTAX_MTU
|
| 333 | RTAX_WINDOW,
|
| 334 | #define RTAX_WINDOW RTAX_WINDOW
|
| 335 | RTAX_RTT,
|
| 336 | #define RTAX_RTT RTAX_RTT
|
| 337 | RTAX_RTTVAR,
|
| 338 | #define RTAX_RTTVAR RTAX_RTTVAR
|
| 339 | RTAX_SSTHRESH,
|
| 340 | #define RTAX_SSTHRESH RTAX_SSTHRESH
|
| 341 | RTAX_CWND,
|
| 342 | #define RTAX_CWND RTAX_CWND
|
| 343 | RTAX_ADVMSS,
|
| 344 | #define RTAX_ADVMSS RTAX_ADVMSS
|
| 345 | RTAX_REORDERING,
|
| 346 | #define RTAX_REORDERING RTAX_REORDERING
|
| 347 | RTAX_HOPLIMIT,
|
| 348 | #define RTAX_HOPLIMIT RTAX_HOPLIMIT
|
| 349 | RTAX_INITCWND,
|
| 350 | #define RTAX_INITCWND RTAX_INITCWND
|
| 351 | RTAX_FEATURES,
|
| 352 | #define RTAX_FEATURES RTAX_FEATURES
|
| 353 | __RTAX_MAX
|
| 354 | };
|
| 355 |
|
| 356 | #define RTAX_MAX (__RTAX_MAX - 1)
|
| 357 |
|
| 358 | #define RTAX_FEATURE_ECN 0x00000001
|
| 359 | #define RTAX_FEATURE_SACK 0x00000002
|
| 360 | #define RTAX_FEATURE_TIMESTAMP 0x00000004
|
| 361 | #define RTAX_FEATURE_ALLFRAG 0x00000008
|
| 362 |
|
| 363 | struct rta_session
|
| 364 | {
|
| 365 | __u8 proto;
|
| 366 | __u8 pad1;
|
| 367 | __u16 pad2;
|
| 368 |
|
| 369 | union {
|
| 370 | struct {
|
| 371 | __u16 sport;
|
| 372 | __u16 dport;
|
| 373 | } ports;
|
| 374 |
|
| 375 | struct {
|
| 376 | __u8 type;
|
| 377 | __u8 code;
|
| 378 | __u16 ident;
|
| 379 | } icmpt;
|
| 380 |
|
| 381 | __u32 spi;
|
| 382 | } u;
|
| 383 | };
|
| 384 |
|
| 385 |
|
| 386 | |
| 387 | * Interface address.
|
| 388 | ***
|
| 389 |
|
| 390 | struct ifaddrmsg
|
| 391 | {
|
| 392 | unsigned char ifa_family;
|
| 393 | unsigned char ifa_prefixlen;
|
| 394 | unsigned char ifa_flags;
|
| 395 | unsigned char ifa_scope;
|
| 396 | int ifa_index;
|
| 397 | };
|
| 398 |
|
| 399 | enum
|
| 400 | {
|
| 401 | IFA_UNSPEC,
|
| 402 | IFA_ADDRESS,
|
| 403 | IFA_LOCAL,
|
| 404 | IFA_LABEL,
|
| 405 | IFA_BROADCAST,
|
| 406 | IFA_ANYCAST,
|
| 407 | IFA_CACHEINFO,
|
| 408 | IFA_MULTICAST,
|
| 409 | __IFA_MAX
|
| 410 | };
|
| 411 |
|
| 412 | #define IFA_MAX (__IFA_MAX - 1)
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 | #define IFA_F_SECONDARY 0x01
|
| 417 | #define IFA_F_TEMPORARY IFA_F_SECONDARY
|
| 418 |
|
| 419 | #define IFA_F_DEPRECATED 0x20
|
| 420 | #define IFA_F_TENTATIVE 0x40
|
| 421 | #define IFA_F_PERMANENT 0x80
|
| 422 |
|
| 423 | struct ifa_cacheinfo
|
| 424 | {
|
| 425 | __u32 ifa_prefered;
|
| 426 | __u32 ifa_valid;
|
| 427 | __u32 cstamp;
|
| 428 | __u32 tstamp;
|
| 429 | };
|
| 430 |
|
| 431 |
|
| 432 | #define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
|
| 433 | #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
|
| 434 |
|
| 435 | |
| 436 | Important comment:
|
| 437 | IFA_ADDRESS is prefix address, rather than local interface address.
|
| 438 | It makes no difference for normally configured broadcast interfaces,
|
| 439 | but for point-to-point IFA_ADDRESS is DESTINATION address,
|
| 440 | local address is supplied in IFA_LOCAL attribute.
|
| 441 |
|
| 442 |
|
| 443 | |
| 444 | * Neighbour discovery.
|
| 445 | ***
|
| 446 |
|
| 447 | struct ndmsg
|
| 448 | {
|
| 449 | unsigned char ndm_family;
|
| 450 | unsigned char ndm_pad1;
|
| 451 | unsigned short ndm_pad2;
|
| 452 | int ndm_ifindex;
|
| 453 | __u16 ndm_state;
|
| 454 | __u8 ndm_flags;
|
| 455 | __u8 ndm_type;
|
| 456 | };
|
| 457 |
|
| 458 | enum
|
| 459 | {
|
| 460 | NDA_UNSPEC,
|
| 461 | NDA_DST,
|
| 462 | NDA_LLADDR,
|
| 463 | NDA_CACHEINFO,
|
| 464 | NDA_PROBES,
|
| 465 | __NDA_MAX
|
| 466 | };
|
| 467 |
|
| 468 | #define NDA_MAX (__NDA_MAX - 1)
|
| 469 |
|
| 470 | #define NDA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
|
| 471 | #define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg))
|
| 472 |
|
| 473 | |
| 474 | * Neighbor Cache Entry Flags
|
| 475 |
|
| 476 |
|
| 477 | #define NTF_PROXY 0x08
|
| 478 | #define NTF_ROUTER 0x80
|
| 479 |
|
| 480 | |
| 481 | * Neighbor Cache Entry States.
|
| 482 |
|
| 483 |
|
| 484 | #define NUD_INCOMPLETE 0x01
|
| 485 | #define NUD_REACHABLE 0x02
|
| 486 | #define NUD_STALE 0x04
|
| 487 | #define NUD_DELAY 0x08
|
| 488 | #define NUD_PROBE 0x10
|
| 489 | #define NUD_FAILED 0x20
|
| 490 |
|
| 491 |
|
| 492 | #define NUD_NOARP 0x40
|
| 493 | #define NUD_PERMANENT 0x80
|
| 494 | #define NUD_NONE 0x00
|
| 495 |
|
| 496 |
|
| 497 | struct nda_cacheinfo
|
| 498 | {
|
| 499 | __u32 ndm_confirmed;
|
| 500 | __u32 ndm_used;
|
| 501 | __u32 ndm_updated;
|
| 502 | __u32 ndm_refcnt;
|
| 503 | };
|
| 504 |
|
| 505 |
|
| 506 | |
| 507 | * Neighbour tables specific messages.
|
| 508 | *
|
| 509 | * To retrieve the neighbour tables send RTM_GETNEIGHTBL with the
|
| 510 | * NLM_F_DUMP flag set. Every neighbour table configuration is
|
| 511 | * spread over multiple messages to avoid running into message
|
| 512 | * size limits on systems with many interfaces. The first message
|
| 513 | * in the sequence transports all not device specific data such as
|
| 514 | * statistics, configuration, and the default parameter set.
|
| 515 | * This message is followed by 0..n messages carrying device
|
| 516 | * specific parameter sets.
|
| 517 | * Although the ordering should be sufficient, NDTA_NAME can be
|
| 518 | * used to identify sequences. The initial message can be identified
|
| 519 | * by checking for NDTA_CONFIG. The device specific messages do
|
| 520 | * not contain this TLV but have NDTPA_IFINDEX set to the
|
| 521 | * corresponding interface index.
|
| 522 | *
|
| 523 | * To change neighbour table attributes, send RTM_SETNEIGHTBL
|
| 524 | * with NDTA_NAME set. Changeable attribute include NDTA_THRESH[1-3],
|
| 525 | * NDTA_GC_INTERVAL, and all TLVs in NDTA_PARMS unless marked
|
| 526 | * otherwise. Device specific parameter sets can be changed by
|
| 527 | * setting NDTPA_IFINDEX to the interface index of the corresponding
|
| 528 | * device.
|
| 529 | ***
|
| 530 |
|
| 531 | struct ndt_stats
|
| 532 | {
|
| 533 | __u64 ndts_allocs;
|
| 534 | __u64 ndts_destroys;
|
| 535 | __u64 ndts_hash_grows;
|
| 536 | __u64 ndts_res_failed;
|
| 537 | __u64 ndts_lookups;
|
| 538 | __u64 ndts_hits;
|
| 539 | __u64 ndts_rcv_probes_mcast;
|
| 540 | __u64 ndts_rcv_probes_ucast;
|
| 541 | __u64 ndts_periodic_gc_runs;
|
| 542 | __u64 ndts_forced_gc_runs;
|
| 543 | };
|
| 544 |
|
| 545 | enum {
|
| 546 | NDTPA_UNSPEC,
|
| 547 | NDTPA_IFINDEX,
|
| 548 | NDTPA_REFCNT,
|
| 549 | NDTPA_REACHABLE_TIME,
|
| 550 | NDTPA_BASE_REACHABLE_TIME,
|
| 551 | NDTPA_RETRANS_TIME,
|
| 552 | NDTPA_GC_STALETIME,
|
| 553 | NDTPA_DELAY_PROBE_TIME,
|
| 554 | NDTPA_QUEUE_LEN,
|
| 555 | NDTPA_APP_PROBES,
|
| 556 | NDTPA_UCAST_PROBES,
|
| 557 | NDTPA_MCAST_PROBES,
|
| 558 | NDTPA_ANYCAST_DELAY,
|
| 559 | NDTPA_PROXY_DELAY,
|
| 560 | NDTPA_PROXY_QLEN,
|
| 561 | NDTPA_LOCKTIME,
|
| 562 | __NDTPA_MAX
|
| 563 | };
|
| 564 | #define NDTPA_MAX (__NDTPA_MAX - 1)
|
| 565 |
|
| 566 | struct ndtmsg
|
| 567 | {
|
| 568 | __u8 ndtm_family;
|
| 569 | __u8 ndtm_pad1;
|
| 570 | __u16 ndtm_pad2;
|
| 571 | };
|
| 572 |
|
| 573 | struct ndt_config
|
| 574 | {
|
| 575 | __u16 ndtc_key_len;
|
| 576 | __u16 ndtc_entry_size;
|
| 577 | __u32 ndtc_entries;
|
| 578 | __u32 ndtc_last_flush;
|
| 579 | __u32 ndtc_last_rand;
|
| 580 | __u32 ndtc_hash_rnd;
|
| 581 | __u32 ndtc_hash_mask;
|
| 582 | __u32 ndtc_hash_chain_gc;
|
| 583 | __u32 ndtc_proxy_qlen;
|
| 584 | };
|
| 585 |
|
| 586 | enum {
|
| 587 | NDTA_UNSPEC,
|
| 588 | NDTA_NAME,
|
| 589 | NDTA_THRESH1,
|
| 590 | NDTA_THRESH2,
|
| 591 | NDTA_THRESH3,
|
| 592 | NDTA_CONFIG,
|
| 593 | NDTA_PARMS,
|
| 594 | NDTA_STATS,
|
| 595 | NDTA_GC_INTERVAL,
|
| 596 | __NDTA_MAX
|
| 597 | };
|
| 598 | #define NDTA_MAX (__NDTA_MAX - 1)
|
| 599 |
|
| 600 | #define NDTA_RTA(r) ((struct rtattr*)(((char*)(r)) + \
|
| 601 | NLMSG_ALIGN(sizeof(struct ndtmsg))))
|
| 602 | #define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg))
|
| 603 |
|
| 604 |
|
| 605 | |
| 606 | * General form of address family dependent message.
|
| 607 | ***
|
| 608 |
|
| 609 | struct rtgenmsg
|
| 610 | {
|
| 611 | unsigned char rtgen_family;
|
| 612 | };
|
| 613 |
|
| 614 | |
| 615 | * Link layer specific messages.
|
| 616 | ***
|
| 617 |
|
| 618 | |
| 619 | * passes link level specific information, not dependent
|
| 620 | * on network protocol.
|
| 621 |
|
| 622 |
|
| 623 | struct ifinfomsg
|
| 624 | {
|
| 625 | unsigned char ifi_family;
|
| 626 | unsigned char __ifi_pad;
|
| 627 | unsigned short ifi_type;
|
| 628 | int ifi_index;
|
| 629 | unsigned ifi_flags;
|
| 630 | unsigned ifi_change;
|
| 631 | };
|
| 632 |
|
| 633 | |
| 634 | * prefix information
|
| 635 | ***
|
| 636 |
|
| 637 | struct prefixmsg
|
| 638 | {
|
| 639 | unsigned char prefix_family;
|
| 640 | unsigned char prefix_pad1;
|
| 641 | unsigned short prefix_pad2;
|
| 642 | int prefix_ifindex;
|
| 643 | unsigned char prefix_type;
|
| 644 | unsigned char prefix_len;
|
| 645 | unsigned char prefix_flags;
|
| 646 | unsigned char prefix_pad3;
|
| 647 | };
|
| 648 |
|
| 649 | enum
|
| 650 | {
|
| 651 | PREFIX_UNSPEC,
|
| 652 | PREFIX_ADDRESS,
|
| 653 | PREFIX_CACHEINFO,
|
| 654 | __PREFIX_MAX
|
| 655 | };
|
| 656 |
|
| 657 | #define PREFIX_MAX (__PREFIX_MAX - 1)
|
| 658 |
|
| 659 | struct prefix_cacheinfo
|
| 660 | {
|
| 661 | __u32 preferred_time;
|
| 662 | __u32 valid_time;
|
| 663 | };
|
| 664 |
|
| 665 |
|
| 666 | struct rtnl_link_stats
|
| 667 | {
|
| 668 | __u32 rx_packets;
|
| 669 | __u32 tx_packets;
|
| 670 | __u32 rx_bytes;
|
| 671 | __u32 tx_bytes;
|
| 672 | __u32 rx_errors;
|
| 673 | __u32 tx_errors;
|
| 674 | __u32 rx_dropped;
|
| 675 | __u32 tx_dropped;
|
| 676 | __u32 multicast;
|
| 677 | __u32 collisions;
|
| 678 |
|
| 679 |
|
| 680 | __u32 rx_length_errors;
|
| 681 | __u32 rx_over_errors;
|
| 682 | __u32 rx_crc_errors;
|
| 683 | __u32 rx_frame_errors;
|
| 684 | __u32 rx_fifo_errors;
|
| 685 | __u32 rx_missed_errors;
|
| 686 |
|
| 687 |
|
| 688 | __u32 tx_aborted_errors;
|
| 689 | __u32 tx_carrier_errors;
|
| 690 | __u32 tx_fifo_errors;
|
| 691 | __u32 tx_heartbeat_errors;
|
| 692 | __u32 tx_window_errors;
|
| 693 |
|
| 694 |
|
| 695 | __u32 rx_compressed;
|
| 696 | __u32 tx_compressed;
|
| 697 | };
|
| 698 |
|
| 699 |
|
| 700 | struct rtnl_link_ifmap
|
| 701 | {
|
| 702 | __u64 mem_start;
|
| 703 | __u64 mem_end;
|
| 704 | __u64 base_addr;
|
| 705 | __u16 irq;
|
| 706 | __u8 dma;
|
| 707 | __u8 port;
|
| 708 | };
|
| 709 |
|
| 710 | enum
|
| 711 | {
|
| 712 | IFLA_UNSPEC,
|
| 713 | IFLA_ADDRESS,
|
| 714 | IFLA_BROADCAST,
|
| 715 | IFLA_IFNAME,
|
| 716 | IFLA_MTU,
|
| 717 | IFLA_LINK,
|
| 718 | IFLA_QDISC,
|
| 719 | IFLA_STATS,
|
| 720 | IFLA_COST,
|
| 721 | #define IFLA_COST IFLA_COST
|
| 722 | IFLA_PRIORITY,
|
| 723 | #define IFLA_PRIORITY IFLA_PRIORITY
|
| 724 | IFLA_MASTER,
|
| 725 | #define IFLA_MASTER IFLA_MASTER
|
| 726 | IFLA_WIRELESS,
|
| 727 | #define IFLA_WIRELESS IFLA_WIRELESS
|
| 728 | IFLA_PROTINFO,
|
| 729 | #define IFLA_PROTINFO IFLA_PROTINFO
|
| 730 | IFLA_TXQLEN,
|
| 731 | #define IFLA_TXQLEN IFLA_TXQLEN
|
| 732 | IFLA_MAP,
|
| 733 | #define IFLA_MAP IFLA_MAP
|
| 734 | IFLA_WEIGHT,
|
| 735 | #define IFLA_WEIGHT IFLA_WEIGHT
|
| 736 | __IFLA_MAX
|
| 737 | };
|
| 738 |
|
| 739 |
|
| 740 | #define IFLA_MAX (__IFLA_MAX - 1)
|
| 741 |
|
| 742 | #define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
|
| 743 | #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
|
| 744 |
|
| 745 | |
| 746 |
|
| 747 | IFF_* flags.
|
| 748 |
|
| 749 | The only change is:
|
| 750 | IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are
|
| 751 | more not changeable by user. They describe link media
|
| 752 | characteristics and set by device driver.
|
| 753 |
|
| 754 | Comments:
|
| 755 | - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid
|
| 756 | - If neither of these three flags are set;
|
| 757 | the interface is NBMA.
|
| 758 |
|
| 759 | - IFF_MULTICAST does not mean anything special:
|
| 760 | multicasts can be used on all not-NBMA links.
|
| 761 | IFF_MULTICAST means that this media uses special encapsulation
|
| 762 | for multicast frames. Apparently, all IFF_POINTOPOINT and
|
| 763 | IFF_BROADCAST devices are able to use multicasts too.
|
| 764 |
|
| 765 |
|
| 766 | |
| 767 | For usual devices it is equal ifi_index.
|
| 768 | If it is a "virtual interface" (f.e. tunnel), ifi_link
|
| 769 | can point to real physical interface (f.e. for bandwidth calculations),
|
| 770 | or maybe 0, what means, that real media is unknown (usual
|
| 771 | for IPIP tunnels, when route to endpoint is allowed to change)
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 | enum
|
| 776 | {
|
| 777 | IFLA_INET6_UNSPEC,
|
| 778 | IFLA_INET6_FLAGS,
|
| 779 | IFLA_INET6_CONF,
|
| 780 | IFLA_INET6_STATS,
|
| 781 | IFLA_INET6_MCAST,
|
| 782 | IFLA_INET6_CACHEINFO,
|
| 783 | __IFLA_INET6_MAX
|
| 784 | };
|
| 785 |
|
| 786 | #define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1)
|
| 787 |
|
| 788 | struct ifla_cacheinfo
|
| 789 | {
|
| 790 | __u32 max_reasm_len;
|
| 791 | __u32 tstamp;
|
| 792 | __u32 reachable_time;
|
| 793 | __u32 retrans_time;
|
| 794 | };
|
| 795 |
|
| 796 | |
| 797 | * Traffic control messages.
|
| 798 | ***
|
| 799 |
|
| 800 | struct tcmsg
|
| 801 | {
|
| 802 | unsigned char tcm_family;
|
| 803 | unsigned char tcm__pad1;
|
| 804 | unsigned short tcm__pad2;
|
| 805 | int tcm_ifindex;
|
| 806 | __u32 tcm_handle;
|
| 807 | __u32 tcm_parent;
|
| 808 | __u32 tcm_info;
|
| 809 | };
|
| 810 |
|
| 811 | enum
|
| 812 | {
|
| 813 | TCA_UNSPEC,
|
| 814 | TCA_KIND,
|
| 815 | TCA_OPTIONS,
|
| 816 | TCA_STATS,
|
| 817 | TCA_XSTATS,
|
| 818 | TCA_RATE,
|
| 819 | TCA_FCNT,
|
| 820 | TCA_STATS2,
|
| 821 | __TCA_MAX
|
| 822 | };
|
| 823 |
|
| 824 | #define TCA_MAX (__TCA_MAX - 1)
|
| 825 |
|
| 826 | #define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
|
| 827 | #define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 | #define RTMGRP_LINK 1
|
| 833 | #define RTMGRP_NOTIFY 2
|
| 834 | #define RTMGRP_NEIGH 4
|
| 835 | #define RTMGRP_TC 8
|
| 836 |
|
| 837 | #define RTMGRP_IPV4_IFADDR 0x10
|
| 838 | #define RTMGRP_IPV4_MROUTE 0x20
|
| 839 | #define RTMGRP_IPV4_ROUTE 0x40
|
| 840 |
|
| 841 | #define RTMGRP_IPV6_IFADDR 0x100
|
| 842 | #define RTMGRP_IPV6_MROUTE 0x200
|
| 843 | #define RTMGRP_IPV6_ROUTE 0x400
|
| 844 | #define RTMGRP_IPV6_IFINFO 0x800
|
| 845 |
|
| 846 | #define RTMGRP_DECnet_IFADDR 0x1000
|
| 847 | #define RTMGRP_DECnet_ROUTE 0x4000
|
| 848 |
|
| 849 | #define RTMGRP_IPV6_PREFIX 0x20000
|
| 850 |
|
| 851 |
|
| 852 | struct tcamsg
|
| 853 | {
|
| 854 | unsigned char tca_family;
|
| 855 | unsigned char tca__pad1;
|
| 856 | unsigned short tca__pad2;
|
| 857 | };
|
| 858 | #define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
|
| 859 | #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
|
| 860 | #define TCA_ACT_TAB 1
|
| 861 | #define TCAA_MAX 1
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 | #ifdef __KERNEL__
|
| 866 |
|
| 867 | #include <linux/config.h>
|
| 868 |
|
| 869 | extern size_t rtattr_strlcpy(char *dest, const struct rtattr *rta, size_t size);
|
| 870 | static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str)
|
| 871 | {
|
| 872 | int len = strlen(str) + 1;
|
| 873 | return len > rta->rta_len || memcmp(RTA_DATA(rta), str, len);
|
| 874 | }
|
| 875 |
|
| 876 | extern int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len);
|
| 877 |
|
| 878 | #define rtattr_parse_nested(tb, max, rta) \
|
| 879 | rtattr_parse((tb), (max), RTA_DATA((rta)), RTA_PAYLOAD((rta)))
|
| 880 |
|
| 881 | extern struct sock *rtnl;
|
| 882 |
|
| 883 | struct rtnetlink_link
|
| 884 | {
|
| 885 | int (*doit)(struct sk_buff *, struct nlmsghdr*, void *attr);
|
| 886 | int (*dumpit)(struct sk_buff *, struct netlink_callback *cb);
|
| 887 | };
|
| 888 |
|
| 889 | extern struct rtnetlink_link * rtnetlink_links[NPROTO];
|
| 890 | extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo);
|
| 891 | extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
|
| 892 |
|
| 893 | extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data);
|
| 894 |
|
| 895 | #define RTA_PUT(skb, attrtype, attrlen, data) \
|
| 896 | ({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
|
| 897 | goto rtattr_failure; \
|
| 898 | __rta_fill(skb, attrtype, attrlen, data); })
|
| 899 |
|
| 900 | #define RTA_APPEND(skb, attrlen, data) \
|
| 901 | ({ if (unlikely(skb_tailroom(skb) < (int)(attrlen))) \
|
| 902 | goto rtattr_failure; \
|
| 903 | memcpy(skb_put(skb, attrlen), data, attrlen); })
|
| 904 |
|
| 905 | #define RTA_PUT_NOHDR(skb, attrlen, data) \
|
| 906 | ({ RTA_APPEND(skb, RTA_ALIGN(attrlen), data); \
|
| 907 | memset(skb->tail - (RTA_ALIGN(attrlen) - attrlen), 0, \
|
| 908 | RTA_ALIGN(attrlen) - attrlen); })
|
| 909 |
|
| 910 | #define RTA_PUT_U8(skb, attrtype, value) \
|
| 911 | ({ u8 _tmp = (value); \
|
| 912 | RTA_PUT(skb, attrtype, sizeof(u8), &_tmp); })
|
| 913 |
|
| 914 | #define RTA_PUT_U16(skb, attrtype, value) \
|
| 915 | ({ u16 _tmp = (value); \
|
| 916 | RTA_PUT(skb, attrtype, sizeof(u16), &_tmp); })
|
| 917 |
|
| 918 | #define RTA_PUT_U32(skb, attrtype, value) \
|
| 919 | ({ u32 _tmp = (value); \
|
| 920 | RTA_PUT(skb, attrtype, sizeof(u32), &_tmp); })
|
| 921 |
|
| 922 | #define RTA_PUT_U64(skb, attrtype, value) \
|
| 923 | ({ u64 _tmp = (value); \
|
| 924 | RTA_PUT(skb, attrtype, sizeof(u64), &_tmp); })
|
| 925 |
|
| 926 | #define RTA_PUT_SECS(skb, attrtype, value) \
|
| 927 | RTA_PUT_U64(skb, attrtype, (value) / HZ)
|
| 928 |
|
| 929 | #define RTA_PUT_MSECS(skb, attrtype, value) \
|
| 930 | RTA_PUT_U64(skb, attrtype, jiffies_to_msecs(value))
|
| 931 |
|
| 932 | #define RTA_PUT_STRING(skb, attrtype, value) \
|
| 933 | RTA_PUT(skb, attrtype, strlen(value) + 1, value)
|
| 934 |
|
| 935 | #define RTA_PUT_FLAG(skb, attrtype) \
|
| 936 | RTA_PUT(skb, attrtype, 0, NULL);
|
| 937 |
|
| 938 | #define RTA_NEST(skb, type) \
|
| 939 | ({ struct rtattr *__start = (struct rtattr *) (skb)->tail; \
|
| 940 | RTA_PUT(skb, type, 0, NULL); \
|
| 941 | __start; })
|
| 942 |
|
| 943 | #define RTA_NEST_END(skb, start) \
|
| 944 | ({ (start)->rta_len = ((skb)->tail - (unsigned char *) (start)); \
|
| 945 | (skb)->len; })
|
| 946 |
|
| 947 | #define RTA_NEST_CANCEL(skb, start) \
|
| 948 | ({ if (start) \
|
| 949 | skb_trim(skb, (unsigned char *) (start) - (skb)->data); \
|
| 950 | -1; })
|
| 951 |
|
| 952 | #define RTA_GET_U8(rta) \
|
| 953 | ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u8)) \
|
| 954 | goto rtattr_failure; \
|
| 955 | *(u8 *) RTA_DATA(rta); })
|
| 956 |
|
| 957 | #define RTA_GET_U16(rta) \
|
| 958 | ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u16)) \
|
| 959 | goto rtattr_failure; \
|
| 960 | *(u16 *) RTA_DATA(rta); })
|
| 961 |
|
| 962 | #define RTA_GET_U32(rta) \
|
| 963 | ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u32)) \
|
| 964 | goto rtattr_failure; \
|
| 965 | *(u32 *) RTA_DATA(rta); })
|
| 966 |
|
| 967 | #define RTA_GET_U64(rta) \
|
| 968 | ({ u64 _tmp; \
|
| 969 | if (!rta || RTA_PAYLOAD(rta) < sizeof(u64)) \
|
| 970 | goto rtattr_failure; \
|
| 971 | memcpy(&_tmp, RTA_DATA(rta), sizeof(_tmp)); \
|
| 972 | _tmp; })
|
| 973 |
|
| 974 | #define RTA_GET_FLAG(rta) (!!(rta))
|
| 975 |
|
| 976 | #define RTA_GET_SECS(rta) ((unsigned long) RTA_GET_U64(rta) * HZ)
|
| 977 | #define RTA_GET_MSECS(rta) (msecs_to_jiffies((unsigned long) RTA_GET_U64(rta)))
|
| 978 |
|
| 979 | static inline struct rtattr *
|
| 980 | __rta_reserve(struct sk_buff *skb, int attrtype, int attrlen)
|
| 981 | {
|
| 982 | struct rtattr *rta;
|
| 983 | int size = RTA_LENGTH(attrlen);
|
| 984 |
|
| 985 | rta = (struct rtattr*)skb_put(skb, RTA_ALIGN(size));
|
| 986 | rta->rta_type = attrtype;
|
| 987 | rta->rta_len = size;
|
| 988 | memset(RTA_DATA(rta) + attrlen, 0, RTA_ALIGN(size) - size);
|
| 989 | return rta;
|
| 990 | }
|
| 991 |
|
| 992 | #define __RTA_PUT(skb, attrtype, attrlen) \
|
| 993 | ({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
|
| 994 | goto rtattr_failure; \
|
| 995 | __rta_reserve(skb, attrtype, attrlen); })
|
| 996 |
|
| 997 | extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);
|
| 998 |
|
| 999 | extern struct semaphore rtnl_sem;
|
| 1000 |
|
| 1001 | #define rtnl_shlock() down(&rtnl_sem)
|
| 1002 | #define rtnl_shlock_nowait() down_trylock(&rtnl_sem)
|
| 1003 |
|
| 1004 | #define rtnl_shunlock() do { up(&rtnl_sem); \
|
| 1005 | if (rtnl && rtnl->sk_receive_queue.qlen) \
|
| 1006 | rtnl->sk_data_ready(rtnl, 0); \
|
| 1007 | } while(0)
|
| 1008 |
|
| 1009 | extern void rtnl_lock(void);
|
| 1010 | extern int rtnl_lock_interruptible(void);
|
| 1011 | extern void rtnl_unlock(void);
|
| 1012 | extern void rtnetlink_init(void);
|
| 1013 |
|
| 1014 | #define ASSERT_RTNL() do { \
|
| 1015 | if (unlikely(down_trylock(&rtnl_sem) == 0)) { \
|
| 1016 | up(&rtnl_sem); \
|
| 1017 | printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
|
| 1018 | __FILE__, __LINE__); \
|
| 1019 | dump_stack(); \
|
| 1020 | } \
|
| 1021 | } while(0)
|
| 1022 |
|
| 1023 | #define BUG_TRAP(x) do { \
|
| 1024 | if (unlikely(!(x))) { \
|
| 1025 | printk(KERN_ERR "KERNEL: assertion (%s) failed at %s (%d)\n", \
|
| 1026 | #x, __FILE__ , __LINE__); \
|
| 1027 | } \
|
| 1028 | } while(0)
|
| 1029 |
|
| 1030 | #endif
|
| 1031 |
|
| 1032 |
|
| 1033 | #endif
|