Examples of OctetString


Examples of org.snmp4j.smi.OctetString

      ScopedPDU scopedPDU = (ScopedPDU)request;
      if (contextEngine != null) {
        scopedPDU.setContextEngineID(OctetString.fromHexStringPairs(contextEngine));
      }
      if (contextName != null) {
        scopedPDU.setContextName(new OctetString(contextName));
      }
    }
    else {
      request = new PDU();
    }
View Full Code Here

Examples of org.snmp4j.smi.OctetString

   * @param o2 the second object to be compared.
   * @return a negative integer, zero, or a positive integer as the first
   *   argument is less than, equal to, or greater than the second.
   */
  public int compare(Object o1, Object o2) {
    OctetString os1 = (OctetString) o1;
    OctetString os2 = (OctetString) o2;

    int result = 0;
    if (!impliedLength) {
      result = os1.length() - os2.length();
    }
    if (result == 0) {
      result = os1.compareTo(os2);
    }
    return result;
View Full Code Here

Examples of org.snmp4j.smi.OctetString

    private Snmp _snmp;
    private CommunityTarget _target;

    public SnmpHelper(String address, String community) {
        _target = new CommunityTarget();
        _target.setCommunity(new OctetString(community));
        _target.setVersion(SnmpConstants.version2c);
        _target.setAddress(new UdpAddress(address));
        try {
            _snmp = new Snmp(new DefaultUdpTransportMapping());
        } catch (IOException e) {
View Full Code Here

Examples of org.snmp4j.smi.OctetString

                trap.add(new VariableBinding(getOID(CsSnmpConstants.CLUSTER_ID), new UnsignedInteger32(snmpTrapInfo
                    .getClusterId())));
            }

            if (snmpTrapInfo.getMessage() != null) {
                trap.add(new VariableBinding(getOID(CsSnmpConstants.MESSAGE), new OctetString(snmpTrapInfo.getMessage
                    ())));
            } else {
                throw new CloudRuntimeException(" What is the use of alert without message ");
            }

            if (snmpTrapInfo.getGenerationTime() != null) {
                trap.add(new VariableBinding(getOID(CsSnmpConstants.GENERATION_TIME),
                    new OctetString(snmpTrapInfo.getGenerationTime().toString())));
            } else {
                trap.add(new VariableBinding(getOID(CsSnmpConstants.GENERATION_TIME)));
            }
        } else {
            throw new CloudRuntimeException(" Invalid alert Type ");
View Full Code Here

Examples of org.snmp4j.smi.OctetString

        // Could save some CPU cycles:
        // transport.setAsyncMsgProcessingSupported(false);
        Snmp snmp = new Snmp(transport);

        if (version == SnmpConstants.version3) {
            USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0);
            SecurityModels.getInstance().addSecurityModel(usm);
            addUsmUser(snmp);
        }

        return snmp;
View Full Code Here

Examples of org.snmp4j.smi.OctetString

                variable = new UnsignedInteger32(Long.parseLong(value));
                break;
            }

            case 's': {
                variable = new OctetString(value);
                break;
            }

            case 'x': {
                variable = OctetString.fromString(value, ':', 16);
View Full Code Here

Examples of org.snmp4j.smi.OctetString

        vbs.add(vb);
    }

    private static OctetString createOctetString(String s) {
        OctetString octetString;
        if (s.startsWith("0x")) {
            octetString = OctetString.fromHexString(s.substring(2), ':');
        } else {
            octetString = new OctetString(s);
        }

        return octetString;
    }
View Full Code Here

Examples of org.snmp4j.smi.OctetString

            assertVariableBindingIsPrefixed(variableBinding, oidPrefix);
            assertVariableBindingHasStringValue(variableBinding);

            switch (variableBindingsIterator.previousIndex()) {
            case 2:
                assertEquals(variableBinding.getVariable(), new OctetString(expectedValues.getAlertDefinitionName()));
                break;
            case 3:
                assertEquals(variableBinding.getVariable(), new OctetString(expectedValues.getResourceName()));
                break;
            case 4:
                assertEquals(variableBinding.getVariable(), new OctetString(expectedValues.getPlatformName()));
                break;
            case 5:
                assertEquals(variableBinding.getVariable(), new OctetString(expectedValues.getAlertConditions()));
                break;
            case 6:
                assertEquals(variableBinding.getVariable(), new OctetString(expectedValues.getAlertPriority()
                    .toString().toLowerCase()));
                break;
            case 7:
                assertEquals(variableBinding.getVariable(), new OctetString(expectedValues.getAlertUrl()));
                break;
            case 8:
                assertEquals(variableBinding.getVariable(), new OctetString(expectedValues.getPlatformName() + "::"
                    + expectedValues.getResourceName() + "::"));
                break;
            default:
                throw new RuntimeException("Unexpected index: " + variableBindingsIterator.previousIndex());
            }
View Full Code Here

Examples of org.snmp4j.smi.OctetString

        }
    }

    private void add(PDU pdu, OID oid, Object message) {
        String s = String.valueOf(message);
        pdu.add(new VariableBinding(oid, new OctetString(s)));
    }
View Full Code Here

Examples of org.snmp4j.smi.OctetString

        }

        Address address = GenericAddress.parse("udp:" + host + "/" + port);
        this.target = new CommunityTarget();
        this.target.setAddress(address);
        this.target.setCommunity(new OctetString(community));
        this.target.setVersion(this.version);
        this.target.setRetries(retries);
        this.target.setTimeout(timeout);
    }
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.