snmp_agent_object.c
Go to the documentation of this file.
1 /**
2  * @file snmp_agent_object.c
3  * @brief MIB object access
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2026 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.6.8
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL SNMP_TRACE_LEVEL
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "snmp/snmp_agent.h"
37 #include "snmp/snmp_agent_object.h"
38 #include "core/crypto.h"
39 #include "encoding/asn1.h"
40 #include "encoding/oid.h"
41 #include "debug.h"
42 
43 //Check TCP/IP stack configuration
44 #if (SNMP_AGENT_SUPPORT == ENABLED)
45 
46 
47 /**
48  * @brief Assign object value
49  * @param[in] context Pointer to the SNMP agent context
50  * @param[in] message Pointer to the received SNMP message
51  * @param[in] var Variable binding
52  * @param[in] commit This flag specifies whether the changes should be
53  * committed to the MIB base
54  * @return Error code
55  **/
56 
58  const SnmpMessage *message, SnmpVarBind *var, bool_t commit)
59 {
60  error_t error;
61  size_t n;
63  const MibObject *object;
64 
65  //Search the MIB for the specified object
66  error = snmpFindMibObject(context, var->oid, var->oidLen, &object);
67  //Cannot found the specified object?
68  if(error)
69  {
70  return error;
71  }
72 
73  //Debug message
74  TRACE_INFO(" %s\r\n", object->name);
75 
76  //Make sure the specified object is available for set operations
77  if(object->access != MIB_ACCESS_WRITE_ONLY &&
78  object->access != MIB_ACCESS_READ_WRITE &&
79  object->access != MIB_ACCESS_READ_CREATE)
80  {
81  return ERROR_NOT_WRITABLE;
82  }
83 
84 #if (SNMP_AGENT_VACM_SUPPORT == ENABLED)
85  //Access control verification
86  error = snmpIsAccessAllowed(context, message, var->oid, var->oidLen);
87  //Access denied?
88  if(error)
89  {
90  return error;
91  }
92 #endif
93 
94  //Check class
95  if(var->objClass != object->objClass)
96  {
97  return ERROR_WRONG_TYPE;
98  }
99 
100  //Check type
101  if(var->objType != object->objType)
102  {
103  return ERROR_WRONG_TYPE;
104  }
105 
106  //Point to the object value
107  value = (MibVariant *) var->value;
108  //Get the length of the object value
109  n = var->valueLen;
110 
111  //Check object class
112  if(object->objClass == ASN1_CLASS_UNIVERSAL)
113  {
114  //Check object type
115  if(object->objType == ASN1_TYPE_INTEGER)
116  {
117  int32_t val;
118 
119  //Integer objects use ASN.1 encoding rules
120  error = snmpDecodeInt32(var->value, n, &val);
121  //Conversion failed?
122  if(error)
123  {
124  return ERROR_WRONG_ENCODING;
125  }
126 
127  //Point to the scratch buffer
128  value = (MibVariant *) context->response.buffer;
129  //Save resulting value
130  value->integer = val;
131  //Integer size
132  n = sizeof(int32_t);
133  }
134  }
135  else if(object->objClass == ASN1_CLASS_APPLICATION)
136  {
137  //Check object type
138  if(object->objType == MIB_TYPE_IP_ADDRESS)
139  {
140  //IpAddress objects have fixed size
141  if(n != object->valueSize)
142  {
143  return ERROR_WRONG_LENGTH;
144  }
145  }
146  else if(object->objType == MIB_TYPE_COUNTER32 ||
147  object->objType == MIB_TYPE_GAUGE32 ||
148  object->objType == MIB_TYPE_TIME_TICKS)
149  {
150  uint32_t val;
151 
152  //Counter32, Gauge32 and TimeTicks objects use ASN.1 encoding rules
153  error = snmpDecodeUnsignedInt32(var->value, n, &val);
154  //Conversion failed?
155  if(error)
156  {
157  return ERROR_WRONG_ENCODING;
158  }
159 
160  //Point to the scratch buffer
161  value = (MibVariant *) context->response.buffer;
162  //Save resulting value
163  value->counter32 = val;
164  //Integer size
165  n = sizeof(uint32_t);
166  }
167  else if(object->objType == MIB_TYPE_COUNTER64)
168  {
169  uint64_t val;
170 
171 #if (SNMP_V1_SUPPORT == ENABLED)
172  //Any SNMPv1 request which contains a variable binding with a
173  //Counter64 value is ill-formed and shall be discarded (refer
174  //to RFC 3584, section 4.2.2.1)
175  if(message->version == SNMP_VERSION_1)
176  {
177  return ERROR_INVALID_TAG;
178  }
179 #endif
180  //Counter64 objects use ASN.1 encoding rules
181  error = snmpDecodeUnsignedInt64(var->value, n, &val);
182  //Conversion failed?
183  if(error)
184  {
185  return ERROR_WRONG_ENCODING;
186  }
187 
188  //Point to the scratch buffer
189  value = (MibVariant *) context->response.buffer;
190  //Save resulting value
191  value->counter64 = val;
192  //Integer size
193  n = sizeof(uint64_t);
194  }
195  }
196 
197  //Objects can be assigned a value using a callback function
198  if(object->setValue != NULL)
199  {
200  //Invoke callback function to assign object value
201  error = object->setValue(object, var->oid, var->oidLen, value, n, commit);
202  }
203  //Simple scalar objects can also be attached to a variable
204  else if(object->value != NULL)
205  {
206  //Check the length of the object
207  if(n <= object->valueSize)
208  {
209  //Check whether the changes shall be committed to the MIB base
210  if(commit)
211  {
212  //Record the length of the object value
213  if(object->valueLen != NULL)
214  {
215  *object->valueLen = n;
216  }
217 
218  //Set object value
219  osMemcpy(object->value, value, n);
220  }
221 
222  //Successful write operation
223  error = NO_ERROR;
224  }
225  else
226  {
227  //Invalid length
228  error = ERROR_WRONG_LENGTH;
229  }
230  }
231  else
232  {
233  //Report an error
234  error = ERROR_WRITE_FAILED;
235  }
236 
237  //Return status code
238  return error;
239 }
240 
241 
242 /**
243  * @brief Retrieve object value
244  * @param[in] context Pointer to the SNMP agent context
245  * @param[in] message Pointer to the received SNMP message
246  * @param[out] var Variable binding
247  * @return Error code
248  **/
249 
251  const SnmpMessage *message, SnmpVarBind *var)
252 {
253  error_t error;
254  size_t n;
255  MibVariant *value;
256  const MibObject *object;
257 
258  //Search the MIB for the specified object
259  error = snmpFindMibObject(context, var->oid, var->oidLen, &object);
260  //Cannot found the specified object?
261  if(error)
262  {
263  return error;
264  }
265 
266  //Debug message
267  TRACE_INFO(" %s\r\n", object->name);
268 
269  //Check the maximal level of access for the specified object
270  if(object->access == MIB_ACCESS_READ_ONLY ||
271  object->access == MIB_ACCESS_READ_WRITE ||
272  object->access == MIB_ACCESS_READ_CREATE)
273  {
274  //The object is available for get operations
275  }
276  else if(object->access == MIB_ACCESS_FOR_NOTIFY)
277  {
278  //The object is accessible only via a notification
279  if(message->pduType != SNMP_PDU_TRAP &&
280  message->pduType != SNMP_PDU_TRAP_V2 &&
281  message->pduType != SNMP_PDU_INFORM_REQUEST)
282  {
283  return ERROR_ACCESS_DENIED;
284  }
285  }
286  else
287  {
288  //The object is not available for get operations
289  return ERROR_ACCESS_DENIED;
290  }
291 
292 #if (SNMP_AGENT_VACM_SUPPORT == ENABLED)
293  //Access control verification
294  error = snmpIsAccessAllowed(context, message, var->oid, var->oidLen);
295  //Access denied?
296  if(error)
297  {
298  return error;
299  }
300 #endif
301 
302  //Buffer where to store the object value
303  value = (MibVariant *) (context->response.varBindList +
304  context->response.varBindListLen + context->response.oidLen);
305 
306  //Number of bytes available in the buffer
307  n = context->response.varBindListMaxLen -
308  (context->response.varBindListLen + context->response.oidLen);
309 
310  //Check object class
311  if(object->objClass == ASN1_CLASS_UNIVERSAL)
312  {
313  //Check object type
314  if(object->objType == ASN1_TYPE_INTEGER)
315  {
316  //Make sure the buffer is large enough
317  if(n < object->valueSize)
318  {
319  return ERROR_BUFFER_OVERFLOW;
320  }
321 
322  //Integer objects have fixed size
323  n = object->valueSize;
324  }
325  }
326  else if(object->objClass == ASN1_CLASS_APPLICATION)
327  {
328  //Check object type
329  if(object->objType == MIB_TYPE_IP_ADDRESS ||
330  object->objType == MIB_TYPE_COUNTER32 ||
331  object->objType == MIB_TYPE_GAUGE32 ||
332  object->objType == MIB_TYPE_TIME_TICKS ||
333  object->objType == MIB_TYPE_COUNTER64)
334  {
335  //Make sure the buffer is large enough
336  if(n < object->valueSize)
337  {
338  return ERROR_BUFFER_OVERFLOW;
339  }
340 
341  //IpAddress, Counter32, Gauge32, TimeTicks and
342  //Counter64 objects have fixed size
343  n = object->valueSize;
344  }
345  }
346 
347  //Object value can be retrieved using a callback function
348  if(object->getValue != NULL)
349  {
350  //Invoke callback function to retrieve object value
351  error = object->getValue(object, var->oid, var->oidLen, value, &n);
352  //Unable to retrieve object value?
353  if(error)
354  {
355  return error;
356  }
357  }
358  //Simple scalar objects can also be attached to a variable
359  else if(object->value != NULL)
360  {
361  //Fixed or variable-length object?
362  if(object->valueLen != NULL)
363  {
364  //Make sure the buffer is large enough
365  if(n < *object->valueLen)
366  {
367  return ERROR_BUFFER_OVERFLOW;
368  }
369 
370  //Get the length of the object value
371  n = *object->valueLen;
372  }
373 
374  //Retrieve object value
375  osMemcpy(value, object->value, n);
376  }
377  else
378  {
379  //Report an error
380  return ERROR_READ_FAILED;
381  }
382 
383  //Check object class
384  if(object->objClass == ASN1_CLASS_UNIVERSAL)
385  {
386  //Check object type
387  if(object->objType == ASN1_TYPE_INTEGER)
388  {
389  //Encode Integer objects using ASN.1 rules
390  error = snmpEncodeInt32(value->integer, (uint8_t *) value, &n);
391  }
392  else
393  {
394  //No conversion required for OctetString and ObjectIdentifier objects
395  error = NO_ERROR;
396  }
397  }
398  else if(object->objClass == ASN1_CLASS_APPLICATION)
399  {
400  //Check object type
401  if(object->objType == MIB_TYPE_COUNTER32 ||
402  object->objType == MIB_TYPE_GAUGE32 ||
403  object->objType == MIB_TYPE_TIME_TICKS)
404  {
405  //Encode Counter32, Gauge32 and TimeTicks objects using ASN.1 rules
406  error = snmpEncodeUnsignedInt32(value->counter32, (uint8_t *) value, &n);
407  }
408  else if(object->objType == MIB_TYPE_COUNTER64)
409  {
410 #if (SNMP_V1_SUPPORT == ENABLED)
411  //On receipt of an SNMPv1 GetRequest-PDU containing a variable binding
412  //whose name field points to an object instance of type Counter64, a
413  //GetResponse-PDU SHALL be returned, with an error-status of noSuchName
414  if(message->version == SNMP_VERSION_1)
415  {
416  //Report an error
417  error = ERROR_OBJECT_NOT_FOUND;
418  }
419  else
420 #endif
421  {
422  //Encode Counter64 objects using ASN.1 rules
423  error = snmpEncodeUnsignedInt64(value->counter64,
424  (uint8_t *) value, &n);
425  }
426  }
427  else
428  {
429  //No conversion required for Opaque objects
430  error = NO_ERROR;
431  }
432  }
433 
434  //Check status code
435  if(!error)
436  {
437  //Save object class and type
438  var->objClass = object->objClass;
439  var->objType = object->objType;
440 
441  //Save object value
442  var->value = (uint8_t *) value;
443  var->valueLen = n;
444  }
445 
446  //Return status code
447  return error;
448 }
449 
450 
451 /**
452  * @brief Search MIBs for the next object
453  * @param[in] context Pointer to the SNMP agent context
454  * @param[in] message Pointer to the received SNMP message
455  * @param[in] var Variable binding
456  * @return Error pointer
457  **/
458 
460  const SnmpMessage *message, SnmpVarBind *var)
461 {
462  error_t error;
463  uint_t i;
464  uint_t j;
465  size_t n;
466  uint_t numObjects;
467  size_t bufferLen;
468  uint8_t *curOid;
469  size_t curOidLen;
470  uint8_t *nextOid;
471  size_t nextOidLen;
472  uint8_t *tempOid;
473  size_t tempOidLen;
474  const MibObject *object;
475  const MibObject *nextObject;
476 
477  //Initialize status code
478  error = NO_ERROR;
479 
480  //Calculate the length of the buffer
481  bufferLen = context->response.varBindListMaxLen -
482  context->response.varBindListLen;
483 
484  //Initialize pointer
485  nextObject = NULL;
486 
487  //Buffer where to store the resulting OID
488  nextOid = context->response.varBindList + context->response.varBindListLen;
489  nextOidLen = 0;
490 
491  //Loop through MIBs
492  for(i = 0; i < SNMP_AGENT_MAX_MIBS; i++)
493  {
494  //Valid MIB?
495  if(context->mibTable[i] != NULL &&
496  context->mibTable[i]->numObjects > 0)
497  {
498  //Get the total number of objects
499  numObjects = context->mibTable[i]->numObjects;
500 
501  //Point to the last object of the MIB
502  object = &context->mibTable[i]->objects[numObjects - 1];
503 
504  //Discard instance sub-identifier
505  n = MIN(var->oidLen, object->oidLen);
506 
507  //Perform lexicographical comparison
508  if(oidComp(var->oid, n, object->oid, object->oidLen) <= 0)
509  {
510  //Sanity check
511  if((nextOidLen + var->oidLen) > bufferLen)
512  {
513  //Report an error
514  error = ERROR_BUFFER_OVERFLOW;
515  //Exit immediately
516  break;
517  }
518 
519  //Copy the OID from the specified variable binding
520  curOid = nextOid + nextOidLen;
521  curOidLen = var->oidLen;
522  osMemcpy(curOid, var->oid, var->oidLen);
523 
524  //Loop through objects
525  for(j = 0; j < numObjects; )
526  {
527  //Point to the current object
528  object = &context->mibTable[i]->objects[j];
529 
530  //Buffer where to store the OID of the next object
531  tempOid = curOid + curOidLen;
532 
533  //Make sure the current object is accessible
534  if(object->access == MIB_ACCESS_READ_ONLY ||
535  object->access == MIB_ACCESS_READ_WRITE ||
536  object->access == MIB_ACCESS_READ_CREATE)
537  {
538  //Scalar or tabular object?
539  if(object->getNext == NULL)
540  {
541  //Perform lexicographical comparison
542  if(oidComp(curOid, curOidLen, object->oid, object->oidLen) <= 0)
543  {
544  //Take in account the instance sub-identifier to determine
545  //the length of the OID
546  tempOidLen = object->oidLen + 1;
547 
548  //Make sure the buffer is large enough to hold the entire OID
549  if((nextOidLen + curOidLen + tempOidLen) <= bufferLen)
550  {
551  //Copy object identifier
552  osMemcpy(tempOid, object->oid, object->oidLen);
553  //Append instance sub-identifier
554  tempOid[tempOidLen - 1] = 0;
555 
556  //Successful processing
557  error = NO_ERROR;
558  }
559  else
560  {
561  //Report an error
562  error = ERROR_BUFFER_OVERFLOW;
563  }
564  }
565  else
566  {
567  //The specified OID does not lexicographically precede
568  //the name of the current object
569  error = ERROR_OBJECT_NOT_FOUND;
570  }
571  }
572  else
573  {
574  //Discard instance sub-identifier
575  n = MIN(curOidLen, object->oidLen);
576 
577  //Perform lexicographical comparison
578  if(oidComp(curOid, n, object->oid, object->oidLen) <= 0)
579  {
580  //Maximum acceptable size of the OID
581  tempOidLen = bufferLen - nextOidLen - curOidLen;
582 
583  //Search the MIB for the next object
584  error = object->getNext(object, curOid, curOidLen,
585  tempOid, &tempOidLen);
586  }
587  else
588  {
589  //The specified OID does not lexicographically precede
590  //the name of the current object
591  error = ERROR_OBJECT_NOT_FOUND;
592  }
593  }
594 
595 #if (SNMP_V1_SUPPORT == ENABLED)
596  //Check status code
597  if(error == NO_ERROR)
598  {
599  //On receipt of an SNMPv1 GetNextRequest-PDU, any object
600  //instance which contains a syntax of Counter64 shall be
601  //skipped (refer to RFC 3584, section 4.2.2.1)
602  if(message->version == SNMP_VERSION_1)
603  {
604  //Counter64 type?
605  if(object->objClass == ASN1_CLASS_APPLICATION &&
606  object->objType == MIB_TYPE_COUNTER64)
607  {
608  //Skip current object
609  error = ERROR_OBJECT_NOT_FOUND;
610  }
611  }
612  }
613 #endif
614 #if (SNMP_AGENT_VACM_SUPPORT == ENABLED)
615  //Check status code
616  if(error == NO_ERROR)
617  {
618  //Access control verification
619  error = snmpIsAccessAllowed(context, message, tempOid,
620  tempOidLen);
621  }
622 #endif
623  //Check status code
624  if(error == NO_ERROR)
625  {
626  //Save the closest object identifier that follows the
627  //specified OID
628  if(nextObject == NULL)
629  {
630  nextObject = object;
631  nextOidLen = tempOidLen;
632  osMemmove(nextOid, tempOid, tempOidLen);
633  }
634  else if(oidComp(tempOid, tempOidLen, nextOid, nextOidLen) < 0)
635  {
636  nextObject = object;
637  nextOidLen = tempOidLen;
638  osMemmove(nextOid, tempOid, tempOidLen);
639  }
640 
641  //We are done
642  break;
643  }
644  else if(error == ERROR_OBJECT_NOT_FOUND)
645  {
646  //Catch exception
647  error = NO_ERROR;
648 
649  //Jump to the next object in the MIB
650  j++;
651  }
652  else if(error == ERROR_UNKNOWN_CONTEXT ||
654  {
655  //Catch exception
656  error = NO_ERROR;
657 
658  //Check the next instance of the same object
659  curOidLen = tempOidLen;
660  osMemmove(curOid, tempOid, tempOidLen);
661  }
662  else
663  {
664  //Exit immediately
665  break;
666  }
667  }
668  else
669  {
670  //The current object is not accessible
671  j++;
672  }
673  }
674  }
675  }
676 
677  //Any error to report?
678  if(error)
679  {
680  break;
681  }
682  }
683 
684  //Check status code
685  if(!error)
686  {
687  //Next object found?
688  if(nextObject != NULL)
689  {
690  //Replace the original OID with the name of the next object
691  var->oid = nextOid;
692  var->oidLen = nextOidLen;
693 
694  //Save the length of the OID
695  context->response.oidLen = nextOidLen;
696  }
697  else
698  {
699  //The specified OID does not lexicographically precede the
700  //name of some object
701  error = ERROR_OBJECT_NOT_FOUND;
702  }
703  }
704 
705  //Return status code
706  return error;
707 }
708 
709 
710 /**
711  * @brief Search MIBs for the given object
712  * @param[in] context Pointer to the SNMP agent context
713  * @param[in] oid Object identifier
714  * @param[in] oidLen Length of the OID
715  * @param[out] object Pointer the MIB object descriptor
716  * @return Error code
717  **/
718 
720  const uint8_t *oid, size_t oidLen, const MibObject **object)
721 {
722  error_t error;
723  int_t left;
724  int_t right;
725  int_t mid;
726  int_t res;
727  uint_t i;
728  size_t n;
729  const MibObject *objects;
730 
731  //Initialize variables
732  res = -1;
733  mid = 0;
734  objects = NULL;
735 
736  //Loop through MIBs
737  for(i = 0; i < SNMP_AGENT_MAX_MIBS && res != 0; i++)
738  {
739  //Valid MIB?
740  if(context->mibTable[i] != NULL &&
741  context->mibTable[i]->numObjects > 0)
742  {
743  //Point to the list of objects
744  objects = context->mibTable[i]->objects;
745 
746  //Index of the first item
747  left = 0;
748  //Index of the last item
749  right = context->mibTable[i]->numObjects - 1;
750 
751  //Discard instance sub-identifier
752  n = MIN(oidLen, objects[right].oidLen);
753 
754  //Check object identifier
755  if(oidComp(oid, oidLen, objects[left].oid, objects[left].oidLen) >= 0 &&
756  oidComp(oid, n, objects[right].oid, objects[right].oidLen) <= 0)
757  {
758  //Binary search algorithm
759  while(left <= right && res != 0)
760  {
761  //Calculate the index of the middle item
762  mid = left + (right - left) / 2;
763 
764  //Discard instance sub-identifier
765  n = MIN(oidLen, objects[mid].oidLen);
766 
767  //Perform lexicographic comparison
768  res = oidComp(oid, n, objects[mid].oid, objects[mid].oidLen);
769 
770  //Check the result of the comparison
771  if(res > 0)
772  {
773  left = mid + 1;
774  }
775  else if(res < 0)
776  {
777  right = mid - 1;
778  }
779  }
780  }
781  }
782  }
783 
784  //Object identifier found?
785  if(res == 0)
786  {
787  //Scalar object?
788  if(objects[mid].getNext == NULL)
789  {
790  //The instance sub-identifier shall be 0 for scalar objects
791  if(oidLen == (objects[mid].oidLen + 1) && oid[oidLen - 1] == 0)
792  {
793  //Return a pointer to the matching object
794  *object = &objects[mid];
795  //No error to report
796  error = NO_ERROR;
797  }
798  else
799  {
800  //No such instance...
801  error = ERROR_INSTANCE_NOT_FOUND;
802  }
803  }
804  //Tabular object?
805  else
806  {
807  //Check the length of the OID
808  if(oidLen > objects[mid].oidLen)
809  {
810  //Return a pointer to the matching object
811  *object = &objects[mid];
812  //No error to report
813  error = NO_ERROR;
814  }
815  else
816  {
817  //No such instance...
818  error = ERROR_INSTANCE_NOT_FOUND;
819  }
820  }
821  }
822  else
823  {
824  //No such object...
825  error = ERROR_OBJECT_NOT_FOUND;
826  }
827 
828  //Return status code
829  return error;
830 }
831 
832 #endif
@ MIB_TYPE_IP_ADDRESS
Definition: mib_common.h:60
@ SNMP_PDU_TRAP
Definition: snmp_common.h:154
@ SNMP_PDU_INFORM_REQUEST
Definition: snmp_common.h:156
int bool_t
Definition: compiler_port.h:63
error_t snmpEncodeUnsignedInt32(uint32_t value, uint8_t *dest, size_t *length)
Encode a 32-bit unsigned integer.
@ ERROR_UNKNOWN_CONTEXT
Definition: error.h:265
const uint8_t * value
@ SNMP_PDU_TRAP_V2
Definition: snmp_common.h:157
Variable binding.
signed int int_t
Definition: compiler_port.h:56
@ ERROR_WRONG_TYPE
Definition: error.h:121
@ ERROR_BUFFER_OVERFLOW
Definition: error.h:143
@ MIB_ACCESS_WRITE_ONLY
Definition: mib_common.h:78
OID (Object Identifier)
uint8_t message[]
Definition: chap.h:154
@ ERROR_NOT_WRITABLE
Definition: error.h:150
@ MIB_ACCESS_READ_ONLY
Definition: mib_common.h:79
error_t snmpSetObjectValue(SnmpAgentContext *context, const SnmpMessage *message, SnmpVarBind *var, bool_t commit)
Assign object value.
@ ERROR_AUTHORIZATION_FAILED
Definition: error.h:269
#define SNMP_AGENT_MAX_MIBS
Definition: snmp_agent.h:69
const uint8_t res[]
int_t oidComp(const uint8_t *oid1, size_t oidLen1, const uint8_t *oid2, size_t oidLen2)
Compare object identifiers.
Definition: oid.c:148
uint8_t oid[]
Definition: lldp_tlv.h:300
SNMP agent (Simple Network Management Protocol)
@ MIB_ACCESS_READ_WRITE
Definition: mib_common.h:80
@ MIB_TYPE_COUNTER32
Definition: mib_common.h:61
#define osMemcpy(dest, src, length)
Definition: os_port.h:147
const uint8_t * oid
@ MIB_TYPE_GAUGE32
Definition: mib_common.h:62
uint16_t mid
Definition: coap_common.h:180
error_t
Error codes.
Definition: error.h:43
@ ERROR_INSTANCE_NOT_FOUND
Definition: error.h:259
error_t snmpGetNextObject(SnmpAgentContext *context, const SnmpMessage *message, SnmpVarBind *var)
Search MIBs for the next object.
#define ASN1_CLASS_UNIVERSAL
Definition: asn1.h:52
error_t snmpFindMibObject(SnmpAgentContext *context, const uint8_t *oid, size_t oidLen, const MibObject **object)
Search MIBs for the given object.
@ MIB_ACCESS_FOR_NOTIFY
Definition: mib_common.h:77
General definitions for cryptographic library.
@ ERROR_ACCESS_DENIED
Definition: error.h:149
@ ERROR_WRONG_LENGTH
Definition: error.h:120
#define TRACE_INFO(...)
Definition: debug.h:105
#define MIN(a, b)
Definition: os_port.h:63
@ ASN1_TYPE_INTEGER
Definition: asn1.h:73
error_t snmpIsAccessAllowed(SnmpAgentContext *context, const SnmpMessage *message, const uint8_t *oid, size_t oidLen)
Access control verification.
@ MIB_TYPE_TIME_TICKS
Definition: mib_common.h:64
error_t snmpEncodeInt32(int32_t value, uint8_t *dest, size_t *length)
Encode a 32-bit signed integer.
uint8_t n
@ ERROR_READ_FAILED
Definition: error.h:225
@ ERROR_WRITE_FAILED
Definition: error.h:224
error_t snmpDecodeInt32(const uint8_t *src, size_t length, int32_t *value)
Decode a 32-bit signed integer.
@ ERROR_OBJECT_NOT_FOUND
Definition: error.h:258
#define MibObject
Definition: mib_common.h:46
uint8_t value[]
Definition: tcp.h:376
uint8_t oidLen
Definition: lldp_tlv.h:299
error_t snmpDecodeUnsignedInt64(const uint8_t *src, size_t length, uint64_t *value)
Decode a 64-bit unsigned integer.
SNMP message.
@ SNMP_VERSION_1
Definition: snmp_common.h:138
#define SnmpAgentContext
Definition: snmp_agent.h:36
@ ERROR_WRONG_ENCODING
Definition: error.h:122
MIB object access.
error_t snmpEncodeUnsignedInt64(uint64_t value, uint8_t *dest, size_t *length)
Encode a 64-bit unsigned integer.
@ ERROR_INVALID_TAG
Definition: error.h:114
error_t snmpGetObjectValue(SnmpAgentContext *context, const SnmpMessage *message, SnmpVarBind *var)
Retrieve object value.
uint8_t valueSize
Definition: chap.h:126
MibVariant
Definition: mib_common.h:196
@ MIB_TYPE_COUNTER64
Definition: mib_common.h:66
unsigned int uint_t
Definition: compiler_port.h:57
TCP/IP stack core.
#define ASN1_CLASS_APPLICATION
Definition: asn1.h:53
@ MIB_ACCESS_READ_CREATE
Definition: mib_common.h:81
error_t snmpDecodeUnsignedInt32(const uint8_t *src, size_t length, uint32_t *value)
Decode a 32-bit unsigned integer.
@ NO_ERROR
Success.
Definition: error.h:44
Debugging facilities.
#define osMemmove(dest, src, length)
Definition: os_port.h:153
ASN.1 (Abstract Syntax Notation One)