0

I need to test a driver code based on the snmp++ library.When I started this driver code, I printed out the following error log

  • "Snmp Trap Register Error :SNMP: Response PDU Too Big"

I'm using SNMP++v3.2.25.I found an SNMP simulator on the network and sent it to the SNMP driver.Still print out the error log

  • "Snmp Trap Register Error :SNMP: Response PDU Too Big" .

The SNMP simulator I used was SnmpTrapGen V1.1.I sent in the CMD command for

  • "SnmpTrapGen.Exe -r:172.20.31.126 -p:161 -v:3 -to: 1.3.6.1.4.1.2011.2.15.2.4.3.3.0.1"
int ScsSnmp::init_snmp()
{
    Snmp::socket_startup();
    int status;
//  UdpAddress address(m_local_addr);
    m_snmp = new Snmp(status/*,address*/);
    if (( m_snmp == NULL) || ( status != SNMP_CLASS_SUCCESS))
    {
        printlog(LOGE_SNMP + m_link,"constructing Snmp Object failed ");
    }
    else
    {
        TargetCollection targets;
        OidCollection trapids;
        Oid trapoid = OidAlarmReportNotificationType;
        Oid heartoid = OidHeartbeatNotificationType;
        trapids += trapoid;
        trapids += heartoid;
        m_snmp->notify_set_listen_port(TRAP_LISTEN_PORT);
        ScsSnmp* myself = this;
        if ( status = m_snmp->notify_register( trapids, targets,my_trap_callback,myself) != SNMP_CLASS_SUCCESS)
        {
            printlog(LOGE_SNMP + m_link,"Snmp Trap Register Error : %s ",m_snmp->error_msg(status));
            return -1;
        }
        m_snmp->start_poll_thread(1000);    //1000ms
    }
    return 0;
}

void ScsSnmp::my_trap_callback (int reason, Snmp *session,Pdu &pdu, SnmpTarget &target, void *data)
{
    ScsSnmp* scssnmp = (ScsSnmp*)data;
    printlog(LOGE_SNMP + scssnmp->m_link,"start my_trap_callback");
    if ( reason == SNMP_CLASS_NOTIFICATION) 
    {
        Vb nextVb;
        GenAddress addr;
        target.get_address(addr);
        IpAddress from(addr);   
        Oid notify_id,ent;
        pdu.get_notify_id(notify_id);
        pdu.get_notify_enterprise(ent);
        if (notify_id == OidAlarmReportNotificationType)
        {
            memset(scssnmp->m_alarm_msg,0,128);
            memset(scssnmp->m_alarm_info.station,0,64);
            memset(scssnmp->m_alarm_info.subsystem,0,64);
            memset(scssnmp->m_alarm_info.devicetype,0,64);
            memset(scssnmp->m_alarm_info.device,0,64);
            memset(scssnmp->m_alarm_info.alarm_msg,0,128);
            for (int i = 0;i<pdu.get_vb_count();i++)
            {
                pdu.get_vb(nextVb, i);
                scssnmp->process_alarm_vb(nextVb);
            }
            memset(scssnmp->m_alarm_buf,0,512);
            memcpy(scssnmp->m_alarm_buf,&scssnmp->m_alarm_head,sizeof(alarm_head));
            memcpy(scssnmp->m_alarm_buf+sizeof(alarm_head),&scssnmp->m_alarm_info,sizeof(alarm_event_info));
            bool ret = scssnmp->m_ctrl_inf->addAlarm(scssnmp->m_alarm_buf,512);
            if (ret)
            {
                printlog(LOGE_SNMP + scssnmp->m_link,"add an event alarm success !");
            }
            else
            {
                printlog(LOGE_SNMP + scssnmp->m_link,"add an event alarm failed !");
            }

        }
        else if (notify_id == OidHeartbeatNotificationType)
        {
            printlog(LOGE_SNMP + scssnmp->m_link,"get a heartbeat !");
        }
        else
        {
            printlog(LOGE_SNMP + scssnmp->m_link,"Trap notify id is wrong,id=%s",notify_id.get_printable());
        }

    }
    else
    {
        printlog(LOGE_SNMP + scssnmp->m_link,"Trap Receive Error = ",session->error_msg(reason));
    }
    printlog(LOGE_SNMP + scssnmp->m_link,"end my_trap_callback");
}

I want to send SNMP traps through the emulator.The SNMP driver then receives the data and prints it out.Simply put, you want to test whether the data interface works.But the actual receiving interface keeps printing out error log

  • "Snmp Trap Register Error :SNMP: Response PDU Too Big" .
Aplues
  • 15
  • 4

1 Answers1

0

We encountered this before but it's in a snmp get response. this always indicates the response pdu is larger than 65535 bytes. do a packet capture on port 162 will give a more clear verification. When we encounter this in snmp get request, we decreased the number of OIDs sent in each request to fix this problem.

scugxl
  • 317
  • 4
  • 15