1. /*
  2. * @(#)file SnmpIncomingResponse.java
  3. * @(#)author Sun Microsystems, Inc.
  4. * @(#)version 1.16
  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.internal;
  12. import java.net.InetAddress;
  13. import com.sun.jmx.snmp.SnmpPduFactory;
  14. import com.sun.jmx.snmp.SnmpSecurityParameters;
  15. import com.sun.jmx.snmp.SnmpSecurityException;
  16. import com.sun.jmx.snmp.SnmpTooBigException;
  17. import com.sun.jmx.snmp.SnmpStatusException;
  18. import com.sun.jmx.snmp.SnmpPdu;
  19. import com.sun.jmx.snmp.SnmpMsg;
  20. import com.sun.jmx.snmp.internal.SnmpSecurityCache;
  21. import com.sun.jmx.snmp.SnmpBadSecurityLevelException;
  22. /**
  23. * <P> An <CODE>SnmpIncomingResponse</CODE> handles the unmarshalling of the received response.</P>
  24. * <p><b>This API is a Sun Microsystems internal API and is subject
  25. * to change without notice.</b></p>
  26. * @since 1.5
  27. */
  28. public interface SnmpIncomingResponse {
  29. /**
  30. * Returns the source address.
  31. * @return The source address.
  32. */
  33. public InetAddress getAddress();
  34. /**
  35. * Returns the source port.
  36. * @return The source port.
  37. */
  38. public int getPort();
  39. /**
  40. * Gets the incoming response security parameters.
  41. * @return The security parameters.
  42. **/
  43. public SnmpSecurityParameters getSecurityParameters();
  44. /**
  45. * Call this method in order to reuse <CODE>SnmpOutgoingRequest</CODE> cache.
  46. * @param cache The security cache.
  47. */
  48. public void setSecurityCache(SnmpSecurityCache cache);
  49. /**
  50. * Gets the incoming response security level. This level is defined in
  51. * {@link com.sun.jmx.snmp.SnmpEngine SnmpEngine}.
  52. * @return The security level.
  53. */
  54. public int getSecurityLevel();
  55. /**
  56. * Gets the incoming response security model.
  57. * @return The security model.
  58. */
  59. public int getSecurityModel();
  60. /**
  61. * Gets the incoming response context name.
  62. * @return The context name.
  63. */
  64. public byte[] getContextName();
  65. /**
  66. * Decodes the specified bytes and initializes itself with the received
  67. * response.
  68. *
  69. * @param inputBytes The bytes to be decoded.
  70. *
  71. * @exception SnmpStatusException If the specified bytes are not a valid encoding.
  72. */
  73. public SnmpMsg decodeMessage(byte[] inputBytes,
  74. int byteCount,
  75. InetAddress address,
  76. int port)
  77. throws SnmpStatusException, SnmpSecurityException;
  78. /**
  79. * Gets the request PDU encoded in the received response.
  80. * <P>
  81. * This method decodes the data field and returns the resulting PDU.
  82. *
  83. * @return The resulting PDU.
  84. * @exception SnmpStatusException If the encoding is not valid.
  85. */
  86. public SnmpPdu decodeSnmpPdu()
  87. throws SnmpStatusException;
  88. /**
  89. * Returns the response request Id.
  90. * @param data The flat message.
  91. * @return The request Id.
  92. */
  93. public int getRequestId(byte[] data) throws SnmpStatusException;
  94. /**
  95. * Returns a stringified form of the message to send.
  96. * @return The message state string.
  97. */
  98. public String printMessage();
  99. }