jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibGroup.java
author dfuchs
Wed, 28 Nov 2012 15:14:47 +0100
changeset 14677 1607f4cfc506
parent 5506 202f599c92aa
child 22331 f65a493da643
child 21278 ef8a3a2a72f2
permissions -rw-r--r--
8003476: Cleanup warnings in com.sun.jmx.snmp code Reviewed-by: alanb, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.jmx.snmp.agent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
// java imports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Hashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
// jmx imports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import com.sun.jmx.snmp.SnmpVarBind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import com.sun.jmx.snmp.SnmpStatusException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Represents a node in an SNMP MIB which corresponds to a group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * This class allows subnodes to be registered below a group, providing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * support for nested groups. The subnodes are registered at run time
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * when registering the nested groups in the global MIB OID tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * This class is used by the class generated by <CODE>mibgen</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * You should not need to use this class directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <p><b>This API is a Sun Microsystems internal API  and is subject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * to change without notice.</b></p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
public abstract class SnmpMibGroup extends SnmpMibOid
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    implements Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    // We will register the OID arcs leading to subgroups in this hashtable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    // So for each arc in varList, if the arc is also in subgroups, it leads
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    // to a subgroup, if it is not in subgroup, it leads either to a table
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    // or to a variable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    protected Hashtable<Long, Long> subgroups = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * Tells whether the given arc identifies a table in this group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * @param arc An OID arc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @return <CODE>true</CODE> if `arc' leads to a table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public abstract boolean      isTable(long arc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * Tells whether the given arc identifies a variable (scalar object) in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * this group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @param arc An OID arc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @return <CODE>true</CODE> if `arc' leads to a variable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public abstract boolean      isVariable(long arc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * Tells whether the given arc identifies a readable scalar object in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * this group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @param arc An OID arc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @return <CODE>true</CODE> if `arc' leads to a readable variable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    public abstract boolean      isReadable(long arc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * Gets the table identified by the given `arc'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @param arc An OID arc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @return The <CODE>SnmpMibTable</CODE> identified by `arc', or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     *    <CODE>null</CODE> if `arc' does not identify any table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public abstract SnmpMibTable getTable(long arc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Checks whether the given OID arc identifies a variable (scalar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * object).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @exception If the given `arc' does not identify any variable in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *    group, throws an SnmpStatusException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    public void validateVarId(long arc, Object userData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        if (isVariable(arc) == false)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            throw noSuchObjectException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    // -------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    // We use a hashtable (subgroup) in order to determine whether an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    // OID arc leads to a subgroup. This implementation can be changed if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    // needed...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    // For instance, the subclass could provide a generated isNestedArc()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    // method in which the subgroup OID arcs would be hardcoded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    // However, the generic approach was prefered because at this time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    // groups and subgroups are dynamically registered in the MIB.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * Tell whether the given OID arc identifies a sub-tree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * leading to a nested SNMP sub-group. This method is used internally.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * You shouldn't need to call it directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @param arc An OID arc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @return <CODE>true</CODE> if the given OID arc identifies a subtree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * leading to a nested SNMP sub-group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public boolean isNestedArc(long arc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        if (subgroups == null) return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        Object obj = subgroups.get(new Long(arc));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        // if the arc is registered in the hashtable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        // it leads to a subgroup.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        return (obj != null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * Generic handling of the <CODE>get</CODE> operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * <p>The actual implementation of this method will be generated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * by mibgen. Usually, this implementation only delegates the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * job to some other provided runtime class, which knows how to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * access the MBean. The current toolkit thus provides two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * implementations:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * <ul><li>The standard implementation will directly access the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *         MBean through a java reference,</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     *     <li>The generic implementation will access the MBean through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *         the MBean server.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * <p>Both implementations rely upon specific - and distinct, set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * mibgen generated methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * <p> You can override this method if you need to implement some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * specific policies for minimizing the accesses made to some remote
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * underlying resources.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @param req   The sub-request that must be handled by this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @param depth The depth reached in the OID tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @exception SnmpStatusException An error occurred while accessing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *  the MIB node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     */
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 5506
diff changeset
   170
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    abstract public void get(SnmpMibSubRequest req, int depth)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        throws SnmpStatusException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Generic handling of the <CODE>set</CODE> operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * <p>The actual implementation of this method will be generated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * by mibgen. Usually, this implementation only delegates the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * job to some other provided runtime class, which knows how to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * access the MBean. The current toolkit thus provides two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * implementations:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * <ul><li>The standard implementation will directly access the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     *         MBean through a java reference,</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     *     <li>The generic implementation will access the MBean through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *         the MBean server.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * <p>Both implementations rely upon specific - and distinct, set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * mibgen generated methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * <p> You can override this method if you need to implement some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * specific policies for minimizing the accesses made to some remote
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * underlying resources.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @param req   The sub-request that must be handled by this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @param depth The depth reached in the OID tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @exception SnmpStatusException An error occurred while accessing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     *  the MIB node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     */
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 5506
diff changeset
   200
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    abstract public void set(SnmpMibSubRequest req, int depth)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        throws SnmpStatusException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Generic handling of the <CODE>check</CODE> operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * <p>The actual implementation of this method will be generated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * by mibgen. Usually, this implementation only delegates the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * job to some other provided runtime class, which knows how to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * access the MBean. The current toolkit thus provides two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * implementations:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * <ul><li>The standard implementation will directly access the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     *         MBean through a java reference,</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *     <li>The generic implementation will access the MBean through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *         the MBean server.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * <p>Both implementations rely upon specific - and distinct, set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * mibgen generated methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * <p> You can override this method if you need to implement some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * specific policies for minimizing the accesses made to some remote
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * underlying resources, or if you need to implement some consistency
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * checks between the different values provided in the varbind list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * @param req   The sub-request that must be handled by this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @param depth The depth reached in the OID tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @exception SnmpStatusException An error occurred while accessing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     *  the MIB node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     */
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 5506
diff changeset
   232
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    abstract public void check(SnmpMibSubRequest req, int depth)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        throws SnmpStatusException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    // --------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    // If we reach this node, we are below the root OID, so we just
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    // return.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    // --------------------------------------------------------------------
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 5506
diff changeset
   240
    @Override
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 5506
diff changeset
   241
    public void getRootOid(Vector<Integer> result) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    // -------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    // PACKAGE METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    // -------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    // -------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    // This method can also be overriden in a subclass to provide a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    // different implementation of the isNestedArc() method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    // => if isNestedArc() is hardcoded, then registerSubArc() becomes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    //    useless and can become empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * Register an OID arc that identifies a sub-tree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * leading to a nested SNMP sub-group. This method is used internally.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * You shouldn't ever call it directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * @param arc An OID arc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    void registerNestedArc(long arc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        Long obj = new Long(arc);
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 5506
diff changeset
   263
        if (subgroups == null) subgroups = new Hashtable<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        // registers the arc in the hashtable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        subgroups.put(obj,obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    // -------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    // The SnmpMibOid algorithm relies on the fact that for every arc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    // registered in varList, there is a corresponding node at the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    // position in children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    // So the trick is to register a null node in children for each variable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    // in varList, so that the real subgroup nodes can be inserted at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    // correct location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    // registerObject() should be called for each scalar object and each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    // table arc by the generated subclass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * Register an OID arc that identifies a scalar object or a table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * This method is used internally. You shouldn't ever call it directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @param arc An OID arc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    protected void registerObject(long arc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        throws IllegalAccessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        // this will register the variable in both varList and children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        // The node registered in children will be null, so that the parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        // algorithm will behave as if no node were registered. This is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        // trick that makes the parent algorithm behave as if only subgroups
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        // were registered in varList and children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        long[] oid = new long[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        oid[0] = arc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        super.registerNode(oid,0,null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    // -------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    // registerNode() will be called at runtime when nested groups are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    // registered in the MIB. So we do know that this method will only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    // be called to register nested-groups.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    // We trap registerNode() in order to call registerSubArc()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * Register a child node of this node in the OID tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * This method is used internally. You shouldn't ever call it directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @param oid The oid of the node being registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @param cursor The position reached in the oid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * @param node The node being registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     */
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 5506
diff changeset
   311
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    void registerNode(long[] oid, int cursor ,SnmpMibNode node)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        throws IllegalAccessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        super.registerNode(oid,cursor,node);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        if (cursor < 0) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        if (cursor >= oid.length) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        // if we get here, then it means we are registering a subgroup.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        // We will thus register the sub arc in the subgroups hashtable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        registerNestedArc(oid[cursor]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    // -------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    // see comments in SnmpMibNode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    // -------------------------------------------------------------------
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 5506
diff changeset
   325
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    void findHandlingNode(SnmpVarBind varbind,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                          long[] oid, int depth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                          SnmpRequestTree handlers)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        int length = oid.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        if (handlers == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            throw new SnmpStatusException(SnmpStatusException.snmpRspGenErr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        final Object data = handlers.getUserData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        if (depth >= length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            // Nothing is left... the oid is not valid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            throw new SnmpStatusException(SnmpStatusException.noAccess);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        long arc = oid[depth];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        if (isNestedArc(arc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            // This arc leads to a subgroup: delegates the search to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            // method defined in SnmpMibOid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            super.findHandlingNode(varbind,oid,depth,handlers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        } else if (isTable(arc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            // This arc leads to a table: forward the search to the table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            // Gets the table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            SnmpMibTable table = getTable(arc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            // Forward the search to the table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            table.findHandlingNode(varbind,oid,depth+1,handlers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            // If it's not a variable, throws an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            validateVarId(arc, data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            // The trailing .0 is missing in the OID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            if (depth+2 > length)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                throw noSuchInstanceException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            // There are too many arcs left in the OID (there should remain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            // a single trailing .0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
            if (depth+2 < length)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                throw noSuchInstanceException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            // The last trailing arc is not .0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            if (oid[depth+1] != 0L)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                throw noSuchInstanceException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            // It's one of our variable, register this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            handlers.add(this,depth,varbind);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    // -------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    // See comments in SnmpMibNode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    // -------------------------------------------------------------------
14677
1607f4cfc506 8003476: Cleanup warnings in com.sun.jmx.snmp code
dfuchs
parents: 5506
diff changeset
   383
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    long[] findNextHandlingNode(SnmpVarBind varbind,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                                long[] oid, int pos, int depth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                                SnmpRequestTree handlers, AcmChecker checker)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        int length = oid.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        SnmpMibNode node = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        if (handlers == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            // This should be considered as a genErr, but we do not want to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            // abort the whole request, so we're going to throw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            // a noSuchObject...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            throw noSuchObjectException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        final Object data = handlers.getUserData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        final int pduVersion = handlers.getRequestPduVersion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        // The generic case where the end of the OID has been reached is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        // handled in the superclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        // XXX Revisit: this works but it is somewhat convoluted. Just setting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        //              arc to -1 would work too.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        if (pos >= length)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            return super.findNextHandlingNode(varbind,oid,pos,depth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                                              handlers, checker);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        // Ok, we've got the arc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        long arc = oid[pos];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        long[] result = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        // We have a recursive logic. Should we have a loop instead?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            if (isTable(arc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                // If the arc identifies a table, then we need to forward
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                // the search to the table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                // Gets the table identified by `arc'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                SnmpMibTable table = getTable(arc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                // Forward to the table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                checker.add(depth, arc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                    result = table.findNextHandlingNode(varbind,oid,pos+1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                                                        depth+1,handlers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                                                        checker);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                }catch(SnmpStatusException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                    throw noSuchObjectException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                    checker.remove(depth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                // Build up the leaf OID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                result[depth] = arc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            } else if (isReadable(arc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                // If the arc identifies a readable variable, then two cases:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                if (pos == (length - 1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                    // The end of the OID is reached, so we return the leaf
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                    // corresponding to the variable identified by `arc'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                    // Build up the OID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                    // result = new SnmpOid(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                    // result.insert((int)arc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                    result = new long[depth+2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                    result[depth+1] = 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                    result[depth] = arc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                    checker.add(depth, result, depth, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                        checker.checkCurrentOid();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                    } catch(SnmpStatusException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                        throw noSuchObjectException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                    } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                        checker.remove(depth,2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                    // Registers this node
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                    handlers.add(this,depth,varbind);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                    return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                // The end of the OID is not yet reached, so we must return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                // the next leaf following the variable identified by `arc'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                // We cannot return the variable because whatever follows in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                // the OID will be greater or equals to 0, and 0 identifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                // the variable itself - so we have indeed to return the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                // next object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                // So we do nothing, because this case is handled at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                // end of the if ... else if ... else ... block.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            } else if (isNestedArc(arc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                // Now if the arc leads to a subgroup, we delegate the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                // search to the child, just as done in SnmpMibNode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                // get the child ( = nested arc node).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                final SnmpMibNode child = getChild(arc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                if (child != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                    checker.add(depth, arc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                        result = child.findNextHandlingNode(varbind,oid,pos+1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                                                            depth+1,handlers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                                                            checker);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                        result[depth] = arc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                    } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                        checker.remove(depth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            // The oid is not valid, we will throw an exception in order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
            // to try with the next valid identifier...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            throw noSuchObjectException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        } catch (SnmpStatusException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            // We didn't find anything at the given arc, so we're going
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
            // to try with the next valid arc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
            long[] newOid = new long[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            newOid[0] = getNextVarId(arc,data,pduVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            return findNextHandlingNode(varbind,newOid,0,depth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                                        handlers,checker);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
}