Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"
The ONE Campaign to make poverty history

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents

· Introduction to Operating Systems
· Linux Basics
· Working with the System
· Shells and Utilities
· Editing Files
· Basic Administration
· The Operating System
· The X Windowing System
· The Computer Itself
· Networking
· System Monitoring
· Solving Problems
· Security
· Installing and Upgrading
· Linux and Windows

Glossary
MoreInfo
Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
FAQ
Copyright Info
Terms of Use
Privacy Info
Disclaimer
WorkBoard
Thanks
Donations
Advertising
Masthead / Impressum
Your Account

Communication
Feedback
Forums
Private Messages
Surveys

Features
HOWTOs
News Archive
Submit News
Topics
User Articles
Web Links

Google
Google


The Web
linux-tutorial.info

Who's Online
There are currently, 261 guest(s) and 0 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here

  

rtnetlink



SYNOPSIS

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

       rtnetlink_socket  =  socket(PF_NETLINK,  int  socket_type,
       NETLINK_ROUTE);


DESCRIPTION

       Rtnetlink allows the kernel's routing tables  to  be  read
       and  altered.  It is used within the kernel to communicate
       between various subsystems, though this usage is not docu­
       mented  here,  and  for communication with user-space pro­
       grams.  Network routes,  ip  addresses,  link  parameters,
       neighbour  setups,  queueing  disciplines, traffic classes
       and packet  classifiers  may  all  be  controlled  through
       NETLINK_ROUTE  sockets.   It is based on netlink messages,
       see netlink(7) for more information.


ROUTING ATTRIBUTES

       Some rtnetlink messages have optional attributes after the
       initial header:

       struct rtattr
       {
           unsigned short rta_len;     /* Length of option */
           unsigned short rta_type;    /* Type of option */
           /* Data follows */
       };

       These  attributes  should  be  only  manipulated using the
       RTA_* macros or libnetlink, see rtnetlink(3).


MESSAGES

       Rtnetlink consists of these message types (in addition  to
       standard netlink messages):

       RTM_NEWLINK, RTM_DELLINK, RTM_GETLINK
              Create,  remove or get information about a specific
              network interface.  These messages contain an ifin­
              fomsg  structure  followed  by  a  series of rtattr
              structures.

              struct ifinfomsg
              {
                  unsigned char  ifi_family;  /* AF_UNSPEC */
                  unsigned short ifi_type;    /* Device type */

              IFLA_UNSPEC          -                  unspecified.
              IFLA_ADDRESS         hardware address   interface L2 address
              IFLA_BROADCAST       hardware address   L2 broadcast address.
              IFLA_IFNAME          asciiz string      Device name.
              IFLA_MTU             unsigned int       MTU of the device.
              IFLA_LINK            int                Link type.
              IFLA_QDISC           asciiz string      Queueing discipline.
              IFLA_STATS           struct             Interface Statistics.
                                   net_device_stats

       RTM_NEWADDR,                                  RTM_DELADDR,
       RTM_GETADDR
              Add,  remove  or  receive  information  about an IP
              address associated with an interface. In Linux  2.2
              an  interface can carry multiple IP addresses, this
              replaces the alias device concept in 2.0. In  Linux
              2.2 these messages support IPv4 and IPv6 addresses.
              They contain  an  ifaddrmsg  structure,  optionally
              followed by rtaddr routing attributes.

              struct ifaddrmsg
              {
                  unsigned char  ifa_family;  /* Address type */
                  unsigned char  ifa_prefixlen;/* Prefixlength of the address */
                  unsigned char  ifa_flags;   /* Address flags */
                  unsigned char  ifa_scope;   /* Address scope */
                  int            ifa_index;   /* Interface index   */
              };

              ifa_family  is  the  address family type (currently
              AF_INET or AF_INET6), ifa_prefixlen is  the  length
              of  the  address mask of the address if defined for
              the  family  (like  for  IPv4),  ifa_scope  is  the
              address  scope, ifa_index is the interface index of
              the  interface  the  address  is  associated  with.
              ifa_flags  is  a  flag  word of IFA_F_SECONDARY for
              secondary address (old alias interface), IFA_F_PER­
              MANENT  for a permanent address set by the user and
              other undocumented flags.

               Attributes
              rta_type        value type             description
              -------------------------------------------------------------
              IFA_UNSPEC      -                      unspecified.
              IFA_ADDRESS     raw protocol address   interface address
              IFA_LOCAL       raw protocol address   local address
              IFA_LABEL       asciiz string          name of the interface
              IFA_BROADCAST   raw protocol address   broadcast address.
              IFA_ANYCAST     raw protocol address   anycast address
              IFA_CACHEINFO   struct ifa_cacheinfo   Address information.

                  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 int   rtm_flags;
              };

              rtm_type          Route type
              -----------------------------------------------------------
              RTN_UNSPEC        unknown route
              RTN_UNICAST       a gateway or direct route
              RTN_LOCAL         a local interface route
              RTN_BROADCAST     a  local  broadcast  route  (sent  as  a
                                broadcast)
              RTN_ANYCAST       a local broadcast route (sent as a  uni­
                                cast)
              RTN_MULTICAST     a multicast route
              RTN_BLACKHOLE     a packet dropping route
              RTN_UNREACHABLE   an unreachable destination
              RTN_PROHIBIT      a packet rejection route
              RTN_THROW         continue routing lookup in another table
              RTN_NAT           a network address translation rule
              RTN_XRESOLVE      refer   to  an  external  resolver  (not
                                implemented)

              rtm_protocol      Route origin.
              -----------------------------------------
              RTPROT_UNSPEC     unknown
              RTPROT_REDIRECT   by  an  ICMP  redirect
                                (currently unused)
              RTPROT_KERNEL     by the kernel
              RTPROT_BOOT       during boot
              RTPROT_STATIC     by the administrator

              Values  larger  than  RTPROT_STATIC  are not inter­
              preted by the kernel, they are just for user infor­
              mation.   They  may  be used to tag the source of a
              routing information or to distingush between multi­
              ple  routing  daemons.  See <linux/rtnetlink.h> for
              the routing daemon identifiers  which  are  already
              assigned.

              rtm_scope is the distance to the destination:

              RT_SCOPE_UNIVERSE   global route
              RT_SCOPE_SITE       interior   route  in  the
                                  local autonomous system

              rtm_table specifies the routing table

              RT_TABLE_UNSPEC    an unspecified routing table
              RT_TABLE_DEFAULT   the default table
              RT_TABLE_MAIN      the main table
              RT_TABLE_LOCAL     the local table

              The  user  may  assign  arbitary   values   between
              RT_TABLE_UNSPEC and RT_TABLE_DEFAULT.

               Attributes
              rta_type        value type         description
              --------------------------------------------------------------
              RTA_UNSPEC      -                  ignored.
              RTA_DST         protocol address   Route destination address.
              RTA_SRC         protocol address   Route source address.
              RTA_IIF         int                Input interface index.
              RTA_OIF         int                Output interface index.
              RTA_GATEWAY     protocol address   The gateway of the route
              RTA_PRIORITY    int                Priority of route.
              RTA_PREFSRC
              RTA_METRICS     int                Route metric
              RTA_MULTIPATH
              RTA_PROTOINFO
              RTA_FLOW
              RTA_CACHEINFO

              Fill these values in!

       RTM_NEWNEIGH, RTM_DELNEIGH, RTM_GETNEIGH
              Add,  remove  or receive information about a neigh­
              bour table entry (e.g. an ARP entry).  The  message
              contains an ndmsg structure.

              struct ndmsg
              {
                  unsigned char  ndm_family;
                  int            ndm_ifindex; /* Interface 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;
              };

              ndm_state is a bitmask of the following states:
              NTF_ROUTER   an IPv6 router

              document the members of the struct better

              The  rtaddr  struct  has the following meanings for
              the rta_type field:

              NDA_UNSPEC      unknown type
              NDA_DST         a neighbour cache network layer destination address
              NDA_LLADDR      a neighbour cache link layer address
              NDA_CACHEINFO   cache statistics.

              If the  rta_type  field  is  NDA_CACHEINFO  then  a
              struct nda_cacheinfo header follows

       RTM_NEWRULE, RTM_DELRULE, RTM_GETRULE
              Add,  delete  or retrieve a routing rule. Carries a
              struct rtmsg

       RTM_NEWQDISC, RTM_DELQDISC, RTM_GETQDISC
              Add, remove or get a queueing discipline.  The mes­
              sage contains a struct tcmsg and may be followed by
              a series of attributes.

              struct tcmsg
              {
                  unsigned char  tcm_family;
                  int            tcm_ifindex; /* interface index */
                  __u32          tcm_handle;  /* Qdisc handle */
                  __u32          tcm_parent;  /* Parent qdisc */
                  __u32          tcm_info;
              };

              Attributes
              rta_type      value type            Description
              ------------------------------------------------------------------
              TCA_UNSPEC    -                     unspecified
              TCA_KIND      asciiz string         Name of queueing discipline
              TCA_OPTIONS   byte sequence         Qdisc specific options follow
              TCA_STATS     struct tc_stats       Qdisc statistics.
              TCA_XSTATS    qdisc specific        Module specific statistics.
              TCA_RATE      struct tc_estimator   Rate limit.

              In addition various  other  qdisc  module  specific
              attributes  are  allowed.  For more information see
              the appropriate include files.

       RTM_NEWTCLASS, RTM_DELTCLASS, RTM_GETTCLASS
              Add, remove or get a traffic class.  These messages
              contain a struct tcmsg as described above.

       RTM_NEWTFILTER, RTM_DELTFILTER, RTM_GETTFILTER

Linux Man Page              1999-04-30               RTNETLINK(7)
  




Login
Nickname

Password

Security Code
Security Code
Type Security Code


Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!


Amazon Wish List

Did You Know?
The Linux Tutorial welcomes your suggestions and ideas.


Friends



Tell a Friend About Us

Bookmark and Share



Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.08 Seconds