Пример #1
0
/**
 * Starts SNMP Agent.
 * Allocates UDP pcb and binds it to IP_ADDR_ANY port 161.
 */
void
snmp_init(void)
{
    struct snmp_msg_pstat *msg_ps;
    u8_t i;

    snmp1_pcb = udp_new();
    if (snmp1_pcb != NULL) {
        udp_recv(snmp1_pcb, snmp_recv, (void *)SNMP_IN_PORT);
        udp_bind(snmp1_pcb, IP_ADDR_ANY, SNMP_IN_PORT);
    }
    msg_ps = &msg_input_list[0];
    for (i=0; i<SNMP_CONCURRENT_REQUESTS; i++) {
        msg_ps->state = SNMP_MSG_EMPTY;
        msg_ps->error_index = 0;
        msg_ps->error_status = SNMP_ES_NOERROR;
        msg_ps++;
    }
    trap_msg.pcb = snmp1_pcb;

#ifdef SNMP_PRIVATE_MIB_INIT
    /* If defined, this must be a function-like define to initialize the
     * private MIB after the stack has been initialized.
     * The private MIB can also be initialized in tcpip_callback (or after
     * the stack is initialized), this define is only for convenience. */
    SNMP_PRIVATE_MIB_INIT();
#endif /* SNMP_PRIVATE_MIB_INIT */

    /* The coldstart trap will only be output
       if our outgoing interface is up & configured  */
    snmp_coldstart_trap();
}
Пример #2
0
/**
 * Starts SNMP Agent.
 * Allocates UDP pcb and binds it to IP_ADDR_ANY port 161.
 */
void
snmp_init(void)
{
  struct snmp_msg_pstat *msg_ps;
  u8_t i;

  snmp1_pcb = udp_new();
  if (snmp1_pcb != NULL)
  {
    udp_recv(snmp1_pcb, snmp_recv, (void *)SNMP_IN_PORT);
    udp_bind(snmp1_pcb, IP_ADDR_ANY, SNMP_IN_PORT);
  }
  msg_ps = &msg_input_list[0];
  for (i=0; i<SNMP_CONCURRENT_REQUESTS; i++)
  {
    msg_ps->state = SNMP_MSG_EMPTY;
    msg_ps->error_index = 0;
    msg_ps->error_status = SNMP_ES_NOERROR;
    msg_ps++;
  }
  trap_msg.pcb = snmp1_pcb;
  /* The coldstart trap will only be output
     if our outgoing interface is up & configured  */
  snmp_coldstart_trap();
}