Examples of OctetString


Examples of org.snmp4j.smi.OctetString

        Entry entry = (Entry) it.next();
        MOScope scope = (MOScope) entry.getKey();
        ManagedObject value = (ManagedObject) entry.getValue();
        if ((value instanceof SerializableManagedObject) &&
            (!((SerializableManagedObject) value).isVolatile())) {
          OctetString context = null;
          if (scope instanceof MOContextScope) {
            context = ((MOContextScope) scope).getContext();
          }
          LinkedHashMap objects = (LinkedHashMap) serializableMO.get(context);
          if (objects == null) {
View Full Code Here

Examples of org.snmp4j.smi.OctetString

    else {
      MOScope s1 = (MOScope) o1;
      MOScope s2 = (MOScope) o2;
      if ((s1 instanceof MOContextScope) &&
          (s2 instanceof MOContextScope)) {
        OctetString c1 = ((MOContextScope) s1).getContext();
        OctetString c2 = ((MOContextScope) s2).getContext();
        if ((c1 != null) && (c2 != null)) {
          result = c1.compareTo(c2);
        }
      }
      if (result == 0) {
View Full Code Here

Examples of org.snmp4j.smi.OctetString

  }

  private static int compareScopeAndQuery(MOScope scope, MOQuery query) {
    int result = 0;
    if (scope instanceof MOContextScope) {
      OctetString c1 = ((MOContextScope)scope).getContext();
      OctetString c2 = query.getScope().getContext();
      if ((c1 != null) && (c2 != null)) {
        result = c1.compareTo(c2);
      }
    }
    if (result != 0) {
View Full Code Here

Examples of org.snmp4j.smi.OctetString

   *    if it is.
   */
  public static int validateDisplayString(Variable displayString,
                                          ValueConstraint sizeContraints) {
    if (displayString instanceof OctetString) {
      OctetString os = (OctetString)displayString;
      int status = sizeContraints.validate(displayString);
      if (status != PDU.noError) {
        return status;
      }
      for (int i=0; i<os.length(); i++) {
        if (os.get(i) < 0) {
          return SnmpConstants.SNMP_ERROR_WRONG_VALUE;
        }
        if (os.get(i) == '\r') {
          if (i+1 == os.length()) {
            return SnmpConstants.SNMP_ERROR_WRONG_VALUE;
          }
          else if ((os.get(i+1) != 0) && (os.get(i+1) != '\n')) {
            return SnmpConstants.SNMP_ERROR_WRONG_VALUE;
          }
        }
      }
      return SnmpConstants.SNMP_ERROR_SUCCESS;
View Full Code Here

Examples of org.snmp4j.smi.OctetString

  public static int isValidTagValue(Variable newValue) {
    if (!(newValue instanceof OctetString)) {
      return SnmpConstants.SNMP_ERROR_WRONG_TYPE;
    }
    int status = SnmpConstants.SNMP_ERROR_SUCCESS;
    OctetString os = (OctetString)newValue;
    if (os.length() > 255) {
      status = SnmpConstants.SNMP_ERROR_WRONG_LENGTH;
    }
    else {
      for (int i = 0; i < os.length(); i++) {
        if (isDelimiter(os.get(i))) {
          status = SnmpConstants.SNMP_ERROR_BAD_VALUE;
          break;
        }
      }
    }
View Full Code Here

Examples of org.snmp4j.smi.OctetString

  public OctetString getAddress(Address address) {
    if (address instanceof TransportIpAddress) {
      TransportIpAddress tipaddr = (TransportIpAddress) address;
      byte[] addrBytes = tipaddr.getInetAddress().getAddress();
      OctetString addr = new OctetString(addrBytes);
      addr.append((byte) (tipaddr.getPort() >> 8));
      addr.append((byte) (tipaddr.getPort() & 0xFF));
      return addr;
    }
    return null;
  }
View Full Code Here

Examples of org.snmp4j.smi.OctetString

  public static int isValidTagList(Variable newValue) {
    if (!(newValue instanceof OctetString)) {
      return SnmpConstants.SNMP_ERROR_WRONG_TYPE;
    }
    OctetString os = (OctetString)newValue;
    if (os.length() > 255) {
      return SnmpConstants.SNMP_ERROR_WRONG_LENGTH;
    }
    else if (os.length() > 0) {
      if (SnmpTagValue.isDelimiter(os.get(0)) ||
          SnmpTagValue.isDelimiter(os.get(os.length()-1))) {
        return SnmpConstants.SNMP_ERROR_BAD_VALUE;
      }
      boolean lastWasDelimiter = false;
      for (int i = 0; i < os.length()-1; i++) {
        boolean isDelimiter = SnmpTagValue.isDelimiter(os.get(i));
        if (lastWasDelimiter && isDelimiter) {
          return SnmpConstants.SNMP_ERROR_BAD_VALUE;
        }
        lastWasDelimiter = isDelimiter;
      }
View Full Code Here

Examples of org.snmp4j.smi.OctetString

   *    {@link SnmpConstants#SNMP_ERROR_SUCCESS} if <code>dateAndTime</code>
   *    is valid or an appropriate SNMP error code if not.
   */
  public static int validateDateAndTime(Variable dateAndTime) {
    if (dateAndTime instanceof OctetString) {
      OctetString os = (OctetString)dateAndTime;
      if ((os.length() != 8) && (os.length() != 11)) {
        return SnmpConstants.SNMP_ERROR_WRONG_LENGTH;
      }
      int month = (os.get(2) & 0xFF );
      int date = (os.get(3) & 0xFF );
      int hour = (os.get(4) & 0xFF );
      int minute = (os.get(5) & 0xFF );
      int second = (os.get(6) & 0xFF );
      int deci = (os.get(7) & 0xFF );
      if ((month < 1) || (month > 12) ||
          (date < 1) || (date > 31) || (hour > 23) || (second > 59) ||
          (minute > 59) || (deci > 9)) {
        return SnmpConstants.SNMP_ERROR_WRONG_VALUE;
      }
      if (os.length() == 11) {
        if ((os.get(8) != '+') && (os.get(8) != '-')) {
          return SnmpConstants.SNMP_ERROR_WRONG_VALUE;
        }
      }
      return SnmpConstants.SNMP_ERROR_SUCCESS;
    }
View Full Code Here

Examples of org.snmp4j.smi.OctetString

   *    a <code>GregorianCalendar</code> instance.
   * @return
   *    the corresponding DateAndTime <code>OctetString</code>.
   */
  public static OctetString makeDateAndTime(GregorianCalendar dateAndTime) {
    OctetString os = new OctetString();
    os.append((byte)(dateAndTime.get(Calendar.YEAR)/256));
    os.append((byte)(dateAndTime.get(Calendar.YEAR)%256));
    os.append((byte)(dateAndTime.get(Calendar.MONTH)+1));
    os.append((byte)(dateAndTime.get(Calendar.DAY_OF_MONTH)));
    os.append((byte)(dateAndTime.get(Calendar.HOUR_OF_DAY)));
    os.append((byte)(dateAndTime.get(Calendar.MINUTE)));
    os.append((byte)(dateAndTime.get(Calendar.SECOND)));
    os.append((byte)(dateAndTime.get(Calendar.MILLISECOND)/100));
    if (dateAndTime.getTimeZone() != null) {
      TimeZone tz = dateAndTime.getTimeZone();
      os.append((tz.getRawOffset()>=0) ? "+":"-");
      os.append((byte)(tz.getOffset(dateAndTime.getTimeInMillis())/3600000));
      os.append((byte)(tz.getOffset((dateAndTime.getTimeInMillis())%3600000)/60000));
    }
    return os;
  }
View Full Code Here

Examples of org.snmp4j.smi.OctetString

        } else {
            throw new IllegalArgumentException("Unknown protocol: " + endpoint.getProtocol());
        }

        this.snmp = new Snmp(this.transport);
        this.usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0);
        SecurityModels.getInstance().addSecurityModel(usm);

        // setting up target
        target = new CommunityTarget();
        target.setCommunity(new OctetString(this.endpoint.getSnmpCommunity()));
        target.setAddress(targetAddress);
        target.setRetries(this.endpoint.getRetries());
        target.setTimeout(this.endpoint.getTimeout());
        target.setVersion(this.endpoint.getSnmpVersion());
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.