rtnetlink(7) -- Linux man page
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, 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.
Routing attributes
|
rta_type
| value type
| description
|
|