aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2022-05-02 10:51:08 +0200
committerLuca Deri <deri@ntop.org>2022-05-02 10:51:08 +0200
commitc8f72ef76471cf038bb55ef48179c4795ff638fa (patch)
treea1b404ee71e6e9d9369f198ab02116bce4ae4b40 /src/lib/protocols
parent02d0b5fe13a49ca06179f089e2bf82dedd3043f0 (diff)
Added ndpi_get_flow_error_code() API call
Fixed typo
Diffstat (limited to 'src/lib/protocols')
-rw-r--r--src/lib/protocols/snmp_proto.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/lib/protocols/snmp_proto.c b/src/lib/protocols/snmp_proto.c
index c4c2b95b9..07d5ce35f 100644
--- a/src/lib/protocols/snmp_proto.c
+++ b/src/lib/protocols/snmp_proto.c
@@ -97,11 +97,13 @@ void ndpi_search_snmp(struct ndpi_detection_module_struct *ndpi_struct,
len = get_int(&packet->payload[1], packet->payload_packet_len - 1, &len_length);
+ flow->protos.snmp.version = packet->payload[1 + len_length + 2];
+
if(len > 2 &&
1 + len_length + len == packet->payload_packet_len &&
- (packet->payload[1 + len_length + 2] == 0 /* SNMPv1 */ ||
- packet->payload[1 + len_length + 2] == 1 /* SNMPv2c */ ||
- packet->payload[1 + len_length + 2] == 3 /* SNMPv3 */)) {
+ ((flow->protos.snmp.version == 0 /* SNMPv1 */) ||
+ (flow->protos.snmp.version == 1 /* SNMPv2c */) ||
+ (flow->protos.snmp.version == 3 /* SNMPv3 */))) {
if(flow->extra_packets_func == NULL) {
ndpi_int_snmp_add_connection(ndpi_struct, flow);
@@ -125,6 +127,8 @@ void ndpi_search_snmp(struct ndpi_detection_module_struct *ndpi_struct,
if(snmp_primitive_offset < packet->payload_packet_len) {
u_int8_t snmp_primitive = packet->payload[snmp_primitive_offset] & 0xF;
+ flow->protos.snmp.primitive = snmp_primitive;
+
if(snmp_primitive == 2 /* Get Response */ &&
snmp_primitive_offset + 1 < packet->payload_packet_len) {
offset = snmp_primitive_offset + 1;
@@ -145,6 +149,8 @@ void ndpi_search_snmp(struct ndpi_detection_module_struct *ndpi_struct,
flow->extra_packets_func = NULL; /* We're good now */
+ flow->protos.snmp.error_status = error_status;
+
if(error_status != 0)
ndpi_set_risk(ndpi_struct, flow, NDPI_ERROR_CODE_DETECTED);
}
@@ -152,6 +158,7 @@ void ndpi_search_snmp(struct ndpi_detection_module_struct *ndpi_struct,
}
}
}
+
return;
}
}