001: /*
002: * Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025: package com.sun.jmx.snmp;
026:
027: /**
028: * Is used to represent <CODE>get</CODE>, <CODE>get-next</CODE>, <CODE>set</CODE>, <CODE>response</CODE> SNMP V3 scoped PDUs.
029: *
030: * <p><b>This API is a Sun Microsystems internal API and is subject
031: * to change without notice.</b></p>
032: * @since 1.5
033: */
034: public class SnmpScopedPduRequest extends SnmpScopedPduPacket implements
035: SnmpPduRequestType {
036: private static final long serialVersionUID = 6463060973056773680L;
037:
038: int errorStatus = 0;
039:
040: int errorIndex = 0;
041:
042: /**
043: * Error index setter. Remember that SNMP indices start from 1.
044: * Thus the corresponding <CODE>SnmpVarBind</CODE> is
045: * <CODE>varBindList[errorIndex-1]</CODE>.
046: * @param i Error index.
047: */
048: public void setErrorIndex(int i) {
049: errorIndex = i;
050: }
051:
052: /**
053: * Error status setter. Statuses are defined in
054: * {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
055: * @param s Error status.
056: */
057: public void setErrorStatus(int s) {
058: errorStatus = s;
059: }
060:
061: /**
062: * Error index getter. Remember that SNMP indices start from 1.
063: * Thus the corresponding <CODE>SnmpVarBind</CODE> is
064: * <CODE>varBindList[errorIndex-1]</CODE>.
065: * @return Error index.
066: */
067: public int getErrorIndex() {
068: return errorIndex;
069: }
070:
071: /**
072: * Error status getter. Statuses are defined in
073: * {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
074: * @return Error status.
075: */
076: public int getErrorStatus() {
077: return errorStatus;
078: }
079:
080: /**
081: * Generates the pdu to use for response.
082: * @return Response pdu.
083: */
084: public SnmpPdu getResponsePdu() {
085: SnmpScopedPduRequest result = new SnmpScopedPduRequest();
086: result.address = address;
087: result.port = port;
088: result.version = version;
089: result.requestId = requestId;
090: result.msgId = msgId;
091: result.msgMaxSize = msgMaxSize;
092: result.msgFlags = msgFlags;
093: result.msgSecurityModel = msgSecurityModel;
094: result.contextEngineId = contextEngineId;
095: result.contextName = contextName;
096: result.securityParameters = securityParameters;
097: result.type = pduGetResponsePdu;
098: result.errorStatus = SnmpDefinitions.snmpRspNoError;
099: result.errorIndex = 0;
100: return result;
101: }
102: }
|