SnmpKit.SnmpSim.Device.ErrorConditions (snmpkit v2.0.1)

Error injection functionality for SNMP device simulation. Handles various error conditions like timeouts, packet loss, SNMP errors, and malformed responses.

Summary

Functions

Check if any error conditions should be applied to the PDU. Returns appropriate error response or :continue to proceed normally.

Check if malformed response conditions should be applied.

Check if packet loss conditions should be applied.

Check if SNMP error conditions should be applied.

Check if timeout conditions should be applied.

Create a malformed response based on the error configuration.

Check if device failure condition is active.

Check if PDU OIDs match target OIDs for error injection.

Determine if error should be applied based on probability.

Functions

check_error_conditions(pdu, state)

Check if any error conditions should be applied to the PDU. Returns appropriate error response or :continue to proceed normally.

check_malformed_conditions(pdu, state)

Check if malformed response conditions should be applied.

check_packet_loss_conditions(pdu, state)

Check if packet loss conditions should be applied.

check_snmp_error_conditions(pdu, state)

Check if SNMP error conditions should be applied.

check_timeout_conditions(pdu, state)

Check if timeout conditions should be applied.

create_malformed_response(pdu, config)

Create a malformed response based on the error configuration.

device_failure_active?(state)

Check if device failure condition is active.

oid_matches_target?(pdu, target_oids)

Check if PDU OIDs match target OIDs for error injection.

should_apply_error?(probability)

Determine if error should be applied based on probability.

Draws from the calling process's :rand state. This runs inside the SnmpKit.SnmpSim.Device process, which seeds that state from its :seed option, so a seeded device replays the same decisions for the same request sequence.