/home/tomh/openhip/hip-0.5/src/include/win32/rtnetlink.h

Go to the documentation of this file.
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  *              Routing/neighbour discovery messages.
00017  ****/
00018 
00019 /* Types of messages */
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    Generic structure for encapsulation optional route information.
00059    It is reminiscent of sockaddr, but with sa_family replaced
00060    with attribute type.
00061  */
00062 
00063 struct rtattr
00064 {
00065         unsigned short  rta_len;
00066         unsigned short  rta_type;
00067 };
00068 
00069 /* Macros to handle rtattributes */
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  *              Definitions used in routing table administation.
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;      /* Routing table id */
00097         unsigned char           rtm_protocol;   /* Routing protocol; see below  */
00098         unsigned char           rtm_scope;      /* See below */ 
00099         unsigned char           rtm_type;       /* See below    */
00100 
00101         unsigned                rtm_flags;
00102 };
00103 
00104 /* rtm_type */
00105 
00106 enum
00107 {
00108         RTN_UNSPEC,
00109         RTN_UNICAST,            /* Gateway or direct route      */
00110         RTN_LOCAL,              /* Accept locally               */
00111         RTN_BROADCAST,          /* Accept locally as broadcast,
00112                                    send as broadcast */
00113         RTN_ANYCAST,            /* Accept locally as broadcast,
00114                                    but send as unicast */
00115         RTN_MULTICAST,          /* Multicast route              */
00116         RTN_BLACKHOLE,          /* Drop                         */
00117         RTN_UNREACHABLE,        /* Destination is unreachable   */
00118         RTN_PROHIBIT,           /* Administratively prohibited  */
00119         RTN_THROW,              /* Not in this table            */
00120         RTN_NAT,                /* Translate this address       */
00121         RTN_XRESOLVE,           /* Use external resolver        */
00122 };
00123 
00124 #define RTN_MAX RTN_XRESOLVE
00125 
00126 
00127 /* rtm_protocol */
00128 
00129 #define RTPROT_UNSPEC   0
00130 #define RTPROT_REDIRECT 1       /* Route installed by ICMP redirects;
00131                                    not used by current IPv4 */
00132 #define RTPROT_KERNEL   2       /* Route installed by kernel            */
00133 #define RTPROT_BOOT     3       /* Route installed during boot          */
00134 #define RTPROT_STATIC   4       /* Route installed by administrator     */
00135 
00136 /* Values of protocol >= RTPROT_STATIC are not interpreted by kernel;
00137    they just passed from user and back as is.
00138    It will be used by hypothetical multiple routing daemons.
00139    Note that protocol values should be standardized in order to
00140    avoid conflicts.
00141  */
00142 
00143 #define RTPROT_GATED    8       /* Apparently, GateD */
00144 #define RTPROT_RA       9       /* RDISC/ND router advertisments */
00145 #define RTPROT_MRT      10      /* Merit MRT */
00146 #define RTPROT_ZEBRA    11      /* Zebra */
00147 #define RTPROT_BIRD     12      /* BIRD */
00148 #define RTPROT_DNROUTED 13      /* DECnet routing daemon */
00149 
00150 /* rtm_scope
00151 
00152    Really it is not scope, but sort of distance to the destination.
00153    NOWHERE are reserved for not existing destinations, HOST is our
00154    local addresses, LINK are destinations, located on directly attached
00155    link and UNIVERSE is everywhere in the Universe.
00156 
00157    Intermediate values are also possible f.e. interior routes
00158    could be assigned a value between UNIVERSE and LINK.
00159 */
00160 
00161 enum rt_scope_t
00162 {
00163         RT_SCOPE_UNIVERSE=0,
00164 /* User defined values  */
00165         RT_SCOPE_SITE=200,
00166         RT_SCOPE_LINK=253,
00167         RT_SCOPE_HOST=254,
00168         RT_SCOPE_NOWHERE=255
00169 };
00170 
00171 /* rtm_flags */
00172 
00173 #define RTM_F_NOTIFY            0x100   /* Notify user of route change  */
00174 #define RTM_F_CLONED            0x200   /* This route is cloned         */
00175 #define RTM_F_EQUALIZE          0x400   /* Multipath equalizer: NI      */
00176 
00177 /* Reserved table identifiers */
00178 
00179 enum rt_class_t
00180 {
00181         RT_TABLE_UNSPEC=0,
00182 /* User defined values */
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 /* Routing message attributes */
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 /* RTM_MULTIPATH --- array of struct rtnexthop.
00216  *
00217  * "struct rtnexthop" describres all necessary nexthop information,
00218  * i.e. parameters of path to a destination via this nextop.
00219  *
00220  * At the moment it is impossible to set different prefsrc, mtu, window
00221  * and rtt for different paths from multipath.
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 /* rtnh_flags */
00233 
00234 #define RTNH_F_DEAD             1       /* Nexthop is dead (used by multipath)  */
00235 #define RTNH_F_PERVASIVE        2       /* Do recursive gateway lookup  */
00236 #define RTNH_F_ONLINK           4       /* Gateway is forced on link    */
00237 
00238 /* Macros to handle hexthops */
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 /* RTM_CACHEINFO */
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 /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
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  *              Interface address.
00297  ****/
00298 
00299 struct ifaddrmsg
00300 {
00301         unsigned char   ifa_family;
00302         unsigned char   ifa_prefixlen;  /* The prefix length            */
00303         unsigned char   ifa_flags;      /* Flags                        */
00304         unsigned char   ifa_scope;      /* See above                    */
00305         int             ifa_index;      /* Link 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 /* ifa_flags */
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    Important comment:
00341    IFA_ADDRESS is prefix address, rather than local interface address.
00342    It makes no difference for normally configured broadcast interfaces,
00343    but for point-to-point IFA_ADDRESS is DESTINATION address,
00344    local address is supplied in IFA_LOCAL attribute.
00345  */
00346 
00347 /**************************************************************
00348  *              Neighbour discovery.
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;    /* Link index                   */
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  *      Neighbor Cache Entry Flags
00377  */
00378 
00379 #define NTF_PROXY       0x08    /* == ATF_PUBL */
00380 #define NTF_ROUTER      0x80
00381 
00382 /*
00383  *      Neighbor Cache Entry States.
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 /* Dummy states */
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  *              General form of address family dependent message.
00409  ****/
00410 
00411 struct rtgenmsg
00412 {
00413         unsigned char           rtgen_family;
00414 };
00415 
00416 /*****************************************************************
00417  *              Link layer specific messages.
00418  ****/
00419 
00420 /* struct ifinfomsg
00421  * passes link level specific information, not dependent
00422  * on network protocol.
00423  */
00424 
00425 struct ifinfomsg
00426 {
00427         unsigned char   ifi_family;
00428         unsigned char   __ifi_pad;
00429         unsigned short  ifi_type;               /* ARPHRD_* */
00430         int             ifi_index;              /* Link index   */
00431         unsigned        ifi_flags;              /* IFF_* flags  */
00432         unsigned        ifi_change;             /* IFF_* change mask */
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,          /* Wireless Extension event - see wireless.h */
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 /* ifi_flags.
00462 
00463    IFF_* flags.
00464 
00465    The only change is:
00466    IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are
00467    more not changeable by user. They describe link media
00468    characteristics and set by device driver.
00469 
00470    Comments:
00471    - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid
00472    - If neiher of these three flags are set;
00473      the interface is NBMA.
00474 
00475    - IFF_MULTICAST does not mean anything special:
00476    multicasts can be used on all not-NBMA links.
00477    IFF_MULTICAST means that this media uses special encapsulation
00478    for multicast frames. Apparently, all IFF_POINTOPOINT and
00479    IFF_BROADCAST devices are able to use multicasts too.
00480  */
00481 
00482 /* IFLA_LINK.
00483    For usual devices it is equal ifi_index.
00484    If it is a "virtual interface" (f.e. tunnel), ifi_link
00485    can point to real physical interface (f.e. for bandwidth calculations),
00486    or maybe 0, what means, that real media is unknown (usual
00487    for IPIP tunnels, when route to endpoint is allowed to change)
00488  */
00489 
00490 /*****************************************************************
00491  *              Traffic control messages.
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 /* SUMMARY: maximal rtattr understood by kernel */
00522 
00523 #define RTATTR_MAX              RTA_MAX
00524 
00525 /* RTnetlink multicast groups */
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  /* __LINUX_RTNETLINK_H */

Generated on Mon Oct 22 11:43:43 2007 for OpenHIP by  doxygen 1.5.1