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