Source
SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", zbx_strerror(errno)));
/*
** 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 Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
static char buf_ctl[1024];
/* Low Level Discovery needs a way to get the list of network interfaces available */
/* on the monitored system. HP-UX versions starting from 11.31 have if_nameindex() */
/* available in libc, older versions have it in libipv6 which we do not want to */
/* depend on. So for older versions we use different code to get that list. */
/* More information: */
/* h20000.www2.hp.com/bc/docs/support/SupportManual/c02258083/c02258083.pdf */
static struct strbuf ctlbuf =
{
sizeof(buf_ctl),
0,
buf_ctl
};
static void add_if_name(char **if_list, size_t *if_list_alloc, size_t *if_list_offset, const char *name)
{
if (FAIL == zbx_str_in_list(*if_list, name, ZBX_IF_SEP))
{
if ('\0' != **if_list)
zbx_chrcpy_alloc(if_list, if_list_alloc, if_list_offset, ZBX_IF_SEP);
zbx_strcpy_alloc(if_list, if_list_alloc, if_list_offset, name);
}
}
static int get_if_names(char **if_list, size_t *if_list_alloc, size_t *if_list_offset)
{
int s, ifreq_size, numifs, i, family = AF_INET;
struct sockaddr *from;
u_char *buffer = NULL;
struct ifconf ifc;