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

RMThresholdConfig.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 "RMThresholdConfig.h"
00032 
00033 #include <string.h>
00034 #include <ucd-snmp/util_funcs.h>
00035 #include "rmClient.h"
00036 #include "utility.h"
00037 
00038 
00039 
00040 /* 
00041  * RMThresholdConfig_variables_oid:
00042  *   this is the top level oid that we want to register under.  This
00043  *   is essentially a prefix, with the suffix appearing in the
00044  *   variable below.
00045  */
00046 
00047 
00048 oid RMThresholdConfig_variables_oid[] = { 1,3,6,1,4,1,343,2,15,1,2,2,2 };
00049 
00050 
00051 /* 
00052  * variable4 RMThresholdConfig_variables:
00053  *   this variable defines function callbacks and type return information 
00054  *   for the RMThresholdConfig mib section 
00055  */
00056 
00057 
00058 struct variable4 RMThresholdConfig_variables[] = {
00059 /*  magic number        , variable type , ro/rw , callback fn  , L, oidsuffix */
00060 #define   THRESHOLDCONFIGNEXTINDEX  1
00061   { THRESHOLDCONFIGNEXTINDEX, ASN_UNSIGNED  , RONLY , var_RMThresholdConfig, 1, { 1 } },
00062 #define   THRESHOLDTYPE         5
00063   { THRESHOLDTYPE       , ASN_INTEGER   , RWRITE, var_ThresholdConfigTable, 3, { 2,1,2 } },
00064 #define   THRESHOLDTESTCONDITION  6
00065   { THRESHOLDTESTCONDITION, ASN_INTEGER   , RWRITE, var_ThresholdConfigTable, 3, { 2,1,3 } },
00066 #define   THRESHOLDPRECONDITION  7
00067   { THRESHOLDPRECONDITION, ASN_INTEGER   , RWRITE, var_ThresholdConfigTable, 3, { 2,1,4 } },
00068 #define   THRESHOLDEVENTSEVERITY  9
00069   { THRESHOLDEVENTSEVERITY, ASN_INTEGER   , RWRITE, var_ThresholdConfigTable, 3, { 2,1,5 } },
00070 #define   THRESHOLDCANCELEVENTSEVERITY  10
00071   { THRESHOLDCANCELEVENTSEVERITY, ASN_INTEGER   , RWRITE, var_ThresholdConfigTable, 3, { 2,1,6 } },
00072 #define   THRESHOLDVALUELOW     11
00073   { THRESHOLDVALUELOW   , ASN_UNSIGNED  , RWRITE, var_ThresholdConfigTable, 3, { 2,1,7 } },
00074 #define   THRESHOLDVALUEHIGH    12
00075   { THRESHOLDVALUEHIGH  , ASN_UNSIGNED  , RWRITE, var_ThresholdConfigTable, 3, { 2,1,8 } },
00076 #define   THRESHOLDCONFIGREFCOUNT  13
00077   { THRESHOLDCONFIGREFCOUNT, ASN_INTEGER   , RONLY , var_ThresholdConfigTable, 3, { 2,1,9 } },
00078 #define   THRESHOLDCONFIGSTATUS  14
00079   { THRESHOLDCONFIGSTATUS, ASN_INTEGER   , RWRITE, var_ThresholdConfigTable, 3, { 2,1,10 } },
00080 
00081 };
00082 /*    (L = length of the oidsuffix) */
00083 
00084 
00085 /*
00086  * init_RMThresholdConfig():
00087  *   Initialization routine.  This is called when the agent starts up.
00088  *   At a minimum, registration of your variables should take place here.
00089  */
00090 void init_RMThresholdConfig(void) {
00091 
00092 
00093   /* register ourselves with the agent to handle our mib tree */
00094   REGISTER_MIB("RMThresholdConfig", RMThresholdConfig_variables, variable4,
00095                RMThresholdConfig_variables_oid);
00096 
00097 
00098   /* place any other initialization junk you need here */
00099 }
00100 
00101 
00102 /*
00103  * var_RMThresholdConfig():
00104  *   This function is called every time the agent gets a request for
00105  *   a scalar variable that might be found within your mib section
00106  *   registered above.  It is up to you to do the right thing and
00107  *   return the correct value.
00108  *     You should also correct the value of "var_len" if necessary.
00109  *
00110  *   Please see the documentation for more information about writing
00111  *   module extensions, and check out the examples in the examples
00112  *   and mibII directories.
00113  */
00114 unsigned char *
00115 var_RMThresholdConfig(struct variable *vp, 
00116                 oid     *name, 
00117                 size_t  *length, 
00118                 int     exact, 
00119                 size_t  *var_len, 
00120                 WriteMethod **write_method)
00121 {
00122 
00123 
00124   /* variables we may use later */
00125   static u_long ulong_ret;
00126   /*
00127   static long long_ret;
00128   static unsigned char string[SPRINT_MAX_LEN];
00129   static oid objid[MAX_OID_LEN];
00130   static struct counter64 c64;
00131   */
00132 
00133 
00134   if (header_generic(vp,name,length,exact,var_len,write_method)
00135                                   == MATCH_FAILED )
00136     return NULL;
00137 
00138 
00139   /* 
00140    * this is where we do the value assignments for the mib results.
00141    */
00142   switch(vp->magic) {
00143 
00144 
00145     case THRESHOLDCONFIGNEXTINDEX:
00146         
00147         ulong_ret = getNewId(THRESHOLDCONFIG);
00148         return (unsigned char *) &ulong_ret;
00149 
00150 
00151     default:
00152       ERROR_MSG("");
00153   }
00154   return NULL;
00155 }
00156 
00157 
00158 /*
00159  * var_ThresholdConfigTable():
00160  *   Handle this table separately from the scalar value case.
00161  *   The workings of this are basically the same as for var_RMThresholdConfig above.
00162  */
00163 unsigned char *
00164 var_ThresholdConfigTable(struct variable *vp,
00165             oid     *name,
00166             size_t  *length,
00167             int     exact,
00168             size_t  *var_len,
00169             WriteMethod **write_method)
00170 {
00171 
00172 
00173   /* variables we may use later */
00174   static long long_ret;
00175   static u_long ulong_ret;
00176   /*
00177   static unsigned char string[SPRINT_MAX_LEN];
00178   static oid objid[MAX_OID_LEN];
00179   static struct counter64 c64;
00180   */
00181 
00182   static u_int64_t v64;
00183   unsigned long id;
00184 
00185   id = header_MyGeneric(vp,name,length,exact,var_len,write_method, THRESHOLDCONFIG);
00186   if(id == 0) {
00187     switch(vp->magic) {
00188 
00189       case THRESHOLDTYPE:
00190           *write_method = write_thresholdType;
00191           break;
00192 
00193       case THRESHOLDTESTCONDITION:
00194           *write_method = write_thresholdTestCondition;
00195           break;
00196 
00197       case THRESHOLDPRECONDITION:
00198           *write_method = write_thresholdPreCondition;
00199           break;
00200 
00201       case THRESHOLDEVENTSEVERITY:
00202           *write_method = write_thresholdEventSeverity;
00203           break;
00204 
00205       case THRESHOLDCANCELEVENTSEVERITY:
00206           *write_method = write_thresholdCancelEventSeverity;
00207           break;
00208 
00209       case THRESHOLDVALUELOW:
00210           *write_method = write_thresholdValueLow;
00211           break;
00212 
00213       case THRESHOLDVALUEHIGH:
00214           *write_method = write_thresholdValueHigh;
00215           break;
00216 
00217       case THRESHOLDCONFIGSTATUS:
00218           *write_method = write_thresholdConfigStatus;
00219           break;
00220 
00221       default:
00222         ERROR_MSG("");
00223     }
00224     return NULL;
00225   }
00226 
00227 
00228   /* 
00229    * this is where we do the value assignments for the mib results.
00230    */
00231   switch(vp->magic) {
00232 
00233 
00234     case THRESHOLDTYPE:
00235         *write_method = write_thresholdType;
00236         long_ret = 0;
00237         getInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_TYPE, id, &long_ret);
00238         return (unsigned char *) &long_ret;
00239 
00240     case THRESHOLDTESTCONDITION:
00241         *write_method = write_thresholdTestCondition;
00242         long_ret = 0;
00243         getInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_TESTCONDITION, id, &long_ret);
00244         return (unsigned char *) &long_ret;
00245 
00246     case THRESHOLDPRECONDITION:
00247         *write_method = write_thresholdPreCondition;
00248         long_ret = 0;
00249         getInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_PRECONDITION, id, &long_ret);
00250         return (unsigned char *) &long_ret;
00251 
00252     case THRESHOLDEVENTSEVERITY:
00253         *write_method = write_thresholdEventSeverity;
00254         long_ret = 0;
00255         getInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_EVENTSEVERITY, id, &long_ret);
00256         return (unsigned char *) &long_ret;
00257 
00258     case THRESHOLDCANCELEVENTSEVERITY:
00259         *write_method = write_thresholdCancelEventSeverity;
00260         long_ret = 0;
00261         getInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_CANCELEVENTSEVERITY, id, &long_ret);
00262         return (unsigned char *) &long_ret;
00263 
00264     case THRESHOLDVALUELOW:
00265         *write_method = write_thresholdValueLow;
00266         ulong_ret = 0;
00267         getUnsigned(THRESHOLDCONFIG, THRESHOLDCONFIG_VALUE32, id, &ulong_ret);
00268         return (unsigned char *) &ulong_ret;
00269 
00270     case THRESHOLDVALUEHIGH:
00271         *write_method = write_thresholdValueHigh;
00272 
00273         v64 = 0;
00274         getUnsigned64(THRESHOLDCONFIG, THRESHOLDCONFIG_VALUE32, id, &v64);
00275         ulong_ret = getHigh32(v64);
00276         return (unsigned char *) &ulong_ret;
00277 
00278     case THRESHOLDCONFIGREFCOUNT:
00279         
00280         long_ret = 0;
00281         getInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_REFCOUNT, id, &long_ret);
00282         return (unsigned char *) &long_ret;
00283 
00284     case THRESHOLDCONFIGSTATUS:
00285         *write_method = write_thresholdConfigStatus;
00286         long_ret = 0;
00287         getInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_STATUS, id, &long_ret);
00288         return (unsigned char *) &long_ret;
00289 
00290 
00291     default:
00292       ERROR_MSG("");
00293   }
00294   return NULL;
00295 }
00296 
00297 
00298 
00299 
00300 int
00301 write_thresholdType(int      action,
00302             u_char   *var_val,
00303             u_char   var_val_type,
00304             size_t   var_val_len,
00305             u_char   *statP,
00306             oid      *name,
00307             size_t   name_len)
00308 {
00309   static long *long_ret;
00310   int size;
00311 
00312   int createNew, ret;
00313   unsigned long id;
00314   size_t prefix_len;
00315 
00316   static long oldVal;
00317 
00318   oid suffix[] = { 2, 1, 2 };
00319   createNew = 0;
00320   prefix_len = sizeof(RMThresholdConfig_variables_oid)/sizeof(oid);
00321 
00322   id = header_writeGeneric(name, name_len, RMThresholdConfig_variables_oid, prefix_len, suffix, 3, THRESHOLDCONFIG, &createNew);
00323 
00324   if(id == 0 || (createNew && action == ACTION))
00325     return SNMP_ERR_NOSUCHNAME;
00326 
00327   switch ( action ) {
00328         case RESERVE1:
00329           if (var_val_type != ASN_INTEGER){
00330               fprintf(stderr, "write to thresholdType not ASN_INTEGER\n");
00331               return SNMP_ERR_WRONGTYPE;
00332           }
00333           if (var_val_len > sizeof(long_ret)){
00334               fprintf(stderr,"write to thresholdType: bad length\n");
00335               return SNMP_ERR_WRONGLENGTH;
00336           }
00337           break;
00338 
00339 
00340         case RESERVE2:
00341           size = var_val_len;
00342           long_ret = (long *) var_val;
00343 
00344           if(!createNew) {
00345             ret = getInteger32(THRESHOLDCONFIG,  THRESHOLDCONFIG_TYPE, id, &oldVal);
00346             if(ret)
00347               return SNMP_ERR_INCONSISTENTVALUE;
00348           }
00349 
00350 
00351           break;
00352 
00353 
00354         case FREE:
00355              /* Release any resources that have been allocated */
00356           break;
00357 
00358 
00359         case ACTION:
00360              /* The variable has been stored in long_ret for
00361              you to use, and you have just been asked to do something with
00362              it.  Note that anything done here must be reversable in the UNDO case */
00363           ret = setInteger32(THRESHOLDCONFIG,  THRESHOLDCONFIG_TYPE, id, *long_ret);
00364           if(ret)
00365             return SNMP_ERR_INCONSISTENTVALUE;
00366 
00367           break;
00368 
00369 
00370         case UNDO:
00371              /* Back out any changes made in the ACTION case */
00372           setInteger32(THRESHOLDCONFIG,  THRESHOLDCONFIG_TYPE, id, oldVal);
00373           break;
00374 
00375 
00376         case COMMIT:
00377              /* Things are working well, so it's now safe to make the change
00378              permanently.  Make sure that anything done here can't fail! */
00379           break;
00380   }
00381   return SNMP_ERR_NOERROR;
00382 }
00383 
00384 
00385 
00386 
00387 int
00388 write_thresholdTestCondition(int      action,
00389             u_char   *var_val,
00390             u_char   var_val_type,
00391             size_t   var_val_len,
00392             u_char   *statP,
00393             oid      *name,
00394             size_t   name_len)
00395 {
00396   static long *long_ret;
00397   int size;
00398 
00399   int createNew, ret;
00400   unsigned long id;
00401   size_t prefix_len;
00402 
00403   static long oldVal;
00404 
00405   oid suffix[] = { 2, 1, 3 };
00406   createNew = 0;
00407   prefix_len = sizeof(RMThresholdConfig_variables_oid)/sizeof(oid);
00408 
00409   id = header_writeGeneric(name, name_len, RMThresholdConfig_variables_oid, prefix_len, suffix, 3, THRESHOLDCONFIG, &createNew);
00410 
00411   if(id == 0 || (createNew && action == ACTION))
00412     return SNMP_ERR_NOSUCHNAME;
00413 
00414 
00415   switch ( action ) {
00416         case RESERVE1:
00417           if (var_val_type != ASN_INTEGER){
00418               fprintf(stderr, "write to thresholdTestCondition not ASN_INTEGER\n");
00419               return SNMP_ERR_WRONGTYPE;
00420           }
00421           if (var_val_len > sizeof(long_ret)){
00422               fprintf(stderr,"write to thresholdTestCondition: bad length\n");
00423               return SNMP_ERR_WRONGLENGTH;
00424           }
00425           break;
00426 
00427 
00428         case RESERVE2:
00429           size = var_val_len;
00430           long_ret = (long *) var_val;
00431 
00432           if(!createNew) {
00433             ret = getInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_TESTCONDITION, id, &oldVal);
00434             if(ret)
00435               return SNMP_ERR_INCONSISTENTVALUE;
00436           }
00437 
00438 
00439           break;
00440 
00441 
00442         case FREE:
00443              /* Release any resources that have been allocated */
00444           break;
00445 
00446 
00447         case ACTION:
00448              /* The variable has been stored in long_ret for
00449              you to use, and you have just been asked to do something with
00450              it.  Note that anything done here must be reversable in the UNDO case */
00451           ret = setInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_TESTCONDITION, id, *long_ret);
00452           if(ret)
00453             return SNMP_ERR_INCONSISTENTVALUE;
00454 
00455           break;
00456 
00457 
00458         case UNDO:
00459              /* Back out any changes made in the ACTION case */
00460           setInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_TESTCONDITION, id, oldVal);
00461           break;
00462 
00463 
00464         case COMMIT:
00465              /* Things are working well, so it's now safe to make the change
00466              permanently.  Make sure that anything done here can't fail! */
00467           break;
00468   }
00469   return SNMP_ERR_NOERROR;
00470 }
00471 
00472 
00473 
00474 
00475 int
00476 write_thresholdPreCondition(int      action,
00477             u_char   *var_val,
00478             u_char   var_val_type,
00479             size_t   var_val_len,
00480             u_char   *statP,
00481             oid      *name,
00482             size_t   name_len)
00483 {
00484   static long *long_ret;
00485   int size;
00486 
00487   int createNew, ret;
00488   unsigned long id;
00489   size_t prefix_len;
00490 
00491   static long oldVal;
00492 
00493   oid suffix[] = { 2, 1, 4 };
00494   createNew = 0;
00495   prefix_len = sizeof(RMThresholdConfig_variables_oid)/sizeof(oid);
00496 
00497   id = header_writeGeneric(name, name_len, RMThresholdConfig_variables_oid, prefix_len, suffix, 3, THRESHOLDCONFIG, &createNew);
00498 
00499   if(id == 0 || (createNew && action == ACTION))
00500     return SNMP_ERR_NOSUCHNAME;
00501 
00502 
00503   switch ( action ) {
00504         case RESERVE1:
00505           if (var_val_type != ASN_INTEGER){
00506               fprintf(stderr, "write to thresholdPreCondition not ASN_INTEGER\n");
00507               return SNMP_ERR_WRONGTYPE;
00508           }
00509           if (var_val_len > sizeof(long_ret)){
00510               fprintf(stderr,"write to thresholdPreCondition: bad length\n");
00511               return SNMP_ERR_WRONGLENGTH;
00512           }
00513           break;
00514 
00515 
00516         case RESERVE2:
00517           size = var_val_len;
00518           long_ret = (long *) var_val;
00519 
00520           if(!createNew) {
00521             ret = getInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_PRECONDITION, id, &oldVal);
00522             if(ret)
00523               return SNMP_ERR_INCONSISTENTVALUE;
00524           }
00525 
00526 
00527           break;
00528 
00529 
00530         case FREE:
00531              /* Release any resources that have been allocated */
00532           break;
00533 
00534 
00535         case ACTION:
00536              /* The variable has been stored in long_ret for
00537              you to use, and you have just been asked to do something with
00538              it.  Note that anything done here must be reversable in the UNDO case */
00539           ret = setInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_PRECONDITION, id, *long_ret);
00540           if(ret)
00541             return SNMP_ERR_INCONSISTENTVALUE;
00542 
00543           break;
00544 
00545 
00546         case UNDO:
00547              /* Back out any changes made in the ACTION case */
00548           setInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_PRECONDITION, id, oldVal);
00549           break;
00550 
00551 
00552         case COMMIT:
00553              /* Things are working well, so it's now safe to make the change
00554              permanently.  Make sure that anything done here can't fail! */
00555           break;
00556   }
00557   return SNMP_ERR_NOERROR;
00558 }
00559 
00560 
00561 
00562 
00563 
00564 
00565 int
00566 write_thresholdEventSeverity(int      action,
00567             u_char   *var_val,
00568             u_char   var_val_type,
00569             size_t   var_val_len,
00570             u_char   *statP,
00571             oid      *name,
00572             size_t   name_len)
00573 {
00574   static long *long_ret;
00575   int size;
00576 
00577   int createNew, ret;
00578   unsigned long id;
00579   size_t prefix_len;
00580 
00581   static long oldVal;
00582 
00583   oid suffix[] = { 2, 1, 5 };
00584   createNew = 0;
00585   prefix_len = sizeof(RMThresholdConfig_variables_oid)/sizeof(oid);
00586 
00587   id = header_writeGeneric(name, name_len, RMThresholdConfig_variables_oid, prefix_len, suffix, 3, THRESHOLDCONFIG, &createNew);
00588 
00589   if(id == 0 || (createNew && action == ACTION))
00590     return SNMP_ERR_NOSUCHNAME;
00591 
00592 
00593   switch ( action ) {
00594         case RESERVE1:
00595           if (var_val_type != ASN_INTEGER){
00596               fprintf(stderr, "write to thresholdEventSeverity not ASN_INTEGER\n");
00597               return SNMP_ERR_WRONGTYPE;
00598           }
00599           if (var_val_len > sizeof(long_ret)){
00600               fprintf(stderr,"write to thresholdEventSeverity: bad length\n");
00601               return SNMP_ERR_WRONGLENGTH;
00602           }
00603           break;
00604 
00605 
00606         case RESERVE2:
00607           size = var_val_len;
00608           long_ret = (long *) var_val;
00609 
00610           if(!createNew) {
00611             ret = getInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_EVENTSEVERITY, id, &oldVal);
00612             if(ret)
00613               return SNMP_ERR_INCONSISTENTVALUE;
00614           }
00615 
00616 
00617           break;
00618 
00619 
00620         case FREE:
00621              /* Release any resources that have been allocated */
00622           break;
00623 
00624 
00625         case ACTION:
00626              /* The variable has been stored in long_ret for
00627              you to use, and you have just been asked to do something with
00628              it.  Note that anything done here must be reversable in the UNDO case */
00629           ret = setInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_EVENTSEVERITY, id, *long_ret);
00630           if(ret)
00631             return SNMP_ERR_INCONSISTENTVALUE;
00632 
00633           break;
00634 
00635 
00636         case UNDO:
00637              /* Back out any changes made in the ACTION case */
00638           setInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_EVENTSEVERITY, id, oldVal);
00639           break;
00640 
00641 
00642         case COMMIT:
00643              /* Things are working well, so it's now safe to make the change
00644              permanently.  Make sure that anything done here can't fail! */
00645           break;
00646   }
00647   return SNMP_ERR_NOERROR;
00648 }
00649 
00650 
00651 
00652 
00653 int
00654 write_thresholdCancelEventSeverity(int      action,
00655             u_char   *var_val,
00656             u_char   var_val_type,
00657             size_t   var_val_len,
00658             u_char   *statP,
00659             oid      *name,
00660             size_t   name_len)
00661 {
00662   static long *long_ret;
00663   int size;
00664 
00665   int createNew, ret;
00666   unsigned long id;
00667   size_t prefix_len;
00668 
00669   static long oldVal;
00670 
00671   oid suffix[] = { 2, 1, 6 };
00672   createNew = 0;
00673   prefix_len = sizeof(RMThresholdConfig_variables_oid)/sizeof(oid);
00674 
00675   id = header_writeGeneric(name, name_len, RMThresholdConfig_variables_oid, prefix_len, suffix, 3, THRESHOLDCONFIG, &createNew);
00676 
00677   if(id == 0 || (createNew && action == ACTION))
00678     return SNMP_ERR_NOSUCHNAME;
00679 
00680 
00681   switch ( action ) {
00682         case RESERVE1:
00683           if (var_val_type != ASN_INTEGER){
00684               fprintf(stderr, "write to thresholdCancelEventSeverity not ASN_INTEGER\n");
00685               return SNMP_ERR_WRONGTYPE;
00686           }
00687           if (var_val_len > sizeof(long_ret)){
00688               fprintf(stderr,"write to thresholdCancelEventSeverity: bad length\n");
00689               return SNMP_ERR_WRONGLENGTH;
00690           }
00691           break;
00692 
00693 
00694         case RESERVE2:
00695           size = var_val_len;
00696           long_ret = (long *) var_val;
00697 
00698           if(!createNew) {
00699             ret = getInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_CANCELEVENTSEVERITY, id, &oldVal);
00700             if(ret)
00701               return SNMP_ERR_INCONSISTENTVALUE;
00702           }
00703 
00704 
00705           break;
00706 
00707 
00708         case FREE:
00709              /* Release any resources that have been allocated */
00710           break;
00711 
00712 
00713         case ACTION:
00714              /* The variable has been stored in long_ret for
00715              you to use, and you have just been asked to do something with
00716              it.  Note that anything done here must be reversable in the UNDO case */
00717           ret = setInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_CANCELEVENTSEVERITY, id, *long_ret);
00718           if(ret)
00719             return SNMP_ERR_INCONSISTENTVALUE;
00720 
00721           break;
00722 
00723 
00724         case UNDO:
00725              /* Back out any changes made in the ACTION case */
00726           setInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_CANCELEVENTSEVERITY, id, oldVal);
00727           break;
00728 
00729 
00730         case COMMIT:
00731              /* Things are working well, so it's now safe to make the change
00732              permanently.  Make sure that anything done here can't fail! */
00733           break;
00734   }
00735   return SNMP_ERR_NOERROR;
00736 }
00737 
00738 
00739 
00740 
00741 int
00742 write_thresholdValueLow(int      action,
00743             u_char   *var_val,
00744             u_char   var_val_type,
00745             size_t   var_val_len,
00746             u_char   *statP,
00747             oid      *name,
00748             size_t   name_len)
00749 {
00750   static unsigned long *ulong_ret;
00751   int size;
00752 
00753   int createNew, ret;
00754   unsigned long id;
00755   size_t prefix_len;
00756 
00757   static unsigned long oldVal;
00758 
00759   oid suffix[] = { 2, 1, 7 };
00760   createNew = 0;
00761   prefix_len = sizeof(RMThresholdConfig_variables_oid)/sizeof(oid);
00762 
00763   id = header_writeGeneric(name, name_len, RMThresholdConfig_variables_oid, prefix_len, suffix, 3, THRESHOLDCONFIG, &createNew);
00764 
00765   if(id == 0 || (createNew && action == ACTION))
00766     return SNMP_ERR_NOSUCHNAME;
00767 
00768 
00769   switch ( action ) {
00770         case RESERVE1:
00771           if (var_val_type != ASN_UNSIGNED){
00772               fprintf(stderr, "write to thresholdValueLow not ASN_UNSIGNED\n");
00773               return SNMP_ERR_WRONGTYPE;
00774           }
00775           if (var_val_len > sizeof(ulong_ret)){
00776               fprintf(stderr,"write to thresholdValueLow: bad length\n");
00777               return SNMP_ERR_WRONGLENGTH;
00778           }
00779           break;
00780 
00781 
00782         case RESERVE2:
00783           size = var_val_len;
00784           ulong_ret = (unsigned long *) var_val;
00785 
00786           if(!createNew) {
00787             ret = getUnsigned(THRESHOLDCONFIG, THRESHOLDCONFIG_VALUE32, id, &oldVal);
00788             if(ret)
00789               return SNMP_ERR_INCONSISTENTVALUE;
00790           }
00791 
00792 
00793           break;
00794 
00795 
00796         case FREE:
00797              /* Release any resources that have been allocated */
00798           break;
00799 
00800 
00801         case ACTION:
00802              /* The variable has been stored in ulong_ret for
00803              you to use, and you have just been asked to do something with
00804              it.  Note that anything done here must be reversable in the UNDO case */
00805           ret = setUnsigned(THRESHOLDCONFIG, THRESHOLDCONFIG_VALUE32, id, *ulong_ret);
00806           if(ret)
00807             return SNMP_ERR_INCONSISTENTVALUE;
00808 
00809           break;
00810 
00811 
00812         case UNDO:
00813              /* Back out any changes made in the ACTION case */
00814           setUnsigned(THRESHOLDCONFIG, THRESHOLDCONFIG_VALUE32, id, oldVal);
00815           break;
00816 
00817 
00818         case COMMIT:
00819              /* Things are working well, so it's now safe to make the change
00820              permanently.  Make sure that anything done here can't fail! */
00821           break;
00822   }
00823   return SNMP_ERR_NOERROR;
00824 }
00825 
00826 
00827 
00828 
00829 int
00830 write_thresholdValueHigh(int      action,
00831             u_char   *var_val,
00832             u_char   var_val_type,
00833             size_t   var_val_len,
00834             u_char   *statP,
00835             oid      *name,
00836             size_t   name_len)
00837 {
00838   static unsigned long *ulong_ret;
00839   int size;
00840 
00841   int createNew, ret;
00842   unsigned long id;
00843   size_t prefix_len;
00844 
00845   static u_int64_t oldVal;
00846   u_int64_t v64;
00847 
00848   oid suffix[] = { 2, 1, 8 };
00849   createNew = 0;
00850   prefix_len = sizeof(RMThresholdConfig_variables_oid)/sizeof(oid);
00851 
00852   id = header_writeGeneric(name, name_len, RMThresholdConfig_variables_oid, prefix_len, suffix, 3, THRESHOLDCONFIG, &createNew);
00853 
00854   if(id == 0 || (createNew && action == ACTION))
00855     return SNMP_ERR_NOSUCHNAME;
00856 
00857 
00858   switch ( action ) {
00859         case RESERVE1:
00860           if (var_val_type != ASN_UNSIGNED){
00861               fprintf(stderr, "write to thresholdValueHigh not ASN_UNSIGNED\n");
00862               return SNMP_ERR_WRONGTYPE;
00863           }
00864           if (var_val_len > sizeof(ulong_ret)){
00865               fprintf(stderr,"write to thresholdValueHigh: bad length\n");
00866               return SNMP_ERR_WRONGLENGTH;
00867           }
00868           break;
00869 
00870 
00871         case RESERVE2:
00872           size = var_val_len;
00873           ulong_ret = (unsigned long *) var_val;
00874 
00875           v64 = 0;
00876 
00877           break;
00878 
00879 
00880         case FREE:
00881              /* Release any resources that have been allocated */
00882           break;
00883 
00884 
00885         case ACTION:
00886              /* The variable has been stored in ulong_ret for
00887              you to use, and you have just been asked to do something with
00888              it.  Note that anything done here must be reversable in the UNDO case */
00889 
00890           if(!createNew) {
00891             ret = getUnsigned64(THRESHOLDCONFIG, THRESHOLDCONFIG_VALUE64, id, &oldVal);
00892             if(ret)
00893               return SNMP_ERR_INCONSISTENTVALUE;
00894           }
00895 
00896           v64 = setHigh32(oldVal, *ulong_ret);
00897           ret = setUnsigned64(THRESHOLDCONFIG, THRESHOLDCONFIG_VALUE64, id, v64);
00898           if(ret)
00899             return SNMP_ERR_INCONSISTENTVALUE;
00900 
00901           break;
00902 
00903 
00904         case UNDO:
00905              /* Back out any changes made in the ACTION case */
00906           setUnsigned64(THRESHOLDCONFIG, THRESHOLDCONFIG_VALUE64, id, oldVal);
00907           break;
00908 
00909 
00910         case COMMIT:
00911              /* Things are working well, so it's now safe to make the change
00912              permanently.  Make sure that anything done here can't fail! */
00913           break;
00914   }
00915   return SNMP_ERR_NOERROR;
00916 }
00917 
00918 
00919 
00920 
00921 int
00922 write_thresholdConfigStatus(int      action,
00923             u_char   *var_val,
00924             u_char   var_val_type,
00925             size_t   var_val_len,
00926             u_char   *statP,
00927             oid      *name,
00928             size_t   name_len)
00929 {
00930   static long *long_ret;
00931   int size;
00932 
00933   int createNew, ret;
00934   unsigned long id;
00935   size_t prefix_len;
00936 
00937   static long oldStatus;
00938   static int rowCreated;
00939 
00940   oid suffix[] = { 2, 1, 10 };
00941   createNew = 0;
00942   prefix_len = sizeof(RMThresholdConfig_variables_oid)/sizeof(oid);
00943 
00944   id = header_writeGeneric(name, name_len, RMThresholdConfig_variables_oid, prefix_len, suffix, 3, THRESHOLDCONFIG, &createNew);
00945 
00946   if(action == COMMIT && *long_ret == DESTROY && id == 0)
00947     return SNMP_ERR_NOERROR;
00948 
00949   if(id == 0)
00950     return SNMP_ERR_NOSUCHNAME;
00951 
00952 
00953   switch ( action ) {
00954         case RESERVE1:
00955           if (var_val_type != ASN_INTEGER){
00956               fprintf(stderr, "write to thresholdConfigStatus not ASN_INTEGER\n");
00957               return SNMP_ERR_WRONGTYPE;
00958           }
00959           if (var_val_len > sizeof(long_ret)){
00960               fprintf(stderr,"write to thresholdConfigStatus: bad length\n");
00961               return SNMP_ERR_WRONGLENGTH;
00962           }
00963           break;
00964 
00965 
00966         case RESERVE2:
00967           size = var_val_len;
00968           long_ret = (long *) var_val;
00969 
00970           rowCreated = 0;
00971           oldStatus = 0;
00972           if (*long_ret < ACTIVE || *long_ret > DESTROY ||
00973                *long_ret == NOTREADY)
00974             return SNMP_ERR_INCONSISTENTVALUE;
00975 
00976           if(createNew &&
00977               (*long_ret != CREATEANDWAIT && *long_ret != CREATEANDGO))
00978             return SNMP_ERR_INCONSISTENTVALUE;
00979 
00980           if (*long_ret == NOTINSERVICE || *long_ret == ACTIVE) {
00981             ret = getInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_STATUS, id, &oldStatus);
00982             if(ret)
00983               return SNMP_ERR_INCONSISTENTVALUE;
00984           }
00985 
00986 
00987           break;
00988 
00989 
00990         case FREE:
00991              /* Release any resources that have been allocated */
00992           break;
00993 
00994 
00995         case ACTION:
00996              /* The variable has been stored in long_ret for
00997              you to use, and you have just been asked to do something with
00998              it.  Note that anything done here must be reversable in the UNDO case */
00999           if(*long_ret == CREATEANDWAIT || *long_ret == CREATEANDGO) {
01000             ret = newEntry(THRESHOLDCONFIG, id);
01001             if(ret)
01002               return SNMP_ERR_INCONSISTENTVALUE;
01003 
01004             rowCreated = 1;
01005           }
01006           else if (*long_ret == NOTINSERVICE || *long_ret == ACTIVE) {
01007             ret = setInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_STATUS, id, *long_ret);
01008             if(ret)
01009               return SNMP_ERR_INCONSISTENTVALUE;
01010           }
01011           else if(*long_ret == DESTROY) {
01012             ret = deleteEntry(THRESHOLDCONFIG, id);
01013             if(ret)
01014               return SNMP_ERR_INCONSISTENTVALUE;
01015           }
01016 
01017           break;
01018 
01019 
01020         case UNDO:
01021              /* Back out any changes made in the ACTION case */
01022           if(rowCreated) {
01023             deleteEntry(THRESHOLDCONFIG, id);
01024           }
01025           else if(*long_ret == NOTINSERVICE || *long_ret == ACTIVE) {
01026             if(oldStatus != 0)
01027               setInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_STATUS, id, oldStatus);
01028           }
01029           else if((*long_ret == DESTROY)) {
01030 
01031             // note: don't know how to do this yet. need to be fixed.
01032 
01033           }
01034 
01035           break;
01036 
01037 
01038         case COMMIT:
01039              /* Things are working well, so it's now safe to make the change
01040              permanently.  Make sure that anything done here can't fail! */
01041           if(*long_ret == CREATEANDGO) {
01042             ret = setInteger32(THRESHOLDCONFIG, THRESHOLDCONFIG_STATUS, id, ACTIVE);
01043             if(ret) {
01044               deleteEntry(THRESHOLDCONFIG, id);
01045               return SNMP_ERR_COMMITFAILED;
01046             }
01047           }
01048 
01049           break;
01050   }
01051   return SNMP_ERR_NOERROR;
01052 }
01053 
01054 
01055 
01056 
01057 
01058 

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