Package net.percederberg.mibble.snmp

Examples of net.percederberg.mibble.snmp.SnmpObjectType


     * @throws ParseException if the node analysis discovered errors
     */
    protected Node exitSnmpObjectTypeMacroType(Production node)
        throws ParseException {

        SnmpObjectType  type;
        MibType         syntax = null;
        String          units = null;
        SnmpAccess      access = null;
        SnmpStatus      status = null;
        String          desc = null;
        String          ref = null;
        Object          index = null;
        MibValue        defVal = null;
        Node            child;

        for (int i = 0; i < node.getChildCount(); i++) {
            child = node.getChildAt(i);
            switch (child.getId()) {
            case Asn1Constants.SNMP_SYNTAX_PART:
                syntax = (MibType) getValue(child, 0);
                if (syntax instanceof MibContext) {
                    popContext();
                }
                syntax.setComment(MibAnalyzerUtil.getComments(child));
                break;
            case Asn1Constants.SNMP_UNITS_PART:
                units = getStringValue(child, 0);
                break;
            case Asn1Constants.SNMP_ACCESS_PART:
                access = (SnmpAccess) getValue(child, 0);
                break;
            case Asn1Constants.SNMP_STATUS_PART:
                status = (SnmpStatus) getValue(child, 0);
                break;
            case Asn1Constants.SNMP_DESCR_PART:
                desc = getStringValue(child, 0);
                break;
            case Asn1Constants.SNMP_REFER_PART:
                ref = getStringValue(child, 0);
                break;
            case Asn1Constants.SNMP_INDEX_PART:
                index = getValue(child, 0);
                break;
            case Asn1Constants.SNMP_DEF_VAL_PART:
                defVal = (MibValue) getValue(child, 0);
                break;
            }
        }
        if (index instanceof ArrayList) {
            type = new SnmpObjectType(syntax,
                                      units,
                                      access,
                                      status,
                                      desc,
                                      ref,
                                      (ArrayList) index,
                                      defVal);
        } else {
            type = new SnmpObjectType(syntax,
                                      units,
                                      access,
                                      status,
                                      desc,
                                      ref,
View Full Code Here


     * buttons. This method should be called when a new MIB node is
     * selected or when the UI has been blocked or unblocked.
     */
    public void updateStatus() {
        MibNode         node = frame.getSelectedNode();
        SnmpObjectType  type = null;
        boolean         allowOperation;
        boolean         allowGet;
        boolean         allowSet;

        if (node != null) {
            type = node.getSnmpObjectType();
        }
        allowOperation = !blocked
                      && hostField.getText().length() > 0
                      && portField.getText().length() > 0;
        allowGet = allowOperation
                && oidField.getText().length() > 0;
        allowSet = allowOperation
                && type != null
                && type.getAccess().canWrite();
        oidLabel.setEnabled(allowOperation);
        oidField.setEnabled(allowOperation);
        valueLabel.setEnabled(allowSet);
        valueField.setEnabled(allowSet);
        getButton.setEnabled(allowGet);
View Full Code Here

        SnmpAuthentication  auth = null;
        SnmpPrivacy         privacy = null;
        String              oid = oidField.getText();
        SnmpManager         manager;
        SnmpRequest         request;
        SnmpObjectType      objectType;
        String              value;
        String              message;

        // Validate port number
        try {
            port = Integer.parseInt(portField.getText());
        } catch (NumberFormatException ignore) {
            port = 0;
        }
        if (port <= 0 || port >= 65536) {
            portField.requestFocus();
            message = "Provide valid (numeric) port number in the " +
                      "range [1..65535].";
            JOptionPane.showMessageDialog(frame,
                                          message,
                                          "Port Number Error",
                                          JOptionPane.ERROR_MESSAGE);
            return null;
        }

        // Get SNMP manager parameters
        if (version < 3) {
            if (read) {
                community = new String(readCommunityField.getPassword());
            } else {
                community = new String(writeCommunityField.getPassword());
            }
        } else {
            contextName = contextNameField.getText();
            contextEngine = contextEngineField.getText();
            userName = userNameField.getText();
            if (authTypeCombo.getSelectedIndex() > 0) {
                type = authTypeCombo.getSelectedItem().toString();
                password = new String(authPasswordField.getPassword());
                auth = new SnmpAuthentication(type, password);
            }
            if (privacyTypeCombo.getSelectedIndex() > 0) {
                type = privacyTypeCombo.getSelectedItem().toString();
                password = new String(privacyPasswordField.getPassword());
                privacy = new SnmpPrivacy(type, password);
            }
        }

        // Create SNMP manager
        try {
            if (version == 1) {
                manager = SnmpManager.createSNMPv1(host, port, community);
            } else if (version == 2) {
                manager = SnmpManager.createSNMPv2c(host, port, community);
            } else {
                manager = SnmpManager.createSNMPv3(host,
                                                   port,
                                                   contextName,
                                                   contextEngine,
                                                   userName,
                                                   auth,
                                                   privacy);
            }
        } catch (SnmpException e) {
            JOptionPane.showMessageDialog(frame,
                                          e.getMessage(),
                                          "SNMP Error",
                                          JOptionPane.ERROR_MESSAGE);
            return null;
        }

        // Create request
        if (read) {
            request = new SnmpRequest(oid);
        } else {
            objectType = frame.getSelectedNode().getSnmpObjectType();
            value = valueField.getText();
            request = new SnmpRequest(oid, objectType.getSyntax(), value);
        }

        return new Operation(manager, request, feedback);
    }
View Full Code Here

TOP

Related Classes of net.percederberg.mibble.snmp.SnmpObjectType

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.