Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
rtnetlink(7)
Edit
PageHistory
Diff
Info
LikePages
RTNETLINK !!!RTNETLINK NAME SYNOPSIS DESCRIPTION ROUTING ATTRIBUTES MESSAGES VERSIONS BUGS SEE ALSO ---- !!NAME rtnetlink, NETLINK_ROUTE - Linux IPv4 routing socket. !!SYNOPSIS __#include __ #include __ #include __ #include __ __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 documented here, and for communication with user-space programs. 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 __ifinfomsg__ structure followed by a series of __rtattr__ structures. struct ifinfomsg { unsigned char ifi_family; /* AF_UNSPEC */ unsigned short ifi_type; /* Device type */ int ifi_index; /* Interface index */ unsigned int ifi_flags; /* Device flags */ unsigned int ifi_change; /* change mask */ }; __ifi_flags__ contains the device flags, see __netdevice(7); ifi_index__ is the unique interface index, __ifi_change__ is reserved for future use and should be always set to 0xFFFFFFFF. __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_PERMANENT__ for a permanent address set by the user and other undocumented flags. __RTM_NEWROUTE__, __RTM_DELROUTE__, __RTM_GETROUTE__ Create, remove or receive information about a network route. These messages contain an __rtmsg__ structure with an optional sequence of __rtattr__ structures following. For __RTM_GETROUTE__ setting __rtm_dst_len__ and __rtm_src_len__ to 0 means you get all entries for the specified routing table. For the other fields except __rtm_table__ and __rtm_protocol__ 0 is the wildcard. 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 int rtm_flags; }; Values larger than __RTPROT_STATIC__ are not interpreted by the kernel, they are just for user information. They may be used to tag the source of a routing information or to distingush between multiple routing daemons. See ____ for the routing daemon identifiers which are already assigned. __rtm_scope__ is the distance to the destination: The values between __RT_SCOPE_UNIVERSE__ and __RT_SCOPE_SITE__ are available to the user. The __rtm_flags__ have the following meanings: __rtm_table__ specifies the routing table The user may assign arbitary values between __RT_TABLE_UNSPEC__ and __RT_TABLE_DEFAULT__. __Fill these values in!__ __RTM_NEWNEIGH__, __RTM_DELNEIGH__, __RTM_GETNEIGH__ Add, remove or receive information about a neighbour 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: Valid __ndm_flags__ are: __document the members of the struct better__ The __rtaddr__ struct has the following meanings for the __rta_type__ field: 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 message 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; }; 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__ Add, remove or receive information about a traffic filter. These messages contain a __struct tcmsg__ as described above. !!VERSIONS __rtnetlink__ is a new feature of Linux 2.2. !!BUGS This manual page is lacking and incomplete. !!SEE ALSO netlink(7), cmsg(3), ip(7), rtnetlink(3) ----
5 pages link to
rtnetlink(7)
:
LinuxNetlinkSockets
netdevice(7)
Man7r
netlink(7)
rtnetlink(3)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.