00001 #ifndef __LINUX_RTNETLINK_H
00002 #define __LINUX_RTNETLINK_H
00003
00004 #ifdef __MACOSX__
00005 #define __s8 char
00006 #define __s16 short
00007 #define __s32 int
00008 #define __s64 long long
00009 #endif
00010 #include "netlink.h"
00011
00012 #define RTNL_DEBUG 1
00013
00014
00015
00016
00017
00018
00019
00020
00021 #define RTM_BASE 0x10
00022
00023 #define RTM_NEWLINK (RTM_BASE+0)
00024 #define RTM_DELLINK (RTM_BASE+1)
00025 #define RTM_GETLINK (RTM_BASE+2)
00026
00027 #define RTM_NEWADDR (RTM_BASE+4)
00028 #define RTM_DELADDR (RTM_BASE+5)
00029 #define RTM_GETADDR (RTM_BASE+6)
00030
00031 #define RTM_NEWROUTE (RTM_BASE+8)
00032 #define RTM_DELROUTE (RTM_BASE+9)
00033 #define RTM_GETROUTE (RTM_BASE+10)
00034
00035 #define RTM_NEWNEIGH (RTM_BASE+12)
00036 #define RTM_DELNEIGH (RTM_BASE+13)
00037 #define RTM_GETNEIGH (RTM_BASE+14)
00038
00039 #define RTM_NEWRULE (RTM_BASE+16)
00040 #define RTM_DELRULE (RTM_BASE+17)
00041 #define RTM_GETRULE (RTM_BASE+18)
00042
00043 #define RTM_NEWQDISC (RTM_BASE+20)
00044 #define RTM_DELQDISC (RTM_BASE+21)
00045 #define RTM_GETQDISC (RTM_BASE+22)
00046
00047 #define RTM_NEWTCLASS (RTM_BASE+24)
00048 #define RTM_DELTCLASS (RTM_BASE+25)
00049 #define RTM_GETTCLASS (RTM_BASE+26)
00050
00051 #define RTM_NEWTFILTER (RTM_BASE+28)
00052 #define RTM_DELTFILTER (RTM_BASE+29)
00053 #define RTM_GETTFILTER (RTM_BASE+30)
00054
00055 #define RTM_MAX (RTM_BASE+31)
00056
00057
00058
00059
00060
00061
00062
00063 struct rtattr
00064 {
00065 unsigned short rta_len;
00066 unsigned short rta_type;
00067 };
00068
00069
00070
00071 #define RTA_ALIGNTO 4
00072 #define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) )
00073 #define RTA_OK(rta,len) ((len) > 0 && (rta)->rta_len >= sizeof(struct rtattr) && \
00074 (rta)->rta_len <= (len))
00075 #define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
00076 (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len)))
00077 #define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
00078 #define RTA_SPACE(len) RTA_ALIGN(RTA_LENGTH(len))
00079 #define RTA_DATA(rta) ((void*)(((char*)(rta)) + RTA_LENGTH(0)))
00080 #define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0))
00081
00082
00083
00084
00085
00086
00087
00088
00089 struct rtmsg
00090 {
00091 unsigned char rtm_family;
00092 unsigned char rtm_dst_len;
00093 unsigned char rtm_src_len;
00094 unsigned char rtm_tos;
00095
00096 unsigned char rtm_table;
00097 unsigned char rtm_protocol;
00098 unsigned char rtm_scope;
00099 unsigned char rtm_type;
00100
00101 unsigned rtm_flags;
00102 };
00103
00104
00105
00106 enum
00107 {
00108 RTN_UNSPEC,
00109 RTN_UNICAST,
00110 RTN_LOCAL,
00111 RTN_BROADCAST,
00112
00113 RTN_ANYCAST,
00114
00115 RTN_MULTICAST,
00116 RTN_BLACKHOLE,
00117 RTN_UNREACHABLE,
00118 RTN_PROHIBIT,
00119 RTN_THROW,
00120 RTN_NAT,
00121 RTN_XRESOLVE,
00122 };
00123
00124 #define RTN_MAX RTN_XRESOLVE
00125
00126
00127
00128
00129 #define RTPROT_UNSPEC 0
00130 #define RTPROT_REDIRECT 1
00131
00132 #define RTPROT_KERNEL 2
00133 #define RTPROT_BOOT 3
00134 #define RTPROT_STATIC 4
00135
00136
00137
00138
00139
00140
00141
00142
00143 #define RTPROT_GATED 8
00144 #define RTPROT_RA 9
00145 #define RTPROT_MRT 10
00146 #define RTPROT_ZEBRA 11
00147 #define RTPROT_BIRD 12
00148 #define RTPROT_DNROUTED 13
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 enum rt_scope_t
00162 {
00163 RT_SCOPE_UNIVERSE=0,
00164
00165 RT_SCOPE_SITE=200,
00166 RT_SCOPE_LINK=253,
00167 RT_SCOPE_HOST=254,
00168 RT_SCOPE_NOWHERE=255
00169 };
00170
00171
00172
00173 #define RTM_F_NOTIFY 0x100
00174 #define RTM_F_CLONED 0x200
00175 #define RTM_F_EQUALIZE 0x400
00176
00177
00178
00179 enum rt_class_t
00180 {
00181 RT_TABLE_UNSPEC=0,
00182
00183 RT_TABLE_DEFAULT=253,
00184 RT_TABLE_MAIN=254,
00185 RT_TABLE_LOCAL=255
00186 };
00187 #define RT_TABLE_MAX RT_TABLE_LOCAL
00188
00189
00190
00191
00192
00193 enum rtattr_type_t
00194 {
00195 RTA_UNSPEC,
00196 RTA_DST,
00197 RTA_SRC,
00198 RTA_IIF,
00199 RTA_OIF,
00200 RTA_GATEWAY,
00201 RTA_PRIORITY,
00202 RTA_PREFSRC,
00203 RTA_METRICS,
00204 RTA_MULTIPATH,
00205 RTA_PROTOINFO,
00206 RTA_FLOW,
00207 RTA_CACHEINFO
00208 };
00209
00210 #define RTA_MAX RTA_CACHEINFO
00211
00212 #define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
00213 #define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224 struct rtnexthop
00225 {
00226 unsigned short rtnh_len;
00227 unsigned char rtnh_flags;
00228 unsigned char rtnh_hops;
00229 int rtnh_ifindex;
00230 };
00231
00232
00233
00234 #define RTNH_F_DEAD 1
00235 #define RTNH_F_PERVASIVE 2
00236 #define RTNH_F_ONLINK 4
00237
00238
00239
00240 #define RTNH_ALIGNTO 4
00241 #define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
00242 #define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
00243 ((int)(rtnh)->rtnh_len) <= (len))
00244 #define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
00245 #define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
00246 #define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
00247 #define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
00248
00249
00250
00251 struct rta_cacheinfo
00252 {
00253 __u32 rta_clntref;
00254 __u32 rta_lastuse;
00255 __s32 rta_expires;
00256 __u32 rta_error;
00257 __u32 rta_used;
00258
00259 #define RTNETLINK_HAVE_PEERINFO 1
00260 __u32 rta_id;
00261 __u32 rta_ts;
00262 __u32 rta_tsage;
00263 };
00264
00265
00266
00267 enum
00268 {
00269 RTAX_UNSPEC,
00270 #define RTAX_UNSPEC RTAX_UNSPEC
00271 RTAX_LOCK,
00272 #define RTAX_LOCK RTAX_LOCK
00273 RTAX_MTU,
00274 #define RTAX_MTU RTAX_MTU
00275 RTAX_WINDOW,
00276 #define RTAX_WINDOW RTAX_WINDOW
00277 RTAX_RTT,
00278 #define RTAX_RTT RTAX_RTT
00279 RTAX_RTTVAR,
00280 #define RTAX_RTTVAR RTAX_RTTVAR
00281 RTAX_SSTHRESH,
00282 #define RTAX_SSTHRESH RTAX_SSTHRESH
00283 RTAX_CWND,
00284 #define RTAX_CWND RTAX_CWND
00285 RTAX_ADVMSS,
00286 #define RTAX_ADVMSS RTAX_ADVMSS
00287 RTAX_REORDERING,
00288 #define RTAX_REORDERING RTAX_REORDERING
00289 };
00290
00291 #define RTAX_MAX RTAX_REORDERING
00292
00293
00294
00295
00296
00297
00298
00299 struct ifaddrmsg
00300 {
00301 unsigned char ifa_family;
00302 unsigned char ifa_prefixlen;
00303 unsigned char ifa_flags;
00304 unsigned char ifa_scope;
00305 int ifa_index;
00306 };
00307
00308 enum
00309 {
00310 IFA_UNSPEC,
00311 IFA_ADDRESS,
00312 IFA_LOCAL,
00313 IFA_LABEL,
00314 IFA_BROADCAST,
00315 IFA_ANYCAST,
00316 IFA_CACHEINFO
00317 };
00318
00319 #define IFA_MAX IFA_CACHEINFO
00320
00321
00322
00323 #define IFA_F_SECONDARY 0x01
00324
00325 #define IFA_F_DEPRECATED 0x20
00326 #define IFA_F_TENTATIVE 0x40
00327 #define IFA_F_PERMANENT 0x80
00328
00329 struct ifa_cacheinfo
00330 {
00331 __s32 ifa_prefered;
00332 __s32 ifa_valid;
00333 };
00334
00335
00336 #define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
00337 #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351 struct ndmsg
00352 {
00353 unsigned char ndm_family;
00354 unsigned char ndm_pad1;
00355 unsigned short ndm_pad2;
00356 int ndm_ifindex;
00357 __u16 ndm_state;
00358 __u8 ndm_flags;
00359 __u8 ndm_type;
00360 };
00361
00362 enum
00363 {
00364 NDA_UNSPEC,
00365 NDA_DST,
00366 NDA_LLADDR,
00367 NDA_CACHEINFO
00368 };
00369
00370 #define NDA_MAX NDA_CACHEINFO
00371
00372 #define NDA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
00373 #define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg))
00374
00375
00376
00377
00378
00379 #define NTF_PROXY 0x08
00380 #define NTF_ROUTER 0x80
00381
00382
00383
00384
00385
00386 #define NUD_INCOMPLETE 0x01
00387 #define NUD_REACHABLE 0x02
00388 #define NUD_STALE 0x04
00389 #define NUD_DELAY 0x08
00390 #define NUD_PROBE 0x10
00391 #define NUD_FAILED 0x20
00392
00393
00394 #define NUD_NOARP 0x40
00395 #define NUD_PERMANENT 0x80
00396 #define NUD_NONE 0x00
00397
00398
00399 struct nda_cacheinfo
00400 {
00401 __u32 ndm_confirmed;
00402 __u32 ndm_used;
00403 __u32 ndm_updated;
00404 __u32 ndm_refcnt;
00405 };
00406
00407
00408
00409
00410
00411 struct rtgenmsg
00412 {
00413 unsigned char rtgen_family;
00414 };
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425 struct ifinfomsg
00426 {
00427 unsigned char ifi_family;
00428 unsigned char __ifi_pad;
00429 unsigned short ifi_type;
00430 int ifi_index;
00431 unsigned ifi_flags;
00432 unsigned ifi_change;
00433 };
00434
00435 enum
00436 {
00437 IFLA_UNSPEC,
00438 IFLA_ADDRESS,
00439 IFLA_BROADCAST,
00440 IFLA_IFNAME,
00441 IFLA_MTU,
00442 IFLA_LINK,
00443 IFLA_QDISC,
00444 IFLA_STATS,
00445 IFLA_COST,
00446 #define IFLA_COST IFLA_COST
00447 IFLA_PRIORITY,
00448 #define IFLA_PRIORITY IFLA_PRIORITY
00449 IFLA_MASTER,
00450 #define IFLA_MASTER IFLA_MASTER
00451 IFLA_WIRELESS,
00452 #define IFLA_WIRELESS IFLA_WIRELESS
00453 };
00454
00455
00456 #define IFLA_MAX IFLA_WIRELESS
00457
00458 #define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
00459 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494 struct tcmsg
00495 {
00496 unsigned char tcm_family;
00497 unsigned char tcm__pad1;
00498 unsigned short tcm__pad2;
00499 int tcm_ifindex;
00500 __u32 tcm_handle;
00501 __u32 tcm_parent;
00502 __u32 tcm_info;
00503 };
00504
00505 enum
00506 {
00507 TCA_UNSPEC,
00508 TCA_KIND,
00509 TCA_OPTIONS,
00510 TCA_STATS,
00511 TCA_XSTATS,
00512 TCA_RATE,
00513 };
00514
00515 #define TCA_MAX TCA_RATE
00516
00517 #define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
00518 #define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
00519
00520
00521
00522
00523 #define RTATTR_MAX RTA_MAX
00524
00525
00526
00527 #define RTMGRP_LINK 1
00528 #define RTMGRP_NOTIFY 2
00529 #define RTMGRP_NEIGH 4
00530 #define RTMGRP_TC 8
00531
00532 #define RTMGRP_IPV4_IFADDR 0x10
00533 #define RTMGRP_IPV4_MROUTE 0x20
00534 #define RTMGRP_IPV4_ROUTE 0x40
00535
00536 #define RTMGRP_IPV6_IFADDR 0x100
00537 #define RTMGRP_IPV6_MROUTE 0x200
00538 #define RTMGRP_IPV6_ROUTE 0x400
00539
00540 #define RTMGRP_DECnet_IFADDR 0x1000
00541 #define RTMGRP_DECnet_ROUTE 0x4000
00542
00543 #endif