noc.core.snmp.ber

Module Contents

class noc.core.snmp.ber.BERDecoder

Bases: object

INT_MASK
DECODERS
static split_tlv(msg)
parse_tlv(self, msg)
parse_eoc(self, msg)
parse_boolean(self, msg)
parse_int(self, msg)
>>> BERDecoder().parse_int('')
0
>>> BERDecoder().parse_int('\x00')
0
>>> BERDecoder().parse_int('\x01')
1
>>> BERDecoder().parse_int('\x7f')
127
>>> BERDecoder().parse_int('\x00\x80')
128
>>> BERDecoder().parse_int('\x01\x00')
256
>>> BERDecoder().parse_int('\x80')
-128
>>> BERDecoder().parse_int('\xff\x7f')
-129
Parameters:msg
Returns:integer
parse_real(self, msg)
parse_p_bitstring(self, msg)
parse_p_octetstring(self, msg)
parse_p_t61_string(self, msg)
parse_c_octetstring(self, msg)
parse_c_t61_string(self, msg)
parse_null(self, msg)
parse_a_ipaddress(self, msg)
parse_p_oid(self, msg)
>>> BERDecoder().parse_p_oid("+\x06\x01\x02\x01\x01\x05\x00")
"1.3.6.1.2.1.1.5.0"
parse_compressed_oid(self, msg)
Parameters:msg
Returns:
parse_sequence(self, msg)
parse_implicit(self, msg, tag)
parse_set(self, msg)
parse_opaque(self, msg)
parse_utctime(self, msg)
parse_float(self, msg)

ANSI/IEEE Std 754-1985 binary floating point :param msg: :return:

parse_double(self, msg)

ANSI/IEEE Std 754-1985 binary floating point :param msg: :return:

class noc.core.snmp.ber.BEREncoder

Bases: object

INF
NINF
NAN
MZERO
struct_Q
encode_tlv(self, tag, primitive, data)
encode_octet_string(self, data)
>>> BEREncoder().encode_octet_string("test")
'\x04\x04test'
>>> BEREncoder().encode_octet_string("public")
'\x04\x06public'
>>> BEREncoder().encode_octet_string("")
'\x04\x00'
Parameters:data
Returns:
encode_sequence(self, data)
encode_choice(self, tag, data)
encode_int(self, data)
>>> BEREncoder().encode_int(0)
'\x02\x01\x00'
>>> BEREncoder().encode_int(1)
'\x02\x01\x01'
>>> BEREncoder().encode_int(127)
'\x02\x01\x7f'
>>> BEREncoder().encode_int(128)
'\x02\x02\x00\x80'
>>> BEREncoder().encode_int(256)
'\x02\x02\x01\x00'
>>> BEREncoder().encode_int(-128)
'\x02\x01\x80'
>>> BEREncoder().encode_int(-129)
'\x02\x02\xff\x7f'
encode_real(self, data)
>>> BEREncoder().encode_real(float("+inf"))
'\t\x01@'
>>> BEREncoder().encode_real(float("-inf"))
'\t\x01A'
>>> BEREncoder().encode_real(float("nan"))
'\t\x01B'
>>> BEREncoder().encode_real(float("-0"))
'\t\x01C'
>>> BEREncoder().encode_real(float("1"))
'\t\x080x031E+0'
>>> BEREncoder().encode_real(float("1.5"))
'\t\t0x0315E-1'
Parameters:data
Returns:
encode_null(self)

05 00 :return:

encode_oid(self, data)
>>> BEREncoder().encode_oid("1.3.6.1.2.1.1.5.0")
'\x06\x08+\x06\x01\x02\x01\x01\x05\x00'
Parameters:data
Returns:
noc.core.snmp.ber.decoder
noc.core.snmp.ber.encoder
noc.core.snmp.ber.decode(msg)
noc.core.snmp.ber.BITSTING