Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

305 lines
9.1 KiB

  1. /*
  2. * HrStorage.c v0.10
  3. * Generated in conjunction with Management Factory scripts:
  4. * script version: SNMPv1, 0.16, Apr 25, 1996
  5. * project: D:\TEMP\EXAMPLE\HOSTMIB
  6. ****************************************************************************
  7. * *
  8. * (C) Copyright 1995 DIGITAL EQUIPMENT CORPORATION *
  9. * *
  10. * This software is an unpublished work protected under the *
  11. * the copyright laws of the United States of America, all *
  12. * rights reserved. *
  13. * *
  14. * In the event this software is licensed for use by the United *
  15. * States Government, all use, duplication or disclosure by the *
  16. * United States Government is subject to restrictions as set *
  17. * forth in either subparagraph (c)(1)(ii) of the Rights in *
  18. * Technical Data And Computer Software Clause at DFARS *
  19. * 252.227-7013, or the Commercial Computer Software Restricted *
  20. * Rights Clause at FAR 52.221-19, whichever is applicable. *
  21. * *
  22. ****************************************************************************
  23. *
  24. * Facility:
  25. *
  26. * Windows NT SNMP Extension Agent
  27. *
  28. * Abstract:
  29. *
  30. * This module contains the code for dealing with the get, set, and
  31. * instance name routines for the HrStorage. Actual instrumentation code is
  32. * supplied by the developer.
  33. *
  34. * Functions:
  35. *
  36. * A get and set routine for each attribute in the class.
  37. *
  38. * The routines for instances within the class.
  39. *
  40. * Author:
  41. *
  42. * D. D. Burns @ Webenable Inc
  43. *
  44. * Revision History:
  45. *
  46. * V1.00 - 04/17/97 D. D. Burns Original Creation: Thu Nov 07 16:39:42 1996
  47. *
  48. */
  49. #include <windows.h>
  50. #include <malloc.h>
  51. #include <snmp.h>
  52. #include "mib.h"
  53. #include "smint.h"
  54. #include "hostmsmi.h"
  55. #include "user.h" /* Developer supplied include file */
  56. /*
  57. * GetHrMemorySize
  58. * The amount of physical main memory contained by the host.
  59. *
  60. * Gets the value for HrMemorySize.
  61. *
  62. * Arguments:
  63. *
  64. * outvalue address to return variable value
  65. * accesss Reserved for future security use
  66. * instance address of instance name as ordered native
  67. * data type(s)
  68. *
  69. * Return Codes:
  70. *
  71. * Standard PDU error codes.
  72. *
  73. * SNMP_ERRORSTATUS_NOERROR Successful get
  74. * SNMP_ERRORSTATUS_GENERR Catch-all failure code
  75. * mibtget.c v0.10
  76. *
  77. | =============== From WebEnable Design Spec Rev 3 04/11/97==================
  78. | hrMemorySize
  79. |
  80. | ACCESS SYNTAX
  81. | read-only KBytes
  82. |
  83. | "The amount of physical main memory contained by the host."
  84. |
  85. | DISCUSSION:
  86. |
  87. | Win32 API function "GlobalMemoryStatus" is invoked and the value returned
  88. | in structure MEMORYSTATUS for cell "dwTotalPhys" is used to compute the value
  89. | returned for this attribute.
  90. |
  91. |============================================================================
  92. | 1.3.6.1.2.1.25.2.2.0
  93. | | |
  94. | | *-hrMemorySize
  95. | *-hrStorage
  96. */
  97. UINT
  98. GetHrMemorySize(
  99. OUT KBytes *outvalue ,
  100. IN Access_Credential *access ,
  101. IN InstanceName *instance )
  102. {
  103. MEMORYSTATUS mem_status; /* For "GlobalMemoryStatus()" call */
  104. /* Get the "mem_status" structure filled in */
  105. GlobalMemoryStatus(&mem_status);
  106. /* Return total available physical bytes reduced to 1024 blocks */
  107. *outvalue = (KBytes)(mem_status.dwTotalPhys / 1024);
  108. return SNMP_ERRORSTATUS_NOERROR ;
  109. } /* end of GetHrMemorySize() */
  110. /*
  111. * HrStorageFindInstance
  112. *
  113. * This routine is used to verify that the specified instance is
  114. * valid.
  115. *
  116. * Arguments:
  117. *
  118. * FullOid Address for the full oid - group, variable,
  119. * and instance information
  120. * instance Address for instance specification as an oid
  121. *
  122. * Return Codes:
  123. *
  124. * SNMP_ERRORSTATUS_NOERROR Instance found and valid
  125. * SNMP_ERRORSTATUS_NOSUCHNAME Invalid instance
  126. *
  127. */
  128. UINT
  129. HrStorageFindInstance( IN ObjectIdentifier *FullOid ,
  130. IN OUT ObjectIdentifier *instance )
  131. {
  132. UINT tmp_instance ;
  133. //
  134. // Developer instrumentation code to find appropriate instance goes here.
  135. // For non-tables, it is not necessary to modify this routine.
  136. // However, if there is any context that needs to be set, it can be done
  137. // here.
  138. if ( FullOid->idLength <= HRSTORAGE_VAR_INDEX )
  139. // No instance was specified
  140. return SNMP_ERRORSTATUS_NOSUCHNAME ;
  141. else if ( FullOid->idLength != HRSTORAGE_VAR_INDEX + 1 )
  142. // Instance length is more than 1
  143. return SNMP_ERRORSTATUS_NOSUCHNAME ;
  144. else
  145. // The only valid instance for a non-table are instance 0. If this
  146. // is a non-table, the following code validates the instances. If this
  147. // is a table, developer modification is necessary below.
  148. tmp_instance = FullOid->ids[ HRSTORAGE_VAR_INDEX ] ;
  149. if ( tmp_instance )
  150. return SNMP_ERRORSTATUS_NOSUCHNAME ;
  151. else
  152. {
  153. // the instance is valid. Create the instance portion of the OID
  154. // to be returned from this call.
  155. instance->ids[ 0 ] = tmp_instance ;
  156. instance->idLength = 1 ;
  157. }
  158. return SNMP_ERRORSTATUS_NOERROR ;
  159. } /* end of HrStorageFindInstance() */
  160. /*
  161. * HrStorageFindNextInstance
  162. *
  163. * This routine is called to get the next instance. If no instance
  164. * was passed than return the first instance (1).
  165. *
  166. * Arguments:
  167. *
  168. * FullOid Address for the full oid - group, variable,
  169. * and instance information
  170. * instance Address for instance specification as an oid
  171. *
  172. * Return Codes:
  173. *
  174. * SNMP_ERRORSTATUS_NOERROR Instance found and valid
  175. * SNMP_ERRORSTATUS_NOSUCHNAME Invalid instance
  176. *
  177. */
  178. UINT
  179. HrStorageFindNextInstance( IN ObjectIdentifier *FullOid ,
  180. IN OUT ObjectIdentifier *instance )
  181. {
  182. //
  183. // Developer supplied code to find the next instance of class goes here.
  184. // If this is a class with cardinality 1, no modification of this routine
  185. // is necessary unless additional context needs to be set.
  186. // If the FullOid does not specify an instance, then the only instance
  187. // of the class is returned. If this is a table, the first row of the
  188. // table is returned.
  189. //
  190. // If an instance is specified and this is a non-table class, then
  191. // NOSUCHNAME is returned so that correct MIB rollover processing occurs.
  192. //
  193. // If this is a table, then the next instance is the one following the
  194. // current instance.
  195. //
  196. // If there are no more instances in the table, return NOSUCHNAME.
  197. //
  198. if ( FullOid->idLength <= HRSTORAGE_VAR_INDEX )
  199. {
  200. instance->ids[ 0 ] = 0 ;
  201. instance->idLength = 1 ;
  202. }
  203. else
  204. return SNMP_ERRORSTATUS_NOSUCHNAME ;
  205. return SNMP_ERRORSTATUS_NOERROR ;
  206. } /* end of HrStorageFindNextInstance() */
  207. /*
  208. * HrStorageConvertInstance
  209. *
  210. * This routine is used to convert the object id specification of an
  211. * instance into an ordered native representation. The object id format
  212. * is that object identifier that is returned from the Find Instance
  213. * or Find Next Instance routines. It is NOT the full object identifier
  214. * that contains the group and variable object ids as well. The native
  215. * representation is an argc/argv-like structure that contains the
  216. * ordered variables that define the instance. This is specified by
  217. * the MIB's INDEX clause. See RFC 1212 for information about the INDEX
  218. * clause.
  219. *
  220. *
  221. * Arguments:
  222. *
  223. * oid_spec Address of the object id instance specification
  224. * native_spec Address to return the ordered native instance
  225. * specification
  226. *
  227. * Return Codes:
  228. *
  229. * SUCCESS Conversion complete successfully
  230. * FAILURE Unable to convert object id into native format
  231. *
  232. */
  233. UINT
  234. HrStorageConvertInstance( IN ObjectIdentifier *oid_spec ,
  235. IN OUT InstanceName *native_spec )
  236. {
  237. //
  238. // Developer supplied code to convert instance identifer to native
  239. // specification of instance names goes here.
  240. //
  241. return SUCCESS ;
  242. } /* end of HrStorageConvertInstance() */
  243. /*
  244. * HrStorageFreeInstance
  245. *
  246. * This routine is used to free an ordered native representation of an
  247. * instance name.
  248. *
  249. * Arguments:
  250. *
  251. * instance Address to return the ordered native instance
  252. * specification
  253. *
  254. * Return Codes:
  255. *
  256. *
  257. */
  258. void
  259. HrStorageFreeInstance( IN OUT InstanceName *instance )
  260. {
  261. //
  262. // Developer supplied code to free native representation of instance name goes here.
  263. //
  264. } /* end of HrStorageFreeInstance() */