puresnmp_plugins.mpm.v2c module

This module contains the definition for the community-based message-processing model for SNMPv2

class puresnmp_plugins.mpm.v2c.V2CEncodingResult(data: bytes, security_model: SecurityModel[Any, Any] | None = None)

Bases: AbstractEncodingResult

security_model: SecurityModel[PDU, Sequence] | None = None

The security model that was applied by the message-processing module

class puresnmp_plugins.mpm.v2c.V2CMPM(transport_handler: Callable[[bytes], Awaitable[bytes]], lcd: Dict[str, Any])

Bases: MessageProcessingModel[V2CEncodingResult, SecurityModel[PDU, Sequence]]

Message Processing Model for SNMP v2c

decode(whole_msg: bytes, credentials: Credentials) PDU

Convert an SNMPv2c message into a PDU instance

async encode(request_id: int, credentials: Credentials, engine_id: bytes, context_name: bytes, pdu: PDU) V2CEncodingResult

Convert an SNMP PDU into raw bytes for the network.

Parameters:
  • request_id – A unique ID for the request.

  • credentials – Credentials which are used by the model if needed (encryption, authentication, …).

  • engine_id – The engine-id for use in SNMPv3. puresnmp.util contains helper methods to create those according to the RFC.

  • context_name – An identifier for the SNMPv3 context

  • pdu – The plain SNMP PDU to process

Returns:

Raw bytes that can be sent to the network

puresnmp_plugins.mpm.v2c.create(transport_handler: Callable[[bytes], Awaitable[bytes]], lcd: Dict[str, Any]) MessageProcessingModel[V2CEncodingResult, Any]

Creates a new instance of the V2C message-processing-model