001: /*
002: * Copyright 1998-2007 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:
026: package com.sun.jmx.snmp;
027:
028: /**
029: * Is used to represent <CODE>get</CODE>, <CODE>get-next</CODE>, <CODE>set</CODE>, <CODE>response</CODE> and <CODE>SNMPv2-trap</CODE> PDUs.
030: * <P>
031: * You will not usually need to use this class, except if you
032: * decide to implement your own
033: * {@link com.sun.jmx.snmp.SnmpPduFactory SnmpPduFactory} object.
034: *
035: * <p><b>This API is a Sun Microsystems internal API and is subject
036: * to change without notice.</b></p>
037: */
038:
039: public class SnmpPduRequest extends SnmpPduPacket implements
040: SnmpPduRequestType {
041: private static final long serialVersionUID = 2218754017025258979L;
042:
043: /**
044: * Error status. Statuses are defined in
045: * {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
046: * @serial
047: */
048: public int errorStatus = 0;
049:
050: /**
051: * Error index. Remember that SNMP indices start from 1.
052: * Thus the corresponding <CODE>SnmpVarBind</CODE> is
053: * <CODE>varBindList[errorIndex-1]</CODE>.
054: * @serial
055: */
056: public int errorIndex = 0;
057:
058: /**
059: * Implements <CODE>SnmpPduRequestType</CODE> interface.
060: *
061: * @since 1.5
062: */
063: public void setErrorIndex(int i) {
064: errorIndex = i;
065: }
066:
067: /**
068: * Implements <CODE>SnmpPduRequestType</CODE> interface.
069: *
070: * @since 1.5
071: */
072: public void setErrorStatus(int i) {
073: errorStatus = i;
074: }
075:
076: /**
077: * Implements <CODE>SnmpPduRequestType</CODE> interface.
078: *
079: * @since 1.5
080: */
081: public int getErrorIndex() {
082: return errorIndex;
083: }
084:
085: /**
086: * Implements <CODE>SnmpPduRequestType</CODE> interface.
087: *
088: * @since 1.5
089: */
090: public int getErrorStatus() {
091: return errorStatus;
092: }
093:
094: /**
095: * Implements <CODE>SnmpAckPdu</CODE> interface.
096: *
097: * @since 1.5
098: */
099: public SnmpPdu getResponsePdu() {
100: SnmpPduRequest result = new SnmpPduRequest();
101: result.address = address;
102: result.port = port;
103: result.version = version;
104: result.community = community;
105: result.type = SnmpDefinitions.pduGetResponsePdu;
106: result.requestId = requestId;
107: result.errorStatus = SnmpDefinitions.snmpRspNoError;
108: result.errorIndex = 0;
109:
110: return result;
111: }
112: }
|