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