1. /*
  2. * @(#)file SnmpPduRequest.java
  3. * @(#)author Sun Microsystems, Inc.
  4. * @(#)version 4.17
  5. * @(#)date 04/09/15
  6. *
  7. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  8. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  9. *
  10. */
  11. package com.sun.jmx.snmp;
  12. /**
  13. * Is used to represent <CODE>get</CODE>, <CODE>get-next</CODE>, <CODE>set</CODE>, <CODE>response</CODE> and <CODE>SNMPv2-trap</CODE> PDUs.
  14. * <P>
  15. * You will not usually need to use this class, except if you
  16. * decide to implement your own
  17. * {@link com.sun.jmx.snmp.SnmpPduFactory SnmpPduFactory} object.
  18. *
  19. * @version 4.17 12/19/03
  20. * @author Sun Microsystems, Inc
  21. * <p><b>This API is a Sun Microsystems internal API and is subject
  22. * to change without notice.</b></p>
  23. */
  24. public class SnmpPduRequest extends SnmpPduPacket
  25. implements SnmpPduRequestType {
  26. /**
  27. * Error status. Statuses are defined in
  28. * {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
  29. * @serial
  30. */
  31. public int errorStatus=0 ;
  32. /**
  33. * Error index. Remember that SNMP indices start from 1.
  34. * Thus the corresponding <CODE>SnmpVarBind</CODE> is
  35. * <CODE>varBindList[errorIndex-1]</CODE>.
  36. * @serial
  37. */
  38. public int errorIndex=0 ;
  39. /**
  40. * Implements <CODE>SnmpPduRequestType</CODE> interface.
  41. *
  42. * @since 1.5
  43. */
  44. public void setErrorIndex(int i) {
  45. errorIndex = i;
  46. }
  47. /**
  48. * Implements <CODE>SnmpPduRequestType</CODE> interface.
  49. *
  50. * @since 1.5
  51. */
  52. public void setErrorStatus(int i) {
  53. errorStatus = i;
  54. }
  55. /**
  56. * Implements <CODE>SnmpPduRequestType</CODE> interface.
  57. *
  58. * @since 1.5
  59. */
  60. public int getErrorIndex() { return errorIndex; }
  61. /**
  62. * Implements <CODE>SnmpPduRequestType</CODE> interface.
  63. *
  64. * @since 1.5
  65. */
  66. public int getErrorStatus() { return errorStatus; }
  67. /**
  68. * Implements <CODE>SnmpAckPdu</CODE> interface.
  69. *
  70. * @since 1.5
  71. */
  72. public SnmpPdu getResponsePdu() {
  73. SnmpPduRequest result = new SnmpPduRequest();
  74. result.address = address;
  75. result.port = port;
  76. result.version = version;
  77. result.community = community;
  78. result.type = SnmpDefinitions.pduGetResponsePdu;
  79. result.requestId = requestId;
  80. result.errorStatus = SnmpDefinitions.snmpRspNoError;
  81. result.errorIndex = 0;
  82. return result;
  83. }
  84. }