KVM_IFLIST(3) BSD Programmer's Manual KVM_IFLIST(3)NAME
kvm_iflist, kvm_ifmulti - access network interface configuration
SYNOPSIS
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/route.h>
#include <kvm.h>
#include <kvm_stat.h>
struct if_msghdr *
kvm_iflist(kvm_t *kd, int ifindex, int af, size_t *rlen);
void *
kvm_ifmulti(kvm_t *kd, struct sockaddr_dl *sdl, int pf, size_t *rlen);
DESCRIPTIONkvm_iflist() returns the current network interface configuration as a se-
ries of if_msghdr and ifa_msghdr structures. Each if_msghdr structure
describes a physical interface and is followed by a sockaddr_dl structure
giving the name, and link-level address if applicable, of the interface.
The protocol addresses assigned to the interface are each represented by
an ifa_msghdr structure followed by an appropriate number of the sockaddr
structure variants. See route(4) for info on parsing routing socket-
style messages. The variable rlen is set the length of the returned da-
ta.
The returned information is restricted to a specified interface by set-
ting ifindex to the index of that interface. A value of zero specifies
that the configuration of all interfaces should be returned. The re-
turned protocol address information (ifa_msghdr structures) may be re-
stricted to a specific address family by setting af to the identifier for
that address family (e.g. AF_INET or AF_NS). A value of AF_UNSPEC (i.e.
0) specifies that the protocol information for all protocols should be
returned.
kvm_ifmulti() returns a description of the multicast groups active on the
interface specified by sdl. The pf parameter specifies the protocol fami-
ly for which multicast group membership information will be returned. If
specified as PF_LINK, a linked list of ether_multi structures (as defined
in /usr/include/netinet/if_ether.h) will be returned with the enm_next
pointers will be corrected for the process' address space. If specified
as PF_INET, a linked list of in_multiaddr structures (as defined in
/usr/include/netinet/in.h) will be returned with the ima_next field
pointers corrected for the process' address space. The variable rlen is
set the length of the returned data.
The memory returned by kvm_iflist() and kvm_ifmulti() should be freed
with free(3) when no longer needed. Note that memory is allocated and
should be freed even if the returned value of rlen is zero.
RETURN VALUESkvm_iflist(), and kvm_ifmulti() both return NULL on failure.
BUGS
These routines do not belong in the kvm interface.
SEE ALSOkvm(3), kvm_close(3), kvm_geterr(3), kvm_nlist(3), kvm_open(3),
kvm_openfiles(3), kvm_read(3), kvm_write(3)