1. /*
  2. * @(#)file SnmpMibRequest.java
  3. * @(#)author Sun Microsystems, Inc.
  4. * @(#)version 1.15
  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. package com.sun.jmx.snmp.agent;
  11. import java.util.Enumeration;
  12. import java.util.Vector;
  13. import com.sun.jmx.snmp.SnmpVarBind;
  14. import com.sun.jmx.snmp.SnmpPdu;
  15. import com.sun.jmx.snmp.SnmpEngine;
  16. /**
  17. * This interface models the part of a SNMP request that involves
  18. * a specific MIB. One object implementing this interface will be created
  19. * for every MIB involved in a SNMP request, and that object will be passed
  20. * to the SnmpMibAgent in charge of handling that MIB.
  21. *
  22. * Objects implementing this interface will be allocated by the SNMP engine.
  23. * You will never need to implement this interface. You will only use it.
  24. *
  25. * <p><b>This API is a Sun Microsystems internal API and is subject
  26. * to change without notice.</b></p>
  27. */
  28. public interface SnmpMibRequest {
  29. /**
  30. * Returns the list of varbind to be handled by the SNMP mib node.
  31. *
  32. * @return The element of the enumeration are instances of
  33. * {@link com.sun.jmx.snmp.SnmpVarBind}
  34. */
  35. public Enumeration getElements();
  36. /**
  37. * Returns the vector of varbind to be handled by the SNMP mib node.
  38. * The caller shall not modify this vector.
  39. *
  40. * @return The element of the vector are instances of
  41. * {@link com.sun.jmx.snmp.SnmpVarBind}
  42. */
  43. public Vector getSubList();
  44. /**
  45. * Returns the SNMP protocol version of the original request. If SNMP V1 request are received, the version is upgraded to SNMP V2.
  46. *
  47. * @return The SNMP protocol version of the original request.
  48. */
  49. public int getVersion();
  50. /**
  51. * Returns the SNMP protocol version of the original request. No translation is done on the version. The actual received request SNMP version is returned.
  52. *
  53. * @return The SNMP protocol version of the original request.
  54. *
  55. * @since 1.5
  56. */
  57. public int getRequestPduVersion();
  58. /**
  59. * Returns the local engine. This parameter is returned only if <CODE> SnmpV3AdaptorServer </CODE> is the adaptor receiving this request. Otherwise null is returned.
  60. * @return the local engine.
  61. *
  62. * @since 1.5
  63. */
  64. public SnmpEngine getEngine();
  65. /**
  66. * Gets the incoming request principal. This parameter is returned only if <CODE> SnmpV3AdaptorServer </CODE> is the adaptor receiving this request. Otherwise null is returned.
  67. * @return The request principal.
  68. *
  69. * @since 1.5
  70. **/
  71. public String getPrincipal();
  72. /**
  73. * Gets the incoming request security level. This level is defined in {@link com.sun.jmx.snmp.SnmpEngine SnmpEngine}. This parameter is returned only if <CODE> SnmpV3AdaptorServer </CODE> is the adaptor receiving this request. Otherwise -1 is returned.
  74. * @return The security level.
  75. *
  76. * @since 1.5
  77. */
  78. public int getSecurityLevel();
  79. /**
  80. * Gets the incoming request security model. This parameter is returned only if <CODE> SnmpV3AdaptorServer </CODE> is the adaptor receiving this request. Otherwise -1 is returned.
  81. * @return The security model.
  82. *
  83. * @since 1.5
  84. */
  85. public int getSecurityModel();
  86. /**
  87. * Gets the incoming request context name. This parameter is returned only if <CODE> SnmpV3AdaptorServer </CODE> is the adaptor receiving this request. Otherwise null is returned.
  88. * @return The context name.
  89. *
  90. * @since 1.5
  91. */
  92. public byte[] getContextName();
  93. /**
  94. * Gets the incoming request context name used by Access Control Model in order to allow or deny the access to OIDs. This parameter is returned only if <CODE> SnmpV3AdaptorServer </CODE> is the adaptor receiving this request. Otherwise null is returned.
  95. * @return The checked context name.
  96. *
  97. * @since 1.5
  98. */
  99. public byte[] getAccessContextName();
  100. /**
  101. * Returns a handle on a user allocated contextual object.
  102. * This contextual object is allocated through the SnmpUserDataFactory
  103. * on a per SNMP request basis, and is handed back to the user via
  104. * SnmpMibRequest (and derivative) objects. It is never accessed by
  105. * the system, but might be handed back in multiple threads. It is thus
  106. * the user responsibility to make sure he handles this object in a
  107. * thread safe manner.
  108. */
  109. public Object getUserData();
  110. /**
  111. * Returns the varbind index that should be embedded in an
  112. * SnmpStatusException for this particular varbind.
  113. * This does not necessarily correspond to the "real"
  114. * index value that will be returned in the result PDU.
  115. *
  116. * @param varbind The varbind for which the index value is
  117. * querried. Note that this varbind <b>must</b> have
  118. * been obtained from the enumeration returned by
  119. * <CODE>getElements()</CODE>, or from the vector
  120. * returned by <CODE>getSublist()</CODE>.
  121. *
  122. * @return The varbind index that should be embedded in an
  123. * SnmpStatusException for this particular varbind.
  124. */
  125. public int getVarIndex(SnmpVarBind varbind);
  126. /**
  127. * Adds a varbind to this request sublist. This method is used for
  128. * internal purposes and you should never need to call it directly.
  129. *
  130. * @param varbind The varbind to be added in the sublist.
  131. *
  132. */
  133. public void addVarBind(SnmpVarBind varbind);
  134. /**
  135. * Returns the number of elements (varbinds) in this request sublist.
  136. *
  137. * @return The number of elements in the sublist.
  138. *
  139. **/
  140. public int getSize();
  141. /**
  142. * Returns the SNMP PDU attached to the request.
  143. * @return The SNMP PDU.
  144. *
  145. * @since 1.5
  146. **/
  147. public SnmpPdu getPdu();
  148. }