Package org.snmp4j.smi

Examples of org.snmp4j.smi.Integer32


      target.setAddress(targetAddress);
      target.setRetries(0);
      target.setTimeout(200);
      target.setVersion(SnmpConstants.version2c);
      PDU pdu = new PDU();
      pdu.add(new VariableBinding(new OID(oid), new Integer32(value)));
      pdu.setType(PDU.SET);
      ResponseListener listener = new ResponseListener() {
        public void onResponse(ResponseEvent event) {
        // Always cancel async request when response has been received
        // otherwise a memory leak is created! Not canceling a request
View Full Code Here


      requestPdu.addAllOIDs(bindings);
    } else {
      requestPdu.addAll(bindings);
    }

    requestPdu.setRequestID(new Integer32(Math.abs(this.random.nextInt())));
    return requestPdu;
  }
View Full Code Here

  @Test
  public void testTrap() throws IOException {
    this.v1Client.trap(this.address, new OID(new int[] { 1, 3, 6, 1, 6, 3,
        1, 1, 5 }), PDUv1.WARMSTART, 0, new VariableBinding(new OID(
        new int[] { 1, 3, 6, 1, 6, 3, 1, 1, 5, 3 }), new Integer32(7)));
  }
View Full Code Here

                                                                         // name
                new OctetString("cpublic"), // security name
                getAgent().getContextEngineID(), // local engine ID
                new OctetString("public"), // default context name
                new OctetString(), // transport tag
                new Integer32(StorageType.nonVolatile), // storage type
                new Integer32(RowStatus.active) // row status
        };
        MOTableRow row = communityMIB.getSnmpCommunityEntry().createRow(
                new OctetString("public2public").toSubIndex(true), com2sec);
        communityMIB.getSnmpCommunityEntry().addRow(row);
    }
View Full Code Here

            scalars.put(key, mo);
            registerManagedObject(mo, oid.toString());
        }
        MOScalar mo = scalars.get(key);
        if (mo != null) {
            mo.setValue(new Integer32(value));
        }
    }
View Full Code Here

   * @param model
   *    a <code>SecurityModel</code>. If a security model with the same ID
   *    already
   */
  public void addSecurityModel(SecurityModel model) {
    securityModels.put(new Integer32(model.getID()), model);
  }
View Full Code Here

    }

    length += BER.getBERLengthOfLength(length) + 1;

    // req id, error status, error index
    Integer32 i32 = new Integer32(requestID.getValue());
    length += i32.getBERLength();
    i32 = errorStatus;
    length += i32.getBERLength();
    i32 = errorIndex;
    length += i32.getBERLength();
    i32 = null;
    return length;
  }
View Full Code Here

   * Removes all variable bindings from the PDU and sets the request ID to zero.
   * This can be used to reuse a PDU for another request.
   */
  public void clear() {
    variableBindings.clear();
    setRequestID(new Integer32(0));
  }
View Full Code Here

      logger.error("MPv2c used with unsupported SNMP version");
      return SnmpConstants.SNMP_MP_UNSUPPORTED_SECURITY_MODEL;
    }

    OctetString community = new OctetString(securityName);
    Integer32 version = new Integer32(messageProcessingModel);
    // compute total length
    int length = pdu.getBERLength();
    length += community.getBERLength();
    length += version.getBERLength();

    ByteBuffer buf = ByteBuffer.allocate(length +
                                         BER.getBERLengthOfLength(length) + 1);
    // set the buffer of the outgoing message
    outgoingMessage.setBuffer(buf);

    // encode the message
    BER.encodeHeader(outgoingMessage, BER.SEQUENCE, length);
    version.encodeBER(outgoingMessage);

    community.encodeBER(outgoingMessage);
    pdu.encodeBER(outgoingMessage);

    return SnmpConstants.SNMP_MP_OK;
View Full Code Here

    if (mutableByte.getValue() != BER.SEQUENCE) {
      String txt = "SNMPv2c PDU must start with a SEQUENCE";
      logger.error(txt);
      throw new IOException(txt);
    }
    Integer32 version = new Integer32();
    version.decodeBER(wholeMsg);

    securityName.decodeBER(wholeMsg);
    securityLevel.setValue(SecurityLevel.NOAUTH_NOPRIV);
    securityModel.setValue(SecurityModel.SECURITY_MODEL_SNMPv2c);
    messageProcessingModel.setValue(ID);
View Full Code Here

TOP

Related Classes of org.snmp4j.smi.Integer32

Copyright © 2018 www.massapicom. 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.