Last active
November 4, 2016 13:48
-
-
Save boxofrad/e0f67f9886d8063505fcb09b9a275966 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers | |
UDP_PROTOCOL = 0x11 | |
loop do | |
data = socket.recv(BUFFER_SIZE).bytes | |
frame = EthernetFrame.new(data) | |
next unless frame.ip_packet.protocol == UDP_PROTOCOL && | |
frame.ip_packet.udp_datagram.destination_port == 4321 | |
UDPSocket.new.send( | |
frame.ip_packet.udp_datagram.body.upcase, | |
0, | |
frame.ip_packet.source_ip_address, | |
frame.ip_packet.udp_datagram.source_port | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment