def receive_eth_packet(self):
     """Receive Ethernet Frame and send to State Machine"""
     rad_queue_size = self.radius_output_queue.qsize()
     message = EthernetPacket(self.PORT_ID_MAC, str(self.src_mac), 0x888e,
                              "")
     self.sm.event(EventMessageReceived(message, self.PORT_ID_MAC))
     self.assertEqual(self.radius_output_queue.qsize(), rad_queue_size + 1)
 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)
Beispiel #3
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()