Leaked source code of windows server 2003
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.

309 lines
9.6 KiB

  1. /*
  2. * HrSWRun.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 HrSWRun. 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 - 05/14/97 D. D. Burns Genned: Thu Nov 07 16:46:47 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. #include "HMCACHE.H" /* Cache-related definitions */
  57. /*
  58. * GetHrSWOSIndex
  59. * The value of the hrSWRunIndex for the hrSWRunEntry that represents the
  60. * primary operating system running on this host. This obje
  61. *
  62. * Gets the value for HrSWOSIndex.
  63. *
  64. * Arguments:
  65. *
  66. * outvalue address to return variable value
  67. * accesss Reserved for future security use
  68. * instance address of instance name as ordered native
  69. * data type(s)
  70. *
  71. * Return Codes:
  72. *
  73. * Standard PDU error codes.
  74. *
  75. * SNMP_ERRORSTATUS_NOERROR Successful get
  76. * SNMP_ERRORSTATUS_GENERR Catch-all failure code
  77. * mibtget.c v0.10
  78. *
  79. | =============== From WebEnable Design Spec Rev 3 04/11/97==================
  80. | hrSWOSIndex
  81. |
  82. | ACCESS SYNTAX
  83. | read-only INTEGER (1..2147483647)
  84. |
  85. | "The value of the hrSWRunIndex for the hrSWRunEntry that represents the
  86. | primary operating system running on this host. This object is useful for
  87. | quickly and uniquely identifying that primary operating system."
  88. |
  89. |
  90. | DISCUSSION:
  91. |
  92. | The value for this attribute is the index for the process named "System".
  93. |
  94. |============================================================================
  95. | This value is computed in module "HRSWRUNE.C" in function "AddHrSWRunRow()"
  96. | and stored in that module for global reference by this code.
  97. |============================================================================
  98. | 1.3.6.1.2.1.25.4.1.0
  99. | | |
  100. | | *-hrSWOSIndex
  101. | *-hrSWRun
  102. */
  103. UINT
  104. GetHrSWOSIndex(
  105. OUT Integer *outvalue ,
  106. IN Access_Credential *access ,
  107. IN InstanceName *instance )
  108. {
  109. /*
  110. | Check and Refresh the entire cache for the hrSWRun table
  111. */
  112. if (hrSWRunCache_Refresh() == FALSE) {
  113. return SNMP_ERRORSTATUS_GENERR;
  114. }
  115. *outvalue = SWOSIndex;
  116. return SNMP_ERRORSTATUS_NOERROR ;
  117. } /* end of GetHrSWOSIndex() */
  118. /*
  119. * HrSWRunFindInstance
  120. *
  121. * This routine is used to verify that the specified instance is
  122. * valid.
  123. *
  124. * Arguments:
  125. *
  126. * FullOid Address for the full oid - group, variable,
  127. * and instance information
  128. * instance Address for instance specification as an oid
  129. *
  130. * Return Codes:
  131. *
  132. * SNMP_ERRORSTATUS_NOERROR Instance found and valid
  133. * SNMP_ERRORSTATUS_NOSUCHNAME Invalid instance
  134. *
  135. */
  136. UINT
  137. HrSWRunFindInstance( IN ObjectIdentifier *FullOid ,
  138. IN OUT ObjectIdentifier *instance )
  139. {
  140. UINT tmp_instance ;
  141. //
  142. // Developer instrumentation code to find appropriate instance goes here.
  143. // For non-tables, it is not necessary to modify this routine. However, if
  144. // there is any context that needs to be set, it can be done here.
  145. //
  146. if ( FullOid->idLength <= HRSWRUN_VAR_INDEX )
  147. // No instance was specified
  148. return SNMP_ERRORSTATUS_NOSUCHNAME ;
  149. else if ( FullOid->idLength != HRSWRUN_VAR_INDEX + 1 )
  150. // Instance length is more than 1
  151. return SNMP_ERRORSTATUS_NOSUCHNAME ;
  152. else
  153. // The only valid instance for a non-table are instance 0. If this
  154. // is a non-table, the following code validates the instances. If this
  155. // is a table, developer modification is necessary below.
  156. tmp_instance = FullOid->ids[ HRSWRUN_VAR_INDEX ] ;
  157. if ( tmp_instance )
  158. return SNMP_ERRORSTATUS_NOSUCHNAME ;
  159. else
  160. {
  161. // the instance is valid. Create the instance portion of the OID
  162. // to be returned from this call.
  163. instance->ids[ 0 ] = tmp_instance ;
  164. instance->idLength = 1 ;
  165. }
  166. return SNMP_ERRORSTATUS_NOERROR ;
  167. } /* end of HrSWRunFindInstance() */
  168. /*
  169. * HrSWRunFindNextInstance
  170. *
  171. * This routine is called to get the next instance. If no instance
  172. * was passed than return the first instance (1).
  173. *
  174. * Arguments:
  175. *
  176. * FullOid Address for the full oid - group, variable,
  177. * and instance information
  178. * instance Address for instance specification as an oid
  179. *
  180. * Return Codes:
  181. *
  182. * SNMP_ERRORSTATUS_NOERROR Instance found and valid
  183. * SNMP_ERRORSTATUS_NOSUCHNAME Invalid instance
  184. *
  185. */
  186. UINT
  187. HrSWRunFindNextInstance( IN ObjectIdentifier *FullOid ,
  188. IN OUT ObjectIdentifier *instance )
  189. {
  190. //
  191. // Developer supplied code to find the next instance of class goes here.
  192. // If this is a class with cardinality 1, no modification of this routine
  193. // is necessary unless additional context needs to be set.
  194. // If the FullOid does not specify an instance, then the only instance
  195. // of the class is returned. If this is a table, the first row of the
  196. // table is returned.
  197. //
  198. // If an instance is specified and this is a non-table class, then NOSUCHNAME
  199. // is returned so that correct MIB rollover processing occurs. If this is
  200. // a table, then the next instance is the one following the current instance.
  201. // If there are no more instances in the table, return NOSUCHNAME.
  202. //
  203. if ( FullOid->idLength <= HRSWRUN_VAR_INDEX )
  204. {
  205. instance->ids[ 0 ] = 0 ;
  206. instance->idLength = 1 ;
  207. }
  208. else
  209. return SNMP_ERRORSTATUS_NOSUCHNAME ;
  210. return SNMP_ERRORSTATUS_NOERROR ;
  211. } /* end of HrSWRunFindNextInstance() */
  212. /*
  213. * HrSWRunConvertInstance
  214. *
  215. * This routine is used to convert the object id specification of an
  216. * instance into an ordered native representation. The object id format
  217. * is that object identifier that is returned from the Find Instance
  218. * or Find Next Instance routines. It is NOT the full object identifier
  219. * that contains the group and variable object ids as well. The native
  220. * representation is an argc/argv-like structure that contains the
  221. * ordered variables that define the instance. This is specified by
  222. * the MIB's INDEX clause. See RFC 1212 for information about the INDEX
  223. * clause.
  224. *
  225. *
  226. * Arguments:
  227. *
  228. * oid_spec Address of the object id instance specification
  229. * native_spec Address to return the ordered native instance
  230. * specification
  231. *
  232. * Return Codes:
  233. *
  234. * SUCCESS Conversion complete successfully
  235. * FAILURE Unable to convert object id into native format
  236. *
  237. */
  238. UINT
  239. HrSWRunConvertInstance( IN ObjectIdentifier *oid_spec ,
  240. IN OUT InstanceName *native_spec )
  241. {
  242. //
  243. // Developer supplied code to convert instance identifer to native
  244. // specification of instance names goes here.
  245. //
  246. return SUCCESS ;
  247. } /* end of HrSWRunConvertInstance() */
  248. /*
  249. * HrSWRunFreeInstance
  250. *
  251. * This routine is used to free an ordered native representation of an
  252. * instance name.
  253. *
  254. * Arguments:
  255. *
  256. * instance Address to return the ordered native instance
  257. * specification
  258. *
  259. * Return Codes:
  260. *
  261. *
  262. */
  263. void
  264. HrSWRunFreeInstance( IN OUT InstanceName *instance )
  265. {
  266. //
  267. // Developer supplied code to free native representation of instance name goes here.
  268. //
  269. } /* end of HrSWRunFreeInstance() */