1 | #include "my_snmp.h"
|
---|
2 | #include <string.h>
|
---|
3 | #include "apps/snmp_scalar.h"
|
---|
4 | #include "snmp_mib2.h"
|
---|
5 | #include "apps/snmp.h"
|
---|
6 |
|
---|
7 | OID_DeviceTypeDef CurrSNMP_Device = UPS;
|
---|
8 |
|
---|
9 | char community[16] = {"public"}, trap_community[16] = {"public"};
|
---|
10 |
|
---|
11 | u8_t snmp_sysDescr[] = "SPort";
|
---|
12 | u16_t snmp_sysDescr_len = sizeof(snmp_sysDescr);
|
---|
13 |
|
---|
14 | u8_t snmp_sysContact[] = "";
|
---|
15 | u16_t snmp_sysContact_len = 0;
|
---|
16 |
|
---|
17 | u8_t snmp_sysLocation[] = "";
|
---|
18 | u16_t snmp_sysLocation_len = 0;
|
---|
19 |
|
---|
20 | u8_t snmp_sysName[8];
|
---|
21 | u16_t snmp_sysName_len = 0;
|
---|
22 |
|
---|
23 | u16_t snmp_buffer = 128;
|
---|
24 |
|
---|
25 | const struct snmp_obj_id sysupid = {9,{1,3,6,1,2,1,1,3,0}};
|
---|
26 | const struct snmp_obj_id trapoid = {11,{1,3,6,1,6,3,1,1,4,1,0}};
|
---|
27 |
|
---|
28 | const uint32_t UPS_baseOID[] = {1, 3, 6, 1, 4, 1, 32109, 10001};
|
---|
29 | const uint32_t PLC_baseOID[] = {1, 3, 6, 1, 4, 1, 32109, 10002};
|
---|
30 |
|
---|
31 | /*const struct snmp_obj_id UPS_baseOID = {8, {1, 3, 6, 1, 4, 1, 32109, 10001}};
|
---|
32 | const struct snmp_obj_id PLC_baseOID = {8, {1, 3, 6, 1, 4, 1, 32109, 10002}};*/
|
---|
33 |
|
---|
34 | /*----------------------------------------------------------------------------------------------------------*/
|
---|
35 | /*##########################################################################################################*/
|
---|
36 | /*##########################################################################################################*/
|
---|
37 | /* SNMP OID and FUNCTION UPS 1200 --------------------------------------------------------------------------*/
|
---|
38 |
|
---|
39 | snmp_UPS_Data_typeDef snmp_ups = {{{SNMP_ENUM, NULL},{SNMP_STRING, NULL},{SNMP_STRING, NULL}}, //root
|
---|
40 | {{SNMP_INT16, NULL},{SNMP_INT16, NULL},{SNMP_INT16, NULL},{SNMP_INT16, NULL},{SNMP_INT16, NULL},{SNMP_INT16, NULL},{SNMP_INT16, NULL},{SNMP_ENUM, NULL}}, //parametrs
|
---|
41 | {{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL}}, //sensor
|
---|
42 | {{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL}}, //switch
|
---|
43 | {{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL},{SNMP_ENUM, NULL}}, // alarm list
|
---|
44 | {{SNMP_ENUM, NULL},{SNMP_NONE, NULL},{SNMP_UINT8, NULL}}, // battery
|
---|
45 | {{SNMP_INT16, NULL},{SNMP_INT16, NULL},{SNMP_INT16, NULL},{SNMP_INT16, NULL},{SNMP_INT16, NULL}}, // battery voltage
|
---|
46 | {{SNMP_ENUM, NULL}}, // rm presense 1
|
---|
47 | {{SNMP_ENUM, NULL}}, // rm presense 2
|
---|
48 | {{SNMP_ENUM, NULL}}, // rm presense 3
|
---|
49 | {{SNMP_ENUM, NULL}}};// rm presense 4
|
---|
50 |
|
---|
51 | /* PROTOTYPES FUNCTION UPS 1200 */
|
---|
52 | static s16_t UPS_get_root_value(struct snmp_node_instance* instance, void* value);
|
---|
53 | static s16_t UPS_get_paramerts_value(struct snmp_node_instance* instance, void* value);
|
---|
54 | static s16_t UPS_get_sensor_value(struct snmp_node_instance* instance, void* value);
|
---|
55 | static s16_t UPS_get_switch_value(struct snmp_node_instance* instance, void* value);
|
---|
56 | static s16_t UPS_get_alarms_value(struct snmp_node_instance* instance, void* value);
|
---|
57 | static s16_t UPS_get_battery_value(struct snmp_node_instance* instance, void* value);
|
---|
58 | static s16_t UPS_get_battery_voltage_value(struct snmp_node_instance* instance, void* value);
|
---|
59 | static s16_t UPS_get_rm48_1_value(struct snmp_node_instance* instance, void* value);
|
---|
60 | static s16_t UPS_get_rm48_2_value(struct snmp_node_instance* instance, void* value);
|
---|
61 | static s16_t UPS_get_rm48_3_value(struct snmp_node_instance* instance, void* value);
|
---|
62 | static s16_t UPS_get_rm48_4_value(struct snmp_node_instance* instance, void* value);
|
---|
63 |
|
---|
64 | /* SNMP MIB UPS-1200 */
|
---|
65 | /* 1.1-3 */
|
---|
66 | static const struct snmp_scalar_node UPS_CommonStatus = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, UPS_get_root_value);
|
---|
67 | static const struct snmp_scalar_node UPS_SoftwareVersion = SNMP_SCALAR_CREATE_NODE_READONLY(2, SNMP_ASN1_TYPE_OCTET_STRING, UPS_get_root_value);
|
---|
68 | static const struct snmp_scalar_node UPS_SoftwareSubVersion = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_OCTET_STRING, UPS_get_root_value);
|
---|
69 |
|
---|
70 | /* 1.4.1-8 parametrs*/
|
---|
71 | static const struct snmp_scalar_node UPS_u_load = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, UPS_get_paramerts_value);
|
---|
72 | static const struct snmp_scalar_node UPS_u_bat = SNMP_SCALAR_CREATE_NODE_READONLY(2, SNMP_ASN1_TYPE_INTEGER, UPS_get_paramerts_value);
|
---|
73 | static const struct snmp_scalar_node UPS_u_220 = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_INTEGER, UPS_get_paramerts_value);
|
---|
74 | static const struct snmp_scalar_node UPS_i_load = SNMP_SCALAR_CREATE_NODE_READONLY(4, SNMP_ASN1_TYPE_INTEGER, UPS_get_paramerts_value);
|
---|
75 | static const struct snmp_scalar_node UPS_i_bat = SNMP_SCALAR_CREATE_NODE_READONLY(5, SNMP_ASN1_TYPE_INTEGER, UPS_get_paramerts_value);
|
---|
76 | static const struct snmp_scalar_node UPS_p_acdc = SNMP_SCALAR_CREATE_NODE_READONLY(6, SNMP_ASN1_TYPE_INTEGER, UPS_get_paramerts_value);
|
---|
77 | static const struct snmp_scalar_node UPS_t_bat = SNMP_SCALAR_CREATE_NODE_READONLY(7, SNMP_ASN1_TYPE_INTEGER, UPS_get_paramerts_value);
|
---|
78 | static const struct snmp_scalar_node UPS_i_bat_sign = SNMP_SCALAR_CREATE_NODE_READONLY(8, SNMP_ASN1_TYPE_INTEGER, UPS_get_paramerts_value);
|
---|
79 | static const struct snmp_node* const UPS_paramerts_nodes[] = {&UPS_u_load.node.node, &UPS_u_bat.node.node, &UPS_u_220.node.node,
|
---|
80 | &UPS_i_load.node.node, &UPS_i_bat.node.node, &UPS_p_acdc.node.node,
|
---|
81 | &UPS_t_bat.node.node, &UPS_i_bat_sign.node.node};
|
---|
82 | static const struct snmp_tree_node UPS_paramerts_tree_node = SNMP_CREATE_TREE_NODE(4,UPS_paramerts_nodes);
|
---|
83 |
|
---|
84 | /* 1.5.1-4 sensor*/
|
---|
85 | static const struct snmp_scalar_node UPS_sensor_1 = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, UPS_get_sensor_value);
|
---|
86 | static const struct snmp_scalar_node UPS_sensor_2 = SNMP_SCALAR_CREATE_NODE_READONLY(2, SNMP_ASN1_TYPE_INTEGER, UPS_get_sensor_value);
|
---|
87 | static const struct snmp_scalar_node UPS_sensor_3 = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_INTEGER, UPS_get_sensor_value);
|
---|
88 | static const struct snmp_scalar_node UPS_sensor_4 = SNMP_SCALAR_CREATE_NODE_READONLY(4, SNMP_ASN1_TYPE_INTEGER, UPS_get_sensor_value);
|
---|
89 | static const struct snmp_node* const UPS_sensor_nodes[] = {&UPS_sensor_1.node.node, &UPS_sensor_2.node.node, &UPS_sensor_3.node.node,
|
---|
90 | &UPS_sensor_4.node.node};
|
---|
91 | static const struct snmp_tree_node UPS_sensor_tree_node = SNMP_CREATE_TREE_NODE(5, UPS_sensor_nodes);
|
---|
92 |
|
---|
93 | /* 1.6.1-6 switch*/
|
---|
94 | static const struct snmp_scalar_node UPS_switch_1 = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, UPS_get_switch_value);
|
---|
95 | static const struct snmp_scalar_node UPS_switch_2 = SNMP_SCALAR_CREATE_NODE_READONLY(2, SNMP_ASN1_TYPE_INTEGER, UPS_get_switch_value);
|
---|
96 | static const struct snmp_scalar_node UPS_switch_3 = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_INTEGER, UPS_get_switch_value);
|
---|
97 | static const struct snmp_scalar_node UPS_switch_4 = SNMP_SCALAR_CREATE_NODE_READONLY(4, SNMP_ASN1_TYPE_INTEGER, UPS_get_switch_value);
|
---|
98 | static const struct snmp_scalar_node UPS_switch_5 = SNMP_SCALAR_CREATE_NODE_READONLY(5, SNMP_ASN1_TYPE_INTEGER, UPS_get_switch_value);
|
---|
99 | static const struct snmp_scalar_node UPS_switch_6 = SNMP_SCALAR_CREATE_NODE_READONLY(6, SNMP_ASN1_TYPE_INTEGER, UPS_get_switch_value);
|
---|
100 | static const struct snmp_node* const UPS_switch_nodes[] = {&UPS_switch_1.node.node, &UPS_switch_2.node.node, &UPS_switch_3.node.node,
|
---|
101 | &UPS_switch_4.node.node, &UPS_switch_5.node.node, &UPS_switch_6.node.node};
|
---|
102 | static const struct snmp_tree_node UPS_switch_tree_node = SNMP_CREATE_TREE_NODE(6, UPS_switch_nodes);
|
---|
103 |
|
---|
104 | /* 1.7.1-11 alarm list*/
|
---|
105 | static const struct snmp_scalar_node UPS_off_220 = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, UPS_get_alarms_value);
|
---|
106 | static const struct snmp_scalar_node UPS_off_battery = SNMP_SCALAR_CREATE_NODE_READONLY(2, SNMP_ASN1_TYPE_INTEGER, UPS_get_alarms_value);
|
---|
107 | static const struct snmp_scalar_node UPS_crytical_discharge = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_INTEGER, UPS_get_alarms_value);
|
---|
108 | static const struct snmp_scalar_node UPS_off_load = SNMP_SCALAR_CREATE_NODE_READONLY(4, SNMP_ASN1_TYPE_INTEGER, UPS_get_alarms_value);
|
---|
109 | static const struct snmp_scalar_node UPS_rm48 = SNMP_SCALAR_CREATE_NODE_READONLY(5, SNMP_ASN1_TYPE_INTEGER, UPS_get_alarms_value);
|
---|
110 | static const struct snmp_scalar_node UPS_bat_noconnect = SNMP_SCALAR_CREATE_NODE_READONLY(6, SNMP_ASN1_TYPE_INTEGER, UPS_get_alarms_value);
|
---|
111 | static const struct snmp_scalar_node UPS_rm48_count = SNMP_SCALAR_CREATE_NODE_READONLY(7, SNMP_ASN1_TYPE_INTEGER, UPS_get_alarms_value);
|
---|
112 | static const struct snmp_scalar_node UPS_term_sensor = SNMP_SCALAR_CREATE_NODE_READONLY(8, SNMP_ASN1_TYPE_INTEGER, UPS_get_alarms_value);
|
---|
113 | static const struct snmp_scalar_node UPS_bat_disconnect = SNMP_SCALAR_CREATE_NODE_READONLY(9, SNMP_ASN1_TYPE_INTEGER, UPS_get_alarms_value);
|
---|
114 | static const struct snmp_scalar_node UPS_bat_disbalance = SNMP_SCALAR_CREATE_NODE_READONLY(10, SNMP_ASN1_TYPE_INTEGER, UPS_get_alarms_value);
|
---|
115 | static const struct snmp_scalar_node UPS_bat_nocontrol = SNMP_SCALAR_CREATE_NODE_READONLY(11, SNMP_ASN1_TYPE_INTEGER, UPS_get_alarms_value);
|
---|
116 | static const struct snmp_node* const UPS_alarms_nodes[] = {&UPS_off_220.node.node, &UPS_off_battery.node.node, &UPS_crytical_discharge.node.node,
|
---|
117 | &UPS_off_load.node.node, &UPS_rm48.node.node, &UPS_bat_noconnect.node.node,
|
---|
118 | &UPS_rm48_count.node.node, &UPS_term_sensor.node.node, &UPS_bat_disconnect.node.node,
|
---|
119 | &UPS_bat_disbalance.node.node, &UPS_bat_nocontrol.node.node};
|
---|
120 | static const struct snmp_tree_node UPS_alarms_tree_node = SNMP_CREATE_TREE_NODE(7, UPS_alarms_nodes);
|
---|
121 |
|
---|
122 | /* 1.8.1 and 3 battery*/
|
---|
123 | static const struct snmp_scalar_node UPS_measuring = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, UPS_get_battery_value);
|
---|
124 | static const struct snmp_scalar_node UPS_battery_state = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_INTEGER, UPS_get_battery_value);
|
---|
125 | /* 1.8.2.1-5 battery voltage*/
|
---|
126 | static const struct snmp_scalar_node UPS_u_bat_1 = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, UPS_get_battery_voltage_value);
|
---|
127 | static const struct snmp_scalar_node UPS_u_bat_2 = SNMP_SCALAR_CREATE_NODE_READONLY(2, SNMP_ASN1_TYPE_INTEGER, UPS_get_battery_voltage_value);
|
---|
128 | static const struct snmp_scalar_node UPS_u_bat_3 = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_INTEGER, UPS_get_battery_voltage_value);
|
---|
129 | static const struct snmp_scalar_node UPS_u_bat_4 = SNMP_SCALAR_CREATE_NODE_READONLY(4, SNMP_ASN1_TYPE_INTEGER, UPS_get_battery_voltage_value);
|
---|
130 | static const struct snmp_scalar_node UPS_u_bat_5 = SNMP_SCALAR_CREATE_NODE_READONLY(5, SNMP_ASN1_TYPE_INTEGER, UPS_get_battery_voltage_value);
|
---|
131 | static const struct snmp_node* const UPS_u_bat_nodes[] = {&UPS_u_bat_1.node.node, &UPS_u_bat_2.node.node, &UPS_u_bat_3.node.node,
|
---|
132 | &UPS_u_bat_4.node.node, &UPS_u_bat_5.node.node};
|
---|
133 | static const struct snmp_tree_node UPS_u_bat_tree_node = SNMP_CREATE_TREE_NODE(2, UPS_u_bat_nodes);
|
---|
134 |
|
---|
135 | static const struct snmp_node* const UPS_battery_nodes[] = {&UPS_measuring.node.node, &UPS_u_bat_tree_node.node, &UPS_battery_state.node.node};
|
---|
136 | static const struct snmp_tree_node UPS_battery_tree_node = SNMP_CREATE_TREE_NODE(8, UPS_battery_nodes);
|
---|
137 |
|
---|
138 | /* 1.9.1-4 rm48*/
|
---|
139 | /* 1.9.1.1 rm48 presense*/
|
---|
140 | static const struct snmp_scalar_node UPS_rm48_1_presense = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, UPS_get_rm48_1_value);
|
---|
141 | static const struct snmp_node* const UPS_rm48_1_nodes[] = {&UPS_rm48_1_presense.node.node};
|
---|
142 | static const struct snmp_tree_node UPS_rm48_1_tree_node = SNMP_CREATE_TREE_NODE(1, UPS_rm48_1_nodes);
|
---|
143 | /* 1.9.2.1 rm48 presense*/
|
---|
144 | static const struct snmp_scalar_node UPS_rm48_2_presense = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, UPS_get_rm48_2_value);
|
---|
145 | static const struct snmp_node* const UPS_rm48_2_nodes[] = {&UPS_rm48_2_presense.node.node};
|
---|
146 | static const struct snmp_tree_node UPS_rm48_2_tree_node = SNMP_CREATE_TREE_NODE(2, UPS_rm48_2_nodes);
|
---|
147 | /* 1.9.3.1 rm48 presense*/
|
---|
148 | static const struct snmp_scalar_node UPS_rm48_3_presense = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, UPS_get_rm48_3_value);
|
---|
149 | static const struct snmp_node* const UPS_rm48_3_nodes[] = {&UPS_rm48_3_presense.node.node};
|
---|
150 | static const struct snmp_tree_node UPS_rm48_3_tree_node = SNMP_CREATE_TREE_NODE(3, UPS_rm48_3_nodes);
|
---|
151 | /* 1.9.4.1 rm48 presense*/
|
---|
152 | static const struct snmp_scalar_node UPS_rm48_4_presense = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, UPS_get_rm48_4_value);
|
---|
153 | static const struct snmp_node* const UPS_rm48_4_nodes[] = {&UPS_rm48_4_presense.node.node};
|
---|
154 | static const struct snmp_tree_node UPS_rm48_4_tree_node = SNMP_CREATE_TREE_NODE(4, UPS_rm48_4_nodes);
|
---|
155 |
|
---|
156 | static const struct snmp_node* const UPS_rm48_nodes[] = {&UPS_rm48_1_tree_node.node, &UPS_rm48_2_tree_node.node, &UPS_rm48_3_tree_node.node,
|
---|
157 | &UPS_rm48_4_tree_node.node};
|
---|
158 | static const struct snmp_tree_node UPS_rm48_tree_node = SNMP_CREATE_TREE_NODE(9, UPS_rm48_nodes);
|
---|
159 |
|
---|
160 |
|
---|
161 | static const struct snmp_node* const UPS_mibs_nodes[] = {&UPS_CommonStatus.node.node, &UPS_SoftwareVersion.node.node, &UPS_SoftwareSubVersion.node.node,
|
---|
162 | &UPS_paramerts_tree_node.node, &UPS_sensor_tree_node.node, &UPS_switch_tree_node.node,
|
---|
163 | &UPS_alarms_tree_node.node, &UPS_battery_tree_node.node, &UPS_rm48_tree_node.node};
|
---|
164 | static const struct snmp_tree_node UPS_mibs_tree_node = SNMP_CREATE_TREE_NODE(1, UPS_mibs_nodes);
|
---|
165 | static const struct snmp_mib UPS_snmp_mibs = SNMP_MIB_CREATE(UPS_baseOID, &UPS_mibs_tree_node.node);
|
---|
166 |
|
---|
167 | /* FUNCTION UPS 1200 */
|
---|
168 | /* 1.1-3 */
|
---|
169 | static s16_t UPS_get_root_value(struct snmp_node_instance* instance, void* value)
|
---|
170 | {
|
---|
171 | u32_t *uint_ptr = (u32_t*) value;
|
---|
172 | u32_t len;
|
---|
173 |
|
---|
174 | if(snmp_ups.dRoot[instance->node->oid - 1].type == SNMP_ENUM){ // CommonStatus
|
---|
175 | *uint_ptr = (u32_t)snmp_ups.dRoot[instance->node->oid - 1].value;
|
---|
176 | len = sizeof(*uint_ptr);
|
---|
177 | }
|
---|
178 | else if(snmp_ups.dRoot[instance->node->oid - 1].type == SNMP_STRING){ // SoftwareVersion, SoftwareSubVersion
|
---|
179 |
|
---|
180 | memcpy(uint_ptr, (char*)snmp_ups.dRoot[instance->node->oid - 1].value, strlen((char*)snmp_ups.dRoot[instance->node->oid - 1].value));
|
---|
181 | len = strlen((char*)uint_ptr);
|
---|
182 | }
|
---|
183 | return len;
|
---|
184 | }
|
---|
185 |
|
---|
186 | /* 1.4.1-8 parametrs*/
|
---|
187 | static s16_t UPS_get_paramerts_value(struct snmp_node_instance* instance, void* value)
|
---|
188 | {
|
---|
189 | u32_t *uint_ptr = (u32_t*) value;
|
---|
190 |
|
---|
191 | if(snmp_ups.dParametrs[instance->node->oid - 1].type == SNMP_INT16){
|
---|
192 | *uint_ptr = (u32_t)snmp_ups.dParametrs[instance->node->oid - 1].value;
|
---|
193 | }
|
---|
194 | else if(snmp_ups.dParametrs[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
195 | *uint_ptr = (u32_t)snmp_ups.dParametrs[instance->node->oid - 1].value;
|
---|
196 | }
|
---|
197 |
|
---|
198 | return sizeof(*uint_ptr);
|
---|
199 | }
|
---|
200 |
|
---|
201 | /* 1.5.1-4 sensor*/
|
---|
202 | static s16_t UPS_get_sensor_value(struct snmp_node_instance* instance, void* value)
|
---|
203 | {
|
---|
204 | u32_t *uint_ptr = (u32_t*) value;
|
---|
205 |
|
---|
206 | if(snmp_ups.dSensor[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
207 | *uint_ptr = (u32_t)snmp_ups.dSensor[instance->node->oid - 1].value;
|
---|
208 | }
|
---|
209 |
|
---|
210 | return sizeof(*uint_ptr);
|
---|
211 | }
|
---|
212 |
|
---|
213 | /* 1.6.1-6 switch*/
|
---|
214 | static s16_t UPS_get_switch_value(struct snmp_node_instance* instance, void* value)
|
---|
215 | {
|
---|
216 | u32_t *uint_ptr = (u32_t*) value;
|
---|
217 |
|
---|
218 | if(snmp_ups.dSwitch[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
219 | *uint_ptr = (u32_t)snmp_ups.dSwitch[instance->node->oid - 1].value;
|
---|
220 | }
|
---|
221 |
|
---|
222 | return sizeof(*uint_ptr);
|
---|
223 | }
|
---|
224 |
|
---|
225 | /* 1.7.1-11 alarm list*/
|
---|
226 | static s16_t UPS_get_alarms_value(struct snmp_node_instance* instance, void* value)
|
---|
227 | {
|
---|
228 | u32_t *uint_ptr = (u32_t*) value;
|
---|
229 |
|
---|
230 | if(snmp_ups.dAlarmList[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
231 | *uint_ptr = (u32_t)snmp_ups.dAlarmList[instance->node->oid - 1].value;
|
---|
232 | }
|
---|
233 |
|
---|
234 | return sizeof(*uint_ptr);
|
---|
235 | }
|
---|
236 |
|
---|
237 | /* 1.8.1 and 3 battery*/
|
---|
238 | static s16_t UPS_get_battery_value(struct snmp_node_instance* instance, void* value)
|
---|
239 | {
|
---|
240 | u32_t *uint_ptr = (u32_t*) value;
|
---|
241 |
|
---|
242 | if(snmp_ups.dBattery[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
243 | *uint_ptr = (u32_t)snmp_ups.dBattery[instance->node->oid - 1].value;
|
---|
244 | }
|
---|
245 | else if(snmp_ups.dBattery[instance->node->oid - 1].type == SNMP_UINT8){
|
---|
246 | *uint_ptr = (u32_t)snmp_ups.dBattery[instance->node->oid - 1].value;
|
---|
247 | }
|
---|
248 |
|
---|
249 | return sizeof(*uint_ptr);
|
---|
250 | }
|
---|
251 |
|
---|
252 | /* 1.8.2.1-5 battery voltage*/
|
---|
253 | static s16_t UPS_get_battery_voltage_value(struct snmp_node_instance* instance, void* value)
|
---|
254 | {
|
---|
255 | u32_t *uint_ptr = (u32_t*) value;
|
---|
256 |
|
---|
257 | if(snmp_ups.dBatteryVoltage[instance->node->oid - 1].type == SNMP_INT16){
|
---|
258 | *uint_ptr = (u32_t)snmp_ups.dBatteryVoltage[instance->node->oid - 1].value;
|
---|
259 | }
|
---|
260 |
|
---|
261 | return sizeof(*uint_ptr);
|
---|
262 | }
|
---|
263 |
|
---|
264 | /* 1.9.1.1 rm48 presense 1*/
|
---|
265 | static s16_t UPS_get_rm48_1_value(struct snmp_node_instance* instance, void* value)
|
---|
266 | {
|
---|
267 | u32_t *uint_ptr = (u32_t*) value;
|
---|
268 |
|
---|
269 | if(snmp_ups.dRm48Presense_1[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
270 | *uint_ptr = (u32_t)snmp_ups.dRm48Presense_1[instance->node->oid - 1].value;
|
---|
271 | }
|
---|
272 |
|
---|
273 | return sizeof(*uint_ptr);
|
---|
274 | }
|
---|
275 |
|
---|
276 | /* 1.9.2.1 rm48 presense 2*/
|
---|
277 | static s16_t UPS_get_rm48_2_value(struct snmp_node_instance* instance, void* value)
|
---|
278 | {
|
---|
279 | u32_t *uint_ptr = (u32_t*) value;
|
---|
280 |
|
---|
281 | if(snmp_ups.dRm48Presense_2[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
282 | *uint_ptr = (u32_t)snmp_ups.dRm48Presense_2[instance->node->oid - 1].value;
|
---|
283 | }
|
---|
284 |
|
---|
285 | return sizeof(*uint_ptr);
|
---|
286 | }
|
---|
287 |
|
---|
288 | /* 1.9.3.1 rm48 presense 3*/
|
---|
289 | static s16_t UPS_get_rm48_3_value(struct snmp_node_instance* instance, void* value)
|
---|
290 | {
|
---|
291 | u32_t *uint_ptr = (u32_t*) value;
|
---|
292 |
|
---|
293 | if(snmp_ups.dRm48Presense_3[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
294 | *uint_ptr = (u32_t)snmp_ups.dRm48Presense_3[instance->node->oid - 1].value;
|
---|
295 | }
|
---|
296 |
|
---|
297 | return sizeof(*uint_ptr);
|
---|
298 | }
|
---|
299 |
|
---|
300 | /* 1.9.4.1 rm48 presense 4*/
|
---|
301 | static s16_t UPS_get_rm48_4_value(struct snmp_node_instance* instance, void* value)
|
---|
302 | {
|
---|
303 | u32_t *uint_ptr = (u32_t*) value;
|
---|
304 |
|
---|
305 | if(snmp_ups.dRm48Presense_4[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
306 | *uint_ptr = (u32_t)snmp_ups.dRm48Presense_4[instance->node->oid - 1].value;
|
---|
307 | }
|
---|
308 |
|
---|
309 | return sizeof(*uint_ptr);
|
---|
310 | }
|
---|
311 | /*END SNMP MIB UPS-1200 -----------------------------------------------------------------------------------*/
|
---|
312 | /*##########################################################################################################*/
|
---|
313 |
|
---|
314 | /*##########################################################################################################*/
|
---|
315 | /* SNMP OID and FUNCTION MC04-PLC --------------------------------------------------------------------------*/
|
---|
316 | #include "lwip.h"
|
---|
317 | #include "plc.h"
|
---|
318 |
|
---|
319 | //struct trap_list trap_list_bank[2];
|
---|
320 |
|
---|
321 | extern plc_data_typeDef PLC_Data[AMOUNT_BLOCK_PLC];
|
---|
322 | extern network_settings table_network[MAX_IP];
|
---|
323 |
|
---|
324 | snmp_PLC_Data_typeDef snmp_plc_data[AMOUNT_BLOCK_PLC] =
|
---|
325 | /*near block*/
|
---|
326 | {{table_network[0].ipv4_addr, {{SNMP_ENUM, &PLC_Data[0].CommonAlarm},{SNMP_STRING, &PLC_Data[0].Version},{SNMP_ENUM, &PLC_Data[0].Type_Filter},{SNMP_UINT8, &PLC_Data[0].Power_PRD},{SNMP_UINT8, &PLC_Data[0].FilterATT}}, // root
|
---|
327 | {{SNMP_ENUM, &PLC_Data[0].HF_Channel[0].En},{SNMP_ENUM, &PLC_Data[0].HF_Channel[0].Status_Receiver},{SNMP_ENUM, &PLC_Data[0].HF_Channel[0].Mode},{SNMP_UINT16, &PLC_Data[0].HF_Channel[0].Frequency_Transmitter},{SNMP_UINT16, &PLC_Data[0].HF_Channel[0].Frequency_Receiver},
|
---|
328 | {SNMP_INT16, &PLC_Data[0].HF_Channel[0].Level_Receiver},{SNMP_INT16, &PLC_Data[0].HF_Channel[0].Level_InputSignal},{SNMP_UINT16, &PLC_Data[0].HF_Channel[0].Rate_Transmitter},{SNMP_UINT16, &PLC_Data[0].HF_Channel[0].Rate_Receiver},
|
---|
329 | {SNMP_UINT16, &PLC_Data[0].HF_Channel[0].QualityNoise_Receiver},{SNMP_UINT16,&PLC_Data[0].HF_Channel[0].SNR_Receiver},{SNMP_UINT8,&PLC_Data[0].HF_Channel[0].Kosh_sig},{SNMP_INT8,&PLC_Data[0].HF_Channel[0].Kosh_exp},{SNMP_UINT8,&PLC_Data[0].HF_Channel[0].Kosh_raw}}, // ch 1
|
---|
330 | {{SNMP_ENUM, &PLC_Data[0].HF_Channel[1].En},{SNMP_ENUM, &PLC_Data[0].HF_Channel[1].Status_Receiver},{SNMP_ENUM, &PLC_Data[0].HF_Channel[1].Mode},{SNMP_UINT16, &PLC_Data[0].HF_Channel[1].Frequency_Transmitter},{SNMP_UINT16, &PLC_Data[0].HF_Channel[1].Frequency_Receiver},
|
---|
331 | {SNMP_INT16, &PLC_Data[0].HF_Channel[1].Level_Receiver},{SNMP_INT16, &PLC_Data[0].HF_Channel[1].Level_InputSignal},{SNMP_UINT16, &PLC_Data[0].HF_Channel[1].Rate_Transmitter},{SNMP_UINT16, &PLC_Data[0].HF_Channel[1].Rate_Receiver},
|
---|
332 | {SNMP_UINT16, &PLC_Data[0].HF_Channel[1].QualityNoise_Receiver},{SNMP_UINT16,&PLC_Data[0].HF_Channel[1].SNR_Receiver},{SNMP_UINT8,&PLC_Data[0].HF_Channel[1].Kosh_sig},{SNMP_INT8,&PLC_Data[0].HF_Channel[1].Kosh_exp},{SNMP_UINT8,&PLC_Data[0].HF_Channel[1].Kosh_raw}}, // ch 2
|
---|
333 | {{SNMP_ENUM, &PLC_Data[0].HF_Channel[2].En},{SNMP_ENUM, &PLC_Data[0].HF_Channel[2].Status_Receiver},{SNMP_ENUM, &PLC_Data[0].HF_Channel[2].Mode},{SNMP_UINT16, &PLC_Data[0].HF_Channel[2].Frequency_Transmitter},{SNMP_UINT16, &PLC_Data[0].HF_Channel[2].Frequency_Receiver},
|
---|
334 | {SNMP_INT16, &PLC_Data[0].HF_Channel[2].Level_Receiver},{SNMP_INT16, &PLC_Data[0].HF_Channel[2].Level_InputSignal},{SNMP_UINT16, &PLC_Data[0].HF_Channel[2].Rate_Transmitter},{SNMP_UINT16, &PLC_Data[0].HF_Channel[2].Rate_Receiver},
|
---|
335 | {SNMP_UINT16, &PLC_Data[0].HF_Channel[2].QualityNoise_Receiver},{SNMP_UINT16,&PLC_Data[0].HF_Channel[2].SNR_Receiver},{SNMP_UINT8,&PLC_Data[0].HF_Channel[2].Kosh_sig},{SNMP_INT8,&PLC_Data[0].HF_Channel[2].Kosh_exp},{SNMP_UINT8,&PLC_Data[0].HF_Channel[2].Kosh_raw}}, // ch 3
|
---|
336 | {{SNMP_ENUM, &PLC_Data[0].PowerAmplifier[0].Presence},{SNMP_ENUM, &PLC_Data[0].PowerAmplifier[0].Alarm},{SNMP_UINT8, &PLC_Data[0].PowerAmplifier[0].Level_Transmitter},{SNMP_UINT8, &PLC_Data[0].PowerAmplifier[0].Temp},{SNMP_UINT8, &PLC_Data[0].PowerAmplifier[0].Voltage}}, // pwr amp 1
|
---|
337 | {{SNMP_ENUM, &PLC_Data[0].PowerAmplifier[1].Presence},{SNMP_ENUM, &PLC_Data[0].PowerAmplifier[1].Alarm},{SNMP_UINT8, &PLC_Data[0].PowerAmplifier[1].Level_Transmitter},{SNMP_UINT8, &PLC_Data[0].PowerAmplifier[1].Temp},{SNMP_UINT8, &PLC_Data[0].PowerAmplifier[1].Voltage}}}, // pwr amp 2
|
---|
338 | /*remout blok 1*/
|
---|
339 | {table_network[1].ipv4_addr, {{SNMP_ENUM, &PLC_Data[1].CommonAlarm},{SNMP_STRING, &PLC_Data[1].Version},{SNMP_ENUM, &PLC_Data[1].Type_Filter},{SNMP_UINT8, &PLC_Data[1].Power_PRD},{SNMP_UINT8, &PLC_Data[1].FilterATT}}, // root
|
---|
340 | {{SNMP_ENUM, &PLC_Data[1].HF_Channel[0].En},{SNMP_ENUM, &PLC_Data[1].HF_Channel[0].Status_Receiver},{SNMP_ENUM, &PLC_Data[1].HF_Channel[0].Mode},{SNMP_UINT16, &PLC_Data[1].HF_Channel[0].Frequency_Transmitter},{SNMP_UINT16, &PLC_Data[1].HF_Channel[0].Frequency_Receiver},
|
---|
341 | {SNMP_INT16, &PLC_Data[1].HF_Channel[0].Level_Receiver},{SNMP_INT16, &PLC_Data[1].HF_Channel[0].Level_InputSignal},{SNMP_UINT16, &PLC_Data[1].HF_Channel[0].Rate_Transmitter},{SNMP_UINT16, &PLC_Data[1].HF_Channel[0].Rate_Receiver},
|
---|
342 | {SNMP_UINT16, &PLC_Data[1].HF_Channel[0].QualityNoise_Receiver},{SNMP_UINT16,&PLC_Data[1].HF_Channel[0].SNR_Receiver},{SNMP_UINT8,&PLC_Data[1].HF_Channel[0].Kosh_sig},{SNMP_INT8,&PLC_Data[1].HF_Channel[0].Kosh_exp},{SNMP_UINT8,&PLC_Data[1].HF_Channel[0].Kosh_raw}}, // ch 1
|
---|
343 | {{SNMP_ENUM, &PLC_Data[1].HF_Channel[1].En},{SNMP_ENUM, &PLC_Data[1].HF_Channel[1].Status_Receiver},{SNMP_ENUM, &PLC_Data[1].HF_Channel[1].Mode},{SNMP_UINT16, &PLC_Data[1].HF_Channel[1].Frequency_Transmitter},{SNMP_UINT16, &PLC_Data[1].HF_Channel[1].Frequency_Receiver},
|
---|
344 | {SNMP_INT16, &PLC_Data[1].HF_Channel[1].Level_Receiver},{SNMP_INT16, &PLC_Data[1].HF_Channel[1].Level_InputSignal},{SNMP_UINT16, &PLC_Data[1].HF_Channel[1].Rate_Transmitter},{SNMP_UINT16, &PLC_Data[1].HF_Channel[1].Rate_Receiver},
|
---|
345 | {SNMP_UINT16, &PLC_Data[1].HF_Channel[1].QualityNoise_Receiver},{SNMP_UINT16,&PLC_Data[1].HF_Channel[1].SNR_Receiver},{SNMP_UINT8,&PLC_Data[1].HF_Channel[1].Kosh_sig},{SNMP_INT8,&PLC_Data[1].HF_Channel[1].Kosh_exp},{SNMP_UINT8,&PLC_Data[1].HF_Channel[1].Kosh_raw}}, // ch 2
|
---|
346 | {{SNMP_ENUM, &PLC_Data[1].HF_Channel[2].En},{SNMP_ENUM, &PLC_Data[1].HF_Channel[2].Status_Receiver},{SNMP_ENUM, &PLC_Data[1].HF_Channel[2].Mode},{SNMP_UINT16, &PLC_Data[1].HF_Channel[2].Frequency_Transmitter},{SNMP_UINT16, &PLC_Data[1].HF_Channel[2].Frequency_Receiver},
|
---|
347 | {SNMP_INT16, &PLC_Data[1].HF_Channel[2].Level_Receiver},{SNMP_INT16, &PLC_Data[1].HF_Channel[2].Level_InputSignal},{SNMP_UINT16, &PLC_Data[1].HF_Channel[2].Rate_Transmitter},{SNMP_UINT16, &PLC_Data[1].HF_Channel[2].Rate_Receiver},
|
---|
348 | {SNMP_UINT16, &PLC_Data[1].HF_Channel[2].QualityNoise_Receiver},{SNMP_UINT16,&PLC_Data[1].HF_Channel[2].SNR_Receiver},{SNMP_UINT8,&PLC_Data[1].HF_Channel[2].Kosh_sig},{SNMP_INT8,&PLC_Data[1].HF_Channel[2].Kosh_exp},{SNMP_UINT8,&PLC_Data[1].HF_Channel[2].Kosh_raw}}, // ch 3
|
---|
349 | {{SNMP_ENUM, &PLC_Data[1].PowerAmplifier[0].Presence},{SNMP_ENUM, &PLC_Data[1].PowerAmplifier[0].Alarm},{SNMP_UINT8, &PLC_Data[1].PowerAmplifier[0].Level_Transmitter},{SNMP_UINT8, &PLC_Data[1].PowerAmplifier[0].Temp},{SNMP_UINT8, &PLC_Data[1].PowerAmplifier[0].Voltage}}, // pwr amp 1
|
---|
350 | {{SNMP_ENUM, &PLC_Data[1].PowerAmplifier[1].Presence},{SNMP_ENUM, &PLC_Data[1].PowerAmplifier[1].Alarm},{SNMP_UINT8, &PLC_Data[1].PowerAmplifier[1].Level_Transmitter},{SNMP_UINT8, &PLC_Data[1].PowerAmplifier[1].Temp},{SNMP_UINT8, &PLC_Data[1].PowerAmplifier[1].Voltage}}}, // pwr amp 2
|
---|
351 | /*remout blok 2*/
|
---|
352 | {table_network[2].ipv4_addr, {{SNMP_ENUM, &PLC_Data[2].CommonAlarm},{SNMP_STRING, &PLC_Data[2].Version},{SNMP_ENUM, &PLC_Data[2].Type_Filter},{SNMP_UINT8, &PLC_Data[2].Power_PRD},{SNMP_UINT8, &PLC_Data[2].FilterATT}}, // root
|
---|
353 | {{SNMP_ENUM, &PLC_Data[2].HF_Channel[0].En},{SNMP_ENUM, &PLC_Data[2].HF_Channel[0].Status_Receiver},{SNMP_ENUM, &PLC_Data[2].HF_Channel[0].Mode},{SNMP_UINT16, &PLC_Data[2].HF_Channel[0].Frequency_Transmitter},{SNMP_UINT16, &PLC_Data[2].HF_Channel[0].Frequency_Receiver},
|
---|
354 | {SNMP_INT16, &PLC_Data[2].HF_Channel[0].Level_Receiver},{SNMP_INT16, &PLC_Data[2].HF_Channel[0].Level_InputSignal},{SNMP_UINT16, &PLC_Data[2].HF_Channel[0].Rate_Transmitter},{SNMP_UINT16, &PLC_Data[2].HF_Channel[0].Rate_Receiver},
|
---|
355 | {SNMP_UINT16, &PLC_Data[2].HF_Channel[0].QualityNoise_Receiver},{SNMP_UINT16,&PLC_Data[2].HF_Channel[0].SNR_Receiver},{SNMP_UINT8,&PLC_Data[2].HF_Channel[0].Kosh_sig},{SNMP_INT8,&PLC_Data[2].HF_Channel[0].Kosh_exp},{SNMP_UINT8,&PLC_Data[2].HF_Channel[0].Kosh_raw}}, // ch 1
|
---|
356 | {{SNMP_ENUM, &PLC_Data[2].HF_Channel[1].En},{SNMP_ENUM, &PLC_Data[2].HF_Channel[1].Status_Receiver},{SNMP_ENUM, &PLC_Data[2].HF_Channel[1].Mode},{SNMP_UINT16, &PLC_Data[2].HF_Channel[1].Frequency_Transmitter},{SNMP_UINT16, &PLC_Data[2].HF_Channel[1].Frequency_Receiver},
|
---|
357 | {SNMP_INT16, &PLC_Data[2].HF_Channel[1].Level_Receiver},{SNMP_INT16, &PLC_Data[2].HF_Channel[1].Level_InputSignal},{SNMP_UINT16, &PLC_Data[2].HF_Channel[1].Rate_Transmitter},{SNMP_UINT16, &PLC_Data[2].HF_Channel[1].Rate_Receiver},
|
---|
358 | {SNMP_UINT16, &PLC_Data[2].HF_Channel[1].QualityNoise_Receiver},{SNMP_UINT16,&PLC_Data[2].HF_Channel[1].SNR_Receiver},{SNMP_UINT8,&PLC_Data[2].HF_Channel[1].Kosh_sig},{SNMP_INT8,&PLC_Data[2].HF_Channel[1].Kosh_exp},{SNMP_UINT8,&PLC_Data[2].HF_Channel[1].Kosh_raw}}, // ch 2
|
---|
359 | {{SNMP_ENUM, &PLC_Data[2].HF_Channel[2].En},{SNMP_ENUM, &PLC_Data[2].HF_Channel[2].Status_Receiver},{SNMP_ENUM, &PLC_Data[2].HF_Channel[2].Mode},{SNMP_UINT16, &PLC_Data[2].HF_Channel[2].Frequency_Transmitter},{SNMP_UINT16, &PLC_Data[2].HF_Channel[2].Frequency_Receiver},
|
---|
360 | {SNMP_INT16, &PLC_Data[2].HF_Channel[2].Level_Receiver},{SNMP_INT16, &PLC_Data[2].HF_Channel[2].Level_InputSignal},{SNMP_UINT16, &PLC_Data[2].HF_Channel[2].Rate_Transmitter},{SNMP_UINT16, &PLC_Data[2].HF_Channel[2].Rate_Receiver},
|
---|
361 | {SNMP_UINT16, &PLC_Data[2].HF_Channel[2].QualityNoise_Receiver},{SNMP_UINT16,&PLC_Data[2].HF_Channel[2].SNR_Receiver},{SNMP_UINT8,&PLC_Data[2].HF_Channel[2].Kosh_sig},{SNMP_INT8,&PLC_Data[2].HF_Channel[2].Kosh_exp},{SNMP_UINT8,&PLC_Data[2].HF_Channel[2].Kosh_raw}}, // ch 3
|
---|
362 | {{SNMP_ENUM, &PLC_Data[2].PowerAmplifier[0].Presence},{SNMP_ENUM, &PLC_Data[2].PowerAmplifier[0].Alarm},{SNMP_UINT8, &PLC_Data[2].PowerAmplifier[0].Level_Transmitter},{SNMP_UINT8, &PLC_Data[2].PowerAmplifier[0].Temp},{SNMP_UINT8, &PLC_Data[2].PowerAmplifier[0].Voltage}}, // pwr amp 1
|
---|
363 | {{SNMP_ENUM, &PLC_Data[2].PowerAmplifier[1].Presence},{SNMP_ENUM, &PLC_Data[2].PowerAmplifier[1].Alarm},{SNMP_UINT8, &PLC_Data[2].PowerAmplifier[1].Level_Transmitter},{SNMP_UINT8, &PLC_Data[2].PowerAmplifier[1].Temp},{SNMP_UINT8, &PLC_Data[2].PowerAmplifier[1].Voltage}}}, // pwr amp 2
|
---|
364 | /*remout blok 3*/
|
---|
365 | {table_network[3].ipv4_addr, {{SNMP_ENUM, &PLC_Data[3].CommonAlarm},{SNMP_STRING, &PLC_Data[3].Version},{SNMP_ENUM, &PLC_Data[3].Type_Filter},{SNMP_UINT8, &PLC_Data[3].Power_PRD},{SNMP_UINT8, &PLC_Data[3].FilterATT}}, // root
|
---|
366 | {{SNMP_ENUM, &PLC_Data[3].HF_Channel[0].En},{SNMP_ENUM, &PLC_Data[3].HF_Channel[0].Status_Receiver},{SNMP_ENUM, &PLC_Data[3].HF_Channel[0].Mode},{SNMP_UINT16, &PLC_Data[3].HF_Channel[0].Frequency_Transmitter},{SNMP_UINT16, &PLC_Data[3].HF_Channel[0].Frequency_Receiver},
|
---|
367 | {SNMP_INT16, &PLC_Data[3].HF_Channel[0].Level_Receiver},{SNMP_INT16, &PLC_Data[3].HF_Channel[0].Level_InputSignal},{SNMP_UINT16, &PLC_Data[3].HF_Channel[0].Rate_Transmitter},{SNMP_UINT16, &PLC_Data[3].HF_Channel[0].Rate_Receiver},
|
---|
368 | {SNMP_UINT16, &PLC_Data[3].HF_Channel[0].QualityNoise_Receiver},{SNMP_UINT16,&PLC_Data[3].HF_Channel[0].SNR_Receiver},{SNMP_UINT8,&PLC_Data[3].HF_Channel[0].Kosh_sig},{SNMP_INT8,&PLC_Data[3].HF_Channel[0].Kosh_exp},{SNMP_UINT8,&PLC_Data[3].HF_Channel[0].Kosh_raw}}, // ch 1
|
---|
369 | {{SNMP_ENUM, &PLC_Data[3].HF_Channel[1].En},{SNMP_ENUM, &PLC_Data[3].HF_Channel[1].Status_Receiver},{SNMP_ENUM, &PLC_Data[3].HF_Channel[1].Mode},{SNMP_UINT16, &PLC_Data[3].HF_Channel[1].Frequency_Transmitter},{SNMP_UINT16, &PLC_Data[3].HF_Channel[1].Frequency_Receiver},
|
---|
370 | {SNMP_INT16, &PLC_Data[3].HF_Channel[1].Level_Receiver},{SNMP_INT16, &PLC_Data[3].HF_Channel[1].Level_InputSignal},{SNMP_UINT16, &PLC_Data[3].HF_Channel[1].Rate_Transmitter},{SNMP_UINT16, &PLC_Data[3].HF_Channel[1].Rate_Receiver},
|
---|
371 | {SNMP_UINT16, &PLC_Data[3].HF_Channel[1].QualityNoise_Receiver},{SNMP_UINT16,&PLC_Data[3].HF_Channel[1].SNR_Receiver},{SNMP_UINT8,&PLC_Data[3].HF_Channel[1].Kosh_sig},{SNMP_INT8,&PLC_Data[3].HF_Channel[1].Kosh_exp},{SNMP_UINT8,&PLC_Data[3].HF_Channel[1].Kosh_raw}}, // ch 2
|
---|
372 | {{SNMP_ENUM, &PLC_Data[3].HF_Channel[2].En},{SNMP_ENUM, &PLC_Data[3].HF_Channel[2].Status_Receiver},{SNMP_ENUM, &PLC_Data[3].HF_Channel[2].Mode},{SNMP_UINT16, &PLC_Data[3].HF_Channel[2].Frequency_Transmitter},{SNMP_UINT16, &PLC_Data[3].HF_Channel[2].Frequency_Receiver},
|
---|
373 | {SNMP_INT16, &PLC_Data[3].HF_Channel[2].Level_Receiver},{SNMP_INT16, &PLC_Data[3].HF_Channel[2].Level_InputSignal},{SNMP_UINT16, &PLC_Data[3].HF_Channel[2].Rate_Transmitter},{SNMP_UINT16, &PLC_Data[3].HF_Channel[2].Rate_Receiver},
|
---|
374 | {SNMP_UINT16, &PLC_Data[3].HF_Channel[2].QualityNoise_Receiver},{SNMP_UINT16,&PLC_Data[3].HF_Channel[2].SNR_Receiver},{SNMP_UINT8,&PLC_Data[3].HF_Channel[2].Kosh_sig},{SNMP_INT8,&PLC_Data[3].HF_Channel[2].Kosh_exp},{SNMP_UINT8,&PLC_Data[3].HF_Channel[2].Kosh_raw}}, // ch 3
|
---|
375 | {{SNMP_ENUM, &PLC_Data[3].PowerAmplifier[0].Presence},{SNMP_ENUM, &PLC_Data[3].PowerAmplifier[0].Alarm},{SNMP_UINT8, &PLC_Data[3].PowerAmplifier[0].Level_Transmitter},{SNMP_UINT8, &PLC_Data[3].PowerAmplifier[0].Temp},{SNMP_UINT8, &PLC_Data[3].PowerAmplifier[0].Voltage}}, // pwr amp 1
|
---|
376 | {{SNMP_ENUM, &PLC_Data[3].PowerAmplifier[1].Presence},{SNMP_ENUM, &PLC_Data[3].PowerAmplifier[1].Alarm},{SNMP_UINT8, &PLC_Data[3].PowerAmplifier[1].Level_Transmitter},{SNMP_UINT8, &PLC_Data[3].PowerAmplifier[1].Temp},{SNMP_UINT8, &PLC_Data[3].PowerAmplifier[1].Voltage}}} // pwr amp 2
|
---|
377 | };
|
---|
378 |
|
---|
379 | snmp_PLC_Data_typeDef *snmp_plc_current = &snmp_plc_data[0]; // pointer current work struct; default: near block
|
---|
380 |
|
---|
381 | /* PROTOTYPES FUNCTION PLC */
|
---|
382 | static s16_t PLC_get_root_value(struct snmp_node_instance* instance, void* value);
|
---|
383 | static s16_t PLC_get_ch1_value(struct snmp_node_instance* instance, void* value);
|
---|
384 | static s16_t PLC_get_ch2_value(struct snmp_node_instance* instance, void* value);
|
---|
385 | static s16_t PLC_get_ch3_value(struct snmp_node_instance* instance, void* value);
|
---|
386 | static s16_t PLC_get_PwrAmp1_value(struct snmp_node_instance* instance, void* value);
|
---|
387 | static s16_t PLC_get_PwrAmp2_value(struct snmp_node_instance* instance, void* value);
|
---|
388 |
|
---|
389 | /* SNMP MIB MC04-PLC */
|
---|
390 | static const struct snmp_scalar_node PLC_CommonStatus = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, PLC_get_root_value);
|
---|
391 | static const struct snmp_scalar_node PLC_SoftwareVersion = SNMP_SCALAR_CREATE_NODE_READONLY(2, SNMP_ASN1_TYPE_OCTET_STRING, PLC_get_root_value);
|
---|
392 | static const struct snmp_scalar_node PLC_Type_PRM = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_INTEGER, PLC_get_root_value);
|
---|
393 | static const struct snmp_scalar_node PLC_Power_PRD = SNMP_SCALAR_CREATE_NODE_READONLY(4, SNMP_ASN1_TYPE_INTEGER, PLC_get_root_value);
|
---|
394 | static const struct snmp_scalar_node PLC_ATT_PRM = SNMP_SCALAR_CREATE_NODE_READONLY(5, SNMP_ASN1_TYPE_INTEGER, PLC_get_root_value);
|
---|
395 |
|
---|
396 | /* 1.3.1-10 channel 1*/
|
---|
397 | static const struct snmp_scalar_node PLC_Ch1_En = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch1_value);
|
---|
398 | static const struct snmp_scalar_node PLC_Ch1_State_PRM = SNMP_SCALAR_CREATE_NODE_READONLY(2, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch1_value);
|
---|
399 | static const struct snmp_scalar_node PLC_Ch1_Mode = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch1_value);
|
---|
400 | static const struct snmp_scalar_node PLC_Ch1_F_PRD = SNMP_SCALAR_CREATE_NODE_READONLY(4, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch1_value);
|
---|
401 | static const struct snmp_scalar_node PLC_Ch1_F_PRM = SNMP_SCALAR_CREATE_NODE_READONLY(5, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch1_value);
|
---|
402 | static const struct snmp_scalar_node PLC_Ch1_L_PRM = SNMP_SCALAR_CREATE_NODE_READONLY(6, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch1_value);
|
---|
403 | static const struct snmp_scalar_node PLC_Ch1_L_IS = SNMP_SCALAR_CREATE_NODE_READONLY(7, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch1_value);
|
---|
404 | static const struct snmp_scalar_node PLC_Ch1_Rate_PRD = SNMP_SCALAR_CREATE_NODE_READONLY(8, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch1_value);
|
---|
405 | static const struct snmp_scalar_node PLC_Ch1_Rate_PRM = SNMP_SCALAR_CREATE_NODE_READONLY(9, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch1_value);
|
---|
406 | static const struct snmp_scalar_node PLC_Ch1_quality_noise = SNMP_SCALAR_CREATE_NODE_READONLY(10, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch1_value);
|
---|
407 | static const struct snmp_scalar_node PLC_Ch1_SNR = SNMP_SCALAR_CREATE_NODE_READONLY(11, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch1_value);
|
---|
408 | static const struct snmp_scalar_node PLC_Ch1_Kosh_sig = SNMP_SCALAR_CREATE_NODE_READONLY(12, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch1_value);
|
---|
409 | static const struct snmp_scalar_node PLC_Ch1_Kosh_exp = SNMP_SCALAR_CREATE_NODE_READONLY(13, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch1_value);
|
---|
410 | static const struct snmp_scalar_node PLC_Ch1_Kosh_raw = SNMP_SCALAR_CREATE_NODE_READONLY(14, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch1_value);
|
---|
411 |
|
---|
412 | static const struct snmp_node* const PLC_Ch1_nodes[] = {&PLC_Ch1_En.node.node, &PLC_Ch1_State_PRM.node.node, &PLC_Ch1_Mode.node.node, &PLC_Ch1_F_PRD.node.node,
|
---|
413 | &PLC_Ch1_F_PRM.node.node, &PLC_Ch1_L_PRM.node.node, &PLC_Ch1_L_IS.node.node,
|
---|
414 | &PLC_Ch1_Rate_PRD.node.node, &PLC_Ch1_Rate_PRM.node.node, &PLC_Ch1_quality_noise.node.node,
|
---|
415 | &PLC_Ch1_SNR.node.node, &PLC_Ch1_Kosh_sig.node.node, &PLC_Ch1_Kosh_exp.node.node, &PLC_Ch1_Kosh_raw.node.node};
|
---|
416 | static const struct snmp_tree_node PLC_Ch1_tree_node = SNMP_CREATE_TREE_NODE(6,PLC_Ch1_nodes);
|
---|
417 |
|
---|
418 | /* 1.4.1-10 channel 2*/
|
---|
419 | static const struct snmp_scalar_node PLC_Ch2_En = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch2_value);
|
---|
420 | static const struct snmp_scalar_node PLC_Ch2_State_PRM = SNMP_SCALAR_CREATE_NODE_READONLY(2, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch2_value);
|
---|
421 | static const struct snmp_scalar_node PLC_Ch2_Mode = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch2_value);
|
---|
422 | static const struct snmp_scalar_node PLC_Ch2_F_PRD = SNMP_SCALAR_CREATE_NODE_READONLY(4, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch2_value);
|
---|
423 | static const struct snmp_scalar_node PLC_Ch2_F_PRM = SNMP_SCALAR_CREATE_NODE_READONLY(5, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch2_value);
|
---|
424 | static const struct snmp_scalar_node PLC_Ch2_L_PRM = SNMP_SCALAR_CREATE_NODE_READONLY(6, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch2_value);
|
---|
425 | static const struct snmp_scalar_node PLC_Ch2_L_IS = SNMP_SCALAR_CREATE_NODE_READONLY(7, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch2_value);
|
---|
426 | static const struct snmp_scalar_node PLC_Ch2_Rate_PRD = SNMP_SCALAR_CREATE_NODE_READONLY(8, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch2_value);
|
---|
427 | static const struct snmp_scalar_node PLC_Ch2_Rate_PRM = SNMP_SCALAR_CREATE_NODE_READONLY(9, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch2_value);
|
---|
428 | static const struct snmp_scalar_node PLC_Ch2_quality_noise = SNMP_SCALAR_CREATE_NODE_READONLY(10, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch2_value);
|
---|
429 | static const struct snmp_scalar_node PLC_Ch2_SNR = SNMP_SCALAR_CREATE_NODE_READONLY(11, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch2_value);
|
---|
430 | static const struct snmp_scalar_node PLC_Ch2_Kosh_sig = SNMP_SCALAR_CREATE_NODE_READONLY(12, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch2_value);
|
---|
431 | static const struct snmp_scalar_node PLC_Ch2_Kosh_exp = SNMP_SCALAR_CREATE_NODE_READONLY(13, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch2_value);
|
---|
432 | static const struct snmp_scalar_node PLC_Ch2_Kosh_raw = SNMP_SCALAR_CREATE_NODE_READONLY(14, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch2_value);
|
---|
433 |
|
---|
434 | static const struct snmp_node* const PLC_Ch2_nodes[] = {&PLC_Ch2_En.node.node, &PLC_Ch2_State_PRM.node.node, &PLC_Ch2_Mode.node.node, &PLC_Ch2_F_PRD.node.node,
|
---|
435 | &PLC_Ch2_F_PRM.node.node, &PLC_Ch2_L_PRM.node.node, &PLC_Ch2_L_IS.node.node,
|
---|
436 | &PLC_Ch2_Rate_PRD.node.node, &PLC_Ch2_Rate_PRM.node.node, &PLC_Ch2_quality_noise.node.node,
|
---|
437 | &PLC_Ch2_SNR.node.node, &PLC_Ch2_Kosh_sig.node.node, &PLC_Ch2_Kosh_exp.node.node, &PLC_Ch2_Kosh_raw.node.node};
|
---|
438 | static const struct snmp_tree_node PLC_Ch2_tree_node = SNMP_CREATE_TREE_NODE(7,PLC_Ch2_nodes);
|
---|
439 |
|
---|
440 | /* 1.5.1-10 channel 3*/
|
---|
441 | static const struct snmp_scalar_node PLC_Ch3_En = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch3_value);
|
---|
442 | static const struct snmp_scalar_node PLC_Ch3_State_PRM = SNMP_SCALAR_CREATE_NODE_READONLY(2, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch3_value);
|
---|
443 | static const struct snmp_scalar_node PLC_Ch3_Mode = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch3_value);
|
---|
444 | static const struct snmp_scalar_node PLC_Ch3_F_PRD = SNMP_SCALAR_CREATE_NODE_READONLY(4, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch3_value);
|
---|
445 | static const struct snmp_scalar_node PLC_Ch3_F_PRM = SNMP_SCALAR_CREATE_NODE_READONLY(5, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch3_value);
|
---|
446 | static const struct snmp_scalar_node PLC_Ch3_L_PRM = SNMP_SCALAR_CREATE_NODE_READONLY(6, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch3_value);
|
---|
447 | static const struct snmp_scalar_node PLC_Ch3_L_IS = SNMP_SCALAR_CREATE_NODE_READONLY(7, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch3_value);
|
---|
448 | static const struct snmp_scalar_node PLC_Ch3_Rate_PRD = SNMP_SCALAR_CREATE_NODE_READONLY(8, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch3_value);
|
---|
449 | static const struct snmp_scalar_node PLC_Ch3_Rate_PRM = SNMP_SCALAR_CREATE_NODE_READONLY(9, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch3_value);
|
---|
450 | static const struct snmp_scalar_node PLC_Ch3_quality_noise = SNMP_SCALAR_CREATE_NODE_READONLY(10, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch3_value);
|
---|
451 | static const struct snmp_scalar_node PLC_Ch3_SNR = SNMP_SCALAR_CREATE_NODE_READONLY(11, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch3_value);
|
---|
452 | static const struct snmp_scalar_node PLC_Ch3_Kosh_sig = SNMP_SCALAR_CREATE_NODE_READONLY(12, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch3_value);
|
---|
453 | static const struct snmp_scalar_node PLC_Ch3_Kosh_exp = SNMP_SCALAR_CREATE_NODE_READONLY(13, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch3_value);
|
---|
454 | static const struct snmp_scalar_node PLC_Ch3_Kosh_raw = SNMP_SCALAR_CREATE_NODE_READONLY(14, SNMP_ASN1_TYPE_INTEGER, PLC_get_ch3_value);
|
---|
455 |
|
---|
456 |
|
---|
457 |
|
---|
458 |
|
---|
459 | static const struct snmp_node* const PLC_Ch3_nodes[] = {&PLC_Ch3_En.node.node, &PLC_Ch3_State_PRM.node.node, &PLC_Ch3_Mode.node.node, &PLC_Ch3_F_PRD.node.node,
|
---|
460 | &PLC_Ch3_F_PRM.node.node, &PLC_Ch3_L_PRM.node.node, &PLC_Ch3_L_IS.node.node,
|
---|
461 | &PLC_Ch3_Rate_PRD.node.node, &PLC_Ch3_Rate_PRM.node.node, &PLC_Ch3_quality_noise.node.node,
|
---|
462 | &PLC_Ch3_SNR.node.node, &PLC_Ch3_Kosh_sig.node.node, &PLC_Ch3_Kosh_exp.node.node, &PLC_Ch3_Kosh_raw.node.node};
|
---|
463 | static const struct snmp_tree_node PLC_Ch3_tree_node = SNMP_CREATE_TREE_NODE(8,PLC_Ch3_nodes);
|
---|
464 |
|
---|
465 | /* 1.6.1-2 power amplifier 1*/
|
---|
466 | static const struct snmp_scalar_node PLC_PwrAmp1_presence = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, PLC_get_PwrAmp1_value);
|
---|
467 | static const struct snmp_scalar_node PLC_PwrAmp1_Alarm = SNMP_SCALAR_CREATE_NODE_READONLY(2, SNMP_ASN1_TYPE_INTEGER, PLC_get_PwrAmp1_value);
|
---|
468 | static const struct snmp_scalar_node PLC_PwrAmp1_L_PRD = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_INTEGER, PLC_get_PwrAmp1_value);
|
---|
469 | static const struct snmp_scalar_node PLC_PwrAmp1_temp = SNMP_SCALAR_CREATE_NODE_READONLY(4, SNMP_ASN1_TYPE_INTEGER, PLC_get_PwrAmp1_value);
|
---|
470 | static const struct snmp_scalar_node PLC_PwrAmp1_line_voltage = SNMP_SCALAR_CREATE_NODE_READONLY(5, SNMP_ASN1_TYPE_INTEGER, PLC_get_PwrAmp1_value);
|
---|
471 |
|
---|
472 | static const struct snmp_node* const PLC_PwrAmp1_nodes[] = {&PLC_PwrAmp1_presence.node.node, &PLC_PwrAmp1_Alarm.node.node, &PLC_PwrAmp1_L_PRD.node.node, &PLC_PwrAmp1_temp.node.node, &PLC_PwrAmp1_line_voltage.node.node};
|
---|
473 | static const struct snmp_tree_node PLC_PwrAmp1_tree_node = SNMP_CREATE_TREE_NODE(9,PLC_PwrAmp1_nodes);
|
---|
474 |
|
---|
475 | /* 1.7.1-2 power amplifier 2*/
|
---|
476 | static const struct snmp_scalar_node PLC_PwrAmp2_presence = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_INTEGER, PLC_get_PwrAmp2_value);
|
---|
477 | static const struct snmp_scalar_node PLC_PwrAmp2_Alarm = SNMP_SCALAR_CREATE_NODE_READONLY(2, SNMP_ASN1_TYPE_INTEGER, PLC_get_PwrAmp2_value);
|
---|
478 | static const struct snmp_scalar_node PLC_PwrAmp2_L_PRD = SNMP_SCALAR_CREATE_NODE_READONLY(3, SNMP_ASN1_TYPE_INTEGER, PLC_get_PwrAmp2_value);
|
---|
479 | static const struct snmp_scalar_node PLC_PwrAmp2_temp = SNMP_SCALAR_CREATE_NODE_READONLY(4, SNMP_ASN1_TYPE_INTEGER, PLC_get_PwrAmp2_value);
|
---|
480 | static const struct snmp_scalar_node PLC_PwrAmp2_line_voltage = SNMP_SCALAR_CREATE_NODE_READONLY(5, SNMP_ASN1_TYPE_INTEGER, PLC_get_PwrAmp2_value);
|
---|
481 |
|
---|
482 | static const struct snmp_node* const PLC_PwrAmp2_nodes[] = {&PLC_PwrAmp2_presence.node.node, &PLC_PwrAmp2_Alarm.node.node, &PLC_PwrAmp2_L_PRD.node.node, &PLC_PwrAmp2_temp.node.node, &PLC_PwrAmp2_line_voltage.node.node};
|
---|
483 | static const struct snmp_tree_node PLC_PwrAmp2_tree_node = SNMP_CREATE_TREE_NODE(10,PLC_PwrAmp2_nodes);
|
---|
484 |
|
---|
485 | static const struct snmp_node* const PLC_mibs_nodes[] = {&PLC_CommonStatus.node.node, &PLC_SoftwareVersion.node.node, &PLC_Type_PRM.node.node, &PLC_Power_PRD.node.node,
|
---|
486 | &PLC_ATT_PRM.node.node, &PLC_Ch1_tree_node.node, &PLC_Ch2_tree_node.node,
|
---|
487 | &PLC_Ch3_tree_node.node, &PLC_PwrAmp1_tree_node.node, &PLC_PwrAmp2_tree_node.node};
|
---|
488 |
|
---|
489 | static const struct snmp_tree_node PLC_mibs_tree_node = SNMP_CREATE_TREE_NODE(1, PLC_mibs_nodes);
|
---|
490 | static const struct snmp_mib PLC_snmp_mibs = SNMP_MIB_CREATE(PLC_baseOID, &PLC_mibs_tree_node.node);
|
---|
491 |
|
---|
492 | /* FUNCTION PLC */
|
---|
493 | /* 1.1-5 root*/
|
---|
494 | static s16_t PLC_get_root_value(struct snmp_node_instance* instance, void* value)
|
---|
495 | {
|
---|
496 | u32_t len;
|
---|
497 |
|
---|
498 | if(snmp_plc_current->dRoot[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
499 | *(u32_t*)value = (u32_t)*(u8_t*)snmp_plc_current->dRoot[instance->node->oid - 1].value;
|
---|
500 | len = sizeof((u32_t*)value);
|
---|
501 | }
|
---|
502 | else if(snmp_plc_current->dRoot[instance->node->oid - 1].type == SNMP_STRING){
|
---|
503 | memcpy(value, (char*)snmp_plc_current->dRoot[instance->node->oid - 1].value, strlen((char*)snmp_plc_current->dRoot[instance->node->oid - 1].value));
|
---|
504 | len = strlen((char*)value);
|
---|
505 | }
|
---|
506 | else if(snmp_plc_current->dRoot[instance->node->oid - 1].type == SNMP_UINT8){
|
---|
507 | *(u32_t*)value = (u32_t)*(u8_t*)snmp_plc_current->dRoot[instance->node->oid - 1].value;
|
---|
508 | len = sizeof((u32_t*)value);
|
---|
509 | }
|
---|
510 |
|
---|
511 | return len;
|
---|
512 | }
|
---|
513 |
|
---|
514 | /* 1.6.1-14 channel 1*/
|
---|
515 | static s16_t PLC_get_ch1_value(struct snmp_node_instance* instance, void* value)
|
---|
516 | {
|
---|
517 | u32_t len;
|
---|
518 |
|
---|
519 | if(snmp_plc_current->dCh1[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
520 | *(u32_t*)value = (u32_t)*(u8_t*)snmp_plc_current->dCh1[instance->node->oid - 1].value;
|
---|
521 | len = sizeof((u32_t*)value);
|
---|
522 | }
|
---|
523 | else if(snmp_plc_current->dCh1[instance->node->oid - 1].type == SNMP_UINT16){
|
---|
524 | *(u32_t*)value = (u32_t)*(u16_t*)snmp_plc_current->dCh1[instance->node->oid - 1].value;
|
---|
525 | len = sizeof((u32_t*)value);
|
---|
526 | }
|
---|
527 | else if(snmp_plc_current->dCh1[instance->node->oid - 1].type == SNMP_INT16){
|
---|
528 | *(s32_t*)value = (s32_t)*(s16_t*)snmp_plc_current->dCh1[instance->node->oid - 1].value;
|
---|
529 | len = sizeof((s32_t*)value);
|
---|
530 | }
|
---|
531 | else if(snmp_plc_current->dCh1[instance->node->oid - 1].type == SNMP_UINT8){
|
---|
532 | *(u32_t*)value = (u32_t)*(u8_t*)snmp_plc_current->dCh1[instance->node->oid - 1].value;
|
---|
533 | len = sizeof((u32_t*)value);
|
---|
534 | }
|
---|
535 | else if(snmp_plc_current->dCh1[instance->node->oid - 1].type == SNMP_INT8){
|
---|
536 | *(s32_t*)value = (s32_t)*(s8_t*)snmp_plc_current->dCh1[instance->node->oid - 1].value;
|
---|
537 | len = sizeof((s32_t*)value);
|
---|
538 | }
|
---|
539 |
|
---|
540 | return len;
|
---|
541 | }
|
---|
542 |
|
---|
543 | /* 1.7.1-14 channel 2*/
|
---|
544 | static s16_t PLC_get_ch2_value(struct snmp_node_instance* instance, void* value)
|
---|
545 | {
|
---|
546 | u32_t len;
|
---|
547 |
|
---|
548 | if(snmp_plc_current->dCh2[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
549 | *(u32_t*)value = (u32_t)*(u8_t*)snmp_plc_current->dCh2[instance->node->oid - 1].value;
|
---|
550 | len = sizeof((u32_t*)value);
|
---|
551 | }
|
---|
552 | else if(snmp_plc_current->dCh2[instance->node->oid - 1].type == SNMP_UINT16){
|
---|
553 | *(u32_t*)value = (u32_t)*(u16_t*)snmp_plc_current->dCh2[instance->node->oid - 1].value;
|
---|
554 | len = sizeof((u32_t*)value);
|
---|
555 | }
|
---|
556 | else if(snmp_plc_current->dCh2[instance->node->oid - 1].type == SNMP_INT16){
|
---|
557 | *(s32_t*)value = (s32_t)*(s16_t*)snmp_plc_current->dCh2[instance->node->oid - 1].value;
|
---|
558 | len = sizeof((s32_t*)value);
|
---|
559 | }
|
---|
560 | else if(snmp_plc_current->dCh2[instance->node->oid - 1].type == SNMP_UINT8){
|
---|
561 | *(u32_t*)value = (u32_t)*(u8_t*)snmp_plc_current->dCh2[instance->node->oid - 1].value;
|
---|
562 | len = sizeof((u32_t*)value);
|
---|
563 | }
|
---|
564 | else if(snmp_plc_current->dCh2[instance->node->oid - 1].type == SNMP_INT8){
|
---|
565 | *(s32_t*)value = (s32_t)*(s8_t*)snmp_plc_current->dCh2[instance->node->oid - 1].value;
|
---|
566 | len = sizeof((s32_t*)value);
|
---|
567 | }
|
---|
568 | return len;
|
---|
569 | }
|
---|
570 |
|
---|
571 | /* 1.8.1-14 channel 3*/
|
---|
572 | static s16_t PLC_get_ch3_value(struct snmp_node_instance* instance, void* value)
|
---|
573 | {
|
---|
574 | u32_t len;
|
---|
575 |
|
---|
576 | if(snmp_plc_current->dCh3[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
577 | *(u32_t*)value = (u32_t)*(u8_t*)snmp_plc_current->dCh3[instance->node->oid - 1].value;
|
---|
578 | len = sizeof((u32_t*)value);
|
---|
579 | }
|
---|
580 | else if(snmp_plc_current->dCh3[instance->node->oid - 1].type == SNMP_UINT16){
|
---|
581 | *(u32_t*)value = (u32_t)*(u16_t*)snmp_plc_current->dCh3[instance->node->oid - 1].value;
|
---|
582 | len = sizeof((u32_t*)value);
|
---|
583 | }
|
---|
584 | else if(snmp_plc_current->dCh3[instance->node->oid - 1].type == SNMP_INT16){
|
---|
585 | *(s32_t*)value = (s32_t)*(s16_t*)snmp_plc_current->dCh3[instance->node->oid - 1].value;
|
---|
586 | len = sizeof((s32_t*)value);
|
---|
587 | }
|
---|
588 | else if(snmp_plc_current->dCh3[instance->node->oid - 1].type == SNMP_UINT8){
|
---|
589 | *(u32_t*)value = (u32_t)*(u8_t*)snmp_plc_current->dCh3[instance->node->oid - 1].value;
|
---|
590 | len = sizeof((u32_t*)value);
|
---|
591 | }
|
---|
592 | else if(snmp_plc_current->dCh3[instance->node->oid - 1].type == SNMP_INT8){
|
---|
593 | *(s32_t*)value = (s32_t)*(s8_t*)snmp_plc_current->dCh3[instance->node->oid - 1].value;
|
---|
594 | len = sizeof((s32_t*)value);
|
---|
595 | }
|
---|
596 | return len;
|
---|
597 | }
|
---|
598 |
|
---|
599 | /* 1.9.1-5 power amplifier 1*/
|
---|
600 | static s16_t PLC_get_PwrAmp1_value(struct snmp_node_instance* instance, void* value)
|
---|
601 | {
|
---|
602 | u32_t len;
|
---|
603 |
|
---|
604 | if(snmp_plc_current->dPwrAmp1[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
605 | *(u32_t*)value = (u32_t)*(u8_t*)snmp_plc_current->dPwrAmp1[instance->node->oid - 1].value;
|
---|
606 | len = sizeof((u32_t*)value);
|
---|
607 | }
|
---|
608 | else if(snmp_plc_current->dPwrAmp1[instance->node->oid - 1].type == SNMP_UINT8){
|
---|
609 | *(u32_t*)value = (u32_t)*(u8_t*)snmp_plc_current->dPwrAmp1[instance->node->oid - 1].value;
|
---|
610 | len = sizeof((u32_t*)value);
|
---|
611 | }
|
---|
612 |
|
---|
613 | return len;
|
---|
614 | }
|
---|
615 |
|
---|
616 | /* 1.10.1-5 power amplifier 2*/
|
---|
617 | static s16_t PLC_get_PwrAmp2_value(struct snmp_node_instance* instance, void* value)
|
---|
618 | {
|
---|
619 | u32_t len;
|
---|
620 |
|
---|
621 | if(snmp_plc_current->dPwrAmp2[instance->node->oid - 1].type == SNMP_ENUM){
|
---|
622 | *(u32_t*)value = (u32_t)*(u8_t*)snmp_plc_current->dPwrAmp2[instance->node->oid - 1].value;
|
---|
623 | len = sizeof((u32_t*)value);
|
---|
624 | }
|
---|
625 | else if(snmp_plc_current->dPwrAmp2[instance->node->oid - 1].type == SNMP_UINT8){
|
---|
626 | *(u32_t*)value = (u32_t)*(u8_t*)snmp_plc_current->dPwrAmp2[instance->node->oid - 1].value;
|
---|
627 | len = sizeof((u32_t*)value);
|
---|
628 | }
|
---|
629 |
|
---|
630 | return len;
|
---|
631 | }
|
---|
632 | /*END SNMP MIB MC04-PLC -----------------------------------------------------------------------------------*/
|
---|
633 | /*----------------------------------------------------------------------------------------------------------*/
|
---|
634 | /*##########################################################################################################*/
|
---|
635 | /* GENERAL FUNCTION ----------------------------------------------------------------------------------------*/
|
---|
636 | extern plc_common_typeDef plc_common;
|
---|
637 |
|
---|
638 | uint8_t snmp_route_PLC(const ip4_addr_t *ipaddr) // != my ip addr
|
---|
639 | {
|
---|
640 | if(CurrSNMP_Device != PLC) return 0;
|
---|
641 |
|
---|
642 | snmp_PLC_Data_typeDef *snmp_plc_match;
|
---|
643 | ip4_addr_t ip;
|
---|
644 |
|
---|
645 | for(uint8_t i = 0; i < plc_common.num; i++){
|
---|
646 | snmp_plc_match =&snmp_plc_data[i];
|
---|
647 |
|
---|
648 | if(*snmp_plc_match->ipv4_addr != NULL){
|
---|
649 | ip4addr_aton(snmp_plc_match->ipv4_addr, &ip);
|
---|
650 | if(ip4_addr_cmp(ipaddr, &ip)){
|
---|
651 | snmp_plc_current = snmp_plc_match;
|
---|
652 | return 1;
|
---|
653 | }
|
---|
654 | }
|
---|
655 | }
|
---|
656 | return 0;
|
---|
657 | }
|
---|
658 |
|
---|
659 | struct snmp_obj_id OID_send = {0};
|
---|
660 | struct snmp_varbind vb_1, vb_2, vb_3;
|
---|
661 | u32_t sysuptime;
|
---|
662 |
|
---|
663 | void snmp_trap_send(uint32_t OID, uint32_t value)
|
---|
664 | {
|
---|
665 | if(!snmp_get_traps_enable(0)) return;
|
---|
666 |
|
---|
667 | static uint32_t data;
|
---|
668 | uint8_t OID_len = 0;
|
---|
669 | data = value;
|
---|
670 |
|
---|
671 | switch(CurrSNMP_Device){
|
---|
672 | case PLC:
|
---|
673 | OID_len = sizeof(PLC_baseOID);
|
---|
674 | memcpy(OID_send.id, PLC_baseOID, OID_len);
|
---|
675 | OID_send.len = OID_len / sizeof(u32_t);
|
---|
676 | break;
|
---|
677 | case UPS:
|
---|
678 | OID_len = sizeof(UPS_baseOID);
|
---|
679 | memcpy(OID_send.id, UPS_baseOID, OID_len);
|
---|
680 | OID_send.len = OID_len / sizeof(u32_t);
|
---|
681 | break;
|
---|
682 | }
|
---|
683 |
|
---|
684 | OID_send.id[OID_send.len++] = OID;
|
---|
685 |
|
---|
686 | if(snmp_v1_enabled()){
|
---|
687 | vb_1.prev = NULL;
|
---|
688 | vb_1.type = SNMP_ASN1_TYPE_OBJECT_ID;
|
---|
689 | vb_1.value = (void*)OID_send.id;
|
---|
690 | vb_1.value_len = OID_send.len * sizeof(u32_t);
|
---|
691 | memcpy(vb_1.oid.id, trapoid.id, trapoid.len * sizeof(u32_t));
|
---|
692 | vb_1.oid.len = trapoid.len;
|
---|
693 | vb_1.next =& vb_2;
|
---|
694 |
|
---|
695 | vb_2.prev =& vb_1;
|
---|
696 | vb_2.type = SNMP_ASN1_TYPE_INTEGER;
|
---|
697 | vb_2.value = &data;
|
---|
698 | vb_2.value_len = sizeof(u32_t);
|
---|
699 | memcpy(vb_2.oid.id, OID_send.id, OID_send.len * sizeof(u32_t));
|
---|
700 | vb_2.oid.len = OID_send.len;
|
---|
701 | vb_2.next = NULL;
|
---|
702 | }
|
---|
703 | else{
|
---|
704 | sysuptime = sys_now() / 10;
|
---|
705 |
|
---|
706 | vb_1.prev = NULL;
|
---|
707 | vb_1.type = SNMP_ASN1_TYPE_TIMETICKS;
|
---|
708 | vb_1.value = &sysuptime;
|
---|
709 | vb_1.value_len = sizeof(u32_t);
|
---|
710 | memcpy(vb_1.oid.id, sysupid.id, sysupid.len * sizeof(u32_t));
|
---|
711 | vb_1.oid.len = sysupid.len;
|
---|
712 |
|
---|
713 | vb_2.prev =& vb_1;
|
---|
714 | vb_2.type = SNMP_ASN1_TYPE_OBJECT_ID;
|
---|
715 | vb_2.value = (void*)OID_send.id;
|
---|
716 | vb_2.value_len = OID_send.len * sizeof(u32_t);
|
---|
717 | memcpy(vb_2.oid.id, trapoid.id, trapoid.len * sizeof(u32_t));
|
---|
718 | vb_2.oid.len = trapoid.len;
|
---|
719 | vb_1.next =& vb_2;
|
---|
720 |
|
---|
721 | vb_3.prev =& vb_2;
|
---|
722 | vb_3.type = SNMP_ASN1_TYPE_INTEGER;
|
---|
723 | vb_3.value = &data;
|
---|
724 | vb_3.value_len = sizeof(u32_t);
|
---|
725 | memcpy(vb_3.oid.id, OID_send.id, OID_send.len * sizeof(u32_t));
|
---|
726 | vb_3.oid.len = OID_send.len;
|
---|
727 |
|
---|
728 | vb_2.next =& vb_3;
|
---|
729 | vb_3.next = NULL;
|
---|
730 | }
|
---|
731 | snmp_send_trap(&sysupid, SNMP_GENTRAP_ENTERPRISE_SPECIFIC, 0, &vb_1);
|
---|
732 |
|
---|
733 | vb_1.oid.len = 0;
|
---|
734 | vb_2.oid.len = 0;
|
---|
735 | vb_3.oid.len = 0;
|
---|
736 | OID_send.len = 0;
|
---|
737 | }
|
---|
738 |
|
---|
739 |
|
---|
740 | #include "xml.h"
|
---|
741 |
|
---|
742 | void SnmpPrepare(OID_DeviceTypeDef dev)
|
---|
743 | {
|
---|
744 | char trap_ip[16] = {0};
|
---|
745 | char trap_en = NULL;
|
---|
746 | uint8_t en_trap = 0;
|
---|
747 | ip_addr_t ip;
|
---|
748 | CurrSNMP_Device = (OID_DeviceTypeDef)dev;
|
---|
749 |
|
---|
750 | struct snmp_obj_id SnmpObjId = {8, {1, 3, 6, 1, 4, 1, 32109, CurrSNMP_Device}}; //enterprise oid + device oid
|
---|
751 |
|
---|
752 | if(xml_get_tag("config.xml", "snmp", NULL, "community", community) != XML_OK) memcpy(community, "public", 6);
|
---|
753 | if(xml_get_tag("config.xml", "snmp", NULL, "trap-enable", &trap_en) != XML_OK) en_trap = DISABLE;
|
---|
754 | else en_trap = atoi(&trap_en);
|
---|
755 | if(xml_get_tag("config.xml", "snmp", NULL, "trap-community", trap_community) != XML_OK) memcpy(trap_community, "public", 6);
|
---|
756 | if(xml_get_tag("config.xml", "snmp", NULL, "trap-hostname", trap_ip) != XML_OK) memcpy(trap_ip, "192.168.0.254", 6);
|
---|
757 |
|
---|
758 | snmp_v1_enable(DISABLE);
|
---|
759 | snmp_v2c_enable(ENABLE);
|
---|
760 | //snmp_v3_enable(DISABLE);
|
---|
761 |
|
---|
762 | snmp_set_community(community);
|
---|
763 | snmp_mib2_set_syscontact(snmp_sysContact, &snmp_sysContact_len, snmp_buffer);
|
---|
764 | snmp_mib2_set_syslocation(snmp_sysLocation, &snmp_sysLocation_len, snmp_buffer);
|
---|
765 | snmp_mib2_set_sysdescr(snmp_sysDescr, &snmp_sysDescr_len);
|
---|
766 | snmp_set_device_enterprise_oid(&SnmpObjId);
|
---|
767 |
|
---|
768 | switch(dev) {
|
---|
769 | case UPS:
|
---|
770 | memcpy(snmp_sysName, "UPS 1200", 8);
|
---|
771 | snmp_sysName_len = 8;
|
---|
772 | break;
|
---|
773 | case PLC:
|
---|
774 | memcpy(snmp_sysName, "MC04-PLC", 8);
|
---|
775 | snmp_sysName_len = 8;
|
---|
776 | break;
|
---|
777 | }
|
---|
778 | snmp_mib2_set_sysname(snmp_sysName, &snmp_sysName_len, snmp_buffer);
|
---|
779 |
|
---|
780 |
|
---|
781 | if(dev == UPS){
|
---|
782 | static const struct snmp_mib *UPS_my_snmp_mibs[] = {
|
---|
783 | &mib2,
|
---|
784 | &UPS_snmp_mibs,
|
---|
785 | };
|
---|
786 | snmp_set_mibs(UPS_my_snmp_mibs, LWIP_ARRAYSIZE(UPS_my_snmp_mibs));
|
---|
787 | }
|
---|
788 | else if(dev == PLC){
|
---|
789 | static const struct snmp_mib *PLC_my_snmp_mibs[] = {
|
---|
790 | &mib2,
|
---|
791 | &PLC_snmp_mibs,
|
---|
792 | };
|
---|
793 | snmp_set_mibs(PLC_my_snmp_mibs, LWIP_ARRAYSIZE(PLC_my_snmp_mibs));
|
---|
794 | }
|
---|
795 |
|
---|
796 | snmp_set_community_trap(trap_community);
|
---|
797 | if(en_trap == ENABLE){
|
---|
798 | ip4addr_aton(trap_ip, &ip);
|
---|
799 | snmp_trap_dst_ip_set(0, &ip);
|
---|
800 | snmp_trap_dst_enable(0, ENABLE);
|
---|
801 | }
|
---|
802 |
|
---|
803 | snmp_init();
|
---|
804 | }
|
---|
805 |
|
---|