Esempio n. 1
0
 def test_ethernet_packet_packs(self):
     expected_packed_message = bytes.fromhex(
         "0180c2000003001906eab88c888e0100000501010005010000")
     message = EthernetPacket(dst_mac=MacAddress.from_string("01:80:c2:00:00:03"),
                              src_mac=MacAddress.from_string("00:19:06:ea:b8:8c"),
                              ethertype=0x888e,
                              data=bytes.fromhex("0100000501010005010000"))
     packed_message = message.pack()
     self.assertEqual(expected_packed_message, packed_message)
Esempio n. 2
0
 def ethernet_pack(message, src_mac, dst_mac):
     """Packs a ethernet packet.
     Args:
         message: EAP payload
         src_mac (MacAddress):
         dst_mac (MacAddress):
     Returns:
         packed ethernet packet (bytes)
     """
     data = MessagePacker.pack(message)
     ethernet_packet = EthernetPacket(dst_mac=dst_mac,
                                      src_mac=src_mac,
                                      ethertype=0x888e,
                                      data=data)
     return ethernet_packet.pack()