1 /*
   2  * Copyright (c) 1998, 2007, 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 
  26 
  27 package com.sun.jmx.snmp;
  28 
  29 
  30 
  31 
  32 /**
  33  * Is used to represent <CODE>get</CODE>, <CODE>get-next</CODE>, <CODE>set</CODE>, <CODE>response</CODE> and <CODE>SNMPv2-trap</CODE> PDUs.
  34  * <P>
  35  * You will not usually need to use this class, except if you
  36  * decide to implement your own
  37  * {@link com.sun.jmx.snmp.SnmpPduFactory SnmpPduFactory} object.
  38  *
  39  * <p><b>This API is a Sun Microsystems internal API  and is subject
  40  * to change without notice.</b></p>
  41  */
  42 
  43 public class SnmpPduRequest extends SnmpPduPacket
  44     implements SnmpPduRequestType {
  45     private static final long serialVersionUID = 2218754017025258979L;
  46 
  47 
  48     /**
  49      * Error status. Statuses are defined in
  50      * {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
  51      * @serial
  52      */
  53     public int errorStatus=0 ;
  54 
  55 
  56     /**
  57      * Error index. Remember that SNMP indices start from 1.
  58      * Thus the corresponding <CODE>SnmpVarBind</CODE> is
  59      * <CODE>varBindList[errorIndex-1]</CODE>.
  60      * @serial
  61      */
  62     public int errorIndex=0 ;
  63     /**
  64      * Implements <CODE>SnmpPduRequestType</CODE> interface.
  65      *
  66      * @since 1.5
  67      */
  68     public void setErrorIndex(int i) {
  69         errorIndex = i;
  70     }
  71     /**
  72      * Implements <CODE>SnmpPduRequestType</CODE> interface.
  73      *
  74      * @since 1.5
  75      */
  76     public void setErrorStatus(int i) {
  77         errorStatus = i;
  78     }
  79     /**
  80      * Implements <CODE>SnmpPduRequestType</CODE> interface.
  81      *
  82      * @since 1.5
  83      */
  84     public int getErrorIndex() { return errorIndex; }
  85     /**
  86      * Implements <CODE>SnmpPduRequestType</CODE> interface.
  87      *
  88      * @since 1.5
  89      */
  90     public int getErrorStatus() { return errorStatus; }
  91     /**
  92      * Implements <CODE>SnmpAckPdu</CODE> interface.
  93      *
  94      * @since 1.5
  95      */
  96     public SnmpPdu getResponsePdu() {
  97         SnmpPduRequest result = new SnmpPduRequest();
  98         result.address = address;
  99         result.port = port;
 100         result.version = version;
 101         result.community = community;
 102         result.type = SnmpDefinitions.pduGetResponsePdu;
 103         result.requestId = requestId;
 104         result.errorStatus = SnmpDefinitions.snmpRspNoError;
 105         result.errorIndex = 0;
 106 
 107         return result;
 108     }
 109 }