how to send specific trap in lwip

拈花ヽ惹草 提交于 2021-02-11 12:41:05

问题


I am new to SNMP, I am running SNMP v2 on an embedded device and want to send a trap when the system overheats. right now I have defined this in my mib file:


dartTrapObjects        OBJECT IDENTIFIER ::= {dart 2}
dartTraps            OBJECT IDENTIFIER ::= {dart 3}

temp OBJECT-TYPE
    SYNTAX        Integer32
    MAX-ACCESS    read-write
    STATUS        current
    DESCRIPTION
        "Description for an integer"
    ::= {dartTrapObjects 1}

overheat NOTIFICATION-TYPE
    OBJECTS
    {
        temp
    }
    STATUS    current
    DESCRIPTION
        "A custom SNMPv2 trap"
    ::= {dartTraps 1}

my question is how to send the trap on agent side? I have these functions but not sure how to use them:

err_t snmp_send_trap_specific(s32_t specific_trap, struct snmp_varbind *varbinds)

/** SNMP variable binding descriptor (publically needed for traps) */
struct snmp_varbind
{
  /** pointer to next varbind, NULL for last in list */
  struct snmp_varbind *next;
  /** pointer to previous varbind, NULL for first in list */
  struct snmp_varbind *prev;

  /** object identifier */
  struct snmp_obj_id oid;

  /** value ASN1 type */
  u8_t type;
  /** object value length */
  u16_t value_len;
  /** object value */
  void *value;
};

struct snmp_obj_id
{
  u8_t len;
  u32_t id[SNMP_MAX_OBJ_ID_LEN];
};

来源:https://stackoverflow.com/questions/64722101/how-to-send-specific-trap-in-lwip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!