Examples of SnmpPduRequest


Examples of com.sun.jmx.snmp.SnmpPduRequest

        }

        // First, make an SNMP V2 trap pdu
        // We clone varBindList and insert sysUpTime and snmpTrapOid
        //
        SnmpPduRequest pdu = new SnmpPduRequest() ;
        pdu.address = null ;
        pdu.port = trapPort ;
        pdu.type = pduV2TrapPdu ;
        pdu.version = snmpVersionTwo ;
View Full Code Here

Examples of com.sun.jmx.snmp.SnmpPduRequest

        }

        // First, make an SNMP V2 trap pdu
        // We clone varBindList and insert sysUpTime and snmpTrapOid
        //
        SnmpPduRequest pdu = new SnmpPduRequest() ;
        pdu.address = null ;
        pdu.port = port ;
        pdu.type = pduV2TrapPdu ;
        pdu.version = snmpVersionTwo ;
View Full Code Here

Examples of org.opennms.protocols.snmp.SnmpPduRequest

      sbuf.append("\nPDU Length.......... ").append(pdu.getLength());
      sbuf.append("\nCommunity string.... ").append(community.toString());
   
      if(pdu instanceof SnmpPduRequest)
      {
         SnmpPduRequest spdu = (SnmpPduRequest) pdu;
        
         sbuf.append("\nPDU Error Status.... ").append(spdu.getErrorStatus());
         sbuf.append("\nPDU Error Index..... ").append(spdu.getErrorIndex());
         sbuf.append("\n");
      }
 
      for (int i = 0; i < pdu.getLength(); i++ )
      {
View Full Code Here

Examples of org.opennms.protocols.snmp.SnmpPduRequest

      }
       
      Mapping m = (Mapping)this.notificationMapList.get(index);
     
      // Create trap
      SnmpPduRequest trapPdu = new SnmpPduRequest(SnmpPduPacket.V2TRAP);
       
      // Append the specified varbinds. Get varbinds from mapping and for
      // each one of the former use the wrapper to get data from the
      // notification

      // Get the coresponding wrapper
      NotificationWrapper wrapper =
         (NotificationWrapper)this.notificationWrapperCache.get(index);
       
      if (wrapper != null)
      {
         // Prime the wrapper with the notification contents
         wrapper.prime(n);
           
         List vbList = m.getVarBindList().getVarBindList();
        
         for (int i = 0; i < vbList.size(); i++)
         {
            VarBind vb = (VarBind)vbList.get(i);
               
            // Append the var bind. Interrogate read vb for OID and
            // variable tag. The later is used as the key passed to the
            // wrapper in order for it to locate the required value. That
            // value and the aforementioned OID are used to generate the
            // variable binding
            trapPdu.addVarBind(
               this.snmpVBFactory.make(vb.getOid(), wrapper.get(vb.getTag())));
         }
      }
      else
      {
View Full Code Here

Examples of org.opennms.protocols.snmp.SnmpPduRequest

    * @return SnmpPduRequest filled in with the proper response, or null if cannot process
    * NOTE: this might be changed to throw an exception.
    */  
   public SnmpPduRequest snmpReceivedGet(SnmpPduPacket pdu, boolean getNext)
   {
      SnmpPduRequest response = null;
      int pduLength = pdu.getLength();
     
      log.debug("requestId=" + pdu.getRequestId() + ", pduLength="  + pduLength);
  
      SnmpVarBind[] vblist  = new SnmpVarBind[pduLength];
      int errorStatus = SnmpPduPacket.ErrNoError;
      int errorIndex = 0;

      //Process for each varibind in the request
      for (int i = 0; i < pduLength ; i++ )
      {
         SnmpVarBind vb = pdu.getVarBindAt(i);
         SnmpObjectId oid = vb.getName();
         if (getNext)
         {
            log.debug(
               "Should call getNextOid() to find out what is the next valid OID " +
               "instance in the supported MIB tree. Assign that OID to the VB List " +
               "and then proceed same as that of get request" );
         }
         vblist[i] = new SnmpVarBind(oid);
        
         log.debug("oid=" + oid.toString());
   
         log.debug("Should call the respective interface to retrieve current value for this OID" );

         SnmpSyntax result = null;
        
         if (result == null)
         {
            errorStatus = SnmpPduPacket.ErrNoSuchName;
            errorIndex = i + 1;
            //log.debug("Error Occured " + vb.getName().toString());
         }
         else
         {
            vblist[i].setValue(result);
            log.debug("Varbind[" + i + "] := " + vblist[i].getName().toString());
            log.debug(" --> " + vblist[i].getValue().toString());      
         }
      }
      response = new SnmpPduRequest(SnmpPduPacket.RESPONSE, vblist);
      response.setErrorStatus(errorStatus);
      response.setErrorIndex(errorIndex);
      return response;
   }
View Full Code Here

Examples of org.opennms.protocols.snmp.SnmpPduRequest

    * @return SnmpPduRequest filled in with the proper response, or null if cannot process
    * NOTE: this might be changed to throw an exception.
    */
   public SnmpPduRequest snmpReceivedSet(SnmpPduPacket pdu)
   {
      SnmpPduRequest response = null;
      int errorStatus = SnmpPduPacket.ErrNoError;
      int errorIndex = 0;
      int k = pdu.getLength();
      SnmpVarBind[] vblist  = new SnmpVarBind[k];
    
      for (int i = 0; i < k ; i++ )
      {
         SnmpVarBind vb = pdu.getVarBindAt(i);
         vblist[i] = new SnmpVarBind(vb);
         SnmpObjectId oid = vb.getName();
        
         SnmpSyntax result = null;
         log.debug("Should call the respective interface to assign a value for this OID" );
         
         if (result != null)
         {
            errorStatus = SnmpPduPacket.ErrReadOnly;
            errorIndex = i + 1;
            log.debug("Error occured " + vb.getName().toString());
         }
        
         log.debug("Varbind[" + i + "] := " + vb.getName().toString());
         log.debug(" --> " + vb.getValue().toString());    
      }
    
      response = new SnmpPduRequest(SnmpPduPacket.RESPONSE, vblist);
      response.setErrorStatus(errorStatus);
      response.setErrorIndex(errorIndex);

      return response;
   }
View Full Code Here

Examples of org.opennms.protocols.snmp.SnmpPduRequest

      }
       
      Mapping m = (Mapping)this.notificationMapList.get(index);
     
      // Create trap
      SnmpPduRequest trapPdu = new SnmpPduRequest(SnmpPduPacket.V2TRAP);
       
      // Append the specified varbinds. Get varbinds from mapping and for
      // each one of the former use the wrapper to get data from the
      // notification

      // Get the coresponding wrapper
      NotificationWrapper wrapper =
         (NotificationWrapper)this.notificationWrapperCache.get(index);
       
      if (wrapper != null)
      {
         // Prime the wrapper with the notification contents
         wrapper.prime(n);
           
         List vbList = m.getVarBindList().getVarBindList();
        
         for (int i = 0; i < vbList.size(); i++)
         {
            VarBind vb = (VarBind)vbList.get(i);
               
            // Append the var bind. Interrogate read vb for OID and
            // variable tag. The later is used as the key passed to the
            // wrapper in order for it to locate the required value. That
            // value and the aforementioned OID are used to generate the
            // variable binding
            trapPdu.addVarBind(
               this.snmpVBFactory.make(vb.getOid(), wrapper.get(vb.getTag())));
         }
      }
      else
      {
View Full Code Here

Examples of org.opennms.protocols.snmp.SnmpPduRequest

   */
  public SnmpPduRequest snmpReceivedGet(SnmpPduPacket pdu, boolean getNext)
  {
    try
    {
      SnmpPduRequest response = null;
      int pduLength = pdu.getLength();
      final boolean trace = log.isTraceEnabled();

      if (trace)
        log.trace("requestId=" + pdu.getRequestId() + ", pduLength="
            + pduLength + ", getNext=" + getNext);

      SnmpVarBind[] vblist = new SnmpVarBind[pduLength];
      int errorStatus = SnmpPduPacket.ErrNoError;
      int errorIndex = 0;

      // Process for each varibind in the request
      for (int i = 0; i < pduLength; i++)
      {
        boolean good = true;
        SnmpVarBind vb = pdu.getVarBindAt(i);
        SnmpObjectId oid = vb.getName();
        if (getNext)
        {
          /*
           * We call getNextOid() to find out what is the next valid OID
           * instance in the supported MIB (sub-)tree. Assign that OID to the
           * VB List and then proceed same as that of get request. If the
           * passed oid is already the last, we flag it.
           */
          ComparableSnmpObjectId coid = new ComparableSnmpObjectId(oid);
          oid = getNextOid(coid, true);
          if (oid == null)
          {
            good = false;
          }
          else
          {
            pdu.setVarBindAt(i, new SnmpVarBind(oid));
          }
        }
        if (oid!=null)
          vblist[i] = new SnmpVarBind(oid);
        else
          vblist[i] = new SnmpVarBind(vb.getName()); // oid passed in
       

        if (trace)
          log.trace("oid=" + oid);

        SnmpSyntax result = null;
        if (good && bindings != null)
          result = getValueFor(oid);

        if (trace)
          log.trace("got result of " + result);

        if (result == null || !good)
        {
          errorStatus = SnmpPduPacket.ErrNoSuchName;
          errorIndex = i + 1;
          log.debug("Error Occured " + vb.getName().toString());
        }
        else
        {
          vblist[i].setValue(result);
          log.debug("Varbind[" + i + "] := "
                  + vblist[i].getName().toString());
          log.debug(" --> " + vblist[i].getValue().toString());
        }
      } // for ...
      response = new SnmpPduRequest(SnmpPduPacket.RESPONSE, vblist);
      response.setErrorStatus(errorStatus);
      response.setErrorIndex(errorIndex);
      return response;
    } catch (Exception e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

Examples of org.opennms.protocols.snmp.SnmpPduRequest

   *         cannot process NOTE: this might be changed to throw an exception.
   */
  public SnmpPduRequest snmpReceivedSet(SnmpPduPacket pdu)
   {
    final boolean trace = log.isTraceEnabled();
    SnmpPduRequest response = null;
    int errorStatus = SnmpPduPacket.ErrNoError;
    int errorIndex = 0;
    int k = pdu.getLength();
    SnmpVarBind[] vblist = new SnmpVarBind[k];

    for (int i = 0; i < k; i++)
      {
      SnmpVarBind vb = pdu.getVarBindAt(i);
      vblist[i] = new SnmpVarBind(vb);
      SnmpObjectId oid = vb.getName();
      SnmpSyntax newVal = vb.getValue();
      if (trace)
        log.trace("set: received oid " + oid.toString() + " with value " + newVal.toString());
      SnmpSyntax result = null;
      try
         {
        result = setValueFor(oid,newVal);
      }
         catch (ReadOnlyException e)
         {
        errorStatus = SnmpPduPacket.ErrReadOnly;
        errorIndex = i + 1;
      }

       if (result != null)
       {
        errorStatus = SnmpPduPacket.ErrReadOnly;
        errorIndex = i + 1;
        log.debug("Error occured " + vb.getName().toString());
       }

       if (trace)
          {
         log.trace("Varbind[" + i + "] := " + vb.getName().toString());
         log.trace(" --> " + vb.getValue().toString());
       }
    }
    response = new SnmpPduRequest(SnmpPduPacket.RESPONSE, vblist);
    response.setErrorStatus(errorStatus);
    response.setErrorIndex(errorIndex);

    return response;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.