pduMIB_form.c 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878
  1. /*
  2. * Note: this file originally auto-generated by mib2c
  3. * using mib2c.create-dataset.conf
  4. */
  5. #include <net-snmp/net-snmp-config.h>
  6. #include <net-snmp/net-snmp-includes.h>
  7. #include <net-snmp/agent/net-snmp-agent-includes.h>
  8. #include "pduMIB_form.h"
  9. #include "switch_ctrl.h"
  10. #include "sqlite_handle.h"
  11. #include "common.h"
  12. /** Initialize the pduChannelTable table by defining its contents and how it's structured */
  13. void
  14. initialize_table_pduChannelTable(void)
  15. {
  16. const oid pduChannelTable_oid[] = {1,3,6,1,4,1,2024,1,3,9};
  17. netsnmp_table_data_set *table_set;
  18. /* create the table structure itself */
  19. table_set = netsnmp_create_table_data_set("pduChannelTable");
  20. /* comment this out or delete if you don't support creation of new rows */
  21. table_set->allow_creation = 1;
  22. /***************************************************
  23. * Adding indexes
  24. */
  25. DEBUGMSGTL(("initialize_table_pduChannelTable",
  26. "adding indexes to table pduChannelTable\n"));
  27. netsnmp_table_set_add_indexes(table_set,
  28. ASN_INTEGER, /* index: pduChannelID */
  29. 0);
  30. DEBUGMSGTL(("initialize_table_pduChannelTable",
  31. "adding column types to table pduChannelTable\n"));
  32. netsnmp_table_set_multi_add_default_row(table_set,
  33. COLUMN_PDUCHANNELID, ASN_INTEGER, 0,
  34. NULL, 0,
  35. COLUMN_PDUCHANNELNAME, ASN_OCTET_STR, 0,
  36. NULL, 0,
  37. COLUMN_PDUCHANNELSTATUS, ASN_INTEGER, 1,
  38. NULL, 0,
  39. COLUMN_PDUCHANNELVOLTAGE, ASN_OCTET_STR, 0,
  40. NULL, 0,
  41. COLUMN_PDUCHANNELCURRENT, ASN_OCTET_STR, 0,
  42. NULL, 0,
  43. COLUMN_PDUCHANNELFREQUENCY, ASN_INTEGER, 0,
  44. NULL, 0,
  45. COLUMN_PDUCHANNELCONSUMPTION, ASN_OCTET_STR, 0,
  46. NULL, 0,
  47. COLUMN_PDUCHANNELPOWERFACTOR, ASN_OCTET_STR, 0,
  48. NULL, 0,
  49. COLUMN_PDUCHANNELPACTIVEPOWER, ASN_OCTET_STR, 0,
  50. NULL, 0,
  51. COLUMN_PDUCHANNELREACTIVEPOWER, ASN_OCTET_STR, 0,
  52. NULL, 0,
  53. COLUMN_PDUCHANNELAPPARENTPOWER, ASN_OCTET_STR, 0,
  54. NULL, 0,
  55. 0);
  56. /* registering the table with the master agent */
  57. /* note: if you don't need a subhandler to deal with any aspects
  58. of the request, change pduChannelTable_handler to "NULL" */
  59. netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduChannelTable", pduChannelTable_handler,
  60. pduChannelTable_oid,
  61. OID_LENGTH(pduChannelTable_oid),
  62. HANDLER_CAN_RWRITE),
  63. table_set, NULL);
  64. }
  65. /** Initialize the pduGroupTable table by defining its contents and how it's structured */
  66. void
  67. initialize_table_pduGroupTable(void)
  68. {
  69. const oid pduGroupTable_oid[] = {1,3,6,1,4,1,2024,1,3,10};
  70. netsnmp_table_data_set *table_set;
  71. /* create the table structure itself */
  72. table_set = netsnmp_create_table_data_set("pduGroupTable");
  73. /* comment this out or delete if you don't support creation of new rows */
  74. table_set->allow_creation = 1;
  75. /***************************************************
  76. * Adding indexes
  77. */
  78. DEBUGMSGTL(("initialize_table_pduGroupTable",
  79. "adding indexes to table pduGroupTable\n"));
  80. netsnmp_table_set_add_indexes(table_set,
  81. ASN_INTEGER, /* index: pduGroupID */
  82. 0);
  83. DEBUGMSGTL(("initialize_table_pduGroupTable",
  84. "adding column types to table pduGroupTable\n"));
  85. netsnmp_table_set_multi_add_default_row(table_set,
  86. COLUMN_PDUGROUPID, ASN_INTEGER, 0,
  87. NULL, 0,
  88. COLUMN_PDUGROUPNAME, ASN_OCTET_STR, 1,
  89. NULL, 0,
  90. COLUMN_PDUGROUPLIST, ASN_OCTET_STR, 1,
  91. NULL, 0,
  92. COLUMN_PDUGROUPSTATUS, ASN_INTEGER, 1,
  93. NULL, 0,
  94. 0);
  95. /* registering the table with the master agent */
  96. /* note: if you don't need a subhandler to deal with any aspects
  97. of the request, change pduGroupTable_handler to "NULL" */
  98. netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduGroupTable", pduGroupTable_handler,
  99. pduGroupTable_oid,
  100. OID_LENGTH(pduGroupTable_oid),
  101. HANDLER_CAN_RWRITE),
  102. table_set, NULL);
  103. }
  104. /** Initialize the pduSensorTable table by defining its contents and how it's structured */
  105. void
  106. initialize_table_pduSensorTable(void)
  107. {
  108. const oid pduSensorTable_oid[] = {1,3,6,1,4,1,2024,1,4,1};
  109. netsnmp_table_data_set *table_set;
  110. /* create the table structure itself */
  111. table_set = netsnmp_create_table_data_set("pduSensorTable");
  112. /* comment this out or delete if you don't support creation of new rows */
  113. table_set->allow_creation = 1;
  114. /***************************************************
  115. * Adding indexes
  116. */
  117. DEBUGMSGTL(("initialize_table_pduSensorTable",
  118. "adding indexes to table pduSensorTable\n"));
  119. netsnmp_table_set_add_indexes(table_set,
  120. ASN_INTEGER, /* index: pduSensorID */
  121. 0);
  122. DEBUGMSGTL(("initialize_table_pduSensorTable",
  123. "adding column types to table pduSensorTable\n"));
  124. netsnmp_table_set_multi_add_default_row(table_set,
  125. COLUMN_PDUSENSORID, ASN_INTEGER, 0,
  126. NULL, 0,
  127. COLUMN_PDUSENSORNAME, ASN_OCTET_STR, 0,
  128. NULL, 0,
  129. COLUMN_PDUSENSORTYPE, ASN_INTEGER, 0,
  130. NULL, 0,
  131. COLUMN_PDUSENSORDATACHENNEL, ASN_OCTET_STR, 0,
  132. NULL, 0,
  133. COLUMN_PDUSENSORMODBUSADDRESS, ASN_INTEGER, 0,
  134. NULL, 0,
  135. COLUMN_PDUSENSORSTATUS, ASN_INTEGER, 1,
  136. NULL, 0,
  137. COLUMN_PDUSENSORVALUENUM, ASN_INTEGER, 0,
  138. NULL, 0,
  139. COLUMN_PDUSENSORVALUE1, ASN_OCTET_STR, 0,
  140. NULL, 0,
  141. COLUMN_PDUSENSORVALUE2, ASN_OCTET_STR, 0,
  142. NULL, 0,
  143. 0);
  144. /* registering the table with the master agent */
  145. /* note: if you don't need a subhandler to deal with any aspects
  146. of the request, change pduSensorTable_handler to "NULL" */
  147. netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduSensorTable", pduSensorTable_handler,
  148. pduSensorTable_oid,
  149. OID_LENGTH(pduSensorTable_oid),
  150. HANDLER_CAN_RWRITE),
  151. table_set, NULL);
  152. }
  153. /** Initialize the pduSMTPRecMailTable table by defining its contents and how it's structured */
  154. void
  155. initialize_table_pduSMTPRecMailTable(void)
  156. {
  157. const oid pduSMTPRecMailTable_oid[] = {1,3,6,1,4,1,2024,1,5,3,4};
  158. netsnmp_table_data_set *table_set;
  159. /* create the table structure itself */
  160. table_set = netsnmp_create_table_data_set("pduSMTPRecMailTable");
  161. /* comment this out or delete if you don't support creation of new rows */
  162. table_set->allow_creation = 1;
  163. /***************************************************
  164. * Adding indexes
  165. */
  166. DEBUGMSGTL(("initialize_table_pduSMTPRecMailTable",
  167. "adding indexes to table pduSMTPRecMailTable\n"));
  168. netsnmp_table_set_add_indexes(table_set,
  169. ASN_OCTET_STR, /* index: pduSMTPRecMail */
  170. 0);
  171. DEBUGMSGTL(("initialize_table_pduSMTPRecMailTable",
  172. "adding column types to table pduSMTPRecMailTable\n"));
  173. netsnmp_table_set_multi_add_default_row(table_set,
  174. COLUMN_PDUSMTPRECMAIL, ASN_OCTET_STR, 1,
  175. NULL, 0,
  176. 0);
  177. /* registering the table with the master agent */
  178. /* note: if you don't need a subhandler to deal with any aspects
  179. of the request, change pduSMTPRecMailTable_handler to "NULL" */
  180. netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduSMTPRecMailTable", pduSMTPRecMailTable_handler,
  181. pduSMTPRecMailTable_oid,
  182. OID_LENGTH(pduSMTPRecMailTable_oid),
  183. HANDLER_CAN_RWRITE),
  184. table_set, NULL);
  185. }
  186. /** Initialize the pduMessageNumTable table by defining its contents and how it's structured */
  187. void
  188. initialize_table_pduMessageNumTable(void)
  189. {
  190. const oid pduMessageNumTable_oid[] = {1,3,6,1,4,1,2024,1,5,5,2};
  191. netsnmp_table_data_set *table_set;
  192. /* create the table structure itself */
  193. table_set = netsnmp_create_table_data_set("pduMessageNumTable");
  194. /* comment this out or delete if you don't support creation of new rows */
  195. table_set->allow_creation = 1;
  196. /***************************************************
  197. * Adding indexes
  198. */
  199. DEBUGMSGTL(("initialize_table_pduMessageNumTable",
  200. "adding indexes to table pduMessageNumTable\n"));
  201. netsnmp_table_set_add_indexes(table_set,
  202. ASN_OCTET_STR, /* index: pduMessageRecNum */
  203. 0);
  204. DEBUGMSGTL(("initialize_table_pduMessageNumTable",
  205. "adding column types to table pduMessageNumTable\n"));
  206. netsnmp_table_set_multi_add_default_row(table_set,
  207. COLUMN_PDUMESSAGERECNUM, ASN_OCTET_STR, 1,
  208. NULL, 0,
  209. 0);
  210. /* registering the table with the master agent */
  211. /* note: if you don't need a subhandler to deal with any aspects
  212. of the request, change pduMessageNumTable_handler to "NULL" */
  213. netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduMessageNumTable", pduMessageNumTable_handler,
  214. pduMessageNumTable_oid,
  215. OID_LENGTH(pduMessageNumTable_oid),
  216. HANDLER_CAN_RWRITE),
  217. table_set, NULL);
  218. }
  219. /** Initialize the pduMQTTBrokerTable table by defining its contents and how it's structured */
  220. void
  221. initialize_table_pduMQTTBrokerTable(void)
  222. {
  223. const oid pduMQTTBrokerTable_oid[] = {1,3,6,1,4,1,2024,1,5,6,3};
  224. netsnmp_table_data_set *table_set;
  225. /* create the table structure itself */
  226. table_set = netsnmp_create_table_data_set("pduMQTTBrokerTable");
  227. /* comment this out or delete if you don't support creation of new rows */
  228. table_set->allow_creation = 1;
  229. /***************************************************
  230. * Adding indexes
  231. */
  232. DEBUGMSGTL(("initialize_table_pduMQTTBrokerTable",
  233. "adding indexes to table pduMQTTBrokerTable\n"));
  234. netsnmp_table_set_add_indexes(table_set,
  235. ASN_OCTET_STR, /* index: pduMQTTBrokerName */
  236. 0);
  237. DEBUGMSGTL(("initialize_table_pduMQTTBrokerTable",
  238. "adding column types to table pduMQTTBrokerTable\n"));
  239. netsnmp_table_set_multi_add_default_row(table_set,
  240. COLUMN_PDUMQTTBROKERNAME, ASN_OCTET_STR, 1,
  241. NULL, 0,
  242. COLUMN_PDUMQTTBROKERENABLE, ASN_INTEGER, 1,
  243. NULL, 0,
  244. COLUMN_PDUMQTTBROKERIPORDOMAIN, ASN_OCTET_STR, 1,
  245. NULL, 0,
  246. COLUMN_PDUMQTTBROKERPORT, ASN_INTEGER, 1,
  247. NULL, 0,
  248. COLUMN_PDUMQTTBROKERUSERNAME, ASN_OCTET_STR, 1,
  249. NULL, 0,
  250. COLUMN_PDUMQTTBROKERUSERPW, ASN_OCTET_STR, 1,
  251. NULL, 0,
  252. 0);
  253. /* registering the table with the master agent */
  254. /* note: if you don't need a subhandler to deal with any aspects
  255. of the request, change pduMQTTBrokerTable_handler to "NULL" */
  256. netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduMQTTBrokerTable", pduMQTTBrokerTable_handler,
  257. pduMQTTBrokerTable_oid,
  258. OID_LENGTH(pduMQTTBrokerTable_oid),
  259. HANDLER_CAN_RWRITE),
  260. table_set, NULL);
  261. }
  262. /** Initialize the pduCloudServerTable table by defining its contents and how it's structured */
  263. void
  264. initialize_table_pduCloudServerTable(void)
  265. {
  266. const oid pduCloudServerTable_oid[] = {1,3,6,1,4,1,2024,1,5,7,3};
  267. netsnmp_table_data_set *table_set;
  268. /* create the table structure itself */
  269. table_set = netsnmp_create_table_data_set("pduCloudServerTable");
  270. /* comment this out or delete if you don't support creation of new rows */
  271. table_set->allow_creation = 1;
  272. /***************************************************
  273. * Adding indexes
  274. */
  275. DEBUGMSGTL(("initialize_table_pduCloudServerTable",
  276. "adding indexes to table pduCloudServerTable\n"));
  277. netsnmp_table_set_add_indexes(table_set,
  278. ASN_OCTET_STR, /* index: pduCloudServerName */
  279. 0);
  280. DEBUGMSGTL(("initialize_table_pduCloudServerTable",
  281. "adding column types to table pduCloudServerTable\n"));
  282. netsnmp_table_set_multi_add_default_row(table_set,
  283. COLUMN_PDUCLOUDSERVERNAME, ASN_OCTET_STR, 1,
  284. NULL, 0,
  285. COLUMN_PDUCLOUDSERVERENABLE, ASN_INTEGER, 1,
  286. NULL, 0,
  287. COLUMN_PDUCLOUDSERVERIPORDOMAIN, ASN_OCTET_STR, 1,
  288. NULL, 0,
  289. COLUMN_PDUCLOUDSERVERPORT, ASN_INTEGER, 1,
  290. NULL, 0,
  291. COLUMN_PDUCLOUDSERVERUSERNAME, ASN_OCTET_STR, 1,
  292. NULL, 0,
  293. COLUMN_PDUCLOUDSERVERUSERPW, ASN_OCTET_STR, 1,
  294. NULL, 0,
  295. 0);
  296. /* registering the table with the master agent */
  297. /* note: if you don't need a subhandler to deal with any aspects
  298. of the request, change pduCloudServerTable_handler to "NULL" */
  299. netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduCloudServerTable", pduCloudServerTable_handler,
  300. pduCloudServerTable_oid,
  301. OID_LENGTH(pduCloudServerTable_oid),
  302. HANDLER_CAN_RWRITE),
  303. table_set, NULL);
  304. }
  305. /** Initialize the pduAlarmHistoryTable table by defining its contents and how it's structured */
  306. void
  307. initialize_table_pduAlarmHistoryTable(void)
  308. {
  309. const oid pduAlarmHistoryTable_oid[] = {1,3,6,1,4,1,2024,1,6,1};
  310. netsnmp_table_data_set *table_set;
  311. /* create the table structure itself */
  312. table_set = netsnmp_create_table_data_set("pduAlarmHistoryTable");
  313. /* comment this out or delete if you don't support creation of new rows */
  314. table_set->allow_creation = 1;
  315. /***************************************************
  316. * Adding indexes
  317. */
  318. DEBUGMSGTL(("initialize_table_pduAlarmHistoryTable",
  319. "adding indexes to table pduAlarmHistoryTable\n"));
  320. netsnmp_table_set_add_indexes(table_set,
  321. ASN_INTEGER, /* index: pduAlarmID */
  322. 0);
  323. DEBUGMSGTL(("initialize_table_pduAlarmHistoryTable",
  324. "adding column types to table pduAlarmHistoryTable\n"));
  325. netsnmp_table_set_multi_add_default_row(table_set,
  326. COLUMN_PDUALARMID, ASN_INTEGER, 0,
  327. NULL, 0,
  328. COLUMN_PDUALARMTYPE, ASN_INTEGER, 0,
  329. NULL, 0,
  330. COLUMN_PDUALARMCONTEXT, ASN_OCTET_STR, 0,
  331. NULL, 0,
  332. COLUMN_PDUALARMACTION, ASN_INTEGER, 0,
  333. NULL, 0,
  334. COLUMN_PDUALARMACTIONPARA, ASN_INTEGER, 0,
  335. NULL, 0,
  336. COLUMN_PDUALARMDATE, ASN_OCTET_STR, 0,
  337. NULL, 0,
  338. COLUMN_PDUALARMTIME, ASN_OCTET_STR, 0,
  339. NULL, 0,
  340. 0);
  341. /* registering the table with the master agent */
  342. /* note: if you don't need a subhandler to deal with any aspects
  343. of the request, change pduAlarmHistoryTable_handler to "NULL" */
  344. netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduAlarmHistoryTable", pduAlarmHistoryTable_handler,
  345. pduAlarmHistoryTable_oid,
  346. OID_LENGTH(pduAlarmHistoryTable_oid),
  347. HANDLER_CAN_RWRITE),
  348. table_set, NULL);
  349. }
  350. /** Initialize the pduChannelLimitTable table by defining its contents and how it's structured */
  351. void
  352. initialize_table_pduChannelLimitTable(void)
  353. {
  354. const oid pduChannelLimitTable_oid[] = {1,3,6,1,4,1,2024,1,7,2,6};
  355. netsnmp_table_data_set *table_set;
  356. /* create the table structure itself */
  357. table_set = netsnmp_create_table_data_set("pduChannelLimitTable");
  358. /* comment this out or delete if you don't support creation of new rows */
  359. table_set->allow_creation = 1;
  360. /***************************************************
  361. * Adding indexes
  362. */
  363. DEBUGMSGTL(("initialize_table_pduChannelLimitTable",
  364. "adding indexes to table pduChannelLimitTable\n"));
  365. netsnmp_table_set_add_indexes(table_set,
  366. ASN_INTEGER, /* index: pduChannelLimitID */
  367. 0);
  368. DEBUGMSGTL(("initialize_table_pduChannelLimitTable",
  369. "adding column types to table pduChannelLimitTable\n"));
  370. netsnmp_table_set_multi_add_default_row(table_set,
  371. COLUMN_PDUCHANNELLIMITID, ASN_INTEGER, 0,
  372. NULL, 0,
  373. COLUMN_PDUCHANNELLIMITNAME, ASN_OCTET_STR, 1,
  374. NULL, 0,
  375. COLUMN_PDUCHANNELCURRENTLIMITUP, ASN_OCTET_STR, 1,
  376. NULL, 0,
  377. COLUMN_PDUCHANNELVOLTAGELIMITUP, ASN_OCTET_STR, 1,
  378. NULL, 0,
  379. COLUMN_PDUCHANNELVOLTAGELIMITDOWN, ASN_OCTET_STR, 1,
  380. NULL, 0,
  381. COLUMN_PDUCHANNELPOWERLIMITUP, ASN_OCTET_STR, 1,
  382. NULL, 0,
  383. COLUMN_PDUCHANNELCONSUMPTIONLIMITUP, ASN_OCTET_STR, 1,
  384. NULL, 0,
  385. 0);
  386. /* registering the table with the master agent */
  387. /* note: if you don't need a subhandler to deal with any aspects
  388. of the request, change pduChannelLimitTable_handler to "NULL" */
  389. netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduChannelLimitTable", pduChannelLimitTable_handler,
  390. pduChannelLimitTable_oid,
  391. OID_LENGTH(pduChannelLimitTable_oid),
  392. HANDLER_CAN_RWRITE),
  393. table_set, NULL);
  394. }
  395. /** Initialize the pduSensorLimitTable table by defining its contents and how it's structured */
  396. void
  397. initialize_table_pduSensorLimitTable(void)
  398. {
  399. const oid pduSensorLimitTable_oid[] = {1,3,6,1,4,1,2024,1,7,3,1};
  400. netsnmp_table_data_set *table_set;
  401. /* create the table structure itself */
  402. table_set = netsnmp_create_table_data_set("pduSensorLimitTable");
  403. /* comment this out or delete if you don't support creation of new rows */
  404. table_set->allow_creation = 1;
  405. /***************************************************
  406. * Adding indexes
  407. */
  408. DEBUGMSGTL(("initialize_table_pduSensorLimitTable",
  409. "adding indexes to table pduSensorLimitTable\n"));
  410. netsnmp_table_set_add_indexes(table_set,
  411. ASN_INTEGER, /* index: pduSensorLimitID */
  412. 0);
  413. DEBUGMSGTL(("initialize_table_pduSensorLimitTable",
  414. "adding column types to table pduSensorLimitTable\n"));
  415. netsnmp_table_set_multi_add_default_row(table_set,
  416. COLUMN_PDUSENSORLIMITID, ASN_INTEGER, 1,
  417. NULL, 0,
  418. COLUMN_PDUSENSORLIMITNAME, ASN_OCTET_STR, 1,
  419. NULL, 0,
  420. COLUMN_PDUSENSORLIMITVALUE1UP, ASN_INTEGER, 1,
  421. NULL, 0,
  422. COLUMN_PDUSENSORLIMITVALUE2UP, ASN_INTEGER, 1,
  423. NULL, 0,
  424. COLUMN_PDUSENSORLIMITVALUE1DOWN, ASN_INTEGER, 1,
  425. NULL, 0,
  426. COLUMN_PDUSENSORLIMITVALUE2DOWN, ASN_INTEGER, 1,
  427. NULL, 0,
  428. 0);
  429. /* registering the table with the master agent */
  430. /* note: if you don't need a subhandler to deal with any aspects
  431. of the request, change pduSensorLimitTable_handler to "NULL" */
  432. netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduSensorLimitTable", pduSensorLimitTable_handler,
  433. pduSensorLimitTable_oid,
  434. OID_LENGTH(pduSensorLimitTable_oid),
  435. HANDLER_CAN_RWRITE),
  436. table_set, NULL);
  437. }
  438. void
  439. initialize_table_pduPowerAlarmTable(void)
  440. {
  441. const oid pduPowerAlarmTable_oid[] = {1,3,6,1,4,1,2024,1,6,2};
  442. netsnmp_table_data_set *table_set;
  443. /* create the table structure itself */
  444. table_set = netsnmp_create_table_data_set("pduPowerAlarmTable");
  445. /* comment this out or delete if you don't support creation of new rows */
  446. table_set->allow_creation = 1;
  447. /***************************************************
  448. * Adding indexes
  449. */
  450. DEBUGMSGTL(("initialize_table_pduPowerAlarmTable",
  451. "adding indexes to table pduPowerAlarmTable\n"));
  452. netsnmp_table_set_add_indexes(table_set,
  453. ASN_INTEGER, /* index: pduChannelPowerAlarmID */
  454. 0);
  455. DEBUGMSGTL(("initialize_table_pduPowerAlarmTable",
  456. "adding column types to table pduPowerAlarmTable\n"));
  457. netsnmp_table_set_multi_add_default_row(table_set,
  458. COLUMN_PDUCHANNELPOWERALARMID, ASN_INTEGER, 1,
  459. NULL, 0,
  460. COLUMN_PDUCHANNELPOWERALARMVOLTAGEUP, ASN_INTEGER, 1,
  461. NULL, 0,
  462. COLUMN_PDUCHANNELPOWERALARMVOLTAGEDOWN, ASN_INTEGER, 1,
  463. NULL, 0,
  464. COLUMN_PDUCHANNELPOWERALARMCURRENTUP, ASN_INTEGER, 1,
  465. NULL, 0,
  466. COLUMN_PDUCHANNELPOWERALARMPOWERUP, ASN_INTEGER, 1,
  467. NULL, 0,
  468. COLUMN_PDUCHANNELPOWERALARMCONSUMPTIONUP, ASN_INTEGER, 1,
  469. NULL, 0,
  470. 0);
  471. /* registering the table with the master agent */
  472. /* note: if you don't need a subhandler to deal with any aspects
  473. of the request, change pduPowerAlarmTable_handler to "NULL" */
  474. netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduPowerAlarmTable", pduPowerAlarmTable_handler,
  475. pduPowerAlarmTable_oid,
  476. OID_LENGTH(pduPowerAlarmTable_oid),
  477. HANDLER_CAN_RWRITE),
  478. table_set, NULL);
  479. }
  480. /** Initialize the pduSensorLimitTable table by defining its contents and how it's structured */
  481. void
  482. initialize_table_pduSensorAlarmTable(void)
  483. {
  484. const oid pduSensorAlarmTable_oid[] = {1,3,6,1,4,1,2024,1,6,3};
  485. netsnmp_table_data_set *table_set;
  486. /* create the table structure itself */
  487. table_set = netsnmp_create_table_data_set("pduSensorAlarmTable");
  488. /* comment this out or delete if you don't support creation of new rows */
  489. table_set->allow_creation = 1;
  490. /***************************************************
  491. * Adding indexes
  492. */
  493. DEBUGMSGTL(("initialize_table_pduSensorAlarmTable",
  494. "adding indexes to table pduSensorAlarmTable\n"));
  495. netsnmp_table_set_add_indexes(table_set,
  496. ASN_INTEGER, /* index: pduSensorAlarmID */
  497. 0);
  498. DEBUGMSGTL(("initialize_table_pduSensorAlarmTable",
  499. "adding column types to table pduSensorAlarmTable\n"));
  500. netsnmp_table_set_multi_add_default_row(table_set,
  501. COLUMN_PDUSENSORALARMID, ASN_INTEGER, 1,
  502. NULL, 0,
  503. COLUMN_PDUSENSORALARMVALUE1UP, ASN_OCTET_STR, 1,
  504. NULL, 0,
  505. COLUMN_PDUSENSORALARMVALUE1DOWN, ASN_INTEGER, 1,
  506. NULL, 0,
  507. COLUMN_PDUSENSORALARMVALUE2UP, ASN_INTEGER, 1,
  508. NULL, 0,
  509. COLUMN_PDUSENSORALARMVALUE2DOWN, ASN_INTEGER, 1,
  510. NULL, 0,
  511. 0);
  512. /* registering the table with the master agent */
  513. /* note: if you don't need a subhandler to deal with any aspects
  514. of the request, change pduSensorAlarmTable_handler to "NULL" */
  515. netsnmp_register_table_data_set(netsnmp_create_handler_registration("pduSensorAlarmTable", pduSensorAlarmTable_handler,
  516. pduSensorAlarmTable_oid,
  517. OID_LENGTH(pduSensorAlarmTable_oid),
  518. HANDLER_CAN_RWRITE),
  519. table_set, NULL);
  520. }
  521. /** Initializes the pduMIB module */
  522. void
  523. init_pduMIB_form(void)
  524. {
  525. /* here we initialize all the tables we're planning on supporting */
  526. initialize_table_pduChannelTable();
  527. initialize_table_pduGroupTable();
  528. initialize_table_pduSensorTable();
  529. initialize_table_pduSMTPRecMailTable();
  530. initialize_table_pduMessageNumTable();
  531. initialize_table_pduMQTTBrokerTable();
  532. initialize_table_pduCloudServerTable();
  533. initialize_table_pduAlarmHistoryTable();
  534. initialize_table_pduChannelLimitTable();
  535. initialize_table_pduSensorLimitTable();
  536. initialize_table_pduPowerAlarmTable();
  537. initialize_table_pduSensorAlarmTable();
  538. }
  539. /** handles requests for the pduChannelTable table, if anything else needs to be done */
  540. int
  541. pduChannelTable_handler(
  542. netsnmp_mib_handler *handler,
  543. netsnmp_handler_registration *reginfo,
  544. netsnmp_agent_request_info *reqinfo,
  545. netsnmp_request_info *requests) {
  546. /* perform anything here that you need to do. The requests have
  547. already been processed by the master table_dataset handler, but
  548. this gives you chance to act on the request in some other way
  549. if need be. */
  550. netsnmp_request_info *request;
  551. netsnmp_table_request_info *table_info;
  552. GlobalPowerManger* iterator;
  553. //GlobalPowerInfo powerInfo;
  554. char buffer[16];
  555. oid begin_next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 3, 9, 1, 1, 1};
  556. int max_clonum=11;
  557. switch(reqinfo->mode)
  558. {
  559. case MODE_GET:
  560. case MODE_GETNEXT:
  561. for (request = requests; request; request = request->next)
  562. {
  563. table_info = netsnmp_extract_table_info(request);
  564. if (reqinfo->mode==MODE_GETNEXT)
  565. {
  566. if (table_info->index_oid[0] == 0)
  567. {
  568. table_info->index_oid[0] = 1;
  569. table_info->colnum = 1;
  570. snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
  571. }
  572. else
  573. {
  574. if (table_info->colnum > max_clonum)
  575. {
  576. table_info->index_oid[0] += 1;
  577. table_info->colnum =1;
  578. }
  579. oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 3, 9, 1, table_info->colnum, table_info->index_oid[0]};
  580. snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
  581. }
  582. }
  583. int nIndex=1;
  584. list_for_each_entry(iterator, &__globalDeviceManage._globalPowerManger.list, list)
  585. {
  586. //查询数据库总电源信息 传给所申请的参数结构体
  587. //if(dev_search_power_trend_info(__globalDeviceManage.db,iterator->product_id,0,iterator)!=0)
  588. //{
  589. // log_e("search total power consumption err at pduChannelTable_handler from db.");
  590. //}
  591. //传值给总管理结构体
  592. // for(int i=0;i< TOTAL_COUNT;i++)
  593. // {
  594. // strcpy(_over_all_pwr_back_info._Power_Trend_Info.xAxis[i],__PowerTrendInfo._power_trend_info.xAxis[i]);
  595. // _over_all_pwr_back_info._Power_Trend_Info.ydata[POWER_MERITORIOUS_TYPE][i] = __PowerTrendInfo._power_trend_info.ydata[POWER_MERITORIOUS_TYPE][i];
  596. // _over_all_pwr_back_info._Power_Trend_Info.ydata[POWER_REACTIVE_TYPE][i] = __PowerTrendInfo._power_trend_info.ydata[POWER_REACTIVE_TYPE][i];
  597. // _over_all_pwr_back_info._Power_Trend_Info.ydata[POWER_APPARENT_TYPE][i] = __PowerTrendInfo._power_trend_info.ydata[POWER_APPARENT_TYPE][i];
  598. // }
  599. //if(dev_search_latest_power_info(__globalDeviceManage.db,__globalDeviceManage._globalDevInfo.product.id,iterator->product_ch_id,&powerInfo)!=0)
  600. //{
  601. // log_e("search total pwr err at pduChannelTable_handler from db.");
  602. //}
  603. //else
  604. //{
  605. if (nIndex<table_info->index_oid[0])
  606. {
  607. nIndex++;
  608. continue;
  609. }
  610. memset(buffer,0,sizeof(buffer));
  611. switch (table_info->colnum)
  612. {
  613. case COLUMN_PDUCHANNELID:
  614. if (!iterator)
  615. {
  616. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  617. continue;
  618. }
  619. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->product_ch_id);
  620. break;
  621. case COLUMN_PDUCHANNELNAME:
  622. if (!iterator)
  623. {
  624. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  625. continue;
  626. }
  627. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, iterator->product_ch_name, strlen(iterator->product_ch_name));
  628. break;
  629. case COLUMN_PDUCHANNELSTATUS:
  630. if (!iterator)
  631. {
  632. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  633. continue;
  634. }
  635. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->_PowerInfo.status);
  636. break;
  637. case COLUMN_PDUCHANNELVOLTAGE:
  638. if (!iterator)
  639. {
  640. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  641. continue;
  642. }
  643. sprintf(buffer,"%0.3f",iterator->_PowerInfo.voltage);
  644. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  645. break;
  646. case COLUMN_PDUCHANNELCURRENT:
  647. if (!iterator)
  648. {
  649. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  650. continue;
  651. }
  652. sprintf(buffer,"%0.3f",iterator->_PowerInfo.current);
  653. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  654. break;
  655. case COLUMN_PDUCHANNELFREQUENCY:
  656. if (!iterator)
  657. {
  658. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  659. continue;
  660. }
  661. sprintf(buffer,"%0.3f",iterator->_PowerInfo.freq);
  662. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  663. break;
  664. case COLUMN_PDUCHANNELCONSUMPTION:
  665. if (!iterator)
  666. {
  667. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  668. continue;
  669. }
  670. sprintf(buffer,"%0.3f",iterator->_PowerInfo.consumption);
  671. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  672. break;
  673. case COLUMN_PDUCHANNELPOWERFACTOR:
  674. if (!iterator)
  675. {
  676. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  677. continue;
  678. }
  679. sprintf(buffer,"%0.3f",iterator->_PowerInfo.factor);
  680. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  681. break;
  682. case COLUMN_PDUCHANNELPACTIVEPOWER:
  683. if (!iterator)
  684. {
  685. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  686. continue;
  687. }
  688. sprintf(buffer,"%0.3f",iterator->_PowerInfo.power);
  689. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  690. break;
  691. case COLUMN_PDUCHANNELREACTIVEPOWER:
  692. if (!iterator)
  693. {
  694. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  695. continue;
  696. }
  697. if (iterator->_PowerInfo.factor>0&&iterator->_PowerInfo.factor<=1)
  698. {
  699. sprintf(buffer,"%0.3f",(iterator->_PowerInfo.power/iterator->_PowerInfo.factor)-iterator->_PowerInfo.power);
  700. }else{
  701. sprintf(buffer,"0");
  702. }
  703. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  704. break;
  705. case COLUMN_PDUCHANNELAPPARENTPOWER:
  706. if (!iterator)
  707. {
  708. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  709. continue;
  710. }
  711. if (iterator->_PowerInfo.factor>0)
  712. {
  713. sprintf(buffer,"%0.3f",iterator->_PowerInfo.power/iterator->_PowerInfo.factor);
  714. }else{
  715. sprintf(buffer,"0");
  716. }
  717. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  718. break;
  719. default:
  720. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
  721. break;
  722. }
  723. //}
  724. break;
  725. }
  726. }
  727. break;
  728. case MODE_SET_RESERVE1:
  729. break;
  730. case MODE_SET_RESERVE2:
  731. break;
  732. case MODE_SET_FREE:
  733. break;
  734. case MODE_SET_ACTION:
  735. break;
  736. case MODE_SET_UNDO:
  737. break;
  738. case MODE_SET_COMMIT:
  739. /* XXX: delete temporary storage */
  740. // if (/* XXX: error? */) {
  741. // /* try _really_really_ hard to never get to this point */
  742. // netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_COMMITFAILED);
  743. // }
  744. for (request = requests; request; request = request->next)
  745. {
  746. table_info = netsnmp_extract_table_info(request);
  747. int nIndex = 1;
  748. list_for_each_entry(iterator, &__globalDeviceManage._globalPowerManger.list, list)
  749. {
  750. if (nIndex < table_info->index_oid[0])
  751. {
  752. nIndex++;
  753. continue;
  754. }
  755. memset(buffer, 0, sizeof(buffer));
  756. switch (table_info->colnum)
  757. {
  758. case COLUMN_PDUCHANNELSTATUS:
  759. if (!iterator)
  760. {
  761. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  762. continue;
  763. }
  764. int nCHOpertype = *request->requestvb->val.integer;
  765. if (nCHOpertype!= iterator->_PowerInfo.status)
  766. {
  767. log_d("SNMP Remote switch ctrl:%d", iterator->product_ch_id);
  768. g_switch_set_all_chn_ctrl(&__globalDeviceManage._globalRelaySampManger,
  769. iterator,
  770. iterator->product_saddr,
  771. iterator->product_ch_addr, // 多版端口余8
  772. nCHOpertype,false);
  773. }
  774. break;
  775. }
  776. break;
  777. }
  778. }
  779. break;
  780. default:
  781. /* we should never get here, so this is a really bad error */
  782. snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode );
  783. return SNMP_ERR_GENERR;
  784. }
  785. return SNMP_ERR_NOERROR;
  786. }
  787. /** handles requests for the pduGroupTable table, if anything else needs to be done */
  788. int
  789. pduGroupTable_handler(
  790. netsnmp_mib_handler *handler,
  791. netsnmp_handler_registration *reginfo,
  792. netsnmp_agent_request_info *reqinfo,
  793. netsnmp_request_info *requests) {
  794. /* perform anything here that you need to do. The requests have
  795. already been processed by the master table_dataset handler, but
  796. this gives you chance to act on the request in some other way
  797. if need be. */
  798. netsnmp_request_info *request=NULL;
  799. netsnmp_table_request_info *table_info;
  800. GroupInfo *_GroupInfoTemp = NULL;
  801. GroupInfo group_list;
  802. INIT_LIST_HEAD(&group_list.list);
  803. if (0 != dev_get_group_info(__globalDeviceManage.db, &group_list))
  804. {
  805. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
  806. return SNMP_ERR_GENERR;
  807. }
  808. char buffer[16];
  809. oid begin_next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 3, 10, 1, 1, 1};
  810. int max_clonum = 4;
  811. switch (reqinfo->mode)
  812. {
  813. case MODE_GET:
  814. case MODE_GETNEXT:
  815. for (request = requests; request; request = request->next)
  816. {
  817. table_info = netsnmp_extract_table_info(request);
  818. if (reqinfo->mode == MODE_GETNEXT)
  819. {
  820. if (table_info->index_oid[0] == 0)
  821. {
  822. table_info->index_oid[0] = 1;
  823. table_info->colnum = 1;
  824. snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
  825. }
  826. else
  827. {
  828. if (table_info->colnum > max_clonum)
  829. {
  830. table_info->index_oid[0] += 1;
  831. table_info->colnum = 1;
  832. }
  833. oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 3, 10, 1, table_info->colnum, table_info->index_oid[0]};
  834. snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
  835. }
  836. }
  837. int nIndex = 1;
  838. list_for_each_entry(_GroupInfoTemp, &group_list.list, list)
  839. {
  840. if (nIndex < table_info->index_oid[0])
  841. {
  842. nIndex++;
  843. continue;
  844. }
  845. memset(buffer, 0, sizeof(buffer));
  846. switch (table_info->colnum)
  847. {
  848. case COLUMN_PDUGROUPID:
  849. if (!_GroupInfoTemp)
  850. {
  851. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  852. continue;
  853. }
  854. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, _GroupInfoTemp->GroupID);
  855. break;
  856. case COLUMN_PDUGROUPNAME:
  857. if (!_GroupInfoTemp)
  858. {
  859. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  860. continue;
  861. }
  862. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, _GroupInfoTemp->GroupName, strlen(_GroupInfoTemp->GroupName));
  863. break;
  864. case COLUMN_PDUGROUPLIST:
  865. if (!_GroupInfoTemp)
  866. {
  867. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  868. continue;
  869. }
  870. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, _GroupInfoTemp->GroupChList, strlen(_GroupInfoTemp->GroupChList));
  871. break;
  872. case COLUMN_PDUGROUPSTATUS:
  873. if (!_GroupInfoTemp)
  874. {
  875. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  876. continue;
  877. }
  878. //判断分组状态
  879. int nStatus = 0;
  880. char *pCHlist;
  881. char *pCHListSave;
  882. pCHlist = strtok_r(_GroupInfoTemp->GroupChList, ",", &pCHListSave);
  883. while(pCHlist!=NULL)
  884. {
  885. GlobalPowerManger *_globalPowerMangerTemp = NULL;
  886. list_for_each_entry(_globalPowerMangerTemp, &__globalDeviceManage._globalPowerManger.list, list)
  887. {
  888. if (_globalPowerMangerTemp == NULL)
  889. break;
  890. if (atoi(pCHlist) == _globalPowerMangerTemp->product_ch_id)
  891. {
  892. if (_globalPowerMangerTemp->_PowerInfo.status == 1)
  893. {
  894. nStatus = 1;
  895. break;
  896. }
  897. }
  898. }
  899. pCHlist = strtok_r(NULL, ",",&pCHListSave);
  900. }
  901. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, nStatus);
  902. break;
  903. default:
  904. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
  905. break;
  906. }
  907. //}
  908. break;
  909. }
  910. }
  911. break;
  912. case MODE_SET_RESERVE1:
  913. break;
  914. case MODE_SET_RESERVE2:
  915. break;
  916. case MODE_SET_FREE:
  917. break;
  918. case MODE_SET_ACTION:
  919. break;
  920. case MODE_SET_UNDO:
  921. break;
  922. case MODE_SET_COMMIT:
  923. for (request = requests; request; request = request->next)
  924. {
  925. table_info = netsnmp_extract_table_info(request);
  926. int nIndex = 1;
  927. list_for_each_entry(_GroupInfoTemp, &group_list.list, list)
  928. {
  929. if (nIndex < table_info->index_oid[0])
  930. {
  931. nIndex++;
  932. continue;
  933. }
  934. memset(buffer, 0, sizeof(buffer));
  935. switch (table_info->colnum)
  936. {
  937. case COLUMN_PDUGROUPSTATUS:
  938. if (!_GroupInfoTemp)
  939. {
  940. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
  941. continue;
  942. }
  943. bool nGroupOpertype = *request->requestvb->val.integer;
  944. char *pCHlist;
  945. char *pCHListSave;
  946. pCHlist = strtok_r(_GroupInfoTemp->GroupChList, ",", &pCHListSave);
  947. if (__globalDeviceManage._globalDevInfo.product.pwr_type == 1)
  948. {
  949. unsigned short pAddrCtrl[50];
  950. memset(pAddrCtrl, 0, sizeof(pAddrCtrl));
  951. int ret = 0;
  952. while(pCHlist!=NULL)
  953. {
  954. GlobalPowerManger *_globalPowerMangerTemp = NULL;
  955. list_for_each_entry(_globalPowerMangerTemp, &__globalDeviceManage._globalPowerManger.list, list)
  956. {
  957. if (_globalPowerMangerTemp == NULL)
  958. break;
  959. if (atoi(pCHlist) == _globalPowerMangerTemp->product_ch_id)
  960. {
  961. log_d("SNMP Group switch ctrl:%d", _globalPowerMangerTemp->product_ch_id);
  962. pAddrCtrl[(int)_globalPowerMangerTemp->product_saddr] |= 1 << (_globalPowerMangerTemp->product_ch_addr - 1);
  963. break;
  964. }
  965. }
  966. pCHlist = strtok_r(NULL, ",",&pCHListSave);
  967. }
  968. for (size_t i = 0; i < 50; i++)
  969. {
  970. if (pAddrCtrl[i] != 0)
  971. {
  972. ret = g_switch_set_dcpdu_chns_ctrl(&__globalDeviceManage._globalRelaySampManger,
  973. i,
  974. pAddrCtrl[i],
  975. nGroupOpertype);
  976. if (ret < 0)
  977. {
  978. ret = g_switch_set_dcpdu_chns_ctrl(&__globalDeviceManage._globalRelaySampManger,
  979. i,
  980. pAddrCtrl[i],
  981. nGroupOpertype);
  982. /* code */
  983. }
  984. }
  985. }
  986. }
  987. else
  988. {
  989. while(pCHlist!=NULL)
  990. {
  991. GlobalPowerManger *_globalPowerMangerTemp = NULL;
  992. list_for_each_entry(_globalPowerMangerTemp, &__globalDeviceManage._globalPowerManger.list, list)
  993. {
  994. if (_globalPowerMangerTemp == NULL)
  995. break;
  996. if (atoi(pCHlist) == _globalPowerMangerTemp->product_ch_id)
  997. {
  998. log_d("SNMP Group switch ctrl:%d", _globalPowerMangerTemp->product_ch_id);
  999. g_switch_set_all_chn_ctrl(&__globalDeviceManage._globalRelaySampManger,
  1000. _globalPowerMangerTemp,
  1001. _globalPowerMangerTemp->product_saddr,
  1002. _globalPowerMangerTemp->product_ch_addr, // 多版端口余8
  1003. nGroupOpertype,true);
  1004. break;
  1005. }
  1006. }
  1007. pCHlist = strtok_r(NULL, ",",&pCHListSave);
  1008. }
  1009. }
  1010. }
  1011. break;
  1012. }
  1013. }
  1014. break;
  1015. default:
  1016. /* we should never get here, so this is a really bad error */
  1017. snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode);
  1018. return SNMP_ERR_GENERR;
  1019. }
  1020. return SNMP_ERR_NOERROR;
  1021. }
  1022. /** handles requests for the pduSensorTable table, if anything else needs to be done */
  1023. int
  1024. pduSensorTable_handler(
  1025. netsnmp_mib_handler *handler,
  1026. netsnmp_handler_registration *reginfo,
  1027. netsnmp_agent_request_info *reqinfo,
  1028. netsnmp_request_info *requests) {
  1029. /* perform anything here that you need to do. The requests have
  1030. already been processed by the master table_dataset handler, but
  1031. this gives you chance to act on the request in some other way
  1032. if need be. */
  1033. netsnmp_request_info *request;
  1034. netsnmp_table_request_info *table_info;
  1035. GlobalSensorManger *iterator = NULL;
  1036. //
  1037. char buffer[16];
  1038. oid begin_next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 4, 1, 1, 1, 1};
  1039. int max_clonum = 10;
  1040. switch (reqinfo->mode)
  1041. {
  1042. case MODE_GET:
  1043. case MODE_GETNEXT:
  1044. for (request = requests; request; request = request->next)
  1045. {
  1046. table_info = netsnmp_extract_table_info(request);
  1047. if (reqinfo->mode == MODE_GETNEXT)
  1048. {
  1049. if (table_info->index_oid[0] == 0)
  1050. {
  1051. table_info->index_oid[0] = 1;
  1052. table_info->colnum = 1;
  1053. snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
  1054. }
  1055. else
  1056. {
  1057. if (table_info->colnum > max_clonum)
  1058. {
  1059. table_info->index_oid[0] += 1;
  1060. table_info->colnum = 1;
  1061. }
  1062. oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 4, 1, 1, table_info->colnum, table_info->index_oid[0]};
  1063. snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
  1064. }
  1065. }
  1066. int nIndex = table_info->index_oid[0];
  1067. bool findinstance = false;
  1068. list_for_each_entry(iterator, &__globalDeviceManage._globalSensorManger.list, list)
  1069. {
  1070. if (!iterator || nIndex != iterator->sensor_id)
  1071. {
  1072. continue;
  1073. }
  1074. memset(buffer, 0, sizeof(buffer));
  1075. switch (table_info->colnum)
  1076. {
  1077. case COLUMN_PDUSENSORID:
  1078. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_id);
  1079. break;
  1080. case COLUMN_PDUSENSORNAME:
  1081. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, iterator->sensor_name, strlen(iterator->sensor_name));
  1082. break;
  1083. case COLUMN_PDUSENSORTYPE:
  1084. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_type);
  1085. break;
  1086. case COLUMN_PDUSENSORDATACHENNEL:
  1087. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_interface_type);
  1088. break;
  1089. case COLUMN_PDUSENSORMODBUSADDRESS:
  1090. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_addr);
  1091. break;
  1092. case 6:
  1093. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_node_number);
  1094. break;
  1095. case COLUMN_PDUSENSORSTATUS:
  1096. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_status);
  1097. break;
  1098. case COLUMN_PDUSENSORVALUENUM:
  1099. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_val_count);
  1100. break;
  1101. case COLUMN_PDUSENSORVALUE1:
  1102. sprintf(buffer, "%0.3f", iterator->Cur_sensor_info.val1);
  1103. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  1104. break;
  1105. case COLUMN_PDUSENSORVALUE2:
  1106. sprintf(buffer, "%0.3f", iterator->Cur_sensor_info.val2);
  1107. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  1108. break;
  1109. default:
  1110. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
  1111. break;
  1112. }
  1113. //}
  1114. break;
  1115. }
  1116. }
  1117. break;
  1118. case MODE_SET_RESERVE1:
  1119. break;
  1120. case MODE_SET_RESERVE2:
  1121. break;
  1122. case MODE_SET_FREE:
  1123. break;
  1124. case MODE_SET_ACTION:
  1125. break;
  1126. case MODE_SET_UNDO:
  1127. break;
  1128. case MODE_SET_COMMIT:
  1129. break;
  1130. default:
  1131. /* we should never get here, so this is a really bad error */
  1132. snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode);
  1133. return SNMP_ERR_GENERR;
  1134. }
  1135. return SNMP_ERR_NOERROR;
  1136. }
  1137. /** handles requests for the pduSMTPRecMailTable table, if anything else needs to be done */
  1138. int
  1139. pduSMTPRecMailTable_handler(
  1140. netsnmp_mib_handler *handler,
  1141. netsnmp_handler_registration *reginfo,
  1142. netsnmp_agent_request_info *reqinfo,
  1143. netsnmp_request_info *requests) {
  1144. /* perform anything here that you need to do. The requests have
  1145. already been processed by the master table_dataset handler, but
  1146. this gives you chance to act on the request in some other way
  1147. if need be. */
  1148. return SNMP_ERR_NOERROR;
  1149. }
  1150. /** handles requests for the pduMessageNumTable table, if anything else needs to be done */
  1151. int
  1152. pduMessageNumTable_handler(
  1153. netsnmp_mib_handler *handler,
  1154. netsnmp_handler_registration *reginfo,
  1155. netsnmp_agent_request_info *reqinfo,
  1156. netsnmp_request_info *requests) {
  1157. /* perform anything here that you need to do. The requests have
  1158. already been processed by the master table_dataset handler, but
  1159. this gives you chance to act on the request in some other way
  1160. if need be. */
  1161. return SNMP_ERR_NOERROR;
  1162. }
  1163. /** handles requests for the pduMQTTBrokerTable table, if anything else needs to be done */
  1164. int
  1165. pduMQTTBrokerTable_handler(
  1166. netsnmp_mib_handler *handler,
  1167. netsnmp_handler_registration *reginfo,
  1168. netsnmp_agent_request_info *reqinfo,
  1169. netsnmp_request_info *requests) {
  1170. /* perform anything here that you need to do. The requests have
  1171. already been processed by the master table_dataset handler, but
  1172. this gives you chance to act on the request in some other way
  1173. if need be. */
  1174. return SNMP_ERR_NOERROR;
  1175. }
  1176. /** handles requests for the pduCloudServerTable table, if anything else needs to be done */
  1177. int
  1178. pduCloudServerTable_handler(
  1179. netsnmp_mib_handler *handler,
  1180. netsnmp_handler_registration *reginfo,
  1181. netsnmp_agent_request_info *reqinfo,
  1182. netsnmp_request_info *requests) {
  1183. /* perform anything here that you need to do. The requests have
  1184. already been processed by the master table_dataset handler, but
  1185. this gives you chance to act on the request in some other way
  1186. if need be. */
  1187. return SNMP_ERR_NOERROR;
  1188. }
  1189. /** handles requests for the pduAlarmHistoryTable table, if anything else needs to be done */
  1190. int
  1191. pduAlarmHistoryTable_handler(
  1192. netsnmp_mib_handler *handler,
  1193. netsnmp_handler_registration *reginfo,
  1194. netsnmp_agent_request_info *reqinfo,
  1195. netsnmp_request_info *requests) {
  1196. /* perform anything here that you need to do. The requests have
  1197. already been processed by the master table_dataset handler, but
  1198. this gives you chance to act on the request in some other way
  1199. if need be. */
  1200. netsnmp_request_info *request;
  1201. netsnmp_table_request_info *table_info;
  1202. //
  1203. char buffer[16];
  1204. oid begin_next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 6, 1, 1, 1, 1};
  1205. int max_clonum = 7;
  1206. switch (reqinfo->mode)
  1207. {
  1208. case MODE_GET:
  1209. case MODE_GETNEXT:
  1210. {
  1211. // 初始化表
  1212. int nAlarmNumber = 0;
  1213. _AlarmAckInfo _alarm_ack_info; // 填充数据
  1214. INIT_LIST_HEAD(&_alarm_ack_info.list);
  1215. // 查询数据库,最近的10个报警信息
  1216. char start_time[32] = {0};
  1217. char stop_time[32] = {0};
  1218. struct tm *t;
  1219. struct timeval tv;
  1220. gettimeofday(&tv, NULL);
  1221. t = localtime(&tv.tv_sec);
  1222. sprintf(stop_time, "%04d-%02d-%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, 23, 59, 59);
  1223. sprintf(start_time, "%04d-%02d-%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, 0, 0, 0);
  1224. int ret = dev_search_alarm_info(__globalDeviceManage.db,
  1225. __globalDeviceManage._globalDevInfo.product.id,
  1226. -1, start_time, stop_time,
  1227. 1, 10,
  1228. &_alarm_ack_info, &nAlarmNumber);
  1229. if (ret != 0)
  1230. {
  1231. log_e("get power alarm error.");
  1232. return SNMP_ERR_GENERR;
  1233. }
  1234. for (request = requests; request; request = request->next)
  1235. {
  1236. table_info = netsnmp_extract_table_info(request);
  1237. if (reqinfo->mode == MODE_GETNEXT)
  1238. {
  1239. if (table_info->index_oid[0] == 0)
  1240. {
  1241. table_info->index_oid[0] = 1;
  1242. table_info->colnum = 1;
  1243. snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
  1244. }
  1245. else
  1246. {
  1247. if (table_info->colnum > max_clonum)
  1248. {
  1249. table_info->index_oid[0] += 1;
  1250. table_info->colnum = 1;
  1251. }
  1252. oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 6, 1, 1, table_info->colnum, table_info->index_oid[0]};
  1253. snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
  1254. }
  1255. }
  1256. int nIndex = 1;
  1257. _AlarmAckInfo *_temp;
  1258. list_for_each_entry(_temp, &_alarm_ack_info.list, list)
  1259. {
  1260. if (nIndex < table_info->index_oid[0])
  1261. {
  1262. nIndex++;
  1263. continue;
  1264. }
  1265. if (!_temp)
  1266. {
  1267. break;
  1268. }
  1269. memset(buffer, 0, sizeof(buffer));
  1270. switch (table_info->colnum)
  1271. {
  1272. case COLUMN_PDUALARMID:
  1273. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, nIndex);
  1274. break;
  1275. case COLUMN_PDUALARMTYPE:
  1276. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, _temp->alarmType);
  1277. break;
  1278. case COLUMN_PDUALARMCONTEXT:
  1279. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, _temp->alarmContent, strlen(_temp->alarmContent));
  1280. break;
  1281. case COLUMN_PDUALARMACTION:
  1282. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, -1);
  1283. break;
  1284. case COLUMN_PDUALARMACTIONPARA:
  1285. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, -1);
  1286. break;
  1287. case COLUMN_PDUALARMDATE:
  1288. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, _temp->alarmDate, strlen(_temp->alarmDate));
  1289. break;
  1290. case COLUMN_PDUALARMTIME:
  1291. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, _temp->alarmDate, strlen(_temp->alarmDate));
  1292. break;
  1293. default:
  1294. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
  1295. break;
  1296. }
  1297. //}
  1298. break;
  1299. }
  1300. }
  1301. // 释放资源
  1302. if (0 == ret)
  1303. {
  1304. _AlarmAckInfo *node;
  1305. _AlarmAckInfo *next;
  1306. list_for_each_entry_safe(node, next, &_alarm_ack_info.list, list)
  1307. {
  1308. list_del(&node->list);
  1309. free(node);
  1310. }
  1311. }
  1312. }
  1313. break;
  1314. case MODE_SET_RESERVE1:
  1315. break;
  1316. case MODE_SET_RESERVE2:
  1317. break;
  1318. case MODE_SET_FREE:
  1319. break;
  1320. case MODE_SET_ACTION:
  1321. break;
  1322. case MODE_SET_UNDO:
  1323. break;
  1324. case MODE_SET_COMMIT:
  1325. break;
  1326. default:
  1327. /* we should never get here, so this is a really bad error */
  1328. snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode);
  1329. return SNMP_ERR_GENERR;
  1330. }
  1331. return SNMP_ERR_NOERROR;
  1332. }
  1333. /** handles requests for the pduChannelLimitTable table, if anything else needs to be done */
  1334. int
  1335. pduChannelLimitTable_handler(
  1336. netsnmp_mib_handler *handler,
  1337. netsnmp_handler_registration *reginfo,
  1338. netsnmp_agent_request_info *reqinfo,
  1339. netsnmp_request_info *requests) {
  1340. /* perform anything here that you need to do. The requests have
  1341. already been processed by the master table_dataset handler, but
  1342. this gives you chance to act on the request in some other way
  1343. if need be. */
  1344. netsnmp_request_info *request;
  1345. netsnmp_table_request_info *table_info;
  1346. GlobalPowerManger *iterator = NULL;
  1347. //
  1348. char buffer[16];
  1349. oid begin_next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 7, 2, 6, 1, 1, 1};
  1350. int max_clonum = 7;
  1351. switch (reqinfo->mode)
  1352. {
  1353. case MODE_GET:
  1354. case MODE_GETNEXT:
  1355. for (request = requests; request; request = request->next)
  1356. {
  1357. table_info = netsnmp_extract_table_info(request);
  1358. if (reqinfo->mode == MODE_GETNEXT)
  1359. {
  1360. if (table_info->index_oid[0] == 0)
  1361. {
  1362. table_info->index_oid[0] = 1;
  1363. table_info->colnum = 1;
  1364. snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
  1365. }
  1366. else
  1367. {
  1368. if (table_info->colnum > max_clonum)
  1369. {
  1370. table_info->index_oid[0] += 1;
  1371. table_info->colnum = 1;
  1372. }
  1373. oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 7, 2, 6, 1,table_info->colnum, table_info->index_oid[0]};
  1374. snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
  1375. }
  1376. }
  1377. int nIndex = 1;
  1378. list_for_each_entry(iterator, &__globalDeviceManage._globalPowerManger.list, list)
  1379. {
  1380. if (nIndex < table_info->index_oid[0])
  1381. {
  1382. nIndex++;
  1383. continue;
  1384. }
  1385. if (!iterator)
  1386. {
  1387. break;
  1388. }
  1389. memset(buffer, 0, sizeof(buffer));
  1390. switch (table_info->colnum)
  1391. {
  1392. case COLUMN_PDUCHANNELLIMITID:
  1393. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->product_ch_id);
  1394. break;
  1395. case COLUMN_PDUCHANNELLIMITNAME:
  1396. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, iterator->product_ch_name, strlen(iterator->product_ch_name));
  1397. break;
  1398. case COLUMN_PDUCHANNELCURRENTLIMITUP:
  1399. sprintf(buffer, "%0.2f", iterator->global_over_manager.product_cur_upper_threshold);
  1400. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  1401. break;
  1402. case COLUMN_PDUCHANNELVOLTAGELIMITUP:
  1403. sprintf(buffer, "%0.2f", iterator->global_over_manager.product_vol_upper_threshold);
  1404. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  1405. break;
  1406. case COLUMN_PDUCHANNELVOLTAGELIMITDOWN:
  1407. sprintf(buffer, "%0.2f", iterator->global_over_manager.product_vol_lower_threshold);
  1408. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  1409. break;
  1410. case COLUMN_PDUCHANNELPOWERLIMITUP:
  1411. sprintf(buffer, "%0.2f", iterator->global_over_manager.product_pwr_upper_threshold);
  1412. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  1413. break;
  1414. case COLUMN_PDUCHANNELCONSUMPTIONLIMITUP:
  1415. sprintf(buffer, "%0.2f", iterator->global_over_manager.product_pwrcon_upper_threshold);
  1416. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, buffer, strlen(buffer));
  1417. break;
  1418. default:
  1419. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
  1420. break;
  1421. }
  1422. //}
  1423. break;
  1424. }
  1425. }
  1426. break;
  1427. case MODE_SET_RESERVE1:
  1428. break;
  1429. case MODE_SET_RESERVE2:
  1430. break;
  1431. case MODE_SET_FREE:
  1432. break;
  1433. case MODE_SET_ACTION:
  1434. break;
  1435. case MODE_SET_UNDO:
  1436. break;
  1437. case MODE_SET_COMMIT:
  1438. break;
  1439. default:
  1440. /* we should never get here, so this is a really bad error */
  1441. snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode);
  1442. return SNMP_ERR_GENERR;
  1443. }
  1444. return SNMP_ERR_NOERROR;
  1445. }
  1446. /** handles requests for the pduSensorLimitTable table, if anything else needs to be done */
  1447. int
  1448. pduSensorLimitTable_handler(
  1449. netsnmp_mib_handler *handler,
  1450. netsnmp_handler_registration *reginfo,
  1451. netsnmp_agent_request_info *reqinfo,
  1452. netsnmp_request_info *requests) {
  1453. /* perform anything here that you need to do. The requests have
  1454. already been processed by the master table_dataset handler, but
  1455. this gives you chance to act on the request in some other way
  1456. if need be. */
  1457. netsnmp_request_info *request;
  1458. netsnmp_table_request_info *table_info;
  1459. GlobalSensorManger *iterator = NULL;
  1460. //
  1461. char buffer[16];
  1462. oid begin_next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 7, 3, 1, 1, 1, 1};
  1463. int max_clonum = 6;
  1464. switch (reqinfo->mode)
  1465. {
  1466. case MODE_GET:
  1467. case MODE_GETNEXT:
  1468. for (request = requests; request; request = request->next)
  1469. {
  1470. table_info = netsnmp_extract_table_info(request);
  1471. if (reqinfo->mode == MODE_GETNEXT)
  1472. {
  1473. if (table_info->index_oid[0] == 0)
  1474. {
  1475. table_info->index_oid[0] = 1;
  1476. table_info->colnum = 1;
  1477. snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
  1478. }
  1479. else
  1480. {
  1481. if (table_info->colnum > max_clonum)
  1482. {
  1483. table_info->index_oid[0] += 1;
  1484. table_info->colnum = 1;
  1485. }
  1486. oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 7, 3, 1, 1, table_info->colnum, table_info->index_oid[0]};
  1487. snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
  1488. }
  1489. }
  1490. int nIndex = table_info->index_oid[0];
  1491. list_for_each_entry(iterator, &__globalDeviceManage._globalSensorManger.list, list)
  1492. {
  1493. if (!iterator || nIndex != iterator->sensor_id)
  1494. {
  1495. continue;
  1496. }
  1497. memset(buffer, 0, sizeof(buffer));
  1498. switch (table_info->colnum)
  1499. {
  1500. case COLUMN_PDUSENSORLIMITID:
  1501. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_id);
  1502. break;
  1503. case COLUMN_PDUSENSORLIMITNAME:
  1504. snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, iterator->sensor_name, strlen(iterator->sensor_name));
  1505. break;
  1506. case COLUMN_PDUSENSORLIMITVALUE1UP:
  1507. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->over_manager.sensor_val1_upper_threshold);
  1508. break;
  1509. case COLUMN_PDUSENSORLIMITVALUE2UP:
  1510. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->over_manager.sensor_val2_upper_threshold);
  1511. break;
  1512. case COLUMN_PDUSENSORLIMITVALUE1DOWN:
  1513. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->over_manager.sensor_val1_lower_threshold);
  1514. break;
  1515. case COLUMN_PDUSENSORLIMITVALUE2DOWN:
  1516. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->over_manager.sensor_val2_lower_threshold);
  1517. break;
  1518. default:
  1519. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
  1520. break;
  1521. }
  1522. //}
  1523. break;
  1524. }
  1525. }
  1526. break;
  1527. case MODE_SET_RESERVE1:
  1528. break;
  1529. case MODE_SET_RESERVE2:
  1530. break;
  1531. case MODE_SET_FREE:
  1532. break;
  1533. case MODE_SET_ACTION:
  1534. break;
  1535. case MODE_SET_UNDO:
  1536. break;
  1537. case MODE_SET_COMMIT:
  1538. break;
  1539. default:
  1540. /* we should never get here, so this is a really bad error */
  1541. snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode);
  1542. return SNMP_ERR_GENERR;
  1543. }
  1544. return SNMP_ERR_NOERROR;
  1545. }
  1546. int
  1547. pduPowerAlarmTable_handler(
  1548. netsnmp_mib_handler *handler,
  1549. netsnmp_handler_registration *reginfo,
  1550. netsnmp_agent_request_info *reqinfo,
  1551. netsnmp_request_info *requests) {
  1552. /* perform anything here that you need to do. The requests have
  1553. already been processed by the master table_dataset handler, but
  1554. this gives you chance to act on the request in some other way
  1555. if need be. */
  1556. netsnmp_request_info *request;
  1557. netsnmp_table_request_info *table_info;
  1558. GlobalPowerManger *iterator = NULL;
  1559. //
  1560. char buffer[16];
  1561. oid begin_next_oid[] = {1,3,6,1,4,1,2024,1,6,2,1,1,1};
  1562. int max_clonum = 6;
  1563. switch (reqinfo->mode)
  1564. {
  1565. case MODE_GET:
  1566. case MODE_GETNEXT:
  1567. for (request = requests; request; request = request->next)
  1568. {
  1569. table_info = netsnmp_extract_table_info(request);
  1570. if (reqinfo->mode == MODE_GETNEXT)
  1571. {
  1572. if (table_info->index_oid[0] == 0)
  1573. {
  1574. table_info->index_oid[0] = 1;
  1575. table_info->colnum = 1;
  1576. snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
  1577. }
  1578. else
  1579. {
  1580. if (table_info->colnum > max_clonum)
  1581. {
  1582. table_info->index_oid[0] += 1;
  1583. table_info->colnum = 1;
  1584. }
  1585. oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 6, 2, 1,table_info->colnum, table_info->index_oid[0]};
  1586. snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
  1587. }
  1588. }
  1589. int nIndex = 1;
  1590. list_for_each_entry(iterator, &__globalDeviceManage._globalPowerManger.list, list)
  1591. {
  1592. if (nIndex < table_info->index_oid[0])
  1593. {
  1594. nIndex++;
  1595. continue;
  1596. }
  1597. if (!iterator)
  1598. {
  1599. break;
  1600. }
  1601. memset(buffer, 0, sizeof(buffer));
  1602. switch (table_info->colnum)
  1603. {
  1604. case COLUMN_PDUCHANNELPOWERALARMID:
  1605. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->product_ch_id);
  1606. break;
  1607. case COLUMN_PDUCHANNELPOWERALARMVOLTAGEUP:
  1608. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->_PowerWarninginfo.w_voltage_up);
  1609. break;
  1610. case COLUMN_PDUCHANNELPOWERALARMVOLTAGEDOWN:
  1611. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->_PowerWarninginfo.w_voltage_down);
  1612. break;
  1613. case COLUMN_PDUCHANNELPOWERALARMCURRENTUP:
  1614. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->_PowerWarninginfo.w_current);
  1615. break;
  1616. case COLUMN_PDUCHANNELPOWERALARMPOWERUP:
  1617. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->_PowerWarninginfo.w_power);
  1618. break;
  1619. case COLUMN_PDUCHANNELPOWERALARMCONSUMPTIONUP:
  1620. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->_PowerWarninginfo.w_consumption);
  1621. break;
  1622. default:
  1623. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
  1624. break;
  1625. }
  1626. //}
  1627. break;
  1628. }
  1629. }
  1630. break;
  1631. case MODE_SET_RESERVE1:
  1632. break;
  1633. case MODE_SET_RESERVE2:
  1634. break;
  1635. case MODE_SET_FREE:
  1636. break;
  1637. case MODE_SET_ACTION:
  1638. break;
  1639. case MODE_SET_UNDO:
  1640. break;
  1641. case MODE_SET_COMMIT:
  1642. break;
  1643. default:
  1644. /* we should never get here, so this is a really bad error */
  1645. snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode);
  1646. return SNMP_ERR_GENERR;
  1647. }
  1648. return SNMP_ERR_NOERROR;
  1649. }
  1650. int
  1651. pduSensorAlarmTable_handler(
  1652. netsnmp_mib_handler *handler,
  1653. netsnmp_handler_registration *reginfo,
  1654. netsnmp_agent_request_info *reqinfo,
  1655. netsnmp_request_info *requests) {
  1656. /* perform anything here that you need to do. The requests have
  1657. already been processed by the master table_dataset handler, but
  1658. this gives you chance to act on the request in some other way
  1659. if need be. */
  1660. netsnmp_request_info *request;
  1661. netsnmp_table_request_info *table_info;
  1662. GlobalSensorManger *iterator = NULL;
  1663. //
  1664. char buffer[16];
  1665. oid begin_next_oid[] = {1,3,6,1,4,1,2024,1,6,3,1,1,1};
  1666. int max_clonum = 5;
  1667. switch (reqinfo->mode)
  1668. {
  1669. case MODE_GET:
  1670. case MODE_GETNEXT:
  1671. for (request = requests; request; request = request->next)
  1672. {
  1673. table_info = netsnmp_extract_table_info(request);
  1674. if (reqinfo->mode == MODE_GETNEXT)
  1675. {
  1676. if (table_info->index_oid[0] == 0)
  1677. {
  1678. table_info->index_oid[0] = 1;
  1679. table_info->colnum = 1;
  1680. snmp_set_var_objid(requests->requestvb, begin_next_oid, OID_LENGTH(begin_next_oid));
  1681. }
  1682. else
  1683. {
  1684. if (table_info->colnum > max_clonum)
  1685. {
  1686. table_info->index_oid[0] += 1;
  1687. table_info->colnum = 1;
  1688. }
  1689. oid next_oid[] = {1, 3, 6, 1, 4, 1, 2024, 1, 6, 3, 1, table_info->colnum, table_info->index_oid[0]};
  1690. snmp_set_var_objid(requests->requestvb, next_oid, OID_LENGTH(next_oid));
  1691. }
  1692. }
  1693. int nIndex = table_info->index_oid[0];
  1694. list_for_each_entry(iterator, &__globalDeviceManage._globalSensorManger.list, list)
  1695. {
  1696. if (!iterator || nIndex != iterator->sensor_id)
  1697. {
  1698. continue;
  1699. }
  1700. memset(buffer, 0, sizeof(buffer));
  1701. switch (table_info->colnum)
  1702. {
  1703. case COLUMN_PDUSENSORALARMID:
  1704. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->sensor_id);
  1705. break;
  1706. case COLUMN_PDUSENSORALARMVALUE1UP:
  1707. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->warning_status.sensor_val1_upper);
  1708. break;
  1709. case COLUMN_PDUSENSORALARMVALUE1DOWN:
  1710. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,iterator->warning_status.sensor_val1_lower);
  1711. break;
  1712. case COLUMN_PDUSENSORALARMVALUE2UP:
  1713. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, iterator->warning_status.sensor_val2_upper);
  1714. break;
  1715. case COLUMN_PDUSENSORALARMVALUE2DOWN:
  1716. snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,iterator->warning_status.sensor_val2_lower);
  1717. break;
  1718. default:
  1719. netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
  1720. break;
  1721. }
  1722. //}
  1723. break;
  1724. }
  1725. }
  1726. break;
  1727. case MODE_SET_RESERVE1:
  1728. break;
  1729. case MODE_SET_RESERVE2:
  1730. break;
  1731. case MODE_SET_FREE:
  1732. break;
  1733. case MODE_SET_ACTION:
  1734. break;
  1735. case MODE_SET_UNDO:
  1736. break;
  1737. case MODE_SET_COMMIT:
  1738. break;
  1739. default:
  1740. /* we should never get here, so this is a really bad error */
  1741. snmp_log(LOG_ERR, "unknown mode (%d) in handle_pduType\n", reqinfo->mode);
  1742. return SNMP_ERR_GENERR;
  1743. }
  1744. return SNMP_ERR_NOERROR;
  1745. }