mibII mibif_notify_f mib_netsock mib_if_set_dyn mib_refresh_iflist mib_find_if mib_find_if_sys mib_find_if_name mib_first_if mib_next_if mib_register_newif mib_unregister_newif mib_fetch_ifmib mib_if_admin mib_find_ifa mib_first_ififa mib_next_ififa mib_ifstack_create mib_ifstack_delete mib_find_rcvaddr mib_rcvaddr_create mib_rcvaddr_delete mibif_notify mibif_unnotify - mib-2 module for bsnmpd.
(begemotSnmpdModulePath.mibII = /usr/lib/snmp_mibII.so)
struct mibif { TAILQ_ENTRY(mibif) link; u_int flags; u_int index; /* logical ifindex */ u_int sysindex; char name[IFNAMSIZ]; char descr[256]; struct ifmibdata mib; uint64_t mibtick; void *specmib; size_t specmiblen; u_char *physaddr; u_int physaddrlen; int has_connector; int trap_enable; uint64_t counter_disc; mibif_notify_f xnotify; void *xnotify_data; const struct lmodule *xnotify_mod; struct asn_oid spec_oid; };
The
module tries to implement the semantic if
ifIndex
as described in RFC-2863.
This RFC states, that an interface indexes may not be reused.
That means, for example, if
tun
is a synthetic interface type and the system creates the interface
tun0
destroys this interfaces and again creates a
tun 0
then these interfaces must have different interface indexes, because in fact
they are different interfaces.
If, on the other hand, there is a hardware interface
xl0
and this interface disappears, because its driver is unloaded and appears
again, because the driver is loaded again, the interface index must stay
the same.
implements this by differentiating between real and synthetic (dynamic)
interfaces.
An interface type can be declared dynamic by calling the function
mib_if_set_dyn ();
with the name if the interface type (for example
Qq tun ).
For real interfaces, the module keeps the mapping between the interface name
and its
ifIndex
in a special list, if the interface is unloaded.
For dynamic interfaces
a new
ifIndex
is generated each time the interface comes into existence.
This means, that the interface index as seen by SNMP is not the same index
as used by the system.
The SNMP
ifIndex
is held in field
index
the system's interface index is
sysindex
A call to mib_refresh_iflist causes the entire interface list to be re-created.
The interface list can be traversed with the functions
mib_first_if ();
and
mib_next_if (.);
Be sure not to change the interface list while traversing the list with
these two calls.
There are three functions to find an interface by name or index.
mib_find_if ();
finds an interface by searching for an SNMP
ifIndex
mib_find_if_sys ();
finds an interface by searching for a system interface index and
mib_find_if_name ();
finds an interface by looking for an interface name.
Each of the function returns
NULL
if the interface cannot be found.
The function
mib_fetch_ifmib ();
causes the interface MIB to be refreshed from the kernel.
The function
mib_if_admin ();
can be used to change the interface administrative state to up
(argument is 1) or down (argument is 0).
A module can also register to events on a specific interface.
This is done by calling
mibif_notify (.);
This causes the given callback
Fa func
to be called with the interface pointer, a notification code and
the user argument
Fa uarg
when any of the following events occur:
This mechanism can be used to implement interface type specific MIB parts
in other modules.
The registration can be removed with
mib_unnotify ();
which the return value from
Fa mib_notify .
Any notification registration is removed automatically when the interface
is destroyed or the registering module is unloaded.
Note that only one module can register to any given interface
struct mibifa { TAILQ_ENTRY(mibifa) link; struct in_addr inaddr; struct in_addr inmask; struct in_addr inbcast; struct asn_oid index; u_int ifindex; u_int flags; };
The (ordered) list of IP-addresses on a given interface can be traversed by
calling
mib_first_ififa ();
and
mib_next_ififa (.);
The list should not be considered read-only.
struct mibrcvaddr { TAILQ_ENTRY(mibrcvaddr) link; struct asn_oid index; u_int ifindex; u_char addr[ASN_MAXOIDLEN]; size_t addrlen; u_int flags; }; enum { MIBRCVADDR_VOLATILE = 0x00000001, MIBRCVADDR_BCAST = 0x00000002, MIBRCVADDR_HW = 0x00000004, };
Note, that the assignment of MIBRCVADDR_BCAST is based on a list of known interface types. The flags should be handled by modules implementing interface type specific MIBs.
A receive address can be created with
mib_rcvaddr_create ();
and deleted with
mib_rcvaddr_delete (.);
This needs to be done only for addresses that are not automatically handled
by the system.
A receive address can be found with
mib_find_rcvaddr (.);
A table entry is created with
mib_ifstack_create ();
and deleted with
mib_ifstack_delete (.);
Both functions need the pointers to the interfaces.
Entries are automatically
deleted if any of the interfaces of the entry is destroyed.
The functions handle
both the stack table and the reverse stack table.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |