Helper functions for SNMP agent. More...
#include <limits.h>
#include "core/net.h"
#include "snmp/snmp_agent.h"
#include "snmp/snmp_agent_misc.h"
#include "snmp/snmp_agent_object.h"
#include "mibs/mib2_module.h"
#include "core/crypto.h"
#include "encoding/asn1.h"
#include "encoding/oid.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL SNMP_TRACE_LEVEL |
Functions | |
void | snmpLockMib (SnmpAgentContext *context) |
Lock MIB bases. More... | |
void | snmpUnlockMib (SnmpAgentContext *context) |
Unlock MIB bases. More... | |
SnmpUserEntry * | snmpCreateCommunityEntry (SnmpAgentContext *context) |
Create a new community entry. More... | |
SnmpUserEntry * | snmpFindCommunityEntry (SnmpAgentContext *context, const char_t *community, size_t length) |
Search the community table for a given community string. More... | |
error_t | snmpParseVarBinding (const uint8_t *p, size_t length, SnmpVarBind *var, size_t *consumed) |
Parse variable binding. More... | |
error_t | snmpWriteVarBinding (SnmpAgentContext *context, const SnmpVarBind *var) |
Write variable binding. More... | |
error_t | snmpCopyVarBindingList (SnmpAgentContext *context) |
Copy the list of variable bindings. More... | |
error_t | snmpWriteTrapVarBindingList (SnmpAgentContext *context, uint_t genericTrapType, uint_t specificTrapCode, const SnmpTrapObject *objectList, uint_t objectListSize) |
Format the variable binding list for Trap-PDU or SNMPv2-Trap-PDU. More... | |
error_t | snmpTranslateStatusCode (SnmpMessage *message, error_t status, uint_t index) |
Translate status code. More... | |
Detailed Description
Helper functions for SNMP agent.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneTCP Open.
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.
- Version
- 2.4.4
Definition in file snmp_agent_misc.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL SNMP_TRACE_LEVEL |
Definition at line 32 of file snmp_agent_misc.c.
Function Documentation
◆ snmpCopyVarBindingList()
error_t snmpCopyVarBindingList | ( | SnmpAgentContext * | context | ) |
Copy the list of variable bindings.
- Parameters
-
[in] context Pointer to the SNMP agent context
- Returns
- Error code
Definition at line 449 of file snmp_agent_misc.c.
◆ snmpCreateCommunityEntry()
SnmpUserEntry* snmpCreateCommunityEntry | ( | SnmpAgentContext * | context | ) |
Create a new community entry.
- Parameters
-
[in] context Pointer to the SNMP agent context
- Returns
- Pointer to the newly created entry
Definition at line 147 of file snmp_agent_misc.c.
◆ snmpFindCommunityEntry()
SnmpUserEntry* snmpFindCommunityEntry | ( | SnmpAgentContext * | context, |
const char_t * | community, | ||
size_t | length | ||
) |
Search the community table for a given community string.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] community Pointer to the community string [in] length Length of the community string
- Returns
- Pointer to the matching entry
Definition at line 205 of file snmp_agent_misc.c.
◆ snmpLockMib()
void snmpLockMib | ( | SnmpAgentContext * | context | ) |
Lock MIB bases.
- Parameters
-
[in] context Pointer to the SNMP agent context
Definition at line 62 of file snmp_agent_misc.c.
◆ snmpParseVarBinding()
error_t snmpParseVarBinding | ( | const uint8_t * | p, |
size_t | length, | ||
SnmpVarBind * | var, | ||
size_t * | consumed | ||
) |
Parse variable binding.
- Parameters
-
[in] p Input stream where to read the variable binding [in] length Number of bytes available in the input stream [out] var Variable binding [out] consumed Total number of bytes that have been consumed
- Returns
- Error code
Definition at line 256 of file snmp_agent_misc.c.
◆ snmpTranslateStatusCode()
error_t snmpTranslateStatusCode | ( | SnmpMessage * | message, |
error_t | status, | ||
uint_t | index | ||
) |
Translate status code.
- Parameters
-
[in,out] message Pointer to the outgoing SNMP message [in] status Status code [in] index Index of the variable binding in the list that caused an exception
- Returns
- error code
Definition at line 616 of file snmp_agent_misc.c.
◆ snmpUnlockMib()
void snmpUnlockMib | ( | SnmpAgentContext * | context | ) |
Unlock MIB bases.
- Parameters
-
[in] context Pointer to the SNMP agent context
Definition at line 104 of file snmp_agent_misc.c.
◆ snmpWriteTrapVarBindingList()
error_t snmpWriteTrapVarBindingList | ( | SnmpAgentContext * | context, |
uint_t | genericTrapType, | ||
uint_t | specificTrapCode, | ||
const SnmpTrapObject * | objectList, | ||
uint_t | objectListSize | ||
) |
Format the variable binding list for Trap-PDU or SNMPv2-Trap-PDU.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] genericTrapType Generic trap type [in] specificTrapCode Specific code [in] objectList List of object names [in] objectListSize Number of entries in the list
- Returns
- Error code
Definition at line 477 of file snmp_agent_misc.c.
◆ snmpWriteVarBinding()
error_t snmpWriteVarBinding | ( | SnmpAgentContext * | context, |
const SnmpVarBind * | var | ||
) |
Write variable binding.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] var Variable binding
- Returns
- Error code
Definition at line 331 of file snmp_agent_misc.c.