route.7p (2010 09)

r
route(7P) route(7P)
NAME
route - kernel packet forwarding database
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
#include <net/route.h>
#include <net/if.h>
s = socket(AF_ROUTE, SOCK_RAW,
family );
DESCRIPTION
This manpage describes routing socket interface to read and write kernel routing messages.
The information on how to transmit network packets is maintained by the HP-UX kernel in the routing
information database, also known as the routing table. A user process can read or update information in
the routing table by sending routing messages to the kernel via an AF_ROUTE socket. The message
types are described in more detail in the Message Types section below.
The family parameter in the
socket system call shown in the SYNOPSIS may be used to filter the rout-
ing messages the caller receives. The valid values for family are:
AF_INET get routing messages affecting the Internet Protocol.
AF_INET6 get routing messages affecting the Internet Protocol version 6.
AF_UNSPEC get routing messages affecting both AF_INET and AF_INET6 protocols.
Entries in the routing table specify the appropriate remote host or gateway to use when transmitting
packets. These entries are either host-specific, or are applicable to all hosts located on a generic subnet-
work, as specified by a netmask value.
After the system boots, each protocol family adds entries to the routing table for each network interface
configured and ready to transmit network traffic. Normally, the route entry is specified as a direct con-
nection to the destination host or network. For direct routes, the transport layer of the network stack
sends packets directly to the host specified in the packet header. For non-direct routes, the interface for-
wards the packet to the gateway listed in the routing entry for that interface.
When routing packets, the kernel attempts to find an optimal route for each destination. If more than
one entry matches the netmask of the destination, the kernel selects the route with the greater number of
1’s in the netmask.
A default (wildcard) route is used if no other route to a particular remote host or network can be located.
A default route is specified with an all 0 destination address value and a netmask of all 0’s. Default
routes, in combination with routing redirects, provide an economical mechanism for routing network
trafc.
If no routing entry is found, the destination is declared as unreachable, and a routing-miss message
(RTM_MISS) is generated to any user processes using the routing socket facilities, as described below.
Message Types
After creating a routing socket, the process can send commands to the kernel by writing to the socket.
The process can read information from the kernel by reading from the socket. The following message
types can be used to communicate routing information between the user process and the kernel:
RTM_ADD add route
RTM_CHANGE change gateway, metrics or flags
RTM_DELADDR address being removed from interface
RTM_DELETE delete route
RTM_GET report metrics and other information
RTM_IFINFO interface going up, down, etc.
RTM_LOSING kernel suspects route is failing
RTM_LOCK lock specified metrics
RTM_MISS lookup on this address failed
RTM_NEWADDR address being added to interface
RTM_REDIRECT kernel instructs to use different route
RTM_RESOLVE request to resolve destination to link-layer address
All 12 message types can be used to read information from the kernel. To write to the kernel, the process
can issue RTM_ADD, RTM_DELETE, or RTM_GET message types to update information in the routing
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (6 pages)