Objects of message class

Please, note that the names and functionality of the methods described in this section, often mimic corresponding parts of the SNMP protocol specification and the layout of SNMP message.

Instances of message class have the following methods:

encode_bindings(encoded_oids, encoded_vals)
decode_bindings(bindings)

The encode_bindings method takes the lists of BER encoded Object IDs encoded_oids and their associated values encoded_vals, binds them altogether with BER and returns the resulted binding as a string.

The decode_bindings method takes Object IDs & values bindings (as produced by the encode_bindings method), unbinds them with BER decoder and returns a tuple of the lists of BER encoded Object IDs encoded_oids and their associated values encoded_vals.

Object IDs and their respective values are matched agaist each other by their positions in the encoded_oids and encoded_vals lists.

encode_snmp_pdu(type, bindings)
decode_snmp_pdu(pdu)

The encode_snmp_pdu method takes the Object IDs and values bindings (as produced by encode_bindings method), adds some transient information with BER encoder and returns a SNMP Protocol Data Unit (PDU) of specified SNMP request type as a string.

The following type argument values are recognized:

The decode_snmp_pdu method takes the SNMP PDU (as produced by encode_snmp_pdu method), applies BER decoder to it, and returns a tuple of the following layout (type, request_id, error_status, error_index, bindings). Please, refer to SNMP protocol specification for more information on the components of this tuple.

encode_request_sequence(pdu)
decode_response_sequence(message)

The encode_request_sequence method takes the SNMP PDU (as produced by encode_snmp_pdu method), adds some transient information with BER encoder and returns complete SNMP request as a string.

The decode_response_sequence method takes complete SNMP request (as produced by encode_request_sequence method), applies BER decoder to it, and returns a tuple of the following layout (version, community, pdu). Please, refer to SNMP protocol specification for more information on the components of this tuple.

encode_request(type, encoded_oids, encoded_vals)
decode_response(message[, type])

The encode_request method takes the lists of BER encoded Object IDs encoded_oids and their associated values encoded_vals and builds complete SNMP message of specified type by applying encode_bindings, encode_snmp_pdu and encode_request_sequence methods to the input data.

The encode_request method returns complete SNMP message as a string.

The decode_response method takes complete SNMP request (as produced by encode_request method) parses out and returns a tuple of the lists of BER encoded Object IDs encoded_oids and their associated values encoded_vals by applying the decode_request_sequence, decode_snmp_pdu and decode_bindings methods to the input data.

Returned Object IDs and their respective values are matched against each other by their positions in the encoded_oids and encoded_vals lists.

The type argument may be used for verifying that the type of SNMP response matches type, or BadPDUType exception will be flagged.

The default value for type argument is 'GETRESPONSE'.

encode_snmp_trap_pdu(enterprise, address, generic, specific, timeticks, bindings)
decode_snmp_trap_pdu(pdu)

The encode_snmp_trap_pdu method takes the enterpise Object-ID (given as a list of integer sub-IDs), agent IP address (string), generic trap type (integer), specific trap type (integer), timeticks (integer) and variable bindings (as produced by encode_bindings method) and returns SNMP trap PDU (as string).

The decode_snmp_trap_pdu method takes the SNMP PDU (as produced by encode_snmp_trap_pdu method), applies BER decoder to it, and returns a tuple of the following layout (enterprise, address, generic, specific, timeticks, bindings). Please, consult the encode_snmp_trap_pdu method description for more descriptive names of these tuple components.

Please, refer to SNMP protocol specification for more information on the components of the SNMP trap PDU.

encode_trap(enterprise, address, generic, specific, timeticks, [encoded_oids[, encoded_vals]])
decode_trap(message)

The encode_trap method takes the lists of enterpise Object-ID (given as a list of integer sub-IDs), agent IP address (string), generic trap type (integer), specific trap type (integer), timeticks (integer) and BER encoded Object IDs encoded_oids along with their associated values encoded_vals and builds complete SNMP trap message by applying encode_bindings, encode_snmp_trap_pdu and encode_request_sequence methods to the input data.

The encode_trap method returns complete SNMP trap message as a string.

The decode_trap method takes complete SNMP trap message (as produced by encode_trap method) parses out and returns a tuple of the following layout (enterprise, address, generic, specific, timeticks, encoded_oids, encoded_vals) by applying the decode_request_sequence, decode_snmp_trap_pdu and decode_bindings methods to the input data.

Please, consult the encode_trap method description for more information on these tuple components.

Returned Object IDs and their respective values are matched against each other by their positions in the encoded_oids and encoded_vals lists.

Objects of message class have no public instance variables.


ilya@glas.net