def test_sapdiag_items_bind(self): """Test binding of SAPDiagItem classes""" class SAPDiagItemTest(Packet): fields_desc = [StrField("strfield", None)] bind_diagitem(SAPDiagItemTest, "APPL", 0x99, 0xff) item_string = "strfield" item_value = SAPDiagItemTest(strfield=item_string) item = SAPDiagItem("\x10\x99\xff" + pack("!H", len(item_string)) + item_string) self.assertEqual(item.item_value, item_value) self.assertEqual(item.item_length, len(item_string)) self.assertEqual(item.item_value.strfield, item_string) self.assertEqual(str(item.item_value), str(item_value)) self.assertIs(diag_item_get_class(item, "APPL", 0x99, 0xff), SAPDiagItemTest)
# Protocol version (int): 100200 0x00018768 SAP Diag Compressed # 000200 0x000000c8 SAP Diag No Compressed # CodePage (int): 1100 0x0000044c Code Page 1100 # WS Type (int): 5001 0x00001389 SAP GUI Java # 3000 0x00000bb8 SAP GUI Windows # class SAPDiagUserConnect(Packet): name = "SAP Diag User Connect" fields_desc = [ IntField("protocol_version", 100200), IntField("code_page", 1100), IntField("ws_type", 5001) ] bind_diagitem(SAPDiagUserConnect, "APPL", 0x04, 0x02) user_connect_compressed = \ SAPDiagItem(item_type="APPL", item_id="ST_USER", item_sid=0x02, item_value=SAPDiagUserConnect()) user_connect_uncompressed = \ SAPDiagItem(item_type="APPL", item_id="ST_USER", item_sid=0x02, item_value=SAPDiagUserConnect(protocol_version=200)) # Diag Dialog step item
# Diag User connect item # # Protocol version (int): 100200 0x00018768 SAP Diag Compressed # 000200 0x000000c8 SAP Diag No Compressed # CodePage (int): 1100 0x0000044c Code Page 1100 # WS Type (int): 5001 0x00001389 SAP GUI Java # 3000 0x00000bb8 SAP GUI Windows # class SAPDiagUserConnect(Packet): name = "SAP Diag User Connect" fields_desc = [IntField("protocol_version", 100200), IntField("code_page", 1100), IntField("ws_type", 5001)] bind_diagitem(SAPDiagUserConnect, "APPL", 0x04, 0x02) user_connect_compressed = \ SAPDiagItem(item_type="APPL", item_id="ST_USER", item_sid=0x02, item_value=SAPDiagUserConnect()) user_connect_uncompressed = \ SAPDiagItem(item_type="APPL", item_id="ST_USER", item_sid=0x02, item_value=SAPDiagUserConnect(protocol_version=000200)) # Diag Dialog step item