Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

RMSystemInfo.c

Go to the documentation of this file.
00001 /* This file was generated by mib2c and is intended for use as a mib module
00002    for the ucd-snmp snmpd agent. */
00003 
00004 #include <netinet/in.h>
00005 
00006 #ifdef IN_UCD_SNMP_SOURCE
00007 /* If we're compiling this file inside the ucd-snmp source tree */
00008 
00009 
00010 /* This should always be included first before anything else */
00011 #include <config.h>
00012 
00013 
00014 /* minimal include directives */
00015 #include "mibincl.h"
00016 #include "util_funcs.h"
00017 
00018 
00019 #else /* !IN_UCD_SNMP_SOURCE */
00020 
00021 
00022 #include <ucd-snmp/ucd-snmp-config.h>
00023 #include <ucd-snmp/ucd-snmp-includes.h>
00024 #include <ucd-snmp/ucd-snmp-agent-includes.h>
00025 
00026 
00027 #endif /* !IN_UCD_SNMP_SOURCE */
00028 
00029 
00030 #include "RMSystemInfo.h"
00031 #include "rmClient.h"
00032 #include "utility.h"
00033 
00034 #include <stdlib.h>
00035 #include <string.h>
00036 #include <ucd-snmp/util_funcs.h>
00037 
00038 
00039 /* 
00040  * RMSystemInfo_variables_oid:
00041  *   this is the top level oid that we want to register under.  This
00042  *   is essentially a prefix, with the suffix appearing in the
00043  *   variable below.
00044  */
00045 
00046 
00047 oid RMSystemInfo_variables_oid[] = { 1,3,6,1,4,1,343,2,15,1,2,1 };
00048 
00049 
00050 /* 
00051  * variable4 RMSystemInfo_variables:
00052  *   this variable defines function callbacks and type return information 
00053  *   for the RMSystemInfo mib section 
00054  */
00055 
00056 
00057 struct variable4 RMSystemInfo_variables[] = {
00058 /*  magic number        , variable type , ro/rw , callback fn  , L, oidsuffix */
00059 #define   RMVERSIONSTRING       1
00060   { RMVERSIONSTRING     , ASN_OCTET_STR , RONLY , var_RMSystemInfo, 1, { 1 } },
00061 #define   RMSUBSYSTEMCOUNT      2
00062   { RMSUBSYSTEMCOUNT    , ASN_UNSIGNED  , RONLY , var_RMSystemInfo, 1, { 2 } },
00063 #define   SUBSYSTEMUUID         6
00064   { SUBSYSTEMUUID       , ASN_OCTET_STR , RONLY , var_RMSubsystemInfoTable, 3, { 3,1,2 } },
00065 #define   SUBSYSTEMNAME         7
00066   { SUBSYSTEMNAME       , ASN_OCTET_STR , RONLY , var_RMSubsystemInfoTable, 3, { 3,1,3 } },
00067 #define   SUBSYSTEMDESCRIPTION  8
00068   { SUBSYSTEMDESCRIPTION, ASN_OCTET_STR , RONLY , var_RMSubsystemInfoTable, 3, { 3,1,4 } },
00069 #define   SUBSYSTEMRESOURCECOUNT  9
00070   { SUBSYSTEMRESOURCECOUNT, ASN_UNSIGNED  , RONLY , var_RMSubsystemInfoTable, 3, { 3,1,5 } },
00071 #define   SUBSYSTEMSTATISTICSCOUNT  10
00072   { SUBSYSTEMSTATISTICSCOUNT, ASN_UNSIGNED  , RONLY , var_RMSubsystemInfoTable, 3, { 3,1,6 } },
00073 #define   RESOURCENAME          14
00074   { RESOURCENAME        , ASN_OCTET_STR , RONLY , var_RMResourceInfoTable, 3, { 4,1,2 } },
00075 #define   RESOURCEDESCRIPTION   15
00076   { RESOURCEDESCRIPTION , ASN_OCTET_STR , RONLY , var_RMResourceInfoTable, 3, { 4,1,3 } },
00077 #define   STATISTICNAME         19
00078   { STATISTICNAME       , ASN_OCTET_STR , RONLY , var_RMStatisticInfoTable, 3, { 5,1,2 } },
00079 #define   STATISTICDESCRIPTION  20
00080   { STATISTICDESCRIPTION, ASN_OCTET_STR , RONLY , var_RMStatisticInfoTable, 3, { 5,1,3 } },
00081 #define   STATISTICUNIT         21
00082   { STATISTICUNIT       , ASN_OCTET_STR , RONLY , var_RMStatisticInfoTable, 3, { 5,1,4 } },
00083 #define   STATISTICTYPE         22
00084   { STATISTICTYPE       , ASN_INTEGER   , RONLY , var_RMStatisticInfoTable, 3, { 5,1,5 } },
00085 #define   STATISTICSIZE         23
00086   { STATISTICSIZE       , ASN_INTEGER   , RONLY , var_RMStatisticInfoTable, 3, { 5,1,6 } },
00087 #define   STATISTICSCALE        24
00088   { STATISTICSCALE      , ASN_INTEGER   , RONLY , var_RMStatisticInfoTable, 3, { 5,1,7 } },
00089 #define   STATISTICGAUGEUPPERBOUNDLOW  25
00090   { STATISTICGAUGEUPPERBOUNDLOW, ASN_UNSIGNED  , RONLY , var_RMStatisticInfoTable, 3, { 5,1,8 } },
00091 #define   STATISTICGAUGEUPPERBOUNDHIGH  26
00092   { STATISTICGAUGEUPPERBOUNDHIGH, ASN_UNSIGNED  , RONLY , var_RMStatisticInfoTable, 3, { 5,1,9 } },
00093 #define   STATISTICCOUNTERRESETVALUELOW  27
00094   { STATISTICCOUNTERRESETVALUELOW, ASN_UNSIGNED  , RWRITE, var_RMStatisticInfoTable, 3, { 5,1,10 } },
00095 #define   STATISTICCOUNTERRESETVALUEHIGH  28
00096   { STATISTICCOUNTERRESETVALUEHIGH, ASN_UNSIGNED  , RWRITE, var_RMStatisticInfoTable, 3, { 5,1,11 } },
00097 #define   STATISTICCOUNTERRESET  29
00098   { STATISTICCOUNTERRESET, ASN_INTEGER   , RWRITE, var_RMStatisticInfoTable, 3, { 5,1,12 } },
00099 
00100 #define PLUGINUUID            30 
00101   { PLUGINUUID          , ASN_OCTET_STR , RONLY ,  var_RMDataCapturePluginInfoTable, 3, { 6,1,2 } },
00102 
00103 #define PLUGINNAME          31
00104   { PLUGINNAME          , ASN_OCTET_STR , RONLY , var_RMDataCapturePluginInfoTable, 3, { 6,1,3} },
00105 };
00106 /*    (L = length of the oidsuffix) */
00107 
00108 
00109 /*
00110  * init_RMSystemInfo():
00111  *   Initialization routine.  This is called when the agent starts up.
00112  *   At a minimum, registration of your variables should take place here.
00113  */
00114 void init_RMSystemInfo(void) {
00115 
00116 
00117   /* register ourselves with the agent to handle our mib tree */
00118   REGISTER_MIB("RMSystemInfo", RMSystemInfo_variables, variable4,
00119                RMSystemInfo_variables_oid);
00120 
00121 
00122   /* place any other initialization junk you need here */
00123 }
00124 
00125 
00126 /*
00127  * var_RMSystemInfo():
00128  *   This function is called every time the agent gets a request for
00129  *   a scalar variable that might be found within your mib section
00130  *   registered above.  It is up to you to do the right thing and
00131  *   return the correct value.
00132  *     You should also correct the value of "var_len" if necessary.
00133  *
00134  *   Please see the documentation for more information about writing
00135  *   module extensions, and check out the examples in the examples
00136  *   and mibII directories.
00137  */
00138 unsigned char *
00139 var_RMSystemInfo(struct variable *vp, 
00140                 oid     *name, 
00141                 size_t  *length, 
00142                 int     exact, 
00143                 size_t  *var_len, 
00144                 WriteMethod **write_method)
00145 {
00146 
00147 
00148   /* variables we may use later */
00149   static u_long ulong_ret;
00150   static unsigned char string[SPRINT_MAX_LEN];
00151 
00152   int version;
00153 
00154 
00155   if (header_generic(vp,name,length,exact,var_len,write_method)
00156                                   == MATCH_FAILED )
00157     return NULL;
00158 
00159 
00160   /* 
00161    * this is where we do the value assignments for the mib results.
00162    */
00163   switch(vp->magic) {
00164 
00165 
00166     case RMVERSIONSTRING:
00167         
00168         *string = 0;
00169 
00170         version = getRMVersion();
00171         snprintf(string, SPRINT_MAX_LEN, "%d", version);
00172         *var_len = strlen(string);
00173         return (unsigned char *) string;
00174 
00175     case RMSUBSYSTEMCOUNT:
00176         
00177         ulong_ret = getCount(SUBSYSTEMINFO);
00178         return (unsigned char *) &ulong_ret;
00179 
00180 
00181     default:
00182       ERROR_MSG("");
00183   }
00184   return NULL;
00185 }
00186 
00187 
00188 /*
00189  * var_RMSubsystemInfoTable():
00190  *   Handle this table separately from the scalar value case.
00191  *   The workings of this are basically the same as for var_RMSystemInfo above.
00192  */
00193 unsigned char *
00194 var_RMSubsystemInfoTable(struct variable *vp,
00195             oid     *name,
00196             size_t  *length,
00197             int     exact,
00198             size_t  *var_len,
00199             WriteMethod **write_method)
00200 {
00201 
00202 
00203   /* variables we may use later */
00204   static u_long ulong_ret;
00205   static unsigned char string[SPRINT_MAX_LEN];
00206 
00207   char * str = NULL;
00208   int ret;
00209   unsigned long id;
00210 
00211   id = header_MyGeneric(vp,name,length,exact,var_len,write_method, SUBSYSTEMINFO);
00212   if(id == 0)
00213     return NULL;
00214 
00215 
00216   /* 
00217    * this is where we do the value assignments for the mib results.
00218    */
00219   switch(vp->magic) {
00220 
00221 
00222     case SUBSYSTEMUUID:
00223         
00224         *string = 0;
00225         getUUIDString(SUBSYSTEMINFO, SUBSYSTEMINFO_UUID, id, string);
00226         *var_len = strlen(string);
00227         return (unsigned char *) string;
00228 
00229     case SUBSYSTEMNAME:
00230         
00231         *string = 0;
00232         ret = getString(SUBSYSTEMINFO, SUBSYSTEMINFO_NAME, id, &str);
00233         if(!ret && str != NULL) {
00234           strncpy(string, str, SPRINT_MAX_LEN);
00235           free(str);
00236         }
00237         *var_len = strlen(string);
00238         return (unsigned char *) string;
00239 
00240     case SUBSYSTEMDESCRIPTION:
00241         
00242         *string = 0;
00243         ret = getString(SUBSYSTEMINFO, SUBSYSTEMINFO_DESCRIPTION, id, &str);
00244         if(!ret && str != NULL) {
00245           strncpy(string, str, SPRINT_MAX_LEN);
00246           free(str);
00247         }
00248         *var_len = strlen(string);
00249         return (unsigned char *) string;
00250 
00251     case SUBSYSTEMRESOURCECOUNT:
00252         
00253         ulong_ret = 0;
00254         getUnsigned(SUBSYSTEMINFO, SUBSYSTEMINFO_RESOURCECOUNT, id, &ulong_ret);
00255         return (unsigned char *) &ulong_ret;
00256 
00257     case SUBSYSTEMSTATISTICSCOUNT:
00258         
00259         ulong_ret = 0;
00260         getUnsigned(SUBSYSTEMINFO, SUBSYSTEMINFO_STATISTICCOUNT, id, &ulong_ret);
00261         return (unsigned char *) &ulong_ret;
00262 
00263 
00264     default:
00265       ERROR_MSG("");
00266   }
00267   return NULL;
00268 }
00269 
00270 /*
00271  * var_RMResourceInfoTable():
00272  *   Handle this table separately from the scalar value case.
00273  *   The workings of this are basically the same as for var_RMSystemInfo above.
00274  */
00275 unsigned char *
00276 var_RMResourceInfoTable(struct variable *vp,
00277             oid     *name,
00278             size_t  *length,
00279             int     exact,
00280             size_t  *var_len,
00281             WriteMethod **write_method)
00282 {
00283 
00284 
00285   /* variables we may use later */
00286   static unsigned char string[SPRINT_MAX_LEN];
00287 
00288   char * str = NULL;
00289   int ret;
00290   unsigned long id;
00291 
00292   id = header_resourceInfo(vp,name,length,exact,var_len,write_method);
00293   if(id == 0)
00294     return NULL;
00295 
00296   /* 
00297    * this is where we do the value assignments for the mib results.
00298    */
00299   switch(vp->magic) {
00300 
00301 
00302     case RESOURCENAME:
00303         
00304         *string = 0;
00305         ret = getString(RESORUCEINFO, RESORUCEINFO_NAME, id, &str);
00306         if(!ret && str != NULL) {
00307           strncpy(string, str, SPRINT_MAX_LEN);
00308           free(str);
00309         }
00310         *var_len = strlen(string);
00311         return (unsigned char *) string;
00312 
00313     case RESOURCEDESCRIPTION:
00314         
00315         *string = 0;
00316         ret = getString(RESORUCEINFO, RESOURCEINFO_DESCRIPTION, id, &str);
00317         if(!ret && str != NULL) {
00318           strncpy(string, str, SPRINT_MAX_LEN);
00319           free(str);
00320         }
00321         *var_len = strlen(string);
00322         return (unsigned char *) string;
00323 
00324 
00325     default:
00326       ERROR_MSG("");
00327   }
00328   return NULL;
00329 }
00330 
00331 /*
00332  * var_RMStatisticInfoTable():
00333  *   Handle this table separately from the scalar value case.
00334  *   The workings of this are basically the same as for var_RMSystemInfo above.
00335  */
00336 unsigned char *
00337 var_RMStatisticInfoTable(struct variable *vp,
00338             oid     *name,
00339             size_t  *length,
00340             int     exact,
00341             size_t  *var_len,
00342             WriteMethod **write_method)
00343 {
00344 
00345 
00346   /* variables we may use later */
00347   static long long_ret;
00348   static u_long ulong_ret;
00349   static unsigned char string[SPRINT_MAX_LEN];
00350 
00351   char * str = NULL;
00352   int ret;
00353   unsigned long id;
00354   static u_int64_t v64;
00355 
00356   id = header_statisticInfo(vp,name,length,exact,var_len,write_method);
00357   if(id == 0)
00358     return NULL;
00359 
00360 
00361   /* 
00362    * this is where we do the value assignments for the mib results.
00363    */
00364   switch(vp->magic) {
00365 
00366 
00367     case STATISTICNAME:
00368         
00369         *string = 0;
00370         ret = getString(STATISTICINFO, STATISTICINFO_NAME, id, &str);
00371         if(!ret && str != NULL) {
00372           strncpy(string, str, SPRINT_MAX_LEN);
00373           free(str);
00374         }
00375         *var_len = strlen(string);
00376         return (unsigned char *) string;
00377 
00378     case STATISTICDESCRIPTION:
00379         
00380         *string = 0;
00381         ret = getString(STATISTICINFO, STATISTICINFO_DESCRIPTION, id, &str);
00382         if(!ret && str != NULL) {
00383           strncpy(string, str, SPRINT_MAX_LEN);
00384           free(str);
00385         }
00386         *var_len = strlen(string);
00387         return (unsigned char *) string;
00388 
00389     case STATISTICUNIT:
00390         
00391         *string = 0;
00392         ret = getString(STATISTICINFO, STATISTICINFO_UNITS, id, &str);
00393         if(!ret && str != NULL) {
00394           strncpy(string, str, SPRINT_MAX_LEN);
00395           free(str);
00396         }
00397         *var_len = strlen(string);
00398         return (unsigned char *) string;
00399 
00400     case STATISTICTYPE:
00401         
00402         long_ret = 0;
00403         getInteger32(STATISTICINFO, STATISTICINFO_TYPE, id, &long_ret);
00404         return (unsigned char *) &long_ret;
00405 
00406     case STATISTICSIZE:
00407         
00408         long_ret = 0;
00409         getInteger32(STATISTICINFO, STATISTICINFO_SIZE, id, &long_ret);
00410         return (unsigned char *) &long_ret;
00411 
00412     case STATISTICSCALE:
00413         
00414         long_ret = 0;
00415         getInteger32(STATISTICINFO, STATISTICINFO_SCALE, id, &long_ret);
00416         return (unsigned char *) &long_ret;
00417 
00418     case STATISTICGAUGEUPPERBOUNDLOW:
00419         
00420         ulong_ret = 0;
00421         getUnsigned(STATISTICINFO, STATISTICINFO_GAUGEUPPERBOUND32, id, &ulong_ret);
00422         return (unsigned char *) &ulong_ret;
00423 
00424     case STATISTICGAUGEUPPERBOUNDHIGH:
00425         
00426         ulong_ret = 0;
00427         v64 = 0;
00428         getUnsigned64(STATISTICINFO, STATISTICINFO_GAUGEUPPERBOUND64, id, &v64);        ulong_ret = getHigh32(v64);
00429         return (unsigned char *) &ulong_ret;
00430 
00431     case STATISTICCOUNTERRESETVALUELOW:
00432         *write_method = write_statisticCounterResetValueLow;
00433         ulong_ret = 0;
00434         getUnsigned(STATISTICINFO, STATISTICINFO_COUNTERRESETVALUE32, id, &ulong_ret);
00435         return (unsigned char *) &ulong_ret;
00436 
00437     case STATISTICCOUNTERRESETVALUEHIGH:
00438         *write_method = write_statisticCounterResetValueHigh;
00439         ulong_ret = 0;
00440         v64 = 0;
00441         getUnsigned64(STATISTICINFO, STATISTICINFO_COUNTERRESETVALUE64, id, &v64);
00442         ulong_ret = getHigh32(v64);
00443         return (unsigned char *) &ulong_ret;
00444 
00445     case STATISTICCOUNTERRESET:
00446         *write_method = write_statisticCounterReset;
00447         long_ret = 0;
00448         return (unsigned char *) &long_ret;
00449 
00450 
00451     default:
00452       ERROR_MSG("");
00453   }
00454   return NULL;
00455 }
00456 
00457 
00458 /*
00459  * var_RMDataCapturePluginInfoTable():
00460  *   Handle this table separately from the scalar value case.
00461  *   The workings of this are basically the same as for var_RMDataCapturePluginInfoTable above.
00462  */
00463 unsigned char *
00464 var_RMDataCapturePluginInfoTable(struct variable *vp,
00465             oid     *name,
00466             size_t  *length,
00467             int     exact,
00468             size_t  *var_len,
00469             WriteMethod **write_method)
00470 {
00471 
00472 
00473   /* variables we may use later */
00474   size_t count;
00475   int ret, index;
00476   static unsigned char string[SPRINT_MAX_LEN];
00477   char * str;
00478 
00479   count = getCount(DATACAPTUREPLUGININFO);
00480 
00481   /* 
00482    * This assumes that the table is a 'simple' table.
00483    *    See the implementation documentation for the meaning of this.
00484    *    You will need to provide the correct value for the TABLE_SIZE parameter
00485    *
00486    * If this table does not meet the requirements for a simple table,
00487    *    you will need to provide the replacement code yourself.
00488    *    Mib2c is not smart enough to write this for you.
00489    *    Again, see the implementation documentation for what is required.
00490    */
00491   if (header_simple_table(vp,name,length,exact,var_len,write_method, count)
00492                                                 == MATCH_FAILED )
00493     return NULL;
00494 
00495 
00496   index = name[*length -1];
00497 
00498   /* 
00499    * this is where we do the value assignments for the mib results.
00500    */
00501   switch(vp->magic) {
00502 
00503 
00504     case PLUGINUUID:
00505 
00506         *string = 0;
00507         getUUIDString(DATACAPTUREPLUGININFO, DATACAPTUREPLUGININFO_UUID, index, string);
00508         *var_len = strlen(string);
00509         return (unsigned char *) string;
00510 
00511     case PLUGINNAME:
00512 
00513         *string = 0;
00514         ret = getString(DATACAPTUREPLUGININFO, DATACAPTUREPLUGININFO_NAME, index, &str);
00515         if(!ret && str != NULL) {
00516           strncpy(string, str, SPRINT_MAX_LEN);
00517           free(str);
00518         }
00519         *var_len = strlen(string);
00520         return (unsigned char *) string;
00521 
00522 
00523     default:
00524       ERROR_MSG("");
00525   }
00526   return NULL;
00527 }
00528 
00529 
00530 unsigned long 
00531 findStatisticID(oid         *name,
00532                 size_t      name_len)
00533 {
00534   unsigned long id, nid, subid, resid, statid, rid;
00535 
00536   id = 0;
00537   rid = 0;
00538   while(!getNextId(STATISTICINFO, id, &nid)) {
00539     id = nid;
00540 
00541     getUnsigned(STATISTICINFO, STATISTICINFO_SUBSYSTEMID, id, &subid);
00542     getUnsigned(STATISTICINFO, STATISTICINFO_RESOURCEID, id, &resid);
00543     getUnsigned(STATISTICINFO, STATISTICINFO_ID, id, &statid);
00544 
00545     if( subid == name[name_len - 3] &&
00546         resid == name[name_len - 2] &&
00547         statid == name[name_len - 1] ) {
00548       rid = id;
00549       break;
00550     }
00551   }
00552 
00553   return rid;
00554 }
00555 
00556 
00557 
00558 int
00559 write_statisticCounterResetValueLow(int      action,
00560             u_char   *var_val,
00561             u_char   var_val_type,
00562             size_t   var_val_len,
00563             u_char   *statP,
00564             oid      *name,
00565             size_t   name_len)
00566 {
00567   static unsigned long *ulong_ret;
00568   int size;
00569 
00570   static unsigned long oldVal;
00571   unsigned long id;
00572   int ret;
00573 
00574   id = findStatisticID(name, name_len);
00575   if(id == 0)
00576     return SNMP_ERR_NOSUCHNAME;
00577 
00578 
00579 
00580   switch ( action ) {
00581         case RESERVE1:
00582           if (var_val_type != ASN_UNSIGNED){
00583               fprintf(stderr, "write to statisticCounterResetValueLow not ASN_UNSIGNED\n");
00584               return SNMP_ERR_WRONGTYPE;
00585           }
00586           if (var_val_len > sizeof(ulong_ret)){
00587               fprintf(stderr,"write to statisticCounterResetValueLow: bad length\n");
00588               return SNMP_ERR_WRONGLENGTH;
00589           }
00590           break;
00591 
00592 
00593         case RESERVE2:
00594           size = var_val_len;
00595           ulong_ret = (unsigned long *) var_val;
00596 
00597           ret = getUnsigned(STATISTICINFO,  STATISTICINFO_COUNTERRESETVALUE32, id, &oldVal);
00598           if(ret)
00599             return SNMP_ERR_INCONSISTENTVALUE;
00600 
00601 
00602           break;
00603 
00604 
00605         case FREE:
00606              /* Release any resources that have been allocated */
00607           break;
00608 
00609 
00610         case ACTION:
00611              /* The variable has been stored in ulong_ret for
00612              you to use, and you have just been asked to do something with
00613              it.  Note that anything done here must be reversable in the UNDO case */
00614 
00615           ret = setUnsigned(STATISTICINFO,  STATISTICINFO_COUNTERRESETVALUE32, id, *ulong_ret);
00616           if(ret)
00617             return SNMP_ERR_INCONSISTENTVALUE;
00618 
00619           break;
00620 
00621 
00622         case UNDO:
00623              /* Back out any changes made in the ACTION case */
00624           setUnsigned(STATISTICINFO,  STATISTICINFO_COUNTERRESETVALUE32, id, oldVal);
00625           break;
00626 
00627 
00628         case COMMIT:
00629              /* Things are working well, so it's now safe to make the change
00630              permanently.  Make sure that anything done here can't fail! */
00631           break;
00632   }
00633   return SNMP_ERR_NOERROR;
00634 }
00635 
00636 
00637 
00638 
00639 int
00640 write_statisticCounterResetValueHigh(int      action,
00641             u_char   *var_val,
00642             u_char   var_val_type,
00643             size_t   var_val_len,
00644             u_char   *statP,
00645             oid      *name,
00646             size_t   name_len)
00647 {
00648   static unsigned long *ulong_ret;
00649   int size;
00650 
00651   static u_int64_t oldVal;
00652   unsigned long id;
00653   int ret;
00654   u_int64_t v64;
00655 
00656   id = findStatisticID(name, name_len);
00657   if(id == 0)
00658     return SNMP_ERR_NOSUCHNAME;
00659 
00660 
00661   switch ( action ) {
00662         case RESERVE1:
00663           if (var_val_type != ASN_UNSIGNED){
00664               fprintf(stderr, "write to statisticCounterResetValueHigh not ASN_UNSIGNED\n");
00665               return SNMP_ERR_WRONGTYPE;
00666           }
00667           if (var_val_len > sizeof(ulong_ret)){
00668               fprintf(stderr,"write to statisticCounterResetValueHigh: bad length\n");
00669               return SNMP_ERR_WRONGLENGTH;
00670           }
00671           break;
00672 
00673 
00674         case RESERVE2:
00675           size = var_val_len;
00676           ulong_ret = (unsigned long *) var_val;
00677 
00678           ret = getUnsigned64(STATISTICINFO,  STATISTICINFO_COUNTERRESETVALUE64, id, &oldVal);
00679           if(ret)
00680             return SNMP_ERR_INCONSISTENTVALUE;
00681 
00682 
00683           break;
00684 
00685 
00686         case FREE:
00687              /* Release any resources that have been allocated */
00688           break;
00689 
00690 
00691         case ACTION:
00692              /* The variable has been stored in ulong_ret for
00693              you to use, and you have just been asked to do something with
00694              it.  Note that anything done here must be reversable in the UNDO case */
00695           v64 = setHigh32(oldVal, *ulong_ret);
00696           ret = setUnsigned64(STATISTICINFO,  STATISTICINFO_COUNTERRESETVALUE64, id, v64);
00697           if(ret)
00698             return SNMP_ERR_INCONSISTENTVALUE;
00699 
00700           break;
00701 
00702 
00703         case UNDO:
00704              /* Back out any changes made in the ACTION case */
00705           setUnsigned64(STATISTICINFO,  STATISTICINFO_COUNTERRESETVALUE64, id, oldVal);
00706           break;
00707 
00708 
00709         case COMMIT:
00710              /* Things are working well, so it's now safe to make the change
00711              permanently.  Make sure that anything done here can't fail! */
00712           break;
00713   }
00714   return SNMP_ERR_NOERROR;
00715 }
00716 
00717 
00718 
00719 
00720 int
00721 write_statisticCounterReset(int      action,
00722             u_char   *var_val,
00723             u_char   var_val_type,
00724             size_t   var_val_len,
00725             u_char   *statP,
00726             oid      *name,
00727             size_t   name_len)
00728 {
00729   static long *long_ret;
00730   int size;
00731 
00732   unsigned long id;
00733   int ret;
00734 
00735   id = findStatisticID(name, name_len);
00736   if(id == 0)
00737     return SNMP_ERR_NOSUCHNAME;
00738 
00739 
00740   switch ( action ) {
00741         case RESERVE1:
00742           if (var_val_type != ASN_INTEGER){
00743               fprintf(stderr, "write to statisticCounterReset not ASN_INTEGER\n");
00744               return SNMP_ERR_WRONGTYPE;
00745           }
00746           if (var_val_len > sizeof(long_ret)){
00747               fprintf(stderr,"write to statisticCounterReset: bad length\n");
00748               return SNMP_ERR_WRONGLENGTH;
00749           }
00750           break;
00751 
00752 
00753         case RESERVE2:
00754           size = var_val_len;
00755           long_ret = (long *) var_val;
00756 
00757 
00758           break;
00759 
00760 
00761         case FREE:
00762              /* Release any resources that have been allocated */
00763           break;
00764 
00765 
00766         case ACTION:
00767              /* The variable has been stored in long_ret for
00768              you to use, and you have just been asked to do something with
00769              it.  Note that anything done here must be reversable in the UNDO case */
00770 
00771           ret = setInteger32(STATISTICINFO, STATISTICINFO_COUNTERRESET, id, 0);
00772           if(ret)
00773             return SNMP_ERR_INCONSISTENTVALUE;
00774 
00775           break;
00776 
00777 
00778         case UNDO:
00779              /* Back out any changes made in the ACTION case */
00780           break;
00781 
00782 
00783         case COMMIT:
00784              /* Things are working well, so it's now safe to make the change
00785              permanently.  Make sure that anything done here can't fail! */
00786           break;
00787   }
00788   return SNMP_ERR_NOERROR;
00789 }
00790 
00791 
00792 
00793 
00794 
00795 

Generated on Tue Sep 10 16:46:33 2002 for ResourceMonitorSNMPSubagent by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002