Source
interfaces[i].addr = (1 == interfaces[i].useip ? interfaces[i].ip_orig : interfaces[i].dns_orig);
/*
** 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.
**/
extern unsigned char program_type;
static int compare_interfaces(const void *p1, const void *p2)
{
const DC_INTERFACE2 *i1 = (DC_INTERFACE2 *)p1, *i2 = (DC_INTERFACE2 *)p2;
if (i1->type > i2->type) /* 1st criterion: 'type' in ascending order */
return 1;
if (i1->type < i2->type)
return -1;
if (i1->main > i2->main) /* 2nd criterion: 'main' in descending order */
return -1;
if (i1->main < i2->main)
return 1;
if (i1->interfaceid > i2->interfaceid) /* 3rd criterion: 'interfaceid' in ascending order */
return 1;
if (i1->interfaceid < i2->interfaceid)
return -1;
return 0;
}
/******************************************************************************
* *
* Purpose: get data of all network interfaces for a host from configuration *
* cache and pack into JSON for LLD *
* *
* Parameter: hostid - [IN] the host identifier *
* j - [OUT] JSON with interface data *