| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069 |
- /*
- * 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_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._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];
- 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._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. */
- 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;
- }
|