1 /*
2  * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 package com.sun.jmx.snmp;
26 /**
27  * Is used to represent <CODE>get</CODE>, <CODE>get-next</CODE>, <CODE>set</CODE>, <CODE>response</CODE> SNMP V3 scoped PDUs.
28  *
29  * <p><b>This API is a Sun Microsystems internal API  and is subject
30  * to change without notice.</b></p>
31  * @since 1.5
32  */
33 public class SnmpScopedPduRequest extends SnmpScopedPduPacket
34     implements SnmpPduRequestType {
35     private static final long serialVersionUID = 6463060973056773680L;
36 
37     int errorStatus=0 ;
38 
39     int errorIndex=0 ;
40 
41     /**
42      * Error index setter. Remember that SNMP indices start from 1.
43      * Thus the corresponding <CODE>SnmpVarBind</CODE> is
44      * <CODE>varBindList[errorIndex-1]</CODE>.
45      * @param i Error index.
46      */
setErrorIndex(int i)47     public void setErrorIndex(int i) {
48         errorIndex = i;
49     }
50     /**
51      * Error status setter. Statuses are defined in
52      * {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
53      * @param s Error status.
54      */
setErrorStatus(int s)55     public void setErrorStatus(int s) {
56         errorStatus = s;
57     }
58 
59     /**
60      * Error index getter. Remember that SNMP indices start from 1.
61      * Thus the corresponding <CODE>SnmpVarBind</CODE> is
62      * <CODE>varBindList[errorIndex-1]</CODE>.
63      * @return Error index.
64      */
getErrorIndex()65     public int getErrorIndex() { return errorIndex; }
66     /**
67      * Error status getter. Statuses are defined in
68      * {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
69      * @return Error status.
70      */
getErrorStatus()71     public int getErrorStatus() { return errorStatus; }
72 
73     /**
74      * Generates the pdu to use for response.
75      * @return Response pdu.
76      */
getResponsePdu()77     public SnmpPdu getResponsePdu() {
78         SnmpScopedPduRequest result = new SnmpScopedPduRequest();
79         result.address = address ;
80         result.port = port ;
81         result.version = version ;
82         result.requestId = requestId;
83         result.msgId = msgId;
84         result.msgMaxSize = msgMaxSize;
85         result.msgFlags = msgFlags;
86         result.msgSecurityModel = msgSecurityModel;
87         result.contextEngineId = contextEngineId;
88         result.contextName = contextName;
89         result.securityParameters = securityParameters;
90         result.type = pduGetResponsePdu ;
91         result.errorStatus = SnmpDefinitions.snmpRspNoError ;
92         result.errorIndex = 0 ;
93         return result;
94     }
95 }
96