Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_mib.c
Context not available. | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/smp.h> | |||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
Context not available. | |||||
* - a link-type-specific data | * - a link-type-specific data | ||||
* structure (as might be used | * structure (as might be used | ||||
* by an SNMP agent | * by an SNMP agent | ||||
* .ifdata.<ifindex>.ringinfo | |||||
* - what's in `struct if_ring_data' | |||||
* | * | ||||
* Perhaps someday we will make addresses accessible via this interface | * Perhaps someday we will make addresses accessible via this interface | ||||
* as well (then there will be four such...). The reason that the | * as well (then there will be four such...). The reason that the | ||||
Context not available. | |||||
int error; | int error; | ||||
u_int namelen = arg2; | u_int namelen = arg2; | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
struct ifmibdata ifmd; | struct ifmibdata *ifmd = NULL; | ||||
size_t dlen; | size_t dlen; | ||||
char *dbuf; | char *dbuf; | ||||
Context not available. | |||||
goto out; | goto out; | ||||
case IFDATA_GENERAL: | case IFDATA_GENERAL: | ||||
bzero(&ifmd, sizeof(ifmd)); | ifmd = malloc(sizeof(*ifmd), M_TEMP, M_NOWAIT | M_ZERO); | ||||
strlcpy(ifmd.ifmd_name, ifp->if_xname, sizeof(ifmd.ifmd_name)); | if (ifmd == NULL) { | ||||
error = ENOMEM; | |||||
goto out; | |||||
} | |||||
strlcpy(ifmd->ifmd_name, ifp->if_xname, | |||||
sizeof(ifmd->ifmd_name)); | |||||
ifmd.ifmd_pcount = ifp->if_pcount; | ifmd->ifmd_pcount = ifp->if_pcount; | ||||
if_data_copy(ifp, &ifmd.ifmd_data); | if_data_copy(ifp, &ifmd->ifmd_data); | ||||
ifmd.ifmd_flags = ifp->if_flags; | ifmd->ifmd_flags = ifp->if_flags; | ||||
ifmd.ifmd_snd_len = 0; /* XXXGL */ | ifmd->ifmd_snd_len = 0; /* XXXGL */ | ||||
ifmd.ifmd_snd_maxlen = 0; /* XXXGL */ | ifmd->ifmd_snd_maxlen = 0; /* XXXGL */ | ||||
ifmd.ifmd_snd_drops = if_get_counter(ifp, IFCOUNTER_OQDROPS); | ifmd->ifmd_snd_drops = if_get_counter(ifp, IFCOUNTER_OQDROPS); | ||||
error = SYSCTL_OUT(req, &ifmd, sizeof ifmd); | error = SYSCTL_OUT(req, ifmd, sizeof(*ifmd)); | ||||
if (error) | if (error) | ||||
goto out; | goto out; | ||||
break; | break; | ||||
Context not available. | |||||
error = EPERM; | error = EPERM; | ||||
free(dbuf, M_TEMP); | free(dbuf, M_TEMP); | ||||
goto out; | goto out; | ||||
case IFDATA_RINGINFO: | |||||
dlen = sizeof(*ifmd) + sizeof(struct xifrstat) * mp_ncpus * | |||||
ifp->if_nrings; | |||||
ifmd = malloc(dlen, M_TEMP, M_NOWAIT | M_ZERO); | |||||
if (ifmd == NULL) { | |||||
error = ENOMEM; | |||||
goto out; | |||||
} | |||||
strlcpy(ifmd->ifmd_name, ifp->if_xname, | |||||
sizeof(ifmd->ifmd_name)); | |||||
if_ring_data_copy(ifp, &ifmd->ifmd_ring_data); | |||||
error = SYSCTL_OUT(req, ifmd, dlen); | |||||
if (error) | |||||
goto out; | |||||
break; | |||||
} | } | ||||
out: | out: | ||||
if (ifmd != NULL) | |||||
free(ifmd, M_TEMP); | |||||
if_rele(ifp); | if_rele(ifp); | ||||
return error; | return error; | ||||
} | } | ||||
Context not available. |