Пример #1
0
def test_header_req_decode():
    header = IpmbHeaderReq()
    data = header.decode(b'\x72\x19\x76\x20\x08\x01')
    eq_(header.rq_sa, 0x72)
    eq_(header.rq_lun, 1)
    eq_(header.rs_sa, 0x20)
    eq_(header.rs_lun, 0)
    eq_(header.netfn, 6)
Пример #2
0
def test_header_req_encode():
    header = IpmbHeaderReq()
    header.rs_lun = 0
    header.rs_sa = 0x72
    header.rq_seq = 2
    header.rq_lun = 1
    header.rq_sa = 0x20
    header.netfn = 6
    header.cmd_id = 1
    data = header.encode()
    eq_(data, b'\x72\x18\x76\x20\x09\x01')
Пример #3
0
def test_encode_ipmb_msg():
    header = IpmbHeaderReq()
    header.rs_lun = 0
    header.rs_sa = 0x72
    header.rq_seq = 2
    header.rq_lun = 0
    header.rq_sa = 0x20
    header.netfn = 6
    header.cmd_id = 1

    eq_(encode_ipmb_msg(header, b'\xaa\xbb\xcc'),
        b'\x72\x18\x76\x20\x08\x01\xaa\xbb\xcc\xa6')
Пример #4
0
def test_encode_bridged_message():
    payload = array('B', b'\xaa\xbb')
    t = Target(0)
    t.set_routing([(0x81, 0x20, 7), (0x20, 0x72, None)])
    header = IpmbHeaderReq()
    header.netfn = 6
    header.rs_lun = 0
    header.rq_seq = 0x11
    header.rq_lun = 0
    header.cmd_id = 0xaa
    data = encode_bridged_message(t.routing, header, payload, seq=0x22)
    eq_(
        data,
        b'\x20\x18\xc8\x81\x88\x34\x47\x72\x18\x76\x20\x44\xaa\xaa\xbb\x8d\x7c'
    )
Пример #5
0
def test_rx_filter():
    header_req = IpmbHeaderReq()
    header_req.rs_lun = 1
    header_req.rs_sa = 0x72
    header_req.rq_seq = 2
    header_req.rq_lun = 0
    header_req.rq_sa = 0x20
    header_req.netfn = 6
    header_req.cmd_id = 1

    # requester and responder fields are twisted ... (sa and lun)
    header_rsp = IpmbHeaderReq()
    header_rsp.rs_lun = 0
    header_rsp.rs_sa = 0x20
    header_rsp.rq_seq = 2
    header_rsp.rq_lun = 1
    header_rsp.rq_sa = 0x72
    header_rsp.netfn = 6 + 1
    header_rsp.cmd_id = 1

    rx_data = encode_ipmb_msg(header_rsp, b'\xaa\xbb\xcc')

    ok_(rx_filter(header_req, rx_data))