00001
00002
00003
00004 #include <netinet/in.h>
00005
00006 #ifdef IN_UCD_SNMP_SOURCE
00007
00008
00009
00010
00011 #include <config.h>
00012
00013
00014
00015 #include "mibincl.h"
00016 #include "util_funcs.h"
00017
00018
00019 #else
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
00028
00029
00030 #include "RMGenericConfig.h"
00031
00032 #include <string.h>
00033 #include <ucd-snmp/util_funcs.h>
00034 #include "rmClient.h"
00035 #include "utility.h"
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 oid RMGenericConfig_variables_oid[] = { 1,3,6,1,4,1,343,2,15,1,2,2,1 };
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 struct variable4 RMGenericConfig_variables[] = {
00057
00058 #define GENERICCONFIGNEXTINDEX 1
00059 { GENERICCONFIGNEXTINDEX, ASN_UNSIGNED , RONLY , var_RMGenericConfig, 1, { 1 } },
00060 #define GENERICSUBSYSTEMID 5
00061 { GENERICSUBSYSTEMID , ASN_UNSIGNED , RWRITE, var_GenericConfigTable, 3, { 2,1,2 } },
00062 #define GENERICRESOURCEID 6
00063 { GENERICRESOURCEID , ASN_UNSIGNED , RWRITE, var_GenericConfigTable, 3, { 2,1,3 } },
00064 #define GENERICSTATISTICID 7
00065 { GENERICSTATISTICID , ASN_UNSIGNED , RWRITE, var_GenericConfigTable, 3, { 2,1,4 } },
00066 #define GENERICCONFIGMONITORTYPE 8
00067 { GENERICCONFIGMONITORTYPE, ASN_INTEGER , RWRITE, var_GenericConfigTable, 3, { 2,1,5 } },
00068 #define GENERICSTATISTICTRANSFORM 9
00069 { GENERICSTATISTICTRANSFORM , ASN_INTEGER , RWRITE, var_GenericConfigTable, 3, { 2,1,6 } },
00070 #define GENERICTHRESHOLDCONFIGINDEX 10
00071 { GENERICTHRESHOLDCONFIGINDEX, ASN_UNSIGNED , RWRITE, var_GenericConfigTable, 3, { 2,1,7 } },
00072 #define GENERICWATERMARKCONFIGINDEX 11
00073 { GENERICWATERMARKCONFIGINDEX, ASN_UNSIGNED , RWRITE, var_GenericConfigTable, 3, { 2,1,8 } },
00074 #define GENERICLEAKYBUCKETCONFIGINDEX 12
00075 { GENERICLEAKYBUCKETCONFIGINDEX, ASN_UNSIGNED , RWRITE, var_GenericConfigTable, 3, { 2,1,9 } },
00076 #define GENERICCONFIGREFCOUNT 13
00077 { GENERICCONFIGREFCOUNT, ASN_INTEGER , RONLY , var_GenericConfigTable, 3, { 2,1,10 } },
00078 #define GENERICCONFIGSTATUS 14
00079 { GENERICCONFIGSTATUS , ASN_INTEGER , RWRITE, var_GenericConfigTable, 3, { 2,1,11 } },
00080
00081 };
00082
00083
00084
00085
00086
00087
00088
00089
00090 void init_RMGenericConfig(void) {
00091
00092
00093
00094 REGISTER_MIB("RMGenericConfig", RMGenericConfig_variables, variable4,
00095 RMGenericConfig_variables_oid);
00096
00097
00098
00099 }
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 unsigned char *
00115 var_RMGenericConfig(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
00125 static u_long ulong_ret;
00126
00127
00128
00129
00130
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
00141
00142 switch(vp->magic) {
00143
00144
00145 case GENERICCONFIGNEXTINDEX:
00146
00147 ulong_ret = getNewId(GENERICCONFIG);
00148 return (unsigned char *) &ulong_ret;
00149
00150
00151 default:
00152 ERROR_MSG("");
00153 }
00154 return NULL;
00155 }
00156
00157
00158
00159
00160
00161
00162
00163 unsigned char *
00164 var_GenericConfigTable(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
00174 static long long_ret;
00175 static u_long ulong_ret;
00176
00177
00178
00179
00180
00181
00182 unsigned long id;
00183
00184 id = header_MyGeneric(vp,name,length,exact,var_len,write_method, GENERICCONFIG);
00185 if(id == 0) {
00186 switch(vp->magic) {
00187
00188 case GENERICSUBSYSTEMID:
00189 *write_method = write_genericSubsystemID;
00190 break;
00191
00192 case GENERICRESOURCEID:
00193 *write_method = write_genericResourceID;
00194 break;
00195
00196 case GENERICSTATISTICID:
00197 *write_method = write_genericStatisticID;
00198 break;
00199
00200 case GENERICCONFIGMONITORTYPE:
00201 *write_method = write_genericConfigMonitorType;
00202 break;
00203
00204 case GENERICSTATISTICTRANSFORM:
00205 *write_method = write_genericStatisticTransform;
00206 break;
00207
00208 case GENERICTHRESHOLDCONFIGINDEX:
00209 *write_method = write_genericThresholdConfigIndex;
00210 break;
00211
00212 case GENERICWATERMARKCONFIGINDEX:
00213 *write_method = write_genericWatermarkConfigIndex;
00214 break;
00215
00216 case GENERICLEAKYBUCKETCONFIGINDEX:
00217 *write_method = write_genericLeakyBucketConfigIndex;
00218 break;
00219
00220 case GENERICCONFIGSTATUS:
00221 *write_method = write_genericConfigStatus;
00222 break;
00223
00224 default:
00225 ERROR_MSG("");
00226 }
00227 return NULL;
00228 }
00229
00230
00231
00232
00233 switch(vp->magic) {
00234
00235
00236 case GENERICSUBSYSTEMID:
00237 *write_method = write_genericSubsystemID;
00238 ulong_ret = 0;
00239 getUnsigned(GENERICCONFIG, GENERICCONFIG_SUBSYSTEMID, id, &ulong_ret);
00240 return (unsigned char *) &ulong_ret;
00241
00242 case GENERICRESOURCEID:
00243 *write_method = write_genericResourceID;
00244 ulong_ret = 0;
00245 getUnsigned(GENERICCONFIG, GENERICCONFIG_RESOURCEID, id, &ulong_ret);
00246 return (unsigned char *) &ulong_ret;
00247
00248 case GENERICSTATISTICID:
00249 *write_method = write_genericStatisticID;
00250 ulong_ret = 0;
00251 getUnsigned(GENERICCONFIG, GENERICCONFIG_STATISTICID, id, &ulong_ret);
00252 return (unsigned char *) &ulong_ret;
00253
00254 case GENERICCONFIGMONITORTYPE:
00255 *write_method = write_genericConfigMonitorType;
00256 long_ret = 0;
00257 getInteger32(GENERICCONFIG, GENERICCONFIG_MONITORTYPE, id, &long_ret);
00258 return (unsigned char *) &long_ret;
00259
00260 case GENERICSTATISTICTRANSFORM:
00261 *write_method = write_genericStatisticTransform;
00262 long_ret = 0;
00263 getInteger32(GENERICCONFIG, GENERICCONFIG_STATISTICTRANSFORM, id, &long_ret);
00264 return (unsigned char *) &long_ret;
00265
00266 case GENERICTHRESHOLDCONFIGINDEX:
00267 *write_method = write_genericThresholdConfigIndex;
00268 ulong_ret = 0;
00269 getUnsigned(GENERICCONFIG, GENERICCONFIG_THRESHOLDID, id, &ulong_ret);
00270 return (unsigned char *) &ulong_ret;
00271
00272 case GENERICWATERMARKCONFIGINDEX:
00273 *write_method = write_genericWatermarkConfigIndex;
00274 ulong_ret = 0;
00275 getUnsigned(GENERICCONFIG, GENERICCONFIG_WATERMARKID, id, &ulong_ret);
00276 return (unsigned char *) &ulong_ret;
00277
00278 case GENERICLEAKYBUCKETCONFIGINDEX:
00279 *write_method = write_genericLeakyBucketConfigIndex;
00280 ulong_ret = 0;
00281 getUnsigned(GENERICCONFIG, GENERICCONFIG_LEAKYBUCKETID, id, &ulong_ret);
00282 return (unsigned char *) &ulong_ret;
00283
00284 case GENERICCONFIGREFCOUNT:
00285
00286 long_ret = 0;
00287 getInteger32(GENERICCONFIG, GENERICCONFIG_REFCOUNT, id, &long_ret);
00288 return (unsigned char *) &long_ret;
00289
00290 case GENERICCONFIGSTATUS:
00291 *write_method = write_genericConfigStatus;
00292 long_ret = 0;
00293 getInteger32(GENERICCONFIG, GENERICCONFIG_STATUS, id, &long_ret);
00294 return (unsigned char *) &long_ret;
00295
00296
00297 default:
00298 ERROR_MSG("");
00299 }
00300 return NULL;
00301 }
00302
00303
00304
00305
00306 int
00307 write_genericSubsystemID(int action,
00308 u_char *var_val,
00309 u_char var_val_type,
00310 size_t var_val_len,
00311 u_char *statP,
00312 oid *name,
00313 size_t name_len)
00314 {
00315 static unsigned long *ulong_ret;
00316 int size;
00317
00318 int createNew, ret;
00319 unsigned long id;
00320 size_t prefix_len;
00321
00322 static unsigned long oldVal;
00323
00324 oid suffix[] = { 2, 1, 2 };
00325 createNew = 0;
00326 prefix_len = sizeof(RMGenericConfig_variables_oid)/sizeof(oid);
00327
00328 id = header_writeGeneric(name, name_len, RMGenericConfig_variables_oid, prefix_len, suffix, 3, GENERICCONFIG, &createNew);
00329
00330 if(id == 0 || (createNew && action == ACTION))
00331 return SNMP_ERR_NOSUCHNAME;
00332
00333 switch ( action ) {
00334 case RESERVE1:
00335 if (var_val_type != ASN_UNSIGNED){
00336 fprintf(stderr, "write to genericSubsystemID not ASN_UNSIGNED\n");
00337 return SNMP_ERR_WRONGTYPE;
00338 }
00339 if (var_val_len > sizeof(ulong_ret)){
00340 fprintf(stderr,"write to genericSubsystemID: bad length\n");
00341 return SNMP_ERR_WRONGLENGTH;
00342 }
00343 break;
00344
00345
00346 case RESERVE2:
00347 size = var_val_len;
00348 ulong_ret = (unsigned long *) var_val;
00349
00350 if(!createNew) {
00351 ret = getUnsigned(GENERICCONFIG, GENERICCONFIG_SUBSYSTEMID, id, &oldVal);
00352 if(ret)
00353 return SNMP_ERR_INCONSISTENTVALUE;
00354 }
00355
00356 break;
00357
00358
00359 case FREE:
00360
00361 break;
00362
00363
00364 case ACTION:
00365
00366
00367
00368 ret = setUnsigned(GENERICCONFIG, GENERICCONFIG_SUBSYSTEMID, id, *ulong_ret);
00369 if(ret)
00370 return SNMP_ERR_INCONSISTENTVALUE;
00371
00372 break;
00373
00374
00375 case UNDO:
00376
00377 setUnsigned(GENERICCONFIG, GENERICCONFIG_SUBSYSTEMID, id, oldVal);
00378 break;
00379
00380
00381 case COMMIT:
00382
00383
00384 break;
00385 }
00386 return SNMP_ERR_NOERROR;
00387 }
00388
00389
00390
00391
00392 int
00393 write_genericResourceID(int action,
00394 u_char *var_val,
00395 u_char var_val_type,
00396 size_t var_val_len,
00397 u_char *statP,
00398 oid *name,
00399 size_t name_len)
00400 {
00401 static unsigned long *ulong_ret;
00402 int size;
00403
00404 int createNew, ret;
00405 unsigned long id;
00406 size_t prefix_len;
00407
00408 static unsigned long oldVal;
00409
00410 oid suffix[] = { 2, 1, 3 };
00411 createNew = 0;
00412 prefix_len = sizeof(RMGenericConfig_variables_oid)/sizeof(oid);
00413
00414 id = header_writeGeneric(name, name_len, RMGenericConfig_variables_oid, prefix_len, suffix, 3, GENERICCONFIG, &createNew);
00415
00416 if(id == 0 || (createNew && action == ACTION))
00417 return SNMP_ERR_NOSUCHNAME;
00418
00419
00420 switch ( action ) {
00421 case RESERVE1:
00422 if (var_val_type != ASN_UNSIGNED){
00423 fprintf(stderr, "write to genericResourceID not ASN_UNSIGNED\n");
00424 return SNMP_ERR_WRONGTYPE;
00425 }
00426 if (var_val_len > sizeof(ulong_ret)){
00427 fprintf(stderr,"write to genericResourceID: bad length\n");
00428 return SNMP_ERR_WRONGLENGTH;
00429 }
00430 break;
00431
00432
00433 case RESERVE2:
00434 size = var_val_len;
00435 ulong_ret = (unsigned long *) var_val;
00436
00437 if(!createNew) {
00438 ret = getUnsigned(GENERICCONFIG, GENERICCONFIG_RESOURCEID, id, &oldVal);
00439 if(ret)
00440 return SNMP_ERR_INCONSISTENTVALUE;
00441 }
00442
00443
00444 break;
00445
00446
00447 case FREE:
00448
00449 break;
00450
00451
00452 case ACTION:
00453
00454
00455
00456 ret = setUnsigned(GENERICCONFIG, GENERICCONFIG_RESOURCEID, id, *ulong_ret);
00457 if(ret)
00458 return SNMP_ERR_INCONSISTENTVALUE;
00459
00460 break;
00461
00462
00463 case UNDO:
00464
00465 setUnsigned(GENERICCONFIG, GENERICCONFIG_RESOURCEID, id, oldVal);
00466 break;
00467
00468
00469 case COMMIT:
00470
00471
00472 break;
00473 }
00474 return SNMP_ERR_NOERROR;
00475 }
00476
00477
00478
00479
00480 int
00481 write_genericStatisticID(int action,
00482 u_char *var_val,
00483 u_char var_val_type,
00484 size_t var_val_len,
00485 u_char *statP,
00486 oid *name,
00487 size_t name_len)
00488 {
00489 static unsigned long *ulong_ret;
00490 int size;
00491
00492 int createNew, ret;
00493 unsigned long id;
00494 size_t prefix_len;
00495
00496 static unsigned long oldVal;
00497
00498 oid suffix[] = { 2, 1, 4 };
00499 createNew = 0;
00500 prefix_len = sizeof(RMGenericConfig_variables_oid)/sizeof(oid);
00501
00502 id = header_writeGeneric(name, name_len, RMGenericConfig_variables_oid, prefix_len, suffix, 3, GENERICCONFIG, &createNew);
00503
00504 if(id == 0 || (createNew && action == ACTION))
00505 return SNMP_ERR_NOSUCHNAME;
00506
00507
00508 switch ( action ) {
00509 case RESERVE1:
00510 if (var_val_type != ASN_UNSIGNED){
00511 fprintf(stderr, "write to genericStatisticID not ASN_UNSIGNED\n");
00512 return SNMP_ERR_WRONGTYPE;
00513 }
00514 if (var_val_len > sizeof(ulong_ret)){
00515 fprintf(stderr,"write to genericStatisticID: bad length\n");
00516 return SNMP_ERR_WRONGLENGTH;
00517 }
00518 break;
00519
00520
00521 case RESERVE2:
00522 size = var_val_len;
00523 ulong_ret = (unsigned long *) var_val;
00524
00525 if(!createNew) {
00526 ret = getUnsigned(GENERICCONFIG, GENERICCONFIG_STATISTICID, id, &oldVal);
00527 if(ret)
00528 return SNMP_ERR_INCONSISTENTVALUE;
00529 }
00530
00531
00532 break;
00533
00534
00535 case FREE:
00536
00537 break;
00538
00539
00540 case ACTION:
00541
00542
00543
00544 ret = setUnsigned(GENERICCONFIG, GENERICCONFIG_STATISTICID, id, *ulong_ret);
00545 if(ret)
00546 return SNMP_ERR_INCONSISTENTVALUE;
00547
00548 break;
00549
00550
00551 case UNDO:
00552
00553
00554 setUnsigned(GENERICCONFIG, GENERICCONFIG_STATISTICID, id, oldVal);
00555
00556 break;
00557
00558
00559 case COMMIT:
00560
00561
00562 break;
00563 }
00564 return SNMP_ERR_NOERROR;
00565 }
00566
00567
00568
00569
00570 int
00571 write_genericConfigMonitorType(int action,
00572 u_char *var_val,
00573 u_char var_val_type,
00574 size_t var_val_len,
00575 u_char *statP,
00576 oid *name,
00577 size_t name_len)
00578 {
00579 static long *long_ret;
00580 int size;
00581
00582 int createNew, ret;
00583 unsigned long id;
00584 size_t prefix_len;
00585
00586 static long oldVal;
00587
00588 oid suffix[] = { 2, 1, 5 };
00589 createNew = 0;
00590 prefix_len = sizeof(RMGenericConfig_variables_oid)/sizeof(oid);
00591
00592 id = header_writeGeneric(name, name_len, RMGenericConfig_variables_oid, prefix_len, suffix, 3, GENERICCONFIG, &createNew);
00593
00594 if(id == 0 || (createNew && action == ACTION))
00595 return SNMP_ERR_NOSUCHNAME;
00596
00597
00598 switch ( action ) {
00599 case RESERVE1:
00600 if (var_val_type != ASN_INTEGER){
00601 fprintf(stderr, "write to genericConfigMonitorType not ASN_INTEGER\n");
00602 return SNMP_ERR_WRONGTYPE;
00603 }
00604 if (var_val_len > sizeof(long_ret)){
00605 fprintf(stderr,"write to genericConfigMonitorType: bad length\n");
00606 return SNMP_ERR_WRONGLENGTH;
00607 }
00608 break;
00609
00610
00611 case RESERVE2:
00612 size = var_val_len;
00613 long_ret = (long *) var_val;
00614
00615 if(!createNew) {
00616 ret = getInteger32(GENERICCONFIG, GENERICCONFIG_MONITORTYPE, id, &oldVal);
00617 if(ret)
00618 return SNMP_ERR_INCONSISTENTVALUE;
00619 }
00620
00621 break;
00622
00623
00624 case FREE:
00625
00626 break;
00627
00628
00629 case ACTION:
00630
00631
00632
00633 ret = setInteger32(GENERICCONFIG, GENERICCONFIG_MONITORTYPE, id, *long_ret);
00634 if(ret)
00635 return SNMP_ERR_INCONSISTENTVALUE;
00636
00637 break;
00638
00639
00640 case UNDO:
00641
00642 setInteger32(GENERICCONFIG, GENERICCONFIG_MONITORTYPE, id, oldVal);
00643 break;
00644
00645
00646 case COMMIT:
00647
00648
00649 break;
00650 }
00651 return SNMP_ERR_NOERROR;
00652 }
00653
00654
00655 int
00656 write_genericStatisticTransform(int action,
00657 u_char *var_val,
00658 u_char var_val_type,
00659 size_t var_val_len,
00660 u_char *statP,
00661 oid *name,
00662 size_t name_len)
00663 {
00664 static long *long_ret;
00665 int size;
00666
00667 int createNew, ret;
00668 unsigned long id;
00669 size_t prefix_len;
00670
00671 static long oldVal;
00672
00673 oid suffix[] = { 2, 1, 6 };
00674 createNew = 0;
00675 prefix_len = sizeof(RMGenericConfig_variables_oid)/sizeof(oid);
00676
00677 id = header_writeGeneric(name, name_len, RMGenericConfig_variables_oid, prefix_len, suffix, 3, GENERICCONFIG, &createNew);
00678
00679 if(id == 0 || (createNew && action == ACTION))
00680 return SNMP_ERR_NOSUCHNAME;
00681
00682
00683 switch ( action ) {
00684 case RESERVE1:
00685 if (var_val_type != ASN_INTEGER){
00686 fprintf(stderr, "write to genericConfigMonitorType not ASN_INTEGER\n");
00687 return SNMP_ERR_WRONGTYPE;
00688 }
00689 if (var_val_len > sizeof(long_ret)){
00690 fprintf(stderr,"write to genericConfigMonitorType: bad length\n");
00691 return SNMP_ERR_WRONGLENGTH;
00692 }
00693 break;
00694
00695
00696 case RESERVE2:
00697 size = var_val_len;
00698 long_ret = (long *) var_val;
00699
00700 if(!createNew) {
00701 ret = getInteger32(GENERICCONFIG, GENERICCONFIG_STATISTICTRANSFORM, id, &oldVal);
00702 if(ret)
00703 return SNMP_ERR_INCONSISTENTVALUE;
00704 }
00705
00706 break;
00707
00708
00709 case FREE:
00710
00711 break;
00712
00713
00714 case ACTION:
00715
00716
00717
00718 ret = setInteger32(GENERICCONFIG, GENERICCONFIG_STATISTICTRANSFORM, id, *long_ret);
00719 if(ret)
00720 return SNMP_ERR_INCONSISTENTVALUE;
00721
00722 break;
00723
00724
00725 case UNDO:
00726
00727 setInteger32(GENERICCONFIG, GENERICCONFIG_STATISTICTRANSFORM, id, oldVal);
00728 break;
00729
00730
00731 case COMMIT:
00732
00733
00734 break;
00735 }
00736 return SNMP_ERR_NOERROR;
00737 }
00738
00739 int
00740 write_genericThresholdConfigIndex(int action,
00741 u_char *var_val,
00742 u_char var_val_type,
00743 size_t var_val_len,
00744 u_char *statP,
00745 oid *name,
00746 size_t name_len)
00747 {
00748 static unsigned long *ulong_ret;
00749 int size;
00750
00751 int createNew, ret;
00752 unsigned long id;
00753 size_t prefix_len;
00754
00755 static unsigned long oldVal;
00756
00757 oid suffix[] = { 2, 1, 7 };
00758 createNew = 0;
00759 prefix_len = sizeof(RMGenericConfig_variables_oid)/sizeof(oid);
00760
00761 id = header_writeGeneric(name, name_len, RMGenericConfig_variables_oid, prefix_len, suffix, 3, GENERICCONFIG, &createNew);
00762
00763 if(id == 0 || (createNew && action == ACTION))
00764 return SNMP_ERR_NOSUCHNAME;
00765
00766
00767 switch ( action ) {
00768 case RESERVE1:
00769 if (var_val_type != ASN_UNSIGNED){
00770 fprintf(stderr, "write to genericThresholdConfigIndex not ASN_UNSIGNED\n");
00771 return SNMP_ERR_WRONGTYPE;
00772 }
00773 if (var_val_len > sizeof(ulong_ret)){
00774 fprintf(stderr,"write to genericThresholdConfigIndex: bad length\n");
00775 return SNMP_ERR_WRONGLENGTH;
00776 }
00777 break;
00778
00779
00780 case RESERVE2:
00781 size = var_val_len;
00782 ulong_ret = (unsigned long *) var_val;
00783
00784 if(!createNew) {
00785 ret = getUnsigned(GENERICCONFIG, GENERICCONFIG_THRESHOLDID, id, &oldVal);
00786 if(ret)
00787 return SNMP_ERR_INCONSISTENTVALUE;
00788 }
00789
00790
00791 break;
00792
00793
00794 case FREE:
00795
00796 break;
00797
00798
00799 case ACTION:
00800
00801
00802
00803 ret = setUnsigned(GENERICCONFIG, GENERICCONFIG_THRESHOLDID, id, *ulong_ret);
00804 if(ret)
00805 return SNMP_ERR_INCONSISTENTVALUE;
00806 break;
00807
00808
00809 case UNDO:
00810
00811 setUnsigned(GENERICCONFIG, GENERICCONFIG_THRESHOLDID, id, oldVal);
00812 break;
00813
00814
00815 case COMMIT:
00816
00817
00818 break;
00819 }
00820 return SNMP_ERR_NOERROR;
00821 }
00822
00823
00824
00825
00826 int
00827 write_genericWatermarkConfigIndex(int action,
00828 u_char *var_val,
00829 u_char var_val_type,
00830 size_t var_val_len,
00831 u_char *statP,
00832 oid *name,
00833 size_t name_len)
00834 {
00835 static unsigned long *ulong_ret;
00836 int size;
00837
00838 int createNew, ret;
00839 unsigned long id;
00840 size_t prefix_len;
00841
00842 static unsigned long oldVal;
00843
00844 oid suffix[] = { 2, 1, 8 };
00845 createNew = 0;
00846 prefix_len = sizeof(RMGenericConfig_variables_oid)/sizeof(oid);
00847
00848 id = header_writeGeneric(name, name_len, RMGenericConfig_variables_oid, prefix_len, suffix, 3, GENERICCONFIG, &createNew);
00849
00850 if(id == 0 || (createNew && action == ACTION))
00851 return SNMP_ERR_NOSUCHNAME;
00852
00853
00854 switch ( action ) {
00855 case RESERVE1:
00856 if (var_val_type != ASN_UNSIGNED){
00857 fprintf(stderr, "write to genericWatermarkConfigIndex not ASN_UNSIGNED\n");
00858 return SNMP_ERR_WRONGTYPE;
00859 }
00860 if (var_val_len > sizeof(ulong_ret)){
00861 fprintf(stderr,"write to genericWatermarkConfigIndex: bad length\n");
00862 return SNMP_ERR_WRONGLENGTH;
00863 }
00864 break;
00865
00866
00867 case RESERVE2:
00868 size = var_val_len;
00869 ulong_ret = (unsigned long *) var_val;
00870
00871 if(!createNew) {
00872 ret = getUnsigned(GENERICCONFIG, GENERICCONFIG_WATERMARKID, id, &oldVal);
00873 if(ret)
00874 return SNMP_ERR_INCONSISTENTVALUE;
00875 }
00876
00877
00878 break;
00879
00880
00881 case FREE:
00882
00883 break;
00884
00885
00886 case ACTION:
00887
00888
00889
00890 ret = setUnsigned(GENERICCONFIG, GENERICCONFIG_WATERMARKID, id, *ulong_ret);
00891 if(ret)
00892 return SNMP_ERR_INCONSISTENTVALUE;
00893
00894 break;
00895
00896
00897 case UNDO:
00898
00899 setUnsigned(GENERICCONFIG, GENERICCONFIG_WATERMARKID, id, oldVal);
00900 break;
00901
00902
00903 case COMMIT:
00904
00905
00906 break;
00907 }
00908 return SNMP_ERR_NOERROR;
00909 }
00910
00911
00912
00913
00914 int
00915 write_genericLeakyBucketConfigIndex(int action,
00916 u_char *var_val,
00917 u_char var_val_type,
00918 size_t var_val_len,
00919 u_char *statP,
00920 oid *name,
00921 size_t name_len)
00922 {
00923 static unsigned long *ulong_ret;
00924 int size;
00925
00926 int createNew, ret;
00927 unsigned long id;
00928 size_t prefix_len;
00929
00930 static unsigned long oldVal;
00931
00932 oid suffix[] = { 2, 1, 9 };
00933 createNew = 0;
00934 prefix_len = sizeof(RMGenericConfig_variables_oid)/sizeof(oid);
00935
00936 id = header_writeGeneric(name, name_len, RMGenericConfig_variables_oid, prefix_len, suffix, 3, GENERICCONFIG, &createNew);
00937
00938 if(id == 0 || (createNew && action == ACTION))
00939 return SNMP_ERR_NOSUCHNAME;
00940
00941
00942 switch ( action ) {
00943 case RESERVE1:
00944 if (var_val_type != ASN_UNSIGNED){
00945 fprintf(stderr, "write to genericLeakyBucketConfigIndex not ASN_UNSIGNED\n");
00946 return SNMP_ERR_WRONGTYPE;
00947 }
00948 if (var_val_len > sizeof(ulong_ret)){
00949 fprintf(stderr,"write to genericLeakyBucketConfigIndex: bad length\n");
00950 return SNMP_ERR_WRONGLENGTH;
00951 }
00952 break;
00953
00954
00955 case RESERVE2:
00956 size = var_val_len;
00957 ulong_ret = (unsigned long *) var_val;
00958
00959 if(!createNew) {
00960 ret = getUnsigned(GENERICCONFIG, GENERICCONFIG_LEAKYBUCKETID, id, &oldVal);
00961 if(ret)
00962 return SNMP_ERR_INCONSISTENTVALUE;
00963 }
00964
00965
00966 break;
00967
00968
00969 case FREE:
00970
00971 break;
00972
00973
00974 case ACTION:
00975
00976
00977
00978 ret = setUnsigned(GENERICCONFIG, GENERICCONFIG_LEAKYBUCKETID, id, *ulong_ret);
00979 if(ret)
00980 return SNMP_ERR_INCONSISTENTVALUE;
00981
00982 break;
00983
00984
00985 case UNDO:
00986
00987 setUnsigned(GENERICCONFIG, GENERICCONFIG_LEAKYBUCKETID, id, oldVal);
00988 break;
00989
00990
00991 case COMMIT:
00992
00993
00994 break;
00995 }
00996 return SNMP_ERR_NOERROR;
00997 }
00998
00999
01000
01001
01002 int
01003 write_genericConfigStatus(int action,
01004 u_char *var_val,
01005 u_char var_val_type,
01006 size_t var_val_len,
01007 u_char *statP,
01008 oid *name,
01009 size_t name_len)
01010 {
01011 static long long_ret;
01012 int size;
01013
01014 int createNew, ret;
01015 unsigned long id;
01016 size_t prefix_len;
01017
01018 static long oldStatus;
01019 static int rowCreated;
01020
01021 oid suffix[] = { 2, 1, 11 };
01022 createNew = 0;
01023 prefix_len = sizeof(RMGenericConfig_variables_oid)/sizeof(oid);
01024
01025 id = header_writeGeneric(name, name_len, RMGenericConfig_variables_oid, prefix_len, suffix, 3, GENERICCONFIG, &createNew);
01026
01027 if(action == COMMIT && long_ret == DESTROY && id ==0)
01028 return SNMP_ERR_NOERROR;
01029
01030 if(id == 0)
01031 return SNMP_ERR_NOSUCHNAME;
01032
01033
01034 switch ( action ) {
01035 case RESERVE1:
01036 if (var_val_type != ASN_INTEGER){
01037 fprintf(stderr, "write to genericConfigStatus not ASN_INTEGER\n");
01038 return SNMP_ERR_WRONGTYPE;
01039 }
01040 if (var_val_len > sizeof(long_ret)){
01041 fprintf(stderr,"write to genericConfigStatus: bad length\n");
01042 return SNMP_ERR_WRONGLENGTH;
01043 }
01044 break;
01045
01046
01047 case RESERVE2:
01048 size = var_val_len;
01049 long_ret = (long ) *var_val;
01050
01051 rowCreated = 0;
01052 oldStatus = 0;
01053 if (long_ret < ACTIVE || long_ret > DESTROY ||
01054 long_ret == NOTREADY)
01055 return SNMP_ERR_INCONSISTENTVALUE;
01056
01057 if(createNew &&
01058 (long_ret != CREATEANDWAIT && long_ret != CREATEANDGO))
01059 return SNMP_ERR_INCONSISTENTVALUE;
01060
01061 if (long_ret == NOTINSERVICE || long_ret == ACTIVE) {
01062 ret = getInteger32(GENERICCONFIG, GENERICCONFIG_STATUS, id, &oldStatus);
01063 if(ret)
01064 return SNMP_ERR_INCONSISTENTVALUE;
01065 }
01066
01067
01068 break;
01069
01070
01071 case FREE:
01072
01073 break;
01074
01075
01076 case ACTION:
01077
01078
01079
01080
01081 if(long_ret == CREATEANDWAIT || long_ret == CREATEANDGO) {
01082 ret = newEntry(GENERICCONFIG, id);
01083 if(ret)
01084 return SNMP_ERR_INCONSISTENTVALUE;
01085
01086 rowCreated = 1;
01087 }
01088 else if (long_ret == NOTINSERVICE || long_ret == ACTIVE) {
01089 ret = setInteger32(GENERICCONFIG, GENERICCONFIG_STATUS, id, long_ret);
01090 if(ret)
01091 return SNMP_ERR_INCONSISTENTVALUE;
01092 }
01093 else if(long_ret == DESTROY) {
01094 ret = deleteEntry(GENERICCONFIG, id);
01095 if(ret)
01096 return SNMP_ERR_INCONSISTENTVALUE;
01097 }
01098 break;
01099
01100
01101 case UNDO:
01102
01103 if(rowCreated) {
01104 deleteEntry(GENERICCONFIG, id);
01105 }
01106 else if(long_ret == NOTINSERVICE || long_ret == ACTIVE) {
01107 if(oldStatus != 0)
01108 setInteger32(GENERICCONFIG, GENERICCONFIG_STATUS, id, oldStatus);
01109 }
01110 else if((long_ret == DESTROY)) {
01111
01112
01113
01114 }
01115 break;
01116
01117
01118 case COMMIT:
01119
01120
01121 if(long_ret == CREATEANDGO) {
01122 ret = setInteger32(GENERICCONFIG, GENERICCONFIG_STATUS, id, ACTIVE);
01123 if(ret) {
01124 deleteEntry(GENERICCONFIG, id);
01125 return SNMP_ERR_COMMITFAILED;
01126 }
01127 }
01128 break;
01129 }
01130 return SNMP_ERR_NOERROR;
01131 }
01132
01133
01134
01135
01136
01137