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

RMThresholdControl.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 
00007 #ifdef IN_UCD_SNMP_SOURCE
00008 /* If we're compiling this file inside the ucd-snmp source tree */
00009 
00010 
00011 /* This should always be included first before anything else */
00012 #include <config.h>
00013 
00014 
00015 /* minimal include directives */
00016 #include "mibincl.h"
00017 #include "util_funcs.h"
00018 
00019 
00020 #else /* !IN_UCD_SNMP_SOURCE */
00021 
00022 
00023 #include <ucd-snmp/ucd-snmp-config.h>
00024 #include <ucd-snmp/ucd-snmp-includes.h>
00025 #include <ucd-snmp/ucd-snmp-agent-includes.h>
00026 
00027 
00028 #endif /* !IN_UCD_SNMP_SOURCE */
00029 
00030 
00031 #include "RMThresholdControl.h"
00032 
00033 #include <string.h>
00034 #include <ucd-snmp/util_funcs.h>
00035 #include "utility.h"
00036 #include "rmClient.h"
00037 
00038 
00039 /* 
00040  * RMThresholdControl_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 RMThresholdControl_variables_oid[] = { 1,3,6,1,4,1,343,2,15,1,2,3,2 };
00048 
00049 
00050 /* 
00051  * variable4 RMThresholdControl_variables:
00052  *   this variable defines function callbacks and type return information 
00053  *   for the RMThresholdControl mib section 
00054  */
00055 
00056 
00057 struct variable4 RMThresholdControl_variables[] = {
00058 /*  magic number        , variable type , ro/rw , callback fn  , L, oidsuffix */
00059 #define   THRESHOLDCONTROLNEXTINDEX  1
00060   { THRESHOLDCONTROLNEXTINDEX, ASN_UNSIGNED  , RONLY , var_RMThresholdControl, 1, { 1 } },
00061 #define   THRESHOLDTOLERANCEVALUELOW  5
00062   { THRESHOLDTOLERANCEVALUELOW, ASN_UNSIGNED  , RWRITE, var_ThresholdControlTable, 3, { 2,1,2 } },
00063 #define   THRESHOLDTOLERANCEVALUEHIGH  6
00064   { THRESHOLDTOLERANCEVALUEHIGH, ASN_UNSIGNED  , RWRITE, var_ThresholdControlTable, 3, { 2,1,3 } },
00065 #define   THRESHOLDSAMPLETIMES  7
00066   { THRESHOLDSAMPLETIMES, ASN_UNSIGNED  , RWRITE, var_ThresholdControlTable, 3, { 2,1,4 } },
00067 #define   THRESHOLDLOGRATE      8
00068   { THRESHOLDLOGRATE    , ASN_TIMETICKS , RWRITE, var_ThresholdControlTable, 3, { 2,1,5 } },
00069 #define   THRESHOLDCONTROLREFCOUNT  9
00070   { THRESHOLDCONTROLREFCOUNT, ASN_INTEGER   , RONLY , var_ThresholdControlTable, 3, { 2,1,6 } },
00071 #define   THRESHOLDCONTROLSTATUS  10
00072   { THRESHOLDCONTROLSTATUS, ASN_INTEGER   , RWRITE, var_ThresholdControlTable, 3, { 2,1,7 } },
00073 
00074 };
00075 /*    (L = length of the oidsuffix) */
00076 
00077 
00078 /*
00079  * init_RMThresholdControl():
00080  *   Initialization routine.  This is called when the agent starts up.
00081  *   At a minimum, registration of your variables should take place here.
00082  */
00083 void init_RMThresholdControl(void) {
00084 
00085 
00086   /* register ourselves with the agent to handle our mib tree */
00087   REGISTER_MIB("RMThresholdControl", RMThresholdControl_variables, variable4,
00088                RMThresholdControl_variables_oid);
00089 
00090 
00091   /* place any other initialization junk you need here */
00092 }
00093 
00094 
00095 /*
00096  * var_RMThresholdControl():
00097  *   This function is called every time the agent gets a request for
00098  *   a scalar variable that might be found within your mib section
00099  *   registered above.  It is up to you to do the right thing and
00100  *   return the correct value.
00101  *     You should also correct the value of "var_len" if necessary.
00102  *
00103  *   Please see the documentation for more information about writing
00104  *   module extensions, and check out the examples in the examples
00105  *   and mibII directories.
00106  */
00107 unsigned char *
00108 var_RMThresholdControl(struct variable *vp, 
00109                 oid     *name, 
00110                 size_t  *length, 
00111                 int     exact, 
00112                 size_t  *var_len, 
00113                 WriteMethod **write_method)
00114 {
00115 
00116 
00117   /* variables we may use later */
00118   static u_long ulong_ret;
00119 
00120   /*
00121   static long long_ret;
00122   static unsigned char string[SPRINT_MAX_LEN];
00123   static oid objid[MAX_OID_LEN];
00124   static struct counter64 c64;
00125   */
00126 
00127 
00128   if (header_generic(vp,name,length,exact,var_len,write_method)
00129                                   == MATCH_FAILED )
00130     return NULL;
00131 
00132 
00133   /* 
00134    * this is where we do the value assignments for the mib results.
00135    */
00136   switch(vp->magic) {
00137 
00138 
00139     case THRESHOLDCONTROLNEXTINDEX:
00140         
00141         ulong_ret = getNewId(THRESHOLDCONTROL);
00142         return (unsigned char *) &ulong_ret;
00143 
00144 
00145     default:
00146       ERROR_MSG("");
00147   }
00148   return NULL;
00149 }
00150 
00151 
00152 /*
00153  * var_ThresholdControlTable():
00154  *   Handle this table separately from the scalar value case.
00155  *   The workings of this are basically the same as for var_RMThresholdControl above.
00156  */
00157 unsigned char *
00158 var_ThresholdControlTable(struct variable *vp,
00159             oid     *name,
00160             size_t  *length,
00161             int     exact,
00162             size_t  *var_len,
00163             WriteMethod **write_method)
00164 {
00165 
00166 
00167   /* variables we may use later */
00168   static long long_ret;
00169   static u_long ulong_ret;
00170   /*
00171   static unsigned char string[SPRINT_MAX_LEN];
00172   static oid objid[MAX_OID_LEN];
00173   static struct counter64 c64;
00174   */
00175 
00176 
00177   static u_int64_t v64;
00178   unsigned long id;
00179 
00180   id = header_MyGeneric(vp,name,length,exact,var_len,write_method, THRESHOLDCONTROL);
00181   if(id == 0) {
00182   switch(vp->magic) {
00183 
00184 
00185       case THRESHOLDTOLERANCEVALUELOW:
00186           *write_method = write_thresholdToleranceValueLow;
00187           break;
00188 
00189       case THRESHOLDTOLERANCEVALUEHIGH:
00190           *write_method = write_thresholdToleranceValueHigh;
00191           break;
00192 
00193       case THRESHOLDSAMPLETIMES:
00194           *write_method = write_thresholdSampleTimes;
00195           break;
00196 
00197       case THRESHOLDLOGRATE:
00198           *write_method = write_thresholdLogRate;
00199           break;
00200 
00201       case THRESHOLDCONTROLSTATUS:
00202           *write_method = write_thresholdControlStatus;
00203           break;
00204 
00205       default:
00206         ERROR_MSG("");
00207     }
00208 
00209     return NULL;
00210   }
00211 
00212 
00213   /* 
00214    * this is where we do the value assignments for the mib results.
00215    */
00216   switch(vp->magic) {
00217 
00218 
00219     case THRESHOLDTOLERANCEVALUELOW:
00220         *write_method = write_thresholdToleranceValueLow;
00221         ulong_ret = 0;
00222         getUnsigned(THRESHOLDCONTROL, THRESHOLDCONTROL_TOLERANCE32, id, &ulong_ret);
00223         return (unsigned char *) &ulong_ret;
00224 
00225     case THRESHOLDTOLERANCEVALUEHIGH:
00226         *write_method = write_thresholdToleranceValueHigh;
00227         v64 = 0;
00228         getUnsigned64(THRESHOLDCONTROL, THRESHOLDCONTROL_TOLERANCE64, id, &v64);
00229         ulong_ret = getHigh32(v64);
00230 
00231         return (unsigned char *) &ulong_ret;
00232 
00233     case THRESHOLDSAMPLETIMES:
00234         *write_method = write_thresholdSampleTimes;
00235         ulong_ret = 0;
00236         getUnsigned(THRESHOLDCONTROL,  THRESHOLDCONTROL_SAMPLETIME, id, &ulong_ret);
00237         return (unsigned char *) &ulong_ret;
00238 
00239     case THRESHOLDLOGRATE:
00240         *write_method = write_thresholdLogRate;
00241         ulong_ret = 0;
00242         getUnsigned(THRESHOLDCONTROL,  THRESHOLDCONTROL_LOGRATE, id, &ulong_ret);
00243         long_ret = ulong_ret * 100;
00244         return (unsigned char *) &long_ret;
00245 
00246     case THRESHOLDCONTROLREFCOUNT:
00247         
00248         long_ret = 0;
00249         getInteger32(THRESHOLDCONTROL, THRESHOLDCONTROL_REFCOUNT, id, &long_ret);
00250         return (unsigned char *) &long_ret;
00251 
00252     case THRESHOLDCONTROLSTATUS:
00253         *write_method = write_thresholdControlStatus;
00254         long_ret = 0;
00255         getInteger32(THRESHOLDCONTROL, THRESHOLDCONTROL_STATUS, id, &long_ret);
00256         return (unsigned char *) &long_ret;
00257 
00258 
00259     default:
00260       ERROR_MSG("");
00261   }
00262   return NULL;
00263 }
00264 
00265 
00266 
00267 
00268 int
00269 write_thresholdToleranceValueLow(int      action,
00270             u_char   *var_val,
00271             u_char   var_val_type,
00272             size_t   var_val_len,
00273             u_char   *statP,
00274             oid      *name,
00275             size_t   name_len)
00276 {
00277   static unsigned long *ulong_ret;
00278   int size;
00279 
00280   int createNew, ret;
00281   unsigned long id;
00282   size_t prefix_len;
00283 
00284   static unsigned long oldVal;
00285 
00286   oid suffix[] = { 2, 1, 2 };
00287   createNew = 0;
00288   prefix_len = sizeof(RMThresholdControl_variables_oid)/sizeof(oid);
00289 
00290   id = header_writeGeneric(name, name_len, RMThresholdControl_variables_oid, prefix_len, suffix, 3, THRESHOLDCONTROL, &createNew);
00291 
00292   if(id == 0 || (createNew && action == ACTION))
00293     return SNMP_ERR_NOSUCHNAME;
00294 
00295 
00296   switch ( action ) {
00297         case RESERVE1:
00298           if (var_val_type != ASN_UNSIGNED){
00299               fprintf(stderr, "write to thresholdToleranceValueLow not ASN_UNSIGNED\n");
00300               return SNMP_ERR_WRONGTYPE;
00301           }
00302           if (var_val_len > sizeof(ulong_ret)){
00303               fprintf(stderr,"write to thresholdToleranceValueLow: bad length\n");
00304               return SNMP_ERR_WRONGLENGTH;
00305           }
00306           break;
00307 
00308 
00309         case RESERVE2:
00310           size = var_val_len;
00311           ulong_ret = (unsigned long *) var_val;
00312 
00313           if(!createNew) {
00314             ret = getUnsigned(THRESHOLDCONTROL, THRESHOLDCONTROL_TOLERANCE32, id, &oldVal);
00315             if(ret)
00316               return SNMP_ERR_INCONSISTENTVALUE;
00317           }
00318 
00319 
00320           break;
00321 
00322 
00323         case FREE:
00324              /* Release any resources that have been allocated */
00325           break;
00326 
00327 
00328         case ACTION:
00329              /* The variable has been stored in ulong_ret for
00330              you to use, and you have just been asked to do something with
00331              it.  Note that anything done here must be reversable in the UNDO case */
00332           ret = setUnsigned(THRESHOLDCONTROL, THRESHOLDCONTROL_TOLERANCE32, id, *ulong_ret);
00333           if(ret)
00334             return SNMP_ERR_INCONSISTENTVALUE;
00335 
00336           break;
00337 
00338 
00339         case UNDO:
00340              /* Back out any changes made in the ACTION case */
00341           setUnsigned(THRESHOLDCONTROL, THRESHOLDCONTROL_TOLERANCE32, id, oldVal);
00342           break;
00343 
00344 
00345         case COMMIT:
00346              /* Things are working well, so it's now safe to make the change
00347              permanently.  Make sure that anything done here can't fail! */
00348           break;
00349   }
00350   return SNMP_ERR_NOERROR;
00351 }
00352 
00353 
00354 
00355 
00356 int
00357 write_thresholdToleranceValueHigh(int      action,
00358             u_char   *var_val,
00359             u_char   var_val_type,
00360             size_t   var_val_len,
00361             u_char   *statP,
00362             oid      *name,
00363             size_t   name_len)
00364 {
00365   static unsigned long *ulong_ret;
00366   int size;
00367 
00368   int createNew, ret;
00369   unsigned long id;
00370   size_t prefix_len;
00371 
00372   static u_int64_t oldVal;
00373   u_int64_t v64;
00374 
00375   oid suffix[] = { 2, 1, 3 };
00376   createNew = 0;
00377   prefix_len = sizeof(RMThresholdControl_variables_oid)/sizeof(oid);
00378 
00379   id = header_writeGeneric(name, name_len, RMThresholdControl_variables_oid, prefix_len, suffix, 3, THRESHOLDCONTROL, &createNew);
00380 
00381   if(id == 0 || (createNew && action == ACTION))
00382     return SNMP_ERR_NOSUCHNAME;
00383 
00384 
00385   switch ( action ) {
00386         case RESERVE1:
00387           if (var_val_type != ASN_UNSIGNED){
00388               fprintf(stderr, "write to thresholdToleranceValueHigh not ASN_UNSIGNED\n");
00389               return SNMP_ERR_WRONGTYPE;
00390           }
00391           if (var_val_len > sizeof(ulong_ret)){
00392               fprintf(stderr,"write to thresholdToleranceValueHigh: bad length\n");
00393               return SNMP_ERR_WRONGLENGTH;
00394           }
00395           break;
00396 
00397 
00398         case RESERVE2:
00399           size = var_val_len;
00400           ulong_ret = (unsigned long *) var_val;
00401 
00402           v64 = 0;
00403 
00404           break;
00405 
00406 
00407         case FREE:
00408              /* Release any resources that have been allocated */
00409           break;
00410 
00411 
00412         case ACTION:
00413              /* The variable has been stored in ulong_ret for
00414              you to use, and you have just been asked to do something with
00415              it.  Note that anything done here must be reversable in the UNDO case */
00416           if(!createNew) {
00417             ret = getUnsigned64(THRESHOLDCONTROL, THRESHOLDCONTROL_TOLERANCE64, id, &oldVal);
00418             if(ret)
00419               return SNMP_ERR_INCONSISTENTVALUE;
00420           }
00421 
00422           v64 = setHigh32(oldVal, *ulong_ret);
00423           ret = setUnsigned64(THRESHOLDCONTROL, THRESHOLDCONTROL_TOLERANCE64, id, v64);
00424           if(ret)
00425             return SNMP_ERR_INCONSISTENTVALUE;
00426 
00427           break;
00428 
00429 
00430         case UNDO:
00431              /* Back out any changes made in the ACTION case */
00432           setUnsigned64(THRESHOLDCONTROL, THRESHOLDCONTROL_TOLERANCE64, id, oldVal);
00433           break;
00434 
00435 
00436         case COMMIT:
00437              /* Things are working well, so it's now safe to make the change
00438              permanently.  Make sure that anything done here can't fail! */
00439           break;
00440   }
00441   return SNMP_ERR_NOERROR;
00442 }
00443 
00444 
00445 
00446 
00447 int
00448 write_thresholdSampleTimes(int      action,
00449             u_char   *var_val,
00450             u_char   var_val_type,
00451             size_t   var_val_len,
00452             u_char   *statP,
00453             oid      *name,
00454             size_t   name_len)
00455 {
00456   static unsigned long *ulong_ret;
00457   int size;
00458 
00459   int createNew, ret;
00460   unsigned long id;
00461   size_t prefix_len;
00462 
00463   static unsigned long oldVal;
00464 
00465   oid suffix[] = { 2, 1, 4 };
00466   createNew = 0;
00467   prefix_len = sizeof(RMThresholdControl_variables_oid)/sizeof(oid);
00468 
00469   id = header_writeGeneric(name, name_len, RMThresholdControl_variables_oid, prefix_len, suffix, 3, THRESHOLDCONTROL, &createNew);
00470 
00471   if(id == 0 || (createNew && action == ACTION))
00472     return SNMP_ERR_NOSUCHNAME;
00473 
00474 
00475   switch ( action ) {
00476         case RESERVE1:
00477           if (var_val_type != ASN_UNSIGNED){
00478               fprintf(stderr, "write to thresholdSampleTimes not ASN_UNSIGNED\n");
00479               return SNMP_ERR_WRONGTYPE;
00480           }
00481           if (var_val_len > sizeof(ulong_ret)){
00482               fprintf(stderr,"write to thresholdSampleTimes: bad length\n");
00483               return SNMP_ERR_WRONGLENGTH;
00484           }
00485           break;
00486 
00487 
00488         case RESERVE2:
00489           size = var_val_len;
00490           ulong_ret = (unsigned long *) var_val;
00491 
00492           if(!createNew) {
00493             ret = getUnsigned(THRESHOLDCONTROL, THRESHOLDCONTROL_SAMPLETIME, id, &oldVal);
00494             if(ret)
00495               return SNMP_ERR_INCONSISTENTVALUE;
00496           }
00497 
00498 
00499           break;
00500 
00501 
00502         case FREE:
00503              /* Release any resources that have been allocated */
00504           break;
00505 
00506 
00507         case ACTION:
00508              /* The variable has been stored in ulong_ret for
00509              you to use, and you have just been asked to do something with
00510              it.  Note that anything done here must be reversable in the UNDO case */
00511           ret = setUnsigned(THRESHOLDCONTROL, THRESHOLDCONTROL_SAMPLETIME, id, *ulong_ret);
00512           if(ret)
00513             return SNMP_ERR_INCONSISTENTVALUE;
00514 
00515           break;
00516 
00517 
00518         case UNDO:
00519              /* Back out any changes made in the ACTION case */
00520           setUnsigned(THRESHOLDCONTROL, THRESHOLDCONTROL_SAMPLETIME, id, oldVal);
00521           break;
00522 
00523 
00524         case COMMIT:
00525              /* Things are working well, so it's now safe to make the change
00526              permanently.  Make sure that anything done here can't fail! */
00527           break;
00528   }
00529   return SNMP_ERR_NOERROR;
00530 }
00531 
00532 
00533 
00534 
00535 int
00536 write_thresholdLogRate(int      action,
00537             u_char   *var_val,
00538             u_char   var_val_type,
00539             size_t   var_val_len,
00540             u_char   *statP,
00541             oid      *name,
00542             size_t   name_len)
00543 {
00544   static long *long_ret;
00545   int size;
00546 
00547   int createNew, ret;
00548   unsigned long id;
00549   size_t prefix_len;
00550 
00551   static unsigned long oldVal;
00552 
00553   oid suffix[] = { 2, 1, 5 };
00554   createNew = 0;
00555   prefix_len = sizeof(RMThresholdControl_variables_oid)/sizeof(oid);
00556 
00557   id = header_writeGeneric(name, name_len, RMThresholdControl_variables_oid, prefix_len, suffix, 3, THRESHOLDCONTROL, &createNew);
00558 
00559   if(id == 0 || (createNew && action == ACTION))
00560     return SNMP_ERR_NOSUCHNAME;
00561 
00562 
00563   switch ( action ) {
00564         case RESERVE1:
00565           if (var_val_type != ASN_TIMETICKS){
00566               fprintf(stderr, "write to thresholdLogRate not ASN_TIMETICKS\n");
00567               return SNMP_ERR_WRONGTYPE;
00568           }
00569           if (var_val_len > sizeof(long_ret)){
00570               fprintf(stderr,"write to thresholdLogRate: bad length\n");
00571               return SNMP_ERR_WRONGLENGTH;
00572           }
00573           break;
00574 
00575 
00576         case RESERVE2:
00577           size = var_val_len;
00578           long_ret = (long *) var_val;
00579 
00580           if(!createNew) {
00581             ret = getUnsigned(THRESHOLDCONTROL, THRESHOLDCONTROL_LOGRATE, id, &oldVal);
00582             if(ret)
00583               return SNMP_ERR_INCONSISTENTVALUE;
00584           }
00585 
00586 
00587           break;
00588 
00589 
00590         case FREE:
00591              /* Release any resources that have been allocated */
00592           break;
00593 
00594 
00595         case ACTION:
00596              /* The variable has been stored in long_ret for
00597              you to use, and you have just been asked to do something with
00598              it.  Note that anything done here must be reversable in the UNDO case */
00599           ret = setUnsigned(THRESHOLDCONTROL, THRESHOLDCONTROL_LOGRATE, id, ( (unsigned long) *long_ret )/ 100);
00600           if(ret)
00601             return SNMP_ERR_INCONSISTENTVALUE;
00602 
00603           break;
00604 
00605 
00606         case UNDO:
00607              /* Back out any changes made in the ACTION case */
00608           setUnsigned(THRESHOLDCONTROL, THRESHOLDCONTROL_LOGRATE, id, oldVal);
00609           break;
00610 
00611 
00612         case COMMIT:
00613              /* Things are working well, so it's now safe to make the change
00614              permanently.  Make sure that anything done here can't fail! */
00615           break;
00616   }
00617   return SNMP_ERR_NOERROR;
00618 }
00619 
00620 
00621 
00622 
00623 int
00624 write_thresholdControlStatus(int      action,
00625             u_char   *var_val,
00626             u_char   var_val_type,
00627             size_t   var_val_len,
00628             u_char   *statP,
00629             oid      *name,
00630             size_t   name_len)
00631 {
00632   static long *long_ret;
00633   int size;
00634 
00635   int createNew, ret;
00636   unsigned long id;
00637   size_t prefix_len;
00638 
00639   static long oldStatus;
00640   static int rowCreated;
00641 
00642   oid suffix[] = { 2, 1, 7 };
00643   createNew = 0;
00644   prefix_len = sizeof(RMThresholdControl_variables_oid)/sizeof(oid);
00645 
00646   id = header_writeGeneric(name, name_len, RMThresholdControl_variables_oid, prefix_len, suffix, 3, THRESHOLDCONTROL, &createNew);
00647 
00648   if(action == COMMIT && *long_ret == DESTROY && id ==0)
00649     return SNMP_ERR_NOERROR;
00650 
00651   if(id == 0)
00652     return SNMP_ERR_NOSUCHNAME;
00653 
00654 
00655   switch ( action ) {
00656         case RESERVE1:
00657           if (var_val_type != ASN_INTEGER){
00658               fprintf(stderr, "write to thresholdControlStatus not ASN_INTEGER\n");
00659               return SNMP_ERR_WRONGTYPE;
00660           }
00661           if (var_val_len > sizeof(long_ret)){
00662               fprintf(stderr,"write to thresholdControlStatus: bad length\n");
00663               return SNMP_ERR_WRONGLENGTH;
00664           }
00665           break;
00666 
00667 
00668         case RESERVE2:
00669           size = var_val_len;
00670           long_ret = (long *) var_val;
00671 
00672           rowCreated = 0;
00673           oldStatus = 0;
00674           if (*long_ret < ACTIVE || *long_ret > DESTROY ||
00675                *long_ret == NOTREADY)
00676             return SNMP_ERR_INCONSISTENTVALUE;
00677 
00678           if(createNew &&
00679               (*long_ret != CREATEANDWAIT && *long_ret != CREATEANDGO))
00680             return SNMP_ERR_INCONSISTENTVALUE;
00681 
00682           if (*long_ret == NOTINSERVICE || *long_ret == ACTIVE) {
00683             ret = getInteger32(THRESHOLDCONTROL, THRESHOLDCONTROL_STATUS, id, &oldStatus);
00684             if(ret)
00685               return SNMP_ERR_INCONSISTENTVALUE;
00686           }
00687 
00688 
00689           break;
00690 
00691 
00692         case FREE:
00693              /* Release any resources that have been allocated */
00694           break;
00695 
00696 
00697         case ACTION:
00698              /* The variable has been stored in long_ret for
00699              you to use, and you have just been asked to do something with
00700              it.  Note that anything done here must be reversable in the UNDO case */
00701           if(*long_ret == CREATEANDWAIT || *long_ret == CREATEANDGO) {
00702             ret = newEntry(THRESHOLDCONTROL, id);
00703             if(ret)
00704               return SNMP_ERR_INCONSISTENTVALUE;
00705 
00706             rowCreated = 1;
00707           }
00708           else if (*long_ret == NOTINSERVICE || *long_ret == ACTIVE) {
00709             ret = setInteger32(THRESHOLDCONTROL, THRESHOLDCONTROL_STATUS, id, *long_ret);
00710             if(ret)
00711               return SNMP_ERR_INCONSISTENTVALUE;
00712           }
00713           else if(*long_ret == DESTROY) {
00714             ret = deleteEntry(THRESHOLDCONTROL, id);
00715             if(ret)
00716               return SNMP_ERR_INCONSISTENTVALUE;
00717           }
00718           break;
00719 
00720 
00721         case UNDO:
00722              /* Back out any changes made in the ACTION case */
00723           if(rowCreated) {
00724             deleteEntry(THRESHOLDCONTROL, id);
00725           }
00726           else if(*long_ret == NOTINSERVICE || *long_ret == ACTIVE) {
00727             if(oldStatus != 0)
00728               setInteger32(THRESHOLDCONTROL, THRESHOLDCONTROL_STATUS, id, oldStatus);
00729           }
00730           else if((*long_ret == DESTROY)) {
00731 
00732             // note: don't know how to do this yet. need to be fixed.
00733 
00734           }
00735           break;
00736 
00737 
00738         case COMMIT:
00739              /* Things are working well, so it's now safe to make the change
00740              permanently.  Make sure that anything done here can't fail! */
00741           if(*long_ret == CREATEANDGO) {
00742             ret = setInteger32(THRESHOLDCONTROL, THRESHOLDCONTROL_STATUS, id, ACTIVE);
00743             if(ret) {
00744               deleteEntry(THRESHOLDCONTROL, id);
00745               return SNMP_ERR_COMMITFAILED;
00746             }
00747           }
00748           break;
00749   }
00750   return SNMP_ERR_NOERROR;
00751 }
00752 
00753 
00754 
00755 
00756 
00757 

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