| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068 |
- /*
- * 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 "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_INTEGER, 0,
- NULL, 0,
- COLUMN_PDUSENSORVALUE2, ASN_INTEGER, 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_PDUSENSORLIMITVALUE1, ASN_INTEGER, 1,
- NULL, 0,
- COLUMN_PDUSENSORLIMITVALUE2, 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);
- }
- /** 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();
- }
- /** 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];
- switch(reqinfo->mode)
- {
- case MODE_GET:
- 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(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._global_device_info->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;
- 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];
- switch (reqinfo->mode)
- {
- case MODE_GET:
- 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_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._global_device_info->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[_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. */
- 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. */
- 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. */
- 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. */
- return SNMP_ERR_NOERROR;
- }
|