Source
static int preproc_snmp_walk_to_json_params(const char *params, zbx_vector_snmp_walk_to_json_param_t *parsed_params)
/*
** Zabbix
** Copyright (C) 2001-2023 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.
**/
ZBX_VECTOR_IMPL(snmp_walk_to_json_param, zbx_snmp_walk_to_json_param_t)
ZBX_PTR_VECTOR_IMPL(snmp_walk_to_json_output_val, zbx_snmp_walk_json_output_value_t *)
ZBX_PTR_VECTOR_IMPL(snmp_value_pair, zbx_snmp_value_pair_t *)
static char zbx_snmp_init_done;
static int preproc_snmp_translate_oid(const char *oid_in, char **oid_out)
{
char buffer[MAX_OID_LEN];
oid oid_tmp[MAX_OID_LEN];
size_t oid_len = MAX_OID_LEN;
if (0 != get_node(oid_in, oid_tmp, &oid_len))
{
snprint_objid(buffer, sizeof(buffer), oid_tmp, oid_len);
*oid_out = zbx_strdup(NULL, buffer);
return SUCCEED;
}
return FAIL;
}
static zbx_hash_t snmp_value_pair_hash_func(const void *d)
{
const zbx_snmp_value_pair_t *s;
s = (const zbx_snmp_value_pair_t *)d;
return ZBX_DEFAULT_STRING_HASH_FUNC(s->oid);
}
static int snmp_value_pair_compare_func(const void *d1, const void *d2)
{
const zbx_snmp_value_pair_t *s1 = (const zbx_snmp_value_pair_t *)d1;
const zbx_snmp_value_pair_t *s2 = (const zbx_snmp_value_pair_t *)d2;
return strcmp(s1->oid, s2->oid);
}