KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > snmp > SNMPRequestListener


1 /*
2  * SNMP Package
3  *
4  * Copyright (C) 2004, Jonathan Sevy <jsevy@mcs.drexel.edu>
5  *
6  * This is free software. Redistribution and use in source and binary forms, with
7  * or without modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  * derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
19  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
21  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
23  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  */

29
30
31 package snmp;
32
33
34 /**
35 * SNMPRequestListener is an interface that must be implemented by any class which wishes
36 * to act as a handler for request messages sent from remote SNMP management entities.
37 * The SNMPv1AgentInterface class listens for request messages, and passes any it receives on to
38 * SNMPRequestListener subclasses that have registered with it through its addRequestListener() method.
39 */

40
41 public interface SNMPRequestListener
42 {
43     
44     /**
45     * Handles Get- or Set- request messages. The supplied request PDU may contain multiple OIDs; this
46     * method should process those OIDs it understands, and return an SNMPVarBindList containing those OIDs
47     * which it has handled and their corresponding values. The order of returned OID-value pairs is not
48     * important, as the SNMPv1AgentInterface will order the information appropriately. Each implementer of
49     * SNMPRequestListener will likely handle only a subset of the list of supplied OIDs; those OIDs which
50     * are not relevant to a particular listener should be ignored, to be handled by another SNMPRequestListener.
51     * If any OIDs remain unhandled after all listeners' processRequest() methods have been called, the
52     * SNMPv1AgentInterface will return an appropriate error indication to the management entity.
53     *
54     * @throws SNMPGetException, SNMPSetException
55     * If a listener receives a request for an OID which it is intended to handle, but there is a problem with
56     * the request - e.g., a set-request for a value which is read-only, or an incorrect value type for a set - the
57     * listener should throw an SNMPGetException or SNMPSetException to indicate the error. The exception should
58     * include both the index of the OID in the list of supplied OIDs, as well as an error status code (status values
59     * are provided as constants in the SNMPRequestException class definition). The SNMPRequestException class and
60     * subclasses provide constructors allowing the specification of the error index and status code. Note that the
61     * error index follows the SNMP convention of starting at 1, not 0: thus if there is a problem with the first OID,
62     * the error index should be 1. The SNMPAgentInterface will use the information in the exception to communicate
63     * the error to the requesting management entity. The community name should also be used to determine if a request
64     * is valid for the supplied community name.
65     *
66     */

67     
68     public SNMPSequence processRequest(SNMPPDU requestPDU, String JavaDoc communityName)
69         throws SNMPGetException, SNMPSetException;
70         
71     
72     
73     /**
74     * Handles Get-Next- request messages. The supplied request PDU may contain multiple OIDs; this
75     * method should process those OIDs it understands, and return an SNMPVarBindList containing special
76     * variable pairs indicating those supplied OIDs which it has handled, i.e., it must indicate a
77     * supplied OID, the "next" OID, and the value of this next OID. To do this, the return value is a
78     * sequence of SNMPVariablePairs, in which the first component - the OID - is one of the supplied OIDs,
79     * and the second component - the value - is itself an SNMPVariablePair containing the "next" OID and
80     * its value:
81     *
82     * return value = sequence of SNMPVariablePair(original OID, SNMPVariablePair(following OID, value))
83     *
84     * In this way the SNMPv1AgentInterface which calls this method will be able to determine which of the
85     * supplied OIDs each "next" OID corresponds to.
86     *
87     * The order of returned "double" OID-(OID-value) pairs is not important, as the SNMPv1AgentInterface
88     * will order the information appropriately in the response. Each implementer of
89     * SNMPRequestListener will likely handle only a subset of the list of supplied OIDs; those OIDs which
90     * are not relevant to a particular listener should be ignored, to be handled by another SNMPRequestListener.
91     * If any OIDs remain unhandled after all listeners' processRequest() methods have been called, the
92     * SNMPv1AgentInterface will return an appropriate error indication to the management entity.
93     *
94     * @throws SNMPGetException
95     * If a listener receives a request for an OID which it is intended to handle, but there is a problem with
96     * the request - e.g., a get-next request for a value which is not readable for the supplied community name -
97     * the listener should throw an SNMPGetException to indicate the error. The exception should
98     * include both the index of the OID in the list of supplied OIDs, as well as an error status code (status values
99     * are provided as constants in the SNMPRequestException class definition). The SNMPRequestException class and
100     * subclasses provide constructors allowing the specification of the error index and status code. Note that the
101     * error index follows the SNMP convention of starting at 1, not 0: thus if there is a problem with the first OID,
102     * the error index should be 1. The SNMPAgentInterface will use the information in the exception to communicate
103     * the error to the requesting management entity. The community name should also be used to determine if a request
104     * is valid for the supplied community name.
105     *
106     */

107     
108     public SNMPSequence processGetNextRequest(SNMPPDU requestPDU, String JavaDoc communityName)
109         throws SNMPGetException;
110     
111 }
Popular Tags