Module: EtherPing::Server::Connection
- Included in:
- ConnectionWrapper
- Defined in:
- lib/ether_ping/server.rb
Instance Method Summary collapse
Instance Method Details
#receive_data(packet) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ether_ping/server.rb', line 11 def receive_data(packet) dest_mac = packet[0, 6].unpack('H*') source_mac = packet[6, 6].unpack('H*') ether_type = packet[12, 2].unpack('H*') puts "Src: #{source_mac} Dst: #{dest_mac} Eth: #{ether_type}\n" puts packet[14..-1].unpack('H*') # Exchange the source and destination MAC addresses. packet[0, 6], packet[6, 6] = packet[6, 6], packet[0, 6] send_data packet end |