Computer Science


RTNETLINK(4)        Linux Programmer's Manual        RTNETLINK(4)

NAME
       rtnetlink, NETLINK_ROUTE - Linux IPv4 routing socket.

SYNOPSIS
       #include <asm/types.h>
       #include <linux/netlink.h>
       #include <linux/rtnetlink.h>
       #include <sys/socket.h>

       rtnetlink_socket    =    socket(PF_NETLINK,   socket_type,
       NETLINK_ROUTE);

DESCRIPTION
       UNFINISHED. WORK IN PROGRESS.

       Rtnetlink allows to set up and  read  network  routes,  ip
       addresses,  link  parameters,  neighbour  setups, queueing
       disciplines, traffic classes packet  classifiers.   It  is
       used  to  communicate between user level daemons and setup
       programs and the  kernel  and  to  communicate  internally
       between kernel subsystems (not documented). It is based on
       netlink messages, see netlink(4) for more information.

       Valid family specific netlink message types:

       RTM_NEWLINK, RTM_DELLINK, RTM_GETLINK
               Create, remove or get information about a specific
               network interface.  Carries a ifinfomsg message as
               payload.

       RTM_NEWADDR, RTM_DELADDR, RTM_GETADDR
               Add, remove or receive  information  about  an  IP
               address associated with an interface. In Linux 2.1
               an interface can carry multiple IP addresses, this
               replaces  the  alias  device concept in 2.0. These
               commands handle IP interface address lists.   Pay-
               load is an ifaddrmsg structure.

       RTM_NEWROUTE, RTM_DELROUTE, RTM_GETROUTE
               Create, remove or receive information about a net-
               work route. Payload is a rtmsg structure  with  an
               optional  sequence of rtattr structures following.
               struct rtmsg
               {
                    unsigned char       rtm_family;    /* Address family of route */
                    unsigned char       rtm_dst_len;   /* Length of source */
                    unsigned char       rtm_src_len;   /* Length of destination */
                    unsigned char       rtm_tos;  /* TOS filter */

                    unsigned char       rtm_table;     /* Routing table id */
                    unsigned char       rtm_protocol;  /* Routing protocol; see below     */
                    unsigned char       rtm_scope;     /* See below */
                    unsigned char       rtm_type; /* See below   */

                    unsigned       rtm_flags;
               };

               struct rtattr
               {
                    unsigned short rta_len;
                    unsigned short rta_type;
                   /* Data follows (use RTA_DATA to access) */
               };
       Valid rtm_type values are  RTN_UNICAST  for  specifying  a
       gateway  or  direct route, RTN_LOCAL for a local interface
       route, RTN_BROADCAST for a local broadcast route (sent  as
       broadcast),  RTN_ANYCAST  for a local broadcast route that
       is a sent as unicast,  RTN_MULTICAST  for  a  multitasking
       route,   RTN_BLACKHOLE   for   a  packet  dropping  route,
       RTN_UNREACHABLE for an unreachable  destination,  RTN_PRO-
       HIBIT  for a packet rejection route, RTN_THROW to continue
       routing lookup in another table,  RTN_NAT  for  a  network
       address  translation  rule,  RTN_XRESOLVE  to  refer to an
       external resolver (not  implemented).   Valid  values  for
       rtm_protocol are RTPROT_UNSPEC, RTPROT_REDIRECT for routes
       installed  by  ICMP  redirects   (currently   not   used),
       RTPROT_KERNEL   for   routes   installed  by  the  kernel,
       RTPROT_BOOT   for   routes    installed    during    boot,
       RTPROT_STATIC  for  routes installed by the administrator.
       Values bigger than RTPROT_STATIC are  not  interpreted  by
       the  kernel, they are just for user information. It can be
       used to tag the source of a routing information or to dis-
       tingush    between    multiple    routing   daemons.   See
       linux/rtnetlink.h for  the  already  standardized  routing
       daemon identifiers.  rtm_scope is the distance to the des-
       tination:    RT_SCOPE_UNIVERSE    for    global    routes,
       RT_SCOPE_SITE for intereour routes in the local autonomous
       system, RT_SCOPE_LINK for on  link  routes,  RT_SCOPE_HOST
       for  routes on the local host and RT_SCOPE_NOWHERE for non
       existent destinations. The user may  use  his  own  values
       between   RT_SCOPE_UNIVERSE   and   RT_SCOPE_SITE.   Valid
       rtm_flags  are  RTM_F_NOTIFY  to  notify  the   user   via
       rtnetlink  of  a  route  change,  RTM_F_CLONED  for routes
       cloned  from  other  routes  for  the  destination  cache,
       RTM_F_EQUALIZE for an not yet implemented multicast equal-
       izer.  rtm_table may contain: RT_TABLE_UNSPEC for unspeci-
       fied  routing  table,  RT_TABLE_DEFAULT  for  the  default
       table, RT_TABLE_MAIN for the  main  table,  RT_TABLE_LOCAL
       for  the  local table. The user may assign arbitary values
       between RT_TABLE_UNSPEC and RT_TABLE_DEFAULT.

       RTM_NEWNEIGH, RTM_DELNEIGH, RTM_GETNEIGH
               Add, remove or receive information about a  neigh-
               bour table entry (e.g. an ARP entry). Payload is a
               ndmsg structure.

               struct ndmsg
               {
                    unsigned char  ndm_family;
                    unsigned char  ndm_pad1;
                    unsigned short ndm_pad2;
                    int       ndm_ifindex;   /* Link index            */
                    __u16          ndm_state;  /* State */
                    __u8      ndm_flags;  /* Flags */
                    __u8      ndm_type;
               };

               struct nda_cacheinfo
               {
                    __u32          ndm_confirmed;
                    __u32          ndm_used;
                    __u32          ndm_updated;
                    __u32          ndm_refcnt;
               };
       Valid ndm_type values are: NDA_UNSPEC  for  unknown  type,
       NDA_DST  for  a  neighbour cache network layer destination
       address,  ND_LLADDR  for  a  neighbour  cache  link  layer
       address,  ND_CACHEINFO  for  cache  statistics  (a  struct
       nda_cacheinfo  header   follows).    Valid   states   are:
       NUD_INCOMPLETE  for  a  currently  resolving  cache entry,
       NUD_REACHABLE  for  a  confirmed  working   cache   entry,
       NUD_STALE  for  an  expired  cache entry, NUD_DELAY for an
       entry waiting for a timer, NUD_PROBE  for  a  cache  entry
       that  is  currently  reprobed,  NUD_FAILED  for an invalid
       cache entry, NUD_NOARP for  devices  with  no  destination
       cache,  NUD_PERMANENT  for  static  entries,  NUD_NONE for
       nothing. Valid flags in  ndm_flags  are  NTF_PROXY  for  a
       proxy arp entry, NTF_ROUTER for an IPv6 router.

       See  <linux/rtnetlink.h> for the declaration of the rtmsg,
       ifinfomsg, and ifaddrmsg structures.

BUGS
       This manual page is lacking and incomplete.

VERSIONS
       rtnetlink is a new feature of Linux 2.2.

SEE ALSO
       netlink(4), cmsg(3), ip(4)

Linux Man Page             23 Oct 1998                          1

Back to the index


Apply now!


Handbook

Postgraduate study options

Computer Science Blog



Please give us your feedback or ask us a question

This message is...


My feedback or question is...


My email address is...

(Only if you need a reply)

A to Z Directory | Site map | Accessibility | Copyright | Privacy | Disclaimer | Feedback on this page