| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878 |
- /*
- * Note: this file originally auto-generated by mib2c
- * using mib2c.create-dataset.conf
- */
- #include <net-snmp/net-snmp-config.h>
- #include <net-snmp/net-snmp-includes.h>
- #include <net-snmp/agent/net-snmp-agent-includes.h>
- #include "pduMIB_form.h"
- #include "switch_ctrl.h"
- #include "sqlite_handle.h"
- #include "common.h"
- /** Initialize the pduChannelTable table by defining its contents and how it's structured */
- void
- initialize_table_pduChannelTable(void)
- {
- const oid pduChannelTable_oid[] = {1,3,6,1,4,1,2024,1,3,9};
- netsnmp_table_data_set *table_set;
- /* create the table structure itself */
- table_set = netsnmp_create_table_data_set("pduChannelTable");
- /* comment this out or delete if you don't support creation of new rows */
- table_set->allow_creation = 1;
- /***************************************************
- * Adding indexes
- */
- DEBUGMSGTL(("initialize_table_pduChannelTable",
- "adding indexes to table pduChannelTable\n"));
- netsnmp_table_set_add_indexes(table_set,
- ASN_INTEGER, /* index: pduChannelID */
- 0);
- DEBUGMSGTL(("initialize_table_pduChannelTable",
- "adding column types to table pduChannelTable\n"));
- netsnmp_table_set_multi_add_default_row(table_set,
- COLUMN_PDUCHANNELID, ASN_INTEGER, 0,
- NULL, 0,
- COLUMN_PDUCHANNELNAME, ASN_OCTET_STR, 0,
- NULL, 0,
- COLUMN_PDUCHANNELSTATUS, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUCHANNELVOLTAGE, ASN_OCTET_STR, 0,
- NULL, 0,
- COLUMN_PDUCHANNELCURRENT, ASN_OCTET_STR, 0,
- NULL, 0,
- COLUMN_PDUCHANNELFREQUENCY, ASN_INTEGER, 0,
- NULL, 0,
- COLUMN_PDUCHANNELCONSUMPTION, ASN_OCTET_STR, 0,
- NULL, 0,
- COLUMN_PDUCHANNELPOWERFACTOR, ASN_OCTET_STR, 0,
- NULL, 0,
- COLUMN_PDUCHANNELPACTIVEPOWER, ASN_OCTET_STR, 0,
- NULL, 0,
- COLUMN_PDUCHANNELREACTIVEPOWER, ASN_OCTET_STR, 0,
- NULL, 0,
- COLUMN_PDUCHANNELAPPARENTPOWER, ASN_OCTET_STR, 0,
- NULL, 0,
- 0);
-
- /* registering the table with the master agent */
- /* note: if you don't need a subhandler to deal with any aspects
- of the request, change pduChannelTable_handler to "NULL" */
- netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduChannelTable", pduChannelTable_handler,
- pduChannelTable_oid,
- OID_LENGTH(pduChannelTable_oid),
- HANDLER_CAN_RWRITE),
- table_set, NULL);
- }
- /** Initialize the pduGroupTable table by defining its contents and how it's structured */
- void
- initialize_table_pduGroupTable(void)
- {
- const oid pduGroupTable_oid[] = {1,3,6,1,4,1,2024,1,3,10};
- netsnmp_table_data_set *table_set;
- /* create the table structure itself */
- table_set = netsnmp_create_table_data_set("pduGroupTable");
- /* comment this out or delete if you don't support creation of new rows */
- table_set->allow_creation = 1;
- /***************************************************
- * Adding indexes
- */
- DEBUGMSGTL(("initialize_table_pduGroupTable",
- "adding indexes to table pduGroupTable\n"));
- netsnmp_table_set_add_indexes(table_set,
- ASN_INTEGER, /* index: pduGroupID */
- 0);
- DEBUGMSGTL(("initialize_table_pduGroupTable",
- "adding column types to table pduGroupTable\n"));
- netsnmp_table_set_multi_add_default_row(table_set,
- COLUMN_PDUGROUPID, ASN_INTEGER, 0,
- NULL, 0,
- COLUMN_PDUGROUPNAME, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUGROUPLIST, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUGROUPSTATUS, ASN_INTEGER, 1,
- NULL, 0,
- 0);
-
- /* registering the table with the master agent */
- /* note: if you don't need a subhandler to deal with any aspects
- of the request, change pduGroupTable_handler to "NULL" */
- netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduGroupTable", pduGroupTable_handler,
- pduGroupTable_oid,
- OID_LENGTH(pduGroupTable_oid),
- HANDLER_CAN_RWRITE),
- table_set, NULL);
- }
- /** Initialize the pduSensorTable table by defining its contents and how it's structured */
- void
- initialize_table_pduSensorTable(void)
- {
- const oid pduSensorTable_oid[] = {1,3,6,1,4,1,2024,1,4,1};
- netsnmp_table_data_set *table_set;
- /* create the table structure itself */
- table_set = netsnmp_create_table_data_set("pduSensorTable");
- /* comment this out or delete if you don't support creation of new rows */
- table_set->allow_creation = 1;
- /***************************************************
- * Adding indexes
- */
- DEBUGMSGTL(("initialize_table_pduSensorTable",
- "adding indexes to table pduSensorTable\n"));
- netsnmp_table_set_add_indexes(table_set,
- ASN_INTEGER, /* index: pduSensorID */
- 0);
- DEBUGMSGTL(("initialize_table_pduSensorTable",
- "adding column types to table pduSensorTable\n"));
- netsnmp_table_set_multi_add_default_row(table_set,
- COLUMN_PDUSENSORID, ASN_INTEGER, 0,
- NULL, 0,
- COLUMN_PDUSENSORNAME, ASN_OCTET_STR, 0,
- NULL, 0,
- COLUMN_PDUSENSORTYPE, ASN_INTEGER, 0,
- NULL, 0,
- COLUMN_PDUSENSORDATACHENNEL, ASN_OCTET_STR, 0,
- NULL, 0,
- COLUMN_PDUSENSORMODBUSADDRESS, ASN_INTEGER, 0,
- NULL, 0,
- COLUMN_PDUSENSORSTATUS, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUSENSORVALUENUM, ASN_INTEGER, 0,
- NULL, 0,
- COLUMN_PDUSENSORVALUE1, ASN_OCTET_STR, 0,
- NULL, 0,
- COLUMN_PDUSENSORVALUE2, ASN_OCTET_STR, 0,
- NULL, 0,
- 0);
-
- /* registering the table with the master agent */
- /* note: if you don't need a subhandler to deal with any aspects
- of the request, change pduSensorTable_handler to "NULL" */
- netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduSensorTable", pduSensorTable_handler,
- pduSensorTable_oid,
- OID_LENGTH(pduSensorTable_oid),
- HANDLER_CAN_RWRITE),
- table_set, NULL);
- }
- /** Initialize the pduSMTPRecMailTable table by defining its contents and how it's structured */
- void
- initialize_table_pduSMTPRecMailTable(void)
- {
- const oid pduSMTPRecMailTable_oid[] = {1,3,6,1,4,1,2024,1,5,3,4};
- netsnmp_table_data_set *table_set;
- /* create the table structure itself */
- table_set = netsnmp_create_table_data_set("pduSMTPRecMailTable");
- /* comment this out or delete if you don't support creation of new rows */
- table_set->allow_creation = 1;
- /***************************************************
- * Adding indexes
- */
- DEBUGMSGTL(("initialize_table_pduSMTPRecMailTable",
- "adding indexes to table pduSMTPRecMailTable\n"));
- netsnmp_table_set_add_indexes(table_set,
- ASN_OCTET_STR, /* index: pduSMTPRecMail */
- 0);
- DEBUGMSGTL(("initialize_table_pduSMTPRecMailTable",
- "adding column types to table pduSMTPRecMailTable\n"));
- netsnmp_table_set_multi_add_default_row(table_set,
- COLUMN_PDUSMTPRECMAIL, ASN_OCTET_STR, 1,
- NULL, 0,
- 0);
-
- /* registering the table with the master agent */
- /* note: if you don't need a subhandler to deal with any aspects
- of the request, change pduSMTPRecMailTable_handler to "NULL" */
- netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduSMTPRecMailTable", pduSMTPRecMailTable_handler,
- pduSMTPRecMailTable_oid,
- OID_LENGTH(pduSMTPRecMailTable_oid),
- HANDLER_CAN_RWRITE),
- table_set, NULL);
- }
- /** Initialize the pduMessageNumTable table by defining its contents and how it's structured */
- void
- initialize_table_pduMessageNumTable(void)
- {
- const oid pduMessageNumTable_oid[] = {1,3,6,1,4,1,2024,1,5,5,2};
- netsnmp_table_data_set *table_set;
- /* create the table structure itself */
- table_set = netsnmp_create_table_data_set("pduMessageNumTable");
- /* comment this out or delete if you don't support creation of new rows */
- table_set->allow_creation = 1;
- /***************************************************
- * Adding indexes
- */
- DEBUGMSGTL(("initialize_table_pduMessageNumTable",
- "adding indexes to table pduMessageNumTable\n"));
- netsnmp_table_set_add_indexes(table_set,
- ASN_OCTET_STR, /* index: pduMessageRecNum */
- 0);
- DEBUGMSGTL(("initialize_table_pduMessageNumTable",
- "adding column types to table pduMessageNumTable\n"));
- netsnmp_table_set_multi_add_default_row(table_set,
- COLUMN_PDUMESSAGERECNUM, ASN_OCTET_STR, 1,
- NULL, 0,
- 0);
-
- /* registering the table with the master agent */
- /* note: if you don't need a subhandler to deal with any aspects
- of the request, change pduMessageNumTable_handler to "NULL" */
- netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduMessageNumTable", pduMessageNumTable_handler,
- pduMessageNumTable_oid,
- OID_LENGTH(pduMessageNumTable_oid),
- HANDLER_CAN_RWRITE),
- table_set, NULL);
- }
- /** Initialize the pduMQTTBrokerTable table by defining its contents and how it's structured */
- void
- initialize_table_pduMQTTBrokerTable(void)
- {
- const oid pduMQTTBrokerTable_oid[] = {1,3,6,1,4,1,2024,1,5,6,3};
- netsnmp_table_data_set *table_set;
- /* create the table structure itself */
- table_set = netsnmp_create_table_data_set("pduMQTTBrokerTable");
- /* comment this out or delete if you don't support creation of new rows */
- table_set->allow_creation = 1;
- /***************************************************
- * Adding indexes
- */
- DEBUGMSGTL(("initialize_table_pduMQTTBrokerTable",
- "adding indexes to table pduMQTTBrokerTable\n"));
- netsnmp_table_set_add_indexes(table_set,
- ASN_OCTET_STR, /* index: pduMQTTBrokerName */
- 0);
- DEBUGMSGTL(("initialize_table_pduMQTTBrokerTable",
- "adding column types to table pduMQTTBrokerTable\n"));
- netsnmp_table_set_multi_add_default_row(table_set,
- COLUMN_PDUMQTTBROKERNAME, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUMQTTBROKERENABLE, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUMQTTBROKERIPORDOMAIN, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUMQTTBROKERPORT, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUMQTTBROKERUSERNAME, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUMQTTBROKERUSERPW, ASN_OCTET_STR, 1,
- NULL, 0,
- 0);
-
- /* registering the table with the master agent */
- /* note: if you don't need a subhandler to deal with any aspects
- of the request, change pduMQTTBrokerTable_handler to "NULL" */
- netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduMQTTBrokerTable", pduMQTTBrokerTable_handler,
- pduMQTTBrokerTable_oid,
- OID_LENGTH(pduMQTTBrokerTable_oid),
- HANDLER_CAN_RWRITE),
- table_set, NULL);
- }
- /** Initialize the pduCloudServerTable table by defining its contents and how it's structured */
- void
- initialize_table_pduCloudServerTable(void)
- {
- const oid pduCloudServerTable_oid[] = {1,3,6,1,4,1,2024,1,5,7,3};
- netsnmp_table_data_set *table_set;
- /* create the table structure itself */
- table_set = netsnmp_create_table_data_set("pduCloudServerTable");
- /* comment this out or delete if you don't support creation of new rows */
- table_set->allow_creation = 1;
- /***************************************************
- * Adding indexes
- */
- DEBUGMSGTL(("initialize_table_pduCloudServerTable",
- "adding indexes to table pduCloudServerTable\n"));
- netsnmp_table_set_add_indexes(table_set,
- ASN_OCTET_STR, /* index: pduCloudServerName */
- 0);
- DEBUGMSGTL(("initialize_table_pduCloudServerTable",
- "adding column types to table pduCloudServerTable\n"));
- netsnmp_table_set_multi_add_default_row(table_set,
- COLUMN_PDUCLOUDSERVERNAME, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUCLOUDSERVERENABLE, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUCLOUDSERVERIPORDOMAIN, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUCLOUDSERVERPORT, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUCLOUDSERVERUSERNAME, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUCLOUDSERVERUSERPW, ASN_OCTET_STR, 1,
- NULL, 0,
- 0);
-
- /* registering the table with the master agent */
- /* note: if you don't need a subhandler to deal with any aspects
- of the request, change pduCloudServerTable_handler to "NULL" */
- netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduCloudServerTable", pduCloudServerTable_handler,
- pduCloudServerTable_oid,
- OID_LENGTH(pduCloudServerTable_oid),
- HANDLER_CAN_RWRITE),
- table_set, NULL);
- }
- /** Initialize the pduAlarmHistoryTable table by defining its contents and how it's structured */
- void
- initialize_table_pduAlarmHistoryTable(void)
- {
- const oid pduAlarmHistoryTable_oid[] = {1,3,6,1,4,1,2024,1,6,1};
- netsnmp_table_data_set *table_set;
- /* create the table structure itself */
- table_set = netsnmp_create_table_data_set("pduAlarmHistoryTable");
- /* comment this out or delete if you don't support creation of new rows */
- table_set->allow_creation = 1;
- /***************************************************
- * Adding indexes
- */
- DEBUGMSGTL(("initialize_table_pduAlarmHistoryTable",
- "adding indexes to table pduAlarmHistoryTable\n"));
- netsnmp_table_set_add_indexes(table_set,
- ASN_INTEGER, /* index: pduAlarmID */
- 0);
- DEBUGMSGTL(("initialize_table_pduAlarmHistoryTable",
- "adding column types to table pduAlarmHistoryTable\n"));
- netsnmp_table_set_multi_add_default_row(table_set,
- COLUMN_PDUALARMID, ASN_INTEGER, 0,
- NULL, 0,
- COLUMN_PDUALARMTYPE, ASN_INTEGER, 0,
- NULL, 0,
- COLUMN_PDUALARMCONTEXT, ASN_OCTET_STR, 0,
- NULL, 0,
- COLUMN_PDUALARMACTION, ASN_INTEGER, 0,
- NULL, 0,
- COLUMN_PDUALARMACTIONPARA, ASN_INTEGER, 0,
- NULL, 0,
- COLUMN_PDUALARMDATE, ASN_OCTET_STR, 0,
- NULL, 0,
- COLUMN_PDUALARMTIME, ASN_OCTET_STR, 0,
- NULL, 0,
- 0);
-
- /* registering the table with the master agent */
- /* note: if you don't need a subhandler to deal with any aspects
- of the request, change pduAlarmHistoryTable_handler to "NULL" */
- netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduAlarmHistoryTable", pduAlarmHistoryTable_handler,
- pduAlarmHistoryTable_oid,
- OID_LENGTH(pduAlarmHistoryTable_oid),
- HANDLER_CAN_RWRITE),
- table_set, NULL);
- }
- /** Initialize the pduChannelLimitTable table by defining its contents and how it's structured */
- void
- initialize_table_pduChannelLimitTable(void)
- {
- const oid pduChannelLimitTable_oid[] = {1,3,6,1,4,1,2024,1,7,2,6};
- netsnmp_table_data_set *table_set;
- /* create the table structure itself */
- table_set = netsnmp_create_table_data_set("pduChannelLimitTable");
- /* comment this out or delete if you don't support creation of new rows */
- table_set->allow_creation = 1;
- /***************************************************
- * Adding indexes
- */
- DEBUGMSGTL(("initialize_table_pduChannelLimitTable",
- "adding indexes to table pduChannelLimitTable\n"));
- netsnmp_table_set_add_indexes(table_set,
- ASN_INTEGER, /* index: pduChannelLimitID */
- 0);
- DEBUGMSGTL(("initialize_table_pduChannelLimitTable",
- "adding column types to table pduChannelLimitTable\n"));
- netsnmp_table_set_multi_add_default_row(table_set,
- COLUMN_PDUCHANNELLIMITID, ASN_INTEGER, 0,
- NULL, 0,
- COLUMN_PDUCHANNELLIMITNAME, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUCHANNELCURRENTLIMITUP, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUCHANNELVOLTAGELIMITUP, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUCHANNELVOLTAGELIMITDOWN, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUCHANNELPOWERLIMITUP, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUCHANNELCONSUMPTIONLIMITUP, ASN_OCTET_STR, 1,
- NULL, 0,
- 0);
-
- /* registering the table with the master agent */
- /* note: if you don't need a subhandler to deal with any aspects
- of the request, change pduChannelLimitTable_handler to "NULL" */
- netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduChannelLimitTable", pduChannelLimitTable_handler,
- pduChannelLimitTable_oid,
- OID_LENGTH(pduChannelLimitTable_oid),
- HANDLER_CAN_RWRITE),
- table_set, NULL);
- }
- /** Initialize the pduSensorLimitTable table by defining its contents and how it's structured */
- void
- initialize_table_pduSensorLimitTable(void)
- {
- const oid pduSensorLimitTable_oid[] = {1,3,6,1,4,1,2024,1,7,3,1};
- netsnmp_table_data_set *table_set;
- /* create the table structure itself */
- table_set = netsnmp_create_table_data_set("pduSensorLimitTable");
- /* comment this out or delete if you don't support creation of new rows */
- table_set->allow_creation = 1;
- /***************************************************
- * Adding indexes
- */
- DEBUGMSGTL(("initialize_table_pduSensorLimitTable",
- "adding indexes to table pduSensorLimitTable\n"));
- netsnmp_table_set_add_indexes(table_set,
- ASN_INTEGER, /* index: pduSensorLimitID */
- 0);
- DEBUGMSGTL(("initialize_table_pduSensorLimitTable",
- "adding column types to table pduSensorLimitTable\n"));
- netsnmp_table_set_multi_add_default_row(table_set,
- COLUMN_PDUSENSORLIMITID, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUSENSORLIMITNAME, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUSENSORLIMITVALUE1UP, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUSENSORLIMITVALUE2UP, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUSENSORLIMITVALUE1DOWN, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUSENSORLIMITVALUE2DOWN, ASN_INTEGER, 1,
- NULL, 0,
- 0);
- /* registering the table with the master agent */
- /* note: if you don't need a subhandler to deal with any aspects
- of the request, change pduSensorLimitTable_handler to "NULL" */
- netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduSensorLimitTable", pduSensorLimitTable_handler,
- pduSensorLimitTable_oid,
- OID_LENGTH(pduSensorLimitTable_oid),
- HANDLER_CAN_RWRITE),
- table_set, NULL);
- }
- void
- initialize_table_pduPowerAlarmTable(void)
- {
- const oid pduPowerAlarmTable_oid[] = {1,3,6,1,4,1,2024,1,6,2};
- netsnmp_table_data_set *table_set;
- /* create the table structure itself */
- table_set = netsnmp_create_table_data_set("pduPowerAlarmTable");
- /* comment this out or delete if you don't support creation of new rows */
- table_set->allow_creation = 1;
- /***************************************************
- * Adding indexes
- */
- DEBUGMSGTL(("initialize_table_pduPowerAlarmTable",
- "adding indexes to table pduPowerAlarmTable\n"));
- netsnmp_table_set_add_indexes(table_set,
- ASN_INTEGER, /* index: pduChannelPowerAlarmID */
- 0);
- DEBUGMSGTL(("initialize_table_pduPowerAlarmTable",
- "adding column types to table pduPowerAlarmTable\n"));
- netsnmp_table_set_multi_add_default_row(table_set,
- COLUMN_PDUCHANNELPOWERALARMID, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUCHANNELPOWERALARMVOLTAGEUP, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUCHANNELPOWERALARMVOLTAGEDOWN, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUCHANNELPOWERALARMCURRENTUP, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUCHANNELPOWERALARMPOWERUP, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUCHANNELPOWERALARMCONSUMPTIONUP, ASN_INTEGER, 1,
- NULL, 0,
- 0);
- /* registering the table with the master agent */
- /* note: if you don't need a subhandler to deal with any aspects
- of the request, change pduPowerAlarmTable_handler to "NULL" */
- netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduPowerAlarmTable", pduPowerAlarmTable_handler,
- pduPowerAlarmTable_oid,
- OID_LENGTH(pduPowerAlarmTable_oid),
- HANDLER_CAN_RWRITE),
- table_set, NULL);
- }
- /** Initialize the pduSensorLimitTable table by defining its contents and how it's structured */
- void
- initialize_table_pduSensorAlarmTable(void)
- {
- const oid pduSensorAlarmTable_oid[] = {1,3,6,1,4,1,2024,1,6,3};
- netsnmp_table_data_set *table_set;
- /* create the table structure itself */
- table_set = netsnmp_create_table_data_set("pduSensorAlarmTable");
- /* comment this out or delete if you don't support creation of new rows */
- table_set->allow_creation = 1;
- /***************************************************
- * Adding indexes
- */
- DEBUGMSGTL(("initialize_table_pduSensorAlarmTable",
- "adding indexes to table pduSensorAlarmTable\n"));
- netsnmp_table_set_add_indexes(table_set,
- ASN_INTEGER, /* index: pduSensorAlarmID */
- 0);
- DEBUGMSGTL(("initialize_table_pduSensorAlarmTable",
- "adding column types to table pduSensorAlarmTable\n"));
- netsnmp_table_set_multi_add_default_row(table_set,
- COLUMN_PDUSENSORALARMID, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUSENSORALARMVALUE1UP, ASN_OCTET_STR, 1,
- NULL, 0,
- COLUMN_PDUSENSORALARMVALUE1DOWN, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUSENSORALARMVALUE2UP, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUSENSORALARMVALUE2DOWN, ASN_INTEGER, 1,
- NULL, 0,
- 0);
- /* registering the table with the master agent */
- /* note: if you don't need a subhandler to deal with any aspects
- of the request, change pduSensorAlarmTable_handler to "NULL" */
- netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduSensorAlarmTable", pduSensorAlarmTable_handler,
- pduSensorAlarmTable_oid,
- OID_LENGTH(pduSensorAlarmTable_oid),
- HANDLER_CAN_RWRITE),
- table_set, NULL);
- }
- /** Initializes the pduMIB module */
- void
- init_pduMIB_form(void)
- {
- /* here we initialize all the tables we're planning on supporting */
- initialize_table_pduChannelTable();
- initialize_table_pduGroupTable();
- initialize_table_pduSensorTable();
- initialize_table_pduSMTPRecMailTable();
- initialize_table_pduMessageNumTable();
- initialize_table_pduMQTTBrokerTable();
- initialize_table_pduCloudServerTable();
- initialize_table_pduAlarmHistoryTable();
- initialize_table_pduChannelLimitTable();
- initialize_table_pduSensorLimitTable();
- initialize_table_pduPowerAlarmTable();
- initialize_table_pduSensorAlarmTable();
- }
- /** handles requests for the pduChannelTable table, if anything else needs to be done */
- int
- pduChannelTable_handler(
- netsnmp_mib_handler *handler,
- netsnmp_handler_registration *reginfo,
- netsnmp_agent_request_info *reqinfo,
- netsnmp_request_info *requests) {
- /* perform anything here that you need to do. The requests have
- already been processed by the master table_dataset handler, but
- this gives you chance to act on the request in some other way
- if need be. */
- netsnmp_request_info *request;
- netsnmp_table_request_info *table_info;
- GlobalPowerManger* iterator;
- //GlobalPowerInfo powerInfo;
- char buffer[16];
- oid begin_next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 3, 9, 1, 1, 1};
- int max_clonum=11;
- switch(reqinfo->mode)
- {
- case MODE_GET:
- case MODE_GETNEXT:
- for (request = requests; request; request = request->next)
- {
- table_info = netsnmp_extract_table_info(request);
- if (reqinfo->mode==MODE_GETNEXT)
- {
- if (table_info->index_oid[0] == 0)
- {
- table_info->index_oid[0] = 1;
- table_info->colnum = 1;
- snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
- }
- else
- {
- if (table_info->colnum > max_clonum)
- {
- table_info->index_oid[0] += 1;
- table_info->colnum =1;
- }
- oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 3, 9, 1, table_info->colnum, table_info->index_oid[0]};
- snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
- }
- }
- int nIndex=1;
- list_for_each_entry(iterator, &__globalDeviceManage._globalPowerManger.list, list)
- {
- //查询数据库总电源信息 传给所申请的参数结构体
- //if(dev_search_power_trend_info(__globalDeviceManage.db,iterator->product_id,0,iterator)!=0)
- //{
- // log_e("search total power consumption err at pduChannelTable_handler from db.");
- //}
- //传值给总管理结构体
- // for(int i=0;i< TOTAL_COUNT;i++)
- // {
- // strcpy(_over_all_pwr_back_info._Power_Trend_Info.xAxis[i],__PowerTrendInfo._power_trend_info.xAxis[i]);
- // _over_all_pwr_back_info._Power_Trend_Info.ydata[POWER_MERITORIOUS_TYPE][i] = __PowerTrendInfo._power_trend_info.ydata[POWER_MERITORIOUS_TYPE][i];
- // _over_all_pwr_back_info._Power_Trend_Info.ydata[POWER_REACTIVE_TYPE][i] = __PowerTrendInfo._power_trend_info.ydata[POWER_REACTIVE_TYPE][i];
- // _over_all_pwr_back_info._Power_Trend_Info.ydata[POWER_APPARENT_TYPE][i] = __PowerTrendInfo._power_trend_info.ydata[POWER_APPARENT_TYPE][i];
- // }
- //if(dev_search_latest_power_info(__globalDeviceManage.db,__globalDeviceManage._globalDevInfo.product.id,iterator->product_ch_id,&powerInfo)!=0)
- //{
- // log_e("search total pwr err at pduChannelTable_handler from db.");
- //}
- //else
- //{
- if (nIndex<table_info->index_oid[0])
- {
- nIndex++;
- continue;
- }
- memset(buffer,0,sizeof(buffer));
- switch (table_info->colnum)
- {
- case COLUMN_PDUCHANNELID:
- if (!iterator)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->product_ch_id);
- break;
- case COLUMN_PDUCHANNELNAME:
- if (!iterator)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, iterator->product_ch_name, strlen(iterator->product_ch_name));
- break;
- case COLUMN_PDUCHANNELSTATUS:
- if (!iterator)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->_PowerInfo.status);
- break;
- case COLUMN_PDUCHANNELVOLTAGE:
- if (!iterator)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- sprintf(buffer,"%0.3f",iterator->_PowerInfo.voltage);
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- case COLUMN_PDUCHANNELCURRENT:
- if (!iterator)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- sprintf(buffer,"%0.3f",iterator->_PowerInfo.current);
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- case COLUMN_PDUCHANNELFREQUENCY:
- if (!iterator)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- sprintf(buffer,"%0.3f",iterator->_PowerInfo.freq);
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- case COLUMN_PDUCHANNELCONSUMPTION:
- if (!iterator)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- sprintf(buffer,"%0.3f",iterator->_PowerInfo.consumption);
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- case COLUMN_PDUCHANNELPOWERFACTOR:
- if (!iterator)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- sprintf(buffer,"%0.3f",iterator->_PowerInfo.factor);
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- case COLUMN_PDUCHANNELPACTIVEPOWER:
- if (!iterator)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- sprintf(buffer,"%0.3f",iterator->_PowerInfo.power);
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- case COLUMN_PDUCHANNELREACTIVEPOWER:
- if (!iterator)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- if (iterator->_PowerInfo.factor>0&&iterator->_PowerInfo.factor<=1)
- {
- sprintf(buffer,"%0.3f",(iterator->_PowerInfo.power/iterator->_PowerInfo.factor)-iterator->_PowerInfo.power);
- }else{
- sprintf(buffer,"0");
- }
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- case COLUMN_PDUCHANNELAPPARENTPOWER:
- if (!iterator)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- if (iterator->_PowerInfo.factor>0)
- {
- sprintf(buffer,"%0.3f",iterator->_PowerInfo.power/iterator->_PowerInfo.factor);
- }else{
- sprintf(buffer,"0");
- }
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- default:
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
- break;
- }
- //}
- break;
- }
- }
- break;
- case MODE_SET_RESERVE1:
- break;
- case MODE_SET_RESERVE2:
- break;
- case MODE_SET_FREE:
- break;
- case MODE_SET_ACTION:
- break;
- case MODE_SET_UNDO:
- break;
- case MODE_SET_COMMIT:
- /* XXX: delete temporary storage */
- // if (/* XXX: error? */) {
- // /* try _really_really_ hard to never get to this point */
- // netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_COMMITFAILED);
- // }
-
- for (request = requests; request; request = request->next)
- {
- table_info = netsnmp_extract_table_info(request);
- int nIndex = 1;
- list_for_each_entry(iterator, &__globalDeviceManage._globalPowerManger.list, list)
- {
- if (nIndex < table_info->index_oid[0])
- {
- nIndex++;
- continue;
- }
- memset(buffer, 0, sizeof(buffer));
- switch (table_info->colnum)
- {
- case COLUMN_PDUCHANNELSTATUS:
- if (!iterator)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- int nCHOpertype = *request->requestvb->val.integer;
- if (nCHOpertype!= iterator->_PowerInfo.status)
- {
- log_d("SNMP Remote switch ctrl:%d", iterator->product_ch_id);
- g_switch_set_all_chn_ctrl(&__globalDeviceManage._globalRelaySampManger,
- iterator,
- iterator->product_saddr,
- iterator->product_ch_addr, // 多版端口余8
- nCHOpertype,false);
- }
- break;
- }
- break;
- }
- }
- break;
- default:
- /* we should never get here, so this is a really bad error */
- snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode );
- return SNMP_ERR_GENERR;
- }
- return SNMP_ERR_NOERROR;
- }
- /** handles requests for the pduGroupTable table, if anything else needs to be done */
- int
- pduGroupTable_handler(
- netsnmp_mib_handler *handler,
- netsnmp_handler_registration *reginfo,
- netsnmp_agent_request_info *reqinfo,
- netsnmp_request_info *requests) {
- /* perform anything here that you need to do. The requests have
- already been processed by the master table_dataset handler, but
- this gives you chance to act on the request in some other way
- if need be. */
- netsnmp_request_info *request=NULL;
- netsnmp_table_request_info *table_info;
- GroupInfo *_GroupInfoTemp = NULL;
- GroupInfo group_list;
- INIT_LIST_HEAD(&group_list.list);
- if (0 != dev_get_group_info(__globalDeviceManage.db, &group_list))
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
- return SNMP_ERR_GENERR;
- }
- char buffer[16];
- oid begin_next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 3, 10, 1, 1, 1};
- int max_clonum = 4;
- switch (reqinfo->mode)
- {
- case MODE_GET:
- case MODE_GETNEXT:
- for (request = requests; request; request = request->next)
- {
- table_info = netsnmp_extract_table_info(request);
- if (reqinfo->mode == MODE_GETNEXT)
- {
- if (table_info->index_oid[0] == 0)
- {
- table_info->index_oid[0] = 1;
- table_info->colnum = 1;
- snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
- }
- else
- {
- if (table_info->colnum > max_clonum)
- {
- table_info->index_oid[0] += 1;
- table_info->colnum = 1;
- }
- oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 3, 10, 1, table_info->colnum, table_info->index_oid[0]};
- snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
- }
- }
- int nIndex = 1;
- list_for_each_entry(_GroupInfoTemp, &group_list.list, list)
- {
- if (nIndex < table_info->index_oid[0])
- {
- nIndex++;
- continue;
- }
- memset(buffer, 0, sizeof(buffer));
- switch (table_info->colnum)
- {
- case COLUMN_PDUGROUPID:
- if (!_GroupInfoTemp)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, _GroupInfoTemp->GroupID);
- break;
- case COLUMN_PDUGROUPNAME:
- if (!_GroupInfoTemp)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, _GroupInfoTemp->GroupName, strlen(_GroupInfoTemp->GroupName));
- break;
- case COLUMN_PDUGROUPLIST:
- if (!_GroupInfoTemp)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, _GroupInfoTemp->GroupChList, strlen(_GroupInfoTemp->GroupChList));
- break;
- case COLUMN_PDUGROUPSTATUS:
- if (!_GroupInfoTemp)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- //判断分组状态
- int nStatus = 0;
- char *pCHlist;
- char *pCHListSave;
- pCHlist = strtok_r(_GroupInfoTemp->GroupChList, ",", &pCHListSave);
- while(pCHlist!=NULL)
- {
- GlobalPowerManger *_globalPowerMangerTemp = NULL;
- list_for_each_entry(_globalPowerMangerTemp, &__globalDeviceManage._globalPowerManger.list, list)
- {
- if (_globalPowerMangerTemp == NULL)
- break;
- if (atoi(pCHlist) == _globalPowerMangerTemp->product_ch_id)
- {
- if (_globalPowerMangerTemp->_PowerInfo.status == 1)
- {
- nStatus = 1;
- break;
- }
- }
- }
- pCHlist = strtok_r(NULL, ",",&pCHListSave);
- }
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, nStatus);
- break;
- default:
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
- break;
- }
- //}
- break;
- }
- }
- break;
- case MODE_SET_RESERVE1:
- break;
- case MODE_SET_RESERVE2:
- break;
- case MODE_SET_FREE:
- break;
- case MODE_SET_ACTION:
- break;
- case MODE_SET_UNDO:
- break;
- case MODE_SET_COMMIT:
- for (request = requests; request; request = request->next)
- {
- table_info = netsnmp_extract_table_info(request);
- int nIndex = 1;
- list_for_each_entry(_GroupInfoTemp, &group_list.list, list)
- {
- if (nIndex < table_info->index_oid[0])
- {
- nIndex++;
- continue;
- }
- memset(buffer, 0, sizeof(buffer));
- switch (table_info->colnum)
- {
- case COLUMN_PDUGROUPSTATUS:
- if (!_GroupInfoTemp)
- {
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
- continue;
- }
- bool nGroupOpertype = *request->requestvb->val.integer;
- char *pCHlist;
- char *pCHListSave;
- pCHlist = strtok_r(_GroupInfoTemp->GroupChList, ",", &pCHListSave);
- if (__globalDeviceManage._globalDevInfo.product.pwr_type == 1)
- {
- unsigned short pAddrCtrl[50];
- memset(pAddrCtrl, 0, sizeof(pAddrCtrl));
- int ret = 0;
- while(pCHlist!=NULL)
- {
- GlobalPowerManger *_globalPowerMangerTemp = NULL;
- list_for_each_entry(_globalPowerMangerTemp, &__globalDeviceManage._globalPowerManger.list, list)
- {
- if (_globalPowerMangerTemp == NULL)
- break;
- if (atoi(pCHlist) == _globalPowerMangerTemp->product_ch_id)
- {
- log_d("SNMP Group switch ctrl:%d", _globalPowerMangerTemp->product_ch_id);
- pAddrCtrl[(int)_globalPowerMangerTemp->product_saddr] |= 1 << (_globalPowerMangerTemp->product_ch_addr - 1);
- break;
- }
- }
- pCHlist = strtok_r(NULL, ",",&pCHListSave);
- }
- for (size_t i = 0; i < 50; i++)
- {
- if (pAddrCtrl[i] != 0)
- {
- ret = g_switch_set_dcpdu_chns_ctrl(&__globalDeviceManage._globalRelaySampManger,
- i,
- pAddrCtrl[i],
- nGroupOpertype);
- if (ret < 0)
- {
- ret = g_switch_set_dcpdu_chns_ctrl(&__globalDeviceManage._globalRelaySampManger,
- i,
- pAddrCtrl[i],
- nGroupOpertype);
- /* code */
- }
- }
- }
- }
- else
- {
- while(pCHlist!=NULL)
- {
- GlobalPowerManger *_globalPowerMangerTemp = NULL;
- list_for_each_entry(_globalPowerMangerTemp, &__globalDeviceManage._globalPowerManger.list, list)
- {
- if (_globalPowerMangerTemp == NULL)
- break;
- if (atoi(pCHlist) == _globalPowerMangerTemp->product_ch_id)
- {
- log_d("SNMP Group switch ctrl:%d", _globalPowerMangerTemp->product_ch_id);
- g_switch_set_all_chn_ctrl(&__globalDeviceManage._globalRelaySampManger,
- _globalPowerMangerTemp,
- _globalPowerMangerTemp->product_saddr,
- _globalPowerMangerTemp->product_ch_addr, // 多版端口余8
- nGroupOpertype,true);
- break;
- }
- }
- pCHlist = strtok_r(NULL, ",",&pCHListSave);
- }
- }
- }
- break;
- }
- }
- break;
- default:
- /* we should never get here, so this is a really bad error */
- snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode);
- return SNMP_ERR_GENERR;
- }
- return SNMP_ERR_NOERROR;
- }
- /** handles requests for the pduSensorTable table, if anything else needs to be done */
- int
- pduSensorTable_handler(
- netsnmp_mib_handler *handler,
- netsnmp_handler_registration *reginfo,
- netsnmp_agent_request_info *reqinfo,
- netsnmp_request_info *requests) {
- /* perform anything here that you need to do. The requests have
- already been processed by the master table_dataset handler, but
- this gives you chance to act on the request in some other way
- if need be. */
- netsnmp_request_info *request;
- netsnmp_table_request_info *table_info;
- GlobalSensorManger *iterator = NULL;
- //
- char buffer[16];
- oid begin_next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 4, 1, 1, 1, 1};
- int max_clonum = 10;
- switch (reqinfo->mode)
- {
- case MODE_GET:
- case MODE_GETNEXT:
- for (request = requests; request; request = request->next)
- {
- table_info = netsnmp_extract_table_info(request);
- if (reqinfo->mode == MODE_GETNEXT)
- {
- if (table_info->index_oid[0] == 0)
- {
- table_info->index_oid[0] = 1;
- table_info->colnum = 1;
- snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
- }
- else
- {
- if (table_info->colnum > max_clonum)
- {
- table_info->index_oid[0] += 1;
- table_info->colnum = 1;
- }
- oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 4, 1, 1, table_info->colnum, table_info->index_oid[0]};
- snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
- }
- }
- int nIndex = table_info->index_oid[0];
- bool findinstance = false;
- list_for_each_entry(iterator, &__globalDeviceManage._globalSensorManger.list, list)
- {
- if (!iterator || nIndex != iterator->sensor_id)
- {
- continue;
- }
- memset(buffer, 0, sizeof(buffer));
- switch (table_info->colnum)
- {
- case COLUMN_PDUSENSORID:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_id);
- break;
- case COLUMN_PDUSENSORNAME:
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, iterator->sensor_name, strlen(iterator->sensor_name));
- break;
- case COLUMN_PDUSENSORTYPE:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_type);
- break;
- case COLUMN_PDUSENSORDATACHENNEL:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_interface_type);
- break;
- case COLUMN_PDUSENSORMODBUSADDRESS:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_addr);
- break;
- case 6:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_node_number);
- break;
- case COLUMN_PDUSENSORSTATUS:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_status);
- break;
- case COLUMN_PDUSENSORVALUENUM:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_val_count);
- break;
- case COLUMN_PDUSENSORVALUE1:
- sprintf(buffer, "%0.3f", iterator->Cur_sensor_info.val1);
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- case COLUMN_PDUSENSORVALUE2:
- sprintf(buffer, "%0.3f", iterator->Cur_sensor_info.val2);
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- default:
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
- break;
- }
- //}
- break;
- }
- }
- break;
- case MODE_SET_RESERVE1:
- break;
- case MODE_SET_RESERVE2:
- break;
- case MODE_SET_FREE:
- break;
- case MODE_SET_ACTION:
- break;
- case MODE_SET_UNDO:
- break;
- case MODE_SET_COMMIT:
- break;
- default:
- /* we should never get here, so this is a really bad error */
- snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode);
- return SNMP_ERR_GENERR;
- }
- return SNMP_ERR_NOERROR;
- }
- /** handles requests for the pduSMTPRecMailTable table, if anything else needs to be done */
- int
- pduSMTPRecMailTable_handler(
- netsnmp_mib_handler *handler,
- netsnmp_handler_registration *reginfo,
- netsnmp_agent_request_info *reqinfo,
- netsnmp_request_info *requests) {
- /* perform anything here that you need to do. The requests have
- already been processed by the master table_dataset handler, but
- this gives you chance to act on the request in some other way
- if need be. */
- return SNMP_ERR_NOERROR;
- }
- /** handles requests for the pduMessageNumTable table, if anything else needs to be done */
- int
- pduMessageNumTable_handler(
- netsnmp_mib_handler *handler,
- netsnmp_handler_registration *reginfo,
- netsnmp_agent_request_info *reqinfo,
- netsnmp_request_info *requests) {
- /* perform anything here that you need to do. The requests have
- already been processed by the master table_dataset handler, but
- this gives you chance to act on the request in some other way
- if need be. */
- return SNMP_ERR_NOERROR;
- }
- /** handles requests for the pduMQTTBrokerTable table, if anything else needs to be done */
- int
- pduMQTTBrokerTable_handler(
- netsnmp_mib_handler *handler,
- netsnmp_handler_registration *reginfo,
- netsnmp_agent_request_info *reqinfo,
- netsnmp_request_info *requests) {
- /* perform anything here that you need to do. The requests have
- already been processed by the master table_dataset handler, but
- this gives you chance to act on the request in some other way
- if need be. */
- return SNMP_ERR_NOERROR;
- }
- /** handles requests for the pduCloudServerTable table, if anything else needs to be done */
- int
- pduCloudServerTable_handler(
- netsnmp_mib_handler *handler,
- netsnmp_handler_registration *reginfo,
- netsnmp_agent_request_info *reqinfo,
- netsnmp_request_info *requests) {
- /* perform anything here that you need to do. The requests have
- already been processed by the master table_dataset handler, but
- this gives you chance to act on the request in some other way
- if need be. */
- return SNMP_ERR_NOERROR;
- }
- /** handles requests for the pduAlarmHistoryTable table, if anything else needs to be done */
- int
- pduAlarmHistoryTable_handler(
- netsnmp_mib_handler *handler,
- netsnmp_handler_registration *reginfo,
- netsnmp_agent_request_info *reqinfo,
- netsnmp_request_info *requests) {
- /* perform anything here that you need to do. The requests have
- already been processed by the master table_dataset handler, but
- this gives you chance to act on the request in some other way
- if need be. */
- netsnmp_request_info *request;
- netsnmp_table_request_info *table_info;
- //
- char buffer[16];
- oid begin_next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 6, 1, 1, 1, 1};
- int max_clonum = 7;
- switch (reqinfo->mode)
- {
- case MODE_GET:
- case MODE_GETNEXT:
- {
- // 初始化表
- int nAlarmNumber = 0;
- _AlarmAckInfo _alarm_ack_info; // 填充数据
- INIT_LIST_HEAD(&_alarm_ack_info.list);
- // 查询数据库,最近的10个报警信息
- char start_time[32] = {0};
- char stop_time[32] = {0};
- struct tm *t;
- struct timeval tv;
- gettimeofday(&tv, NULL);
- t = localtime(&tv.tv_sec);
- sprintf(stop_time, "%04d-%02d-%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, 23, 59, 59);
- sprintf(start_time, "%04d-%02d-%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, 0, 0, 0);
- int ret = dev_search_alarm_info(__globalDeviceManage.db,
- __globalDeviceManage._globalDevInfo.product.id,
- -1, start_time, stop_time,
- 1, 10,
- &_alarm_ack_info, &nAlarmNumber);
- if (ret != 0)
- {
- log_e("get power alarm error.");
- return SNMP_ERR_GENERR;
- }
-
- for (request = requests; request; request = request->next)
- {
- table_info = netsnmp_extract_table_info(request);
- if (reqinfo->mode == MODE_GETNEXT)
- {
- if (table_info->index_oid[0] == 0)
- {
- table_info->index_oid[0] = 1;
- table_info->colnum = 1;
- snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
- }
- else
- {
- if (table_info->colnum > max_clonum)
- {
- table_info->index_oid[0] += 1;
- table_info->colnum = 1;
- }
- oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 6, 1, 1, table_info->colnum, table_info->index_oid[0]};
- snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
- }
- }
- int nIndex = 1;
- _AlarmAckInfo *_temp;
- list_for_each_entry(_temp, &_alarm_ack_info.list, list)
- {
- if (nIndex < table_info->index_oid[0])
- {
- nIndex++;
- continue;
- }
- if (!_temp)
- {
- break;
- }
- memset(buffer, 0, sizeof(buffer));
- switch (table_info->colnum)
- {
- case COLUMN_PDUALARMID:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, nIndex);
- break;
- case COLUMN_PDUALARMTYPE:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, _temp->alarmType);
- break;
- case COLUMN_PDUALARMCONTEXT:
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, _temp->alarmContent, strlen(_temp->alarmContent));
- break;
- case COLUMN_PDUALARMACTION:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, -1);
- break;
- case COLUMN_PDUALARMACTIONPARA:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, -1);
- break;
- case COLUMN_PDUALARMDATE:
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, _temp->alarmDate, strlen(_temp->alarmDate));
- break;
- case COLUMN_PDUALARMTIME:
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, _temp->alarmDate, strlen(_temp->alarmDate));
- break;
- default:
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
- break;
- }
- //}
- break;
- }
- }
- // 释放资源
- if (0 == ret)
- {
- _AlarmAckInfo *node;
- _AlarmAckInfo *next;
- list_for_each_entry_safe(node, next, &_alarm_ack_info.list, list)
- {
- list_del(&node->list);
- free(node);
- }
- }
- }
- break;
- case MODE_SET_RESERVE1:
- break;
- case MODE_SET_RESERVE2:
- break;
- case MODE_SET_FREE:
- break;
- case MODE_SET_ACTION:
- break;
- case MODE_SET_UNDO:
- break;
- case MODE_SET_COMMIT:
- break;
- default:
- /* we should never get here, so this is a really bad error */
- snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode);
- return SNMP_ERR_GENERR;
- }
- return SNMP_ERR_NOERROR;
- }
- /** handles requests for the pduChannelLimitTable table, if anything else needs to be done */
- int
- pduChannelLimitTable_handler(
- netsnmp_mib_handler *handler,
- netsnmp_handler_registration *reginfo,
- netsnmp_agent_request_info *reqinfo,
- netsnmp_request_info *requests) {
- /* perform anything here that you need to do. The requests have
- already been processed by the master table_dataset handler, but
- this gives you chance to act on the request in some other way
- if need be. */
- netsnmp_request_info *request;
- netsnmp_table_request_info *table_info;
- GlobalPowerManger *iterator = NULL;
- //
- char buffer[16];
- oid begin_next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 7, 2, 6, 1, 1, 1};
- int max_clonum = 7;
- switch (reqinfo->mode)
- {
- case MODE_GET:
- case MODE_GETNEXT:
- for (request = requests; request; request = request->next)
- {
- table_info = netsnmp_extract_table_info(request);
- if (reqinfo->mode == MODE_GETNEXT)
- {
- if (table_info->index_oid[0] == 0)
- {
- table_info->index_oid[0] = 1;
- table_info->colnum = 1;
- snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
- }
- else
- {
- if (table_info->colnum > max_clonum)
- {
- table_info->index_oid[0] += 1;
- table_info->colnum = 1;
- }
- oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 7, 2, 6, 1,table_info->colnum, table_info->index_oid[0]};
- snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
- }
- }
- int nIndex = 1;
- list_for_each_entry(iterator, &__globalDeviceManage._globalPowerManger.list, list)
- {
- if (nIndex < table_info->index_oid[0])
- {
- nIndex++;
- continue;
- }
- if (!iterator)
- {
- break;
- }
- memset(buffer, 0, sizeof(buffer));
- switch (table_info->colnum)
- {
- case COLUMN_PDUCHANNELLIMITID:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->product_ch_id);
- break;
- case COLUMN_PDUCHANNELLIMITNAME:
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, iterator->product_ch_name, strlen(iterator->product_ch_name));
- break;
- case COLUMN_PDUCHANNELCURRENTLIMITUP:
- sprintf(buffer, "%0.2f", iterator->global_over_manager.product_cur_upper_threshold);
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- case COLUMN_PDUCHANNELVOLTAGELIMITUP:
- sprintf(buffer, "%0.2f", iterator->global_over_manager.product_vol_upper_threshold);
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- case COLUMN_PDUCHANNELVOLTAGELIMITDOWN:
- sprintf(buffer, "%0.2f", iterator->global_over_manager.product_vol_lower_threshold);
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- case COLUMN_PDUCHANNELPOWERLIMITUP:
- sprintf(buffer, "%0.2f", iterator->global_over_manager.product_pwr_upper_threshold);
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- case COLUMN_PDUCHANNELCONSUMPTIONLIMITUP:
- sprintf(buffer, "%0.2f", iterator->global_over_manager.product_pwrcon_upper_threshold);
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
- break;
- default:
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
- break;
- }
- //}
- break;
- }
- }
- break;
- case MODE_SET_RESERVE1:
- break;
- case MODE_SET_RESERVE2:
- break;
- case MODE_SET_FREE:
- break;
- case MODE_SET_ACTION:
- break;
- case MODE_SET_UNDO:
- break;
- case MODE_SET_COMMIT:
- break;
- default:
- /* we should never get here, so this is a really bad error */
- snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode);
- return SNMP_ERR_GENERR;
- }
- return SNMP_ERR_NOERROR;
- }
- /** handles requests for the pduSensorLimitTable table, if anything else needs to be done */
- int
- pduSensorLimitTable_handler(
- netsnmp_mib_handler *handler,
- netsnmp_handler_registration *reginfo,
- netsnmp_agent_request_info *reqinfo,
- netsnmp_request_info *requests) {
- /* perform anything here that you need to do. The requests have
- already been processed by the master table_dataset handler, but
- this gives you chance to act on the request in some other way
- if need be. */
- netsnmp_request_info *request;
- netsnmp_table_request_info *table_info;
- GlobalSensorManger *iterator = NULL;
- //
- char buffer[16];
- oid begin_next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 7, 3, 1, 1, 1, 1};
- int max_clonum = 6;
- switch (reqinfo->mode)
- {
- case MODE_GET:
- case MODE_GETNEXT:
- for (request = requests; request; request = request->next)
- {
- table_info = netsnmp_extract_table_info(request);
- if (reqinfo->mode == MODE_GETNEXT)
- {
- if (table_info->index_oid[0] == 0)
- {
- table_info->index_oid[0] = 1;
- table_info->colnum = 1;
- snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
- }
- else
- {
- if (table_info->colnum > max_clonum)
- {
- table_info->index_oid[0] += 1;
- table_info->colnum = 1;
- }
- oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 7, 3, 1, 1, table_info->colnum, table_info->index_oid[0]};
- snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
- }
- }
- int nIndex = table_info->index_oid[0];
- list_for_each_entry(iterator, &__globalDeviceManage._globalSensorManger.list, list)
- {
- if (!iterator || nIndex != iterator->sensor_id)
- {
- continue;
- }
- memset(buffer, 0, sizeof(buffer));
- switch (table_info->colnum)
- {
- case COLUMN_PDUSENSORLIMITID:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_id);
- break;
- case COLUMN_PDUSENSORLIMITNAME:
- snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, iterator->sensor_name, strlen(iterator->sensor_name));
- break;
- case COLUMN_PDUSENSORLIMITVALUE1UP:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->over_manager.sensor_val1_upper_threshold);
- break;
- case COLUMN_PDUSENSORLIMITVALUE2UP:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->over_manager.sensor_val2_upper_threshold);
- break;
- case COLUMN_PDUSENSORLIMITVALUE1DOWN:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->over_manager.sensor_val1_lower_threshold);
- break;
- case COLUMN_PDUSENSORLIMITVALUE2DOWN:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->over_manager.sensor_val2_lower_threshold);
- break;
- default:
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
- break;
- }
- //}
- break;
- }
- }
- break;
- case MODE_SET_RESERVE1:
- break;
- case MODE_SET_RESERVE2:
- break;
- case MODE_SET_FREE:
- break;
- case MODE_SET_ACTION:
- break;
- case MODE_SET_UNDO:
- break;
- case MODE_SET_COMMIT:
- break;
- default:
- /* we should never get here, so this is a really bad error */
- snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode);
- return SNMP_ERR_GENERR;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- pduPowerAlarmTable_handler(
- netsnmp_mib_handler *handler,
- netsnmp_handler_registration *reginfo,
- netsnmp_agent_request_info *reqinfo,
- netsnmp_request_info *requests) {
- /* perform anything here that you need to do. The requests have
- already been processed by the master table_dataset handler, but
- this gives you chance to act on the request in some other way
- if need be. */
- netsnmp_request_info *request;
- netsnmp_table_request_info *table_info;
- GlobalPowerManger *iterator = NULL;
- //
- char buffer[16];
- oid begin_next_oid[] = {1,3,6,1,4,1,2024,1,6,2,1,1,1};
- int max_clonum = 6;
- switch (reqinfo->mode)
- {
- case MODE_GET:
- case MODE_GETNEXT:
- for (request = requests; request; request = request->next)
- {
- table_info = netsnmp_extract_table_info(request);
- if (reqinfo->mode == MODE_GETNEXT)
- {
- if (table_info->index_oid[0] == 0)
- {
- table_info->index_oid[0] = 1;
- table_info->colnum = 1;
- snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
- }
- else
- {
- if (table_info->colnum > max_clonum)
- {
- table_info->index_oid[0] += 1;
- table_info->colnum = 1;
- }
- oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 6, 2, 1,table_info->colnum, table_info->index_oid[0]};
- snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
- }
- }
- int nIndex = 1;
- list_for_each_entry(iterator, &__globalDeviceManage._globalPowerManger.list, list)
- {
- if (nIndex < table_info->index_oid[0])
- {
- nIndex++;
- continue;
- }
- if (!iterator)
- {
- break;
- }
- memset(buffer, 0, sizeof(buffer));
- switch (table_info->colnum)
- {
- case COLUMN_PDUCHANNELPOWERALARMID:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->product_ch_id);
- break;
- case COLUMN_PDUCHANNELPOWERALARMVOLTAGEUP:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->_PowerWarninginfo.w_voltage_up);
- break;
- case COLUMN_PDUCHANNELPOWERALARMVOLTAGEDOWN:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->_PowerWarninginfo.w_voltage_down);
- break;
- case COLUMN_PDUCHANNELPOWERALARMCURRENTUP:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->_PowerWarninginfo.w_current);
- break;
- case COLUMN_PDUCHANNELPOWERALARMPOWERUP:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->_PowerWarninginfo.w_power);
- break;
- case COLUMN_PDUCHANNELPOWERALARMCONSUMPTIONUP:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->_PowerWarninginfo.w_consumption);
- break;
- default:
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
- break;
- }
- //}
- break;
- }
- }
- break;
- case MODE_SET_RESERVE1:
- break;
- case MODE_SET_RESERVE2:
- break;
- case MODE_SET_FREE:
- break;
- case MODE_SET_ACTION:
- break;
- case MODE_SET_UNDO:
- break;
- case MODE_SET_COMMIT:
- break;
- default:
- /* we should never get here, so this is a really bad error */
- snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode);
- return SNMP_ERR_GENERR;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- pduSensorAlarmTable_handler(
- netsnmp_mib_handler *handler,
- netsnmp_handler_registration *reginfo,
- netsnmp_agent_request_info *reqinfo,
- netsnmp_request_info *requests) {
- /* perform anything here that you need to do. The requests have
- already been processed by the master table_dataset handler, but
- this gives you chance to act on the request in some other way
- if need be. */
- netsnmp_request_info *request;
- netsnmp_table_request_info *table_info;
- GlobalSensorManger *iterator = NULL;
- //
- char buffer[16];
- oid begin_next_oid[] = {1,3,6,1,4,1,2024,1,6,3,1,1,1};
- int max_clonum = 5;
- switch (reqinfo->mode)
- {
- case MODE_GET:
- case MODE_GETNEXT:
- for (request = requests; request; request = request->next)
- {
- table_info = netsnmp_extract_table_info(request);
- if (reqinfo->mode == MODE_GETNEXT)
- {
- if (table_info->index_oid[0] == 0)
- {
- table_info->index_oid[0] = 1;
- table_info->colnum = 1;
- snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
- }
- else
- {
- if (table_info->colnum > max_clonum)
- {
- table_info->index_oid[0] += 1;
- table_info->colnum = 1;
- }
- oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 6, 3, 1, table_info->colnum, table_info->index_oid[0]};
- snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
- }
- }
- int nIndex = table_info->index_oid[0];
- list_for_each_entry(iterator, &__globalDeviceManage._globalSensorManger.list, list)
- {
- if (!iterator || nIndex != iterator->sensor_id)
- {
- continue;
- }
- memset(buffer, 0, sizeof(buffer));
- switch (table_info->colnum)
- {
- case COLUMN_PDUSENSORALARMID:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_id);
- break;
- case COLUMN_PDUSENSORALARMVALUE1UP:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->warning_status.sensor_val1_upper);
- break;
- case COLUMN_PDUSENSORALARMVALUE1DOWN:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,iterator->warning_status.sensor_val1_lower);
- break;
- case COLUMN_PDUSENSORALARMVALUE2UP:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->warning_status.sensor_val2_upper);
- break;
- case COLUMN_PDUSENSORALARMVALUE2DOWN:
- snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,iterator->warning_status.sensor_val2_lower);
- break;
- default:
- netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
- break;
- }
- //}
- break;
- }
- }
- break;
- case MODE_SET_RESERVE1:
- break;
- case MODE_SET_RESERVE2:
- break;
- case MODE_SET_FREE:
- break;
- case MODE_SET_ACTION:
- break;
- case MODE_SET_UNDO:
- break;
- case MODE_SET_COMMIT:
- break;
- default:
- /* we should never get here, so this is a really bad error */
- snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode);
- return SNMP_ERR_GENERR;
- }
- return SNMP_ERR_NOERROR;
- }
|