Переглянути джерело

1、重新生成.c和.h文件,增加工程调用demo

liyuezong 2 роки тому
батько
коміт
7bbe361003

+ 43 - 0
Liyuezong/SNMP协议设计/Gowone-SmartPDU-mib-V2c/agent代理开发的.c及.h文件/main_demo.cpp

@@ -0,0 +1,43 @@
+/*
+ * Note: this file originally auto-generated by mib2c using
+ *        $
+ */
+ 
+#include "pduMIB.h"
+#include <time.h>
+ 
+/** Initializes the pduMIB module */
+
+static int keep_running;
+RETSIGTYPE stop_server(int __attribute__((unused)) a) {
+        keep_running = 0;
+}
+ 
+int main()
+{
+   const char *app_name = "pduMIB";
+   /* we are a subagent */
+   netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1);
+ 
+   /* initialize the agent library */
+   init_agent(app_name);
+ 
+   /* initialize your mib code here */
+   init_pduMIB();
+ 
+   /* pduMIB will be used to read pduMIB.conf files. */
+   init_snmp("pduMIB");
+   keep_running = 1;
+   while(keep_running)
+   {
+        agent_check_and_process(1);/* block every 1 second */
+   }
+   /* at shutdown time */
+   snmp_shutdown(app_name);
+ 
+   /* deinitialize your mib code here */
+ 
+   /* shutdown the agent library */
+   shutdown_agent();
+   return 0;
+}

Різницю між файлами не показано, бо вона завелика
+ 3807 - 4646
Liyuezong/SNMP协议设计/Gowone-SmartPDU-mib-V2c/agent代理开发的.c及.h文件/pduMIB.c


+ 56 - 75
Liyuezong/SNMP协议设计/Gowone-SmartPDU-mib-V2c/agent代理开发的.c及.h文件/pduMIB.h

@@ -1,85 +1,66 @@
 /*
  * Note: this file originally auto-generated by mib2c
- * using mib2c.old-api.conf
+ * using mib2c.scalar.conf
  */
 #ifndef PDUMIB_H
 #define PDUMIB_H
 
 /* function declarations */
 void init_pduMIB(void);
-FindVarMethod var_pduMIB;
-FindVarMethod var_pduChannelTable;
-FindVarMethod var_pduSensorTable;
-FindVarMethod var_pduSMTPRecMailTable;
-FindVarMethod var_pduMessageNumTable;
-FindVarMethod var_pduMQTTBrokerTable;
-FindVarMethod var_pduCloudServerTable;
-FindVarMethod var_pduAlarmHistoryTable;
-FindVarMethod var_pduChannelLimitTable;
-FindVarMethod var_pduSensorLimitTable;
-    WriteMethod write_pduLanIpv4Address;
-    WriteMethod write_pduLanIpv4Mask;
-    WriteMethod write_pduLanIpv6Address;
-    WriteMethod write_pduLanIpv6SubnetLength;
-    WriteMethod write_pduWifiEnable;
-    WriteMethod write_pduWifiIpv4Link;
-    WriteMethod write_pduWifiIpv4Address;
-    WriteMethod write_pduWifiIpv4Mask;
-    WriteMethod write_pduWifiIpv6Address;
-    WriteMethod write_pduWifiIpv6SubnetLength;
-    WriteMethod write_pduModbusAddress;
-    WriteMethod write_pduModbusBaud;
-    WriteMethod write_pduModbusMode;
-    WriteMethod write_pduVpnEnable;
-    WriteMethod write_pduPowerFactor;
-    WriteMethod write_pduTelnetEnable;
-    WriteMethod write_pduTelnetUserName;
-    WriteMethod write_pduTelnetUserPW;
-    WriteMethod write_pduSMTPEnable;
-    WriteMethod write_pduSMTPServer;
-    WriteMethod write_pduSMTPPort;
-    WriteMethod write_pduSNMPEnable;
-    WriteMethod write_pduSNMPTrapEnable;
-    WriteMethod write_pduSNMPProtocolVersion;
-    WriteMethod write_pduMessageEnable;
-    WriteMethod write_pduMQTTEnable;
-    WriteMethod write_pduCloudEnable;
-    WriteMethod write_pduNTPEnable;
-    WriteMethod write_pduNTPTimeZone;
-    WriteMethod write_pduNTPDate;
-    WriteMethod write_pduNTPServerName;
-    WriteMethod write_pduNTPServerIPorDomain;
-    WriteMethod write_pduNTPServerPort;
-    WriteMethod write_pduCurrentLimitUp;
-    WriteMethod write_pduVoltageLimitUp;
-    WriteMethod write_pduVoltageLimitDown;
-    WriteMethod write_pduPowerLimitUp;
-    WriteMethod write_pduConsumptionLimitUp;
-    WriteMethod write_pduRestart;
-    WriteMethod write_pduReset;
-    WriteMethod write_pduSMTPRecMail;
-    WriteMethod write_pduMessageRecNum;
-    WriteMethod write_pduMQTTBrokerName;
-    WriteMethod write_pduMQTTBrokerEnable;
-    WriteMethod write_pduMQTTBrokerIPorDomain;
-    WriteMethod write_pduMQTTBrokerPort;
-    WriteMethod write_pduMQTTBrokerUserName;
-    WriteMethod write_pduMQTTBrokerUserPW;
-    WriteMethod write_pduCloudServerName;
-    WriteMethod write_pduCloudServerEnable;
-    WriteMethod write_pduCloudServerIPorDomain;
-    WriteMethod write_pduCloudServerPort;
-    WriteMethod write_pduCloudServerUserName;
-    WriteMethod write_pduCloudServerUserPW;
-    WriteMethod write_pduChannelLimitName;
-    WriteMethod write_pduChannelCurrentLimitUp;
-    WriteMethod write_pduChannelVoltageLimitUp;
-    WriteMethod write_pduChannelVoltageLimitDown;
-    WriteMethod write_pduChannelPowerLimitUp;
-    WriteMethod write_pduChannelConsumptionLimitUp;
-    WriteMethod write_pduSensorLimitID;
-    WriteMethod write_pduSensorLimitName;
-    WriteMethod write_pduSensorLimitValue1;
-    WriteMethod write_pduSensorLimitValue2;
+Netsnmp_Node_Handler handle_pduId;
+Netsnmp_Node_Handler handle_pduName;
+Netsnmp_Node_Handler handle_pduType;
+Netsnmp_Node_Handler handle_pduFirmware;
+Netsnmp_Node_Handler handle_pduChannelNum;
+Netsnmp_Node_Handler handle_pduSensorNum;
+Netsnmp_Node_Handler handle_pduLanIpv4Link;
+Netsnmp_Node_Handler handle_pduLanIpv4Address;
+Netsnmp_Node_Handler handle_pduLanIpv4Mask;
+Netsnmp_Node_Handler handle_pduLanIpv6Link;
+Netsnmp_Node_Handler handle_pduLanIpv6Address;
+Netsnmp_Node_Handler handle_pduLanIpv6SubnetLength;
+Netsnmp_Node_Handler handle_pduWifiEnable;
+Netsnmp_Node_Handler handle_pduWifiIpv4Link;
+Netsnmp_Node_Handler handle_pduWifiIpv4Address;
+Netsnmp_Node_Handler handle_pduWifiIpv4Mask;
+Netsnmp_Node_Handler handle_pduWifiIpv6Link;
+Netsnmp_Node_Handler handle_pduWifiIpv6Address;
+Netsnmp_Node_Handler handle_pduWifiIpv6SubnetLength;
+Netsnmp_Node_Handler handle_pduModbusAddress;
+Netsnmp_Node_Handler handle_pduModbusBaud;
+Netsnmp_Node_Handler handle_pduModbusMode;
+Netsnmp_Node_Handler handle_pduVpnEnable;
+Netsnmp_Node_Handler handle_pduVoltage;
+Netsnmp_Node_Handler handle_pduCurrent;
+Netsnmp_Node_Handler handle_pduConsumption;
+Netsnmp_Node_Handler handle_pduPowerFactor;
+Netsnmp_Node_Handler handle_pduPactivePower;
+Netsnmp_Node_Handler handle_pduReactivePower;
+Netsnmp_Node_Handler handle_pduApparentPower;
+Netsnmp_Node_Handler handle_pduTelnetEnable;
+Netsnmp_Node_Handler handle_pduTelnetUserName;
+Netsnmp_Node_Handler handle_pduTelnetUserPW;
+Netsnmp_Node_Handler handle_pduSMTPEnable;
+Netsnmp_Node_Handler handle_pduSMTPServer;
+Netsnmp_Node_Handler handle_pduSMTPPort;
+Netsnmp_Node_Handler handle_pduSNMPEnable;
+Netsnmp_Node_Handler handle_pduSNMPTrapEnable;
+Netsnmp_Node_Handler handle_pduSNMPProtocolVersion;
+Netsnmp_Node_Handler handle_pduMessageEnable;
+Netsnmp_Node_Handler handle_pduMQTTEnable;
+Netsnmp_Node_Handler handle_pduCloudEnable;
+Netsnmp_Node_Handler handle_pduNTPEnable;
+Netsnmp_Node_Handler handle_pduNTPTimeZone;
+Netsnmp_Node_Handler handle_pduNTPDate;
+Netsnmp_Node_Handler handle_pduNTPServerName;
+Netsnmp_Node_Handler handle_pduNTPServerIPorDomain;
+Netsnmp_Node_Handler handle_pduNTPServerPort;
+Netsnmp_Node_Handler handle_pduCurrentLimitUp;
+Netsnmp_Node_Handler handle_pduVoltageLimitUp;
+Netsnmp_Node_Handler handle_pduVoltageLimitDown;
+Netsnmp_Node_Handler handle_pduPowerLimitUp;
+Netsnmp_Node_Handler handle_pduConsumptionLimitUp;
+Netsnmp_Node_Handler handle_pduRestart;
+Netsnmp_Node_Handler handle_pduReset;
 
 #endif /* PDUMIB_H */

BIN
Liyuezong/Telnet或SSH指令设计/Telnet或SSH指令设计.xlsx