Source
if (SYSINFO_RET_OK != get_ifdata(if_name, &ibytes, &ipackets, &ierrors, &idropped, NULL, NULL, NULL, NULL, NULL,
/*
** Zabbix
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/* if OpenBSD 5.5 or newer */
/* if Openbsd 5.8 or newer */
/* Workaround: include malloc.h here without _KERNEL to prevent its */
/* inclusion later from if_var.h to avoid malloc() and free() redefinition. */
/* define _KERNEL to enable 'ifnet' and 'ifnet_head' definitions in if_var.h */
/* structs ifnet and ifnet_head are defined in this header since OpenBSD 5.5 */
static struct nlist kernel_symbols[] =
{
{"_ifnet", N_UNDF, 0, 0, 0},
{"_tcbtable", N_UNDF, 0, 0, 0},
{NULL, 0, 0, 0, 0}
};
static int get_ifdata(const char *if_name,
zbx_uint64_t *ibytes, zbx_uint64_t *ipackets, zbx_uint64_t *ierrors, zbx_uint64_t *idropped,
zbx_uint64_t *obytes, zbx_uint64_t *opackets, zbx_uint64_t *oerrors,
zbx_uint64_t *tbytes, zbx_uint64_t *tpackets, zbx_uint64_t *terrors,
zbx_uint64_t *icollisions, char **error)
{
struct ifnet_head head;
struct ifnet *ifp;
kvm_t *kp;
int len = 0;
int ret = SYSINFO_RET_FAIL;
if (NULL == if_name || '\0' == *if_name)
{
*error = zbx_strdup(NULL, "Network interface name cannot be empty.");
return SYSINFO_RET_FAIL;
}