int agentx_notify(netsnmp_session * session, netsnmp_pdu *pdu) { netsnmp_session *sp; netsnmp_variable_list *var; extern const oid sysuptime_oid[], snmptrap_oid[]; extern const size_t sysuptime_oid_len, snmptrap_oid_len; sp = find_agentx_session(session, pdu->sessid); if (sp == NULL) return AGENTX_ERR_NOT_OPEN; var = pdu->variables; if (!var) return AGENTX_ERR_PROCESSING_ERROR; if (snmp_oid_compare(var->name, var->name_length, sysuptime_oid, sysuptime_oid_len) == 0) { var = var->next_variable; } if (!var || snmp_oid_compare(var->name, var->name_length, snmptrap_oid, snmptrap_oid_len) != 0) return AGENTX_ERR_PROCESSING_ERROR; /* * If sysUptime isn't the first varbind, don't worry. * send_trap_vars() will add it if necessary. * * Note that if this behaviour is altered, it will * be necessary to add sysUptime here, * as this is valid AgentX syntax. */ /* If a context name was specified, send the trap using that context. * Otherwise, send the trap without the context using the old method */ if (pdu->contextName != NULL) { send_trap_vars_with_context(-1, -1, pdu->variables, pdu->contextName); } else { send_trap_vars(-1, -1, pdu->variables); } return AGENTX_ERR_NOERROR; }
int agentx_notify(netsnmp_session * session, netsnmp_pdu *pdu) { netsnmp_session *sp; netsnmp_variable_list *var; int got_sysuptime = 0; extern oid sysuptime_oid[], snmptrap_oid[]; extern size_t sysuptime_oid_len, snmptrap_oid_len; sp = find_agentx_session(session, pdu->sessid); if (sp == NULL) return AGENTX_ERR_NOT_OPEN; var = pdu->variables; if (!var) return AGENTX_ERR_PROCESSING_ERROR; if (snmp_oid_compare(var->name, var->name_length, sysuptime_oid, sysuptime_oid_len) == 0) { got_sysuptime = 1; var = var->next_variable; } if (!var || snmp_oid_compare(var->name, var->name_length, snmptrap_oid, snmptrap_oid_len) != 0) return AGENTX_ERR_PROCESSING_ERROR; /* * If sysUptime isn't the first varbind, don't worry. * send_trap_vars() will add it if necessary. * * Note that if this behaviour is altered, it will * be necessary to add sysUptime here, * as this is valid AgentX syntax. */ send_trap_vars(-1, -1, pdu->variables); return AGENTX_ERR_NOERROR; }
void send_easy_trap(int trap, int specific) { send_trap_vars(trap, specific, NULL); }
void send_trap_pdu(netsnmp_pdu *pdu) { send_trap_vars(-1, -1, pdu->variables); }
void send_v2trap(netsnmp_variable_list * vars) { send_trap_vars(-1, -1, vars); }
void send_v2trap ( struct variable_list *vars) { send_trap_vars( -1, -1, vars ); }