SNMP agent (Simple Network Management Protocol) More...
#include "core/net.h"
#include "snmp/snmp_common.h"
#include "snmp/snmp_agent_message.h"
#include "snmp/snmp_agent_trap.h"
#include "snmp/snmp_agent_inform.h"
#include "snmp/snmp_agent_usm.h"
#include "snmp/snmp_agent_vacm.h"
#include "mibs/mib_common.h"
Go to the source code of this file.
Data Structures | |
struct | SnmpAgentSettings |
SNMP agent settings. More... | |
struct | _SnmpAgentContext |
SNMP agent context. More... | |
Macros | |
#define | SnmpAgentContext struct _SnmpAgentContext |
#define | SNMP_AGENT_SUPPORT DISABLED |
#define | SNMP_AGENT_STACK_SIZE 550 |
#define | SNMP_AGENT_PRIORITY OS_TASK_PRIORITY_NORMAL |
#define | SNMP_AGENT_MAX_MIBS 8 |
#define | SNMP_AGENT_MAX_COMMUNITIES 3 |
#define | SNMP_AGENT_MAX_USERS 8 |
#define | SNMP_AGENT_GROUP_TABLE_SIZE 8 |
#define | SNMP_AGENT_ACCESS_TABLE_SIZE 8 |
#define | SNMP_AGENT_VIEW_TABLE_SIZE 8 |
#define | SNMP_AGENT_PRIVATE_CONTEXT |
Typedefs | |
typedef error_t(* | SnmpAgentRandCallback) (uint8_t *data, size_t length) |
Random data generation callback function. More... | |
Functions | |
void | snmpAgentGetDefaultSettings (SnmpAgentSettings *settings) |
Initialize settings with default values. More... | |
error_t | snmpAgentInit (SnmpAgentContext *context, const SnmpAgentSettings *settings) |
SNMP agent initialization. More... | |
error_t | snmpAgentStart (SnmpAgentContext *context) |
Start SNMP agent. More... | |
error_t | snmpAgentStop (SnmpAgentContext *context) |
Stop SNMP agent. More... | |
error_t | snmpAgentLoadMib (SnmpAgentContext *context, const MibModule *module) |
Load a MIB module. More... | |
error_t | snmpAgentUnloadMib (SnmpAgentContext *context, const MibModule *module) |
Unload a MIB module. More... | |
error_t | snmpAgentSetVersion (SnmpAgentContext *context, SnmpVersion versionMin, SnmpVersion versionMax) |
Set minimum and maximum versions permitted. More... | |
error_t | snmpAgentSetEngineBoots (SnmpAgentContext *context, int32_t engineBoots) |
Set the value of the snmpEngineBoots variable. More... | |
error_t | snmpAgentGetEngineBoots (SnmpAgentContext *context, int32_t *engineBoots) |
Get the value of the snmpEngineBoots variable. More... | |
error_t | snmpAgentSetEnterpriseOid (SnmpAgentContext *context, const uint8_t *enterpriseOid, size_t enterpriseOidLen) |
Set enterprise OID. More... | |
error_t | snmpAgentSetContextEngine (SnmpAgentContext *context, const void *contextEngine, size_t contextEngineLen) |
Set context engine identifier. More... | |
error_t | snmpAgentSetContextName (SnmpAgentContext *context, const char_t *contextName) |
Set context name. More... | |
error_t | snmpAgentCreateCommunity (SnmpAgentContext *context, const char_t *community, SnmpAccess mode) |
Create a new community string. More... | |
error_t | snmpAgentDeleteCommunity (SnmpAgentContext *context, const char_t *community) |
Remove a community string. More... | |
error_t | snmpAgentCreateUser (SnmpAgentContext *context, const char_t *userName, SnmpAccess mode, SnmpKeyFormat keyFormat, SnmpAuthProtocol authProtocol, const void *authKey, SnmpPrivProtocol privProtocol, const void *privKey) |
Create a new user. More... | |
error_t | snmpAgentDeleteUser (SnmpAgentContext *context, const char_t *userName) |
Remove existing user. More... | |
error_t | snmpAgentJoinGroup (SnmpAgentContext *context, const char_t *userName, SnmpSecurityModel securityModel, const char_t *groupName) |
Join a group of users. More... | |
error_t | snmpAgentLeaveGroup (SnmpAgentContext *context, const char_t *userName, SnmpSecurityModel securityModel) |
Leave a group of users. More... | |
error_t | snmpAgentCreateAccess (SnmpAgentContext *context, const char_t *groupName, SnmpSecurityModel securityModel, SnmpSecurityLevel securityLevel, const char_t *contextPrefix, SnmpContextMatch contextMatch, const char_t *readViewName, const char_t *writeViewName, const char_t *notifyViewName) |
Create access policy for the specified group name. More... | |
error_t | snmpAgentDeleteAccess (SnmpAgentContext *context, const char_t *groupName, SnmpSecurityModel securityModel, SnmpSecurityLevel securityLevel, const char_t *contextPrefix) |
Delete an existing access policy. More... | |
error_t | snmpAgentCreateView (SnmpAgentContext *context, const char_t *viewName, const uint8_t *subtree, size_t subtreeLen, const uint8_t *mask, size_t maskLen, SnmpViewType type) |
Create a new MIB view. More... | |
error_t | snmpAgentDeleteView (SnmpAgentContext *context, const char_t *viewName, const uint8_t *subtree, size_t subtreeLen) |
Delete an existing MIB view. More... | |
error_t | snmpAgentSendTrap (SnmpAgentContext *context, const IpAddr *destIpAddr, SnmpVersion version, const char_t *userName, uint_t genericTrapType, uint_t specificTrapCode, const SnmpTrapObject *objectList, uint_t objectListSize) |
Send SNMP trap notification. More... | |
error_t | snmpAgentSendInform (SnmpAgentContext *context, const IpAddr *destIpAddr, SnmpVersion version, const char_t *userName, uint_t genericTrapType, uint_t specificTrapCode, const SnmpTrapObject *objectList, uint_t objectListSize) |
Send SNMP inform request. More... | |
void | snmpAgentTask (SnmpAgentContext *context) |
SNMP agent task. More... | |
void | snmpAgentDeinit (SnmpAgentContext *context) |
Release SNMP agent context. More... | |
Detailed Description
SNMP agent (Simple Network Management Protocol)
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.h.
Macro Definition Documentation
◆ SNMP_AGENT_ACCESS_TABLE_SIZE
#define SNMP_AGENT_ACCESS_TABLE_SIZE 8 |
Definition at line 97 of file snmp_agent.h.
◆ SNMP_AGENT_GROUP_TABLE_SIZE
#define SNMP_AGENT_GROUP_TABLE_SIZE 8 |
Definition at line 90 of file snmp_agent.h.
◆ SNMP_AGENT_MAX_COMMUNITIES
#define SNMP_AGENT_MAX_COMMUNITIES 3 |
Definition at line 76 of file snmp_agent.h.
◆ SNMP_AGENT_MAX_MIBS
#define SNMP_AGENT_MAX_MIBS 8 |
Definition at line 69 of file snmp_agent.h.
◆ SNMP_AGENT_MAX_USERS
#define SNMP_AGENT_MAX_USERS 8 |
Definition at line 83 of file snmp_agent.h.
◆ SNMP_AGENT_PRIORITY
#define SNMP_AGENT_PRIORITY OS_TASK_PRIORITY_NORMAL |
Definition at line 64 of file snmp_agent.h.
◆ SNMP_AGENT_PRIVATE_CONTEXT
#define SNMP_AGENT_PRIVATE_CONTEXT |
Definition at line 111 of file snmp_agent.h.
◆ SNMP_AGENT_STACK_SIZE
#define SNMP_AGENT_STACK_SIZE 550 |
Definition at line 57 of file snmp_agent.h.
◆ SNMP_AGENT_SUPPORT
#define SNMP_AGENT_SUPPORT DISABLED |
Definition at line 50 of file snmp_agent.h.
◆ SNMP_AGENT_VIEW_TABLE_SIZE
#define SNMP_AGENT_VIEW_TABLE_SIZE 8 |
Definition at line 104 of file snmp_agent.h.
◆ SnmpAgentContext
#define SnmpAgentContext struct _SnmpAgentContext |
Definition at line 36 of file snmp_agent.h.
Typedef Documentation
◆ SnmpAgentRandCallback
Random data generation callback function.
Definition at line 124 of file snmp_agent.h.
Function Documentation
◆ snmpAgentCreateAccess()
error_t snmpAgentCreateAccess | ( | SnmpAgentContext * | context, |
const char_t * | groupName, | ||
SnmpSecurityModel | securityModel, | ||
SnmpSecurityLevel | securityLevel, | ||
const char_t * | contextPrefix, | ||
SnmpContextMatch | contextMatch, | ||
const char_t * | readViewName, | ||
const char_t * | writeViewName, | ||
const char_t * | notifyViewName | ||
) |
Create access policy for the specified group name.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] groupName NULL-terminated string that contains the group name [in] securityModel Security model [in] securityLevel Security level [in] contextPrefix NULL-terminated string that contains the context name prefix [in] contextMatch Context match [in] readViewName NULL-terminated string that contains the read view name [in] writeViewName NULL-terminated string that contains the write view name [in] notifyViewName NULL-terminated string that contains the notify view name
- Returns
- Error code
Definition at line 1238 of file snmp_agent.c.
◆ snmpAgentCreateCommunity()
error_t snmpAgentCreateCommunity | ( | SnmpAgentContext * | context, |
const char_t * | community, | ||
SnmpAccess | mode | ||
) |
Create a new community string.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] community NULL-terminated string that contains the community name [in] mode Access rights
- Returns
- Error code
Definition at line 700 of file snmp_agent.c.
◆ snmpAgentCreateUser()
error_t snmpAgentCreateUser | ( | SnmpAgentContext * | context, |
const char_t * | userName, | ||
SnmpAccess | mode, | ||
SnmpKeyFormat | keyFormat, | ||
SnmpAuthProtocol | authProtocol, | ||
const void * | authKey, | ||
SnmpPrivProtocol | privProtocol, | ||
const void * | privKey | ||
) |
Create a new user.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] userName NULL-terminated string that contains the user name [in] mode Access rights [in] keyFormat Key format (ASCII password or raw key) [in] authProtocol Authentication type [in] authKey Key to be used for data authentication [in] privProtocol Privacy type [in] privKey Key to be used for data encryption
- Returns
- Error code
Definition at line 832 of file snmp_agent.c.
◆ snmpAgentCreateView()
error_t snmpAgentCreateView | ( | SnmpAgentContext * | context, |
const char_t * | viewName, | ||
const uint8_t * | subtree, | ||
size_t | subtreeLen, | ||
const uint8_t * | mask, | ||
size_t | maskLen, | ||
SnmpViewType | type | ||
) |
Create a new MIB view.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] viewName NULL-terminated string that contains the view name [in] subtree Pointer to the subtree [in] subtreeLen Length of the subtree, in bytes [in] mask Pointer to the bit mask [in] maskLen Length of the bit mask [in] type View type
- Returns
- Error code
Definition at line 1433 of file snmp_agent.c.
◆ snmpAgentDeinit()
void snmpAgentDeinit | ( | SnmpAgentContext * | context | ) |
Release SNMP agent context.
- Parameters
-
[in] context Pointer to the SNMP agent context
Definition at line 2079 of file snmp_agent.c.
◆ snmpAgentDeleteAccess()
error_t snmpAgentDeleteAccess | ( | SnmpAgentContext * | context, |
const char_t * | groupName, | ||
SnmpSecurityModel | securityModel, | ||
SnmpSecurityLevel | securityLevel, | ||
const char_t * | contextPrefix | ||
) |
Delete an existing access policy.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] groupName NULL-terminated string that contains the group name [in] securityModel Security model [in] securityLevel Security level [in] contextPrefix NULL-terminated string that contains the context name prefix
- Returns
- Error code
Definition at line 1373 of file snmp_agent.c.
◆ snmpAgentDeleteCommunity()
error_t snmpAgentDeleteCommunity | ( | SnmpAgentContext * | context, |
const char_t * | community | ||
) |
Remove a community string.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] community NULL-terminated string that contains the community name
- Returns
- Error code
Definition at line 774 of file snmp_agent.c.
◆ snmpAgentDeleteUser()
error_t snmpAgentDeleteUser | ( | SnmpAgentContext * | context, |
const char_t * | userName | ||
) |
Remove existing user.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] userName NULL-terminated string that contains the user name
- Returns
- Error code
Definition at line 1030 of file snmp_agent.c.
◆ snmpAgentDeleteView()
error_t snmpAgentDeleteView | ( | SnmpAgentContext * | context, |
const char_t * | viewName, | ||
const uint8_t * | subtree, | ||
size_t | subtreeLen | ||
) |
Delete an existing MIB view.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] viewName NULL-terminated string that contains the view name [in] subtree Pointer to the subtree [in] subtreeLen Length of the subtree, in bytes
- Returns
- Error code
Definition at line 1535 of file snmp_agent.c.
◆ snmpAgentGetDefaultSettings()
void snmpAgentGetDefaultSettings | ( | SnmpAgentSettings * | settings | ) |
Initialize settings with default values.
- Parameters
-
[out] settings Structure that contains SNMP agent settings
Definition at line 73 of file snmp_agent.c.
◆ snmpAgentGetEngineBoots()
error_t snmpAgentGetEngineBoots | ( | SnmpAgentContext * | context, |
int32_t * | engineBoots | ||
) |
Get the value of the snmpEngineBoots variable.
- Parameters
-
[in] context Pointer to the SNMP agent context [out] engineBoots Number of times the SNMP engine has re-booted
- Returns
- Error code
Definition at line 558 of file snmp_agent.c.
◆ snmpAgentInit()
error_t snmpAgentInit | ( | SnmpAgentContext * | context, |
const SnmpAgentSettings * | settings | ||
) |
SNMP agent initialization.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] settings SNMP agent specific settings
- Returns
- Error code
Definition at line 105 of file snmp_agent.c.
◆ snmpAgentJoinGroup()
error_t snmpAgentJoinGroup | ( | SnmpAgentContext * | context, |
const char_t * | userName, | ||
SnmpSecurityModel | securityModel, | ||
const char_t * | groupName | ||
) |
Join a group of users.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] userName NULL-terminated string that contains the user name [in] securityModel Security model [in] groupName NULL-terminated string that contains the group name
- Returns
- Error code
Definition at line 1084 of file snmp_agent.c.
◆ snmpAgentLeaveGroup()
error_t snmpAgentLeaveGroup | ( | SnmpAgentContext * | context, |
const char_t * | userName, | ||
SnmpSecurityModel | securityModel | ||
) |
Leave a group of users.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] userName NULL-terminated string that contains the user name [in] securityModel Security model
- Returns
- Error code
Definition at line 1177 of file snmp_agent.c.
◆ snmpAgentLoadMib()
error_t snmpAgentLoadMib | ( | SnmpAgentContext * | context, |
const MibModule * | module | ||
) |
Load a MIB module.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] module Pointer the MIB module to be loaded
- Returns
- Error code
Definition at line 350 of file snmp_agent.c.
◆ snmpAgentSendInform()
error_t snmpAgentSendInform | ( | SnmpAgentContext * | context, |
const IpAddr * | destIpAddr, | ||
SnmpVersion | version, | ||
const char_t * | userName, | ||
uint_t | genericTrapType, | ||
uint_t | specificTrapCode, | ||
const SnmpTrapObject * | objectList, | ||
uint_t | objectListSize | ||
) |
Send SNMP inform request.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] destIpAddr Destination IP address [in] version SNMP version identifier [in] userName User name or community name [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 1670 of file snmp_agent.c.
◆ snmpAgentSendTrap()
error_t snmpAgentSendTrap | ( | SnmpAgentContext * | context, |
const IpAddr * | destIpAddr, | ||
SnmpVersion | version, | ||
const char_t * | userName, | ||
uint_t | genericTrapType, | ||
uint_t | specificTrapCode, | ||
const SnmpTrapObject * | objectList, | ||
uint_t | objectListSize | ||
) |
Send SNMP trap notification.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] destIpAddr Destination IP address [in] version SNMP version identifier [in] userName User name or community name [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 1594 of file snmp_agent.c.
◆ snmpAgentSetContextEngine()
error_t snmpAgentSetContextEngine | ( | SnmpAgentContext * | context, |
const void * | contextEngine, | ||
size_t | contextEngineLen | ||
) |
Set context engine identifier.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] contextEngine Pointer to the context engine identifier [in] contextEngineLen Length of the context engine identifier
- Returns
- Error code
Definition at line 622 of file snmp_agent.c.
◆ snmpAgentSetContextName()
error_t snmpAgentSetContextName | ( | SnmpAgentContext * | context, |
const char_t * | contextName | ||
) |
Set context name.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] contextName NULL-terminated string that contains the context name
- Returns
- Error code
Definition at line 659 of file snmp_agent.c.
◆ snmpAgentSetEngineBoots()
error_t snmpAgentSetEngineBoots | ( | SnmpAgentContext * | context, |
int32_t | engineBoots | ||
) |
Set the value of the snmpEngineBoots variable.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] engineBoots Number of times the SNMP engine has re-booted
- Returns
- Error code
Definition at line 519 of file snmp_agent.c.
◆ snmpAgentSetEnterpriseOid()
error_t snmpAgentSetEnterpriseOid | ( | SnmpAgentContext * | context, |
const uint8_t * | enterpriseOid, | ||
size_t | enterpriseOidLen | ||
) |
Set enterprise OID.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] enterpriseOid Pointer to the enterprise OID [in] enterpriseOidLen Length of the enterprise OID
- Returns
- Error code
Definition at line 589 of file snmp_agent.c.
◆ snmpAgentSetVersion()
error_t snmpAgentSetVersion | ( | SnmpAgentContext * | context, |
SnmpVersion | versionMin, | ||
SnmpVersion | versionMax | ||
) |
Set minimum and maximum versions permitted.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] versionMin Minimum version accepted by the SNMP agent [in] versionMax Maximum version accepted by the SNMP agent
- Returns
- Error code
Definition at line 488 of file snmp_agent.c.
◆ snmpAgentStart()
error_t snmpAgentStart | ( | SnmpAgentContext * | context | ) |
Start SNMP agent.
- Parameters
-
[in] context Pointer to the SNMP agent context
- Returns
- Error code
Definition at line 220 of file snmp_agent.c.
◆ snmpAgentStop()
error_t snmpAgentStop | ( | SnmpAgentContext * | context | ) |
Stop SNMP agent.
- Parameters
-
[in] context Pointer to the SNMP agent context
- Returns
- Error code
Definition at line 308 of file snmp_agent.c.
◆ snmpAgentTask()
void snmpAgentTask | ( | SnmpAgentContext * | context | ) |
SNMP agent task.
- Parameters
-
[in] context Pointer to the SNMP agent context
Definition at line 1950 of file snmp_agent.c.
◆ snmpAgentUnloadMib()
error_t snmpAgentUnloadMib | ( | SnmpAgentContext * | context, |
const MibModule * | module | ||
) |
Unload a MIB module.
- Parameters
-
[in] context Pointer to the SNMP agent context [in] module Pointer the MIB module to be unloaded
- Returns
- Error code
Definition at line 430 of file snmp_agent.c.