def test_reference_3b(self): packet = packets.Packet() packet.message_id = b'\x00\x00\x00\x00\xb0\x01' packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested() packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo() packet.opcodes[packets.OpcodeInReplyTo.id].message_id = b'\x00\x00\x00\x00\xa0\x01' self.assertEqual(packet.dump(), b'\x32\x50\x7d\xa3\x00\x00\x00\x00\xb0\x01\x00\x03\x00\x00\x00\x06\x00\x00\x00\x00\xa0\x01')
def test_reference_6d(self): packet = packets.Packet() packet.message_id = bytearray('\x00\x00\x00\x00\xb0\x02') packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested() packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo() packet.opcodes[packets.OpcodeInReplyTo.id].message_id = bytearray('\x00\x00\x00\x00\xa0\x03') self.assertEqual(packet.dump(), bytearray(b'\x32\x50\x7d\xa0\x00\x00\x00\x00\xb0\x02\x00\x03\x00\x00\x00\x06\x00\x00\x00\x00\xa0\x03'))
def test_reference_5b(self): packet = packets.Packet() packet.message_id = bytearray('\x00\x00\x00\x00\xa0\x02') packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested() packet.opcodes[packets.OpcodeInvestigate.id] = packets.OpcodeInvestigate() packet.opcodes[packets.OpcodeInvestigate.id].message_ids.append(bytearray('\x00\x00\x00\x00\xa0\x01')) self.assertEqual(packet.dump(), bytearray(b'\x32\x50\x8d\x81\x00\x00\x00\x00\xa0\x02\x00\x21\x00\x00\x00\x08\x00\x01\x00\x00\x00\x00\xa0\x01'))
def test_reference_6e(self): packet = packets.Packet() packet.message_id = bytearray('\x00\x00\x00\x00\xa0\x04') packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo() packet.opcodes[packets.OpcodeInReplyTo.id].message_id = bytearray('\x00\x00\x00\x00\xb0\x02') packet.opcodes[packets.OpcodeRTTEnclosed.id] = packets.OpcodeRTTEnclosed() packet.opcodes[packets.OpcodeRTTEnclosed.id].rtt_us = 12823 self.assertEqual(packet.dump(), bytearray(b'\x32\x50\x4b\x81\x00\x00\x00\x00\xa0\x04\x00\x06\x00\x06\x00\x00\x00\x00\xb0\x02\x00\x04\x00\x00\x32\x17'))
def test_reference_5d(self): packet = packets.Packet() packet.message_id = bytearray('\x00\x00\x00\x00\xa0\x03') packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo() packet.opcodes[packets.OpcodeInReplyTo.id].message_id = bytearray('\x00\x00\x00\x00\xb0\x01') packet.opcodes[packets.OpcodeRTTEnclosed.id] = packets.OpcodeRTTEnclosed() packet.opcodes[packets.OpcodeRTTEnclosed.id].rtt_us = 12345 self.assertEqual(packet.dump(), bytearray(b'\x32\x50\x4d\x61\x00\x00\x00\x00\xa0\x03\x00\x06\x00\x06\x00\x00\x00\x00\xb0\x01\x00\x04\x00\x00\x30\x39'))
def test_reference_6f(self): packet = packets.Packet() packet.message_id = b'\x00\x00\x00\x00\xa0\x0a' packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested() packet.opcodes[packets.OpcodeInvestigate.id] = packets.OpcodeInvestigate() packet.opcodes[packets.OpcodeInvestigate.id].message_ids.append(b'\x00\x00\x00\x00\xa0\x01') packet.opcodes[packets.OpcodeInvestigate.id].message_ids.append(b'\x00\x00\x00\x00\xa0\x02') self.assertEqual(packet.dump(), b'\x32\x50\xed\x6f\x00\x00\x00\x00\xa0\x0a\x00\x21\x00\x00\x00\x0e\x00\x02\x00\x00\x00\x00\xa0\x01\x00\x00\x00\x00\xa0\x02')
def test_reference_5c(self): packet = packets.Packet() packet.message_id = bytearray('\x00\x00\x00\x00\xb0\x01') packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested() packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo() packet.opcodes[packets.OpcodeInReplyTo.id].message_id = bytearray('\x00\x00\x00\x00\xa0\x02') packet.opcodes[packets.OpcodeInvestigationUnseen.id] = packets.OpcodeInvestigationUnseen() packet.opcodes[packets.OpcodeInvestigationUnseen.id].message_ids.append(bytearray('\x00\x00\x00\x00\xa0\x01')) self.assertEqual(packet.dump(), bytearray(b'\x32\x50\xdd\x87\x00\x00\x00\x00\xb0\x01\x00\x13\x00\x00\x00\x06\x00\x00\x00\x00\xa0\x02\x00\x08\x00\x01\x00\x00\x00\x00\xa0\x01'))
def test_reference_4c(self): packet = packets.Packet() packet.message_id = b'\x00\x00\x00\x00\xb0\x02' packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested() packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo() packet.opcodes[packets.OpcodeInReplyTo.id].message_id = b'\x00\x00\x00\x00\xa0\x02' packet.opcodes[packets.OpcodeInvestigationSeen.id] = packets.OpcodeInvestigationSeen() packet.opcodes[packets.OpcodeInvestigationSeen.id].message_ids.append(b'\x00\x00\x00\x00\xa0\x01') self.assertEqual(packet.dump(), b'\x32\x50\xdd\x8e\x00\x00\x00\x00\xb0\x02\x00\x0b\x00\x00\x00\x06\x00\x00\x00\x00\xa0\x02\x00\x08\x00\x01\x00\x00\x00\x00\xa0\x01')
def test_reference_6h(self): packet = packets.Packet() packet.message_id = bytearray('\x00\x00\x00\x00\xa0\x0b') packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo() packet.opcodes[packets.OpcodeInReplyTo.id].message_id = bytearray('\x00\x00\x00\x00\xb0\x06') packet.opcodes[packets.OpcodeRTTEnclosed.id] = packets.OpcodeRTTEnclosed() packet.opcodes[packets.OpcodeRTTEnclosed.id].rtt_us = 13112 packet.opcodes[packets.OpcodeInvestigationSeen.id] = packets.OpcodeInvestigationSeen() packet.opcodes[packets.OpcodeInvestigationSeen.id].message_ids.append(bytearray('\x00\x00\x00\x00\xb0\x02')) self.assertEqual(packet.dump(), bytearray(b'\x32\x50\x9a\x41\x00\x00\x00\x00\xa0\x0b\x00\x0e\x00\x06\x00\x00\x00\x00\xb0\x06\x00\x04\x00\x00\x33\x38\x00\x08\x00\x01\x00\x00\x00\x00\xb0\x02'))
def test_reference_6c(self): packet = packets.Packet() packet.message_id = bytearray('\x00\x00\x00\x00\xa0\x03') packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested() self.assertEqual(packet.dump(), bytearray(b'\x32\x50\x2d\xab\x00\x00\x00\x00\xa0\x03\x00\x01\x00\x00'))
def test_reference_1a(self): packet = packets.Packet() packet.message_id = bytearray('\x00\x00\x00\x00\xa0\x01') self.assertEqual(packet.dump(), bytearray(b'\x32\x50\x2d\xae\x00\x00\x00\x00\xa0\x01\x00\x00'))
def test_reference_6b(self): packet = packets.Packet() packet.message_id = b'\x00\x00\x00\x00\xa0\x02' packet.opcodes[packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested() self.assertEqual(packet.dump(), b'\x32\x50\x2d\xac\x00\x00\x00\x00\xa0\x02\x00\x01\x00\x00')
# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. from twoping import packets def h(input): return ' '.join('{:02x}'.format(x) for x in input) print('### Example 1') print() packet = packets.Packet() packet.message_id = b'\x00\x00\x00\x00\xa0\x01' print(' CLIENT: {}'.format(h(packet.dump()))) print() print('### Example 2') print() packet = packets.Packet() packet.message_id = b'\x00\x00\x00\x00\xa0\x01' packet.opcodes[ packets.OpcodeReplyRequested.id] = packets.OpcodeReplyRequested() print(' CLIENT: {}'.format(h(packet.dump()))) packet = packets.Packet() packet.message_id = b'\x00\x00\x00\x00\xb0\x01' packet.opcodes[packets.OpcodeInReplyTo.id] = packets.OpcodeInReplyTo() packet.opcodes[