rtalloc rtalloc_ign rtalloc1 rtfree - look up a route in the kernel routing table
When a route with the flag RTF_CLONING is retrieved, and the action of this flag is not masked, the facility automatically generates a new route using information in the old route as a template, and sends an RTM_RESOLVE message to the appropriate interface-address route-management routine (Fn ifa->ifa_rtrequest ) This generated route is called cloned and has RTF_WASCLONED flag set. RTF_PRCLONING flag is obsolete and thus ignored by facility. If the RTF_XRESOLVE flag is set, then the RTM_RESOLVE message is sent instead on the route(4) socket interface, requesting that an external program resolve the address in question and modify the route appropriately.
The default interface is
rtalloc (.);
Its only argument is
Fa ro ,
a pointer to a
``struct route
''
which is defined as follows:
struct route { struct sockaddr ro_dst; struct rtentry *ro_rt; };
Thus, this function can only be used for address families which are
smaller than the default
``struct sockaddr
''
Before calling
rtalloc ();
for the first time, callers should ensure that unused bits of the
structure are set to zero.
On subsequent calls,
rtalloc ();
returns without performing a lookup if
Fa ro->ro_rt
is non-null and the
RTF_UP
flag is set in the route's
rt_flags
field.
The
rtalloc_ign ();
interface can be used when the default actions of
rtalloc ();
in the presence of the
RTF_CLONING
flag is undesired.
The
Fa ro
argument is the same as
rtalloc (,);
but there is additionally a
Fa flags
argument, which lists the flags in the route which are to be
ignored
(in most cases this is
RTF_CLONING
flag).
Both
rtalloc ();
and
rtalloc_ign ();
functions return a pointer to an unlocked
Vt struct rtentry .
The
rtalloc1 ();
function is the most general form of
rtalloc ();
(and both of the other forms are implemented as calls to rtalloc1).
It does not use the
``struct route
''
and is therefore suitable for address families which require more
space than is in a traditional
``struct sockaddr
''
Instead, it takes a
``struct sockaddr *
''
directly as the
Fa sa
argument.
The second argument,
Fa report ,
controls whether
RTM_RESOLVE
requests are sent to the lower layers when an
RTF_CLONING
or
RTF_PRCLONING
route is cloned.
Ordinarily a value of one should be passed, except
in the processing of those lower layers which use the cloning
facility.
The third argument,
Fa flags ,
is a set of flags to ignore, as in
rtalloc_ign (.);
The
rtalloc1 ();
function returns a pointer to a locked
Vt struct rtentry .
The
rtfree ();
function frees a locked route entry, e.g., a previously allocated by
rtalloc1 (.);
The
RTFREE ();
macro is used to free unlocked route entries, previously allocated by
rtalloc ();
or
rtalloc_ign (.);
The
RTFREE ();
macro decrements the reference count on the routing table entry (see below),
and frees it if the reference count has reached zero.
The preferred usage is allocating a route using
rtalloc ();
or
rtalloc_ign ();
and freeing using
RTFREE (.);
The
RT_LOCK ();
macro is used to lock a routing table entry.
The
RT_UNLOCK ();
macro is used to unlock a routing table entry.
The
RT_ADDREF ();
macro increments the reference count on a previously locked route entry.
The
RT_REMREF ();
macro decrements the reference count on a previously locked route entry.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |