Skip to content

Instantly share code, notes, and snippets.

@slankdev
Created April 30, 2017 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slankdev/bd8cd5668b5bd94de354cca8e5849557 to your computer and use it in GitHub Desktop.
Save slankdev/bd8cd5668b5bd94de354cca8e5849557 to your computer and use it in GitHub Desktop.
#include <slankdev/socketfd.h>
#include <slankdev/hexdump.h>
const char* ifname = "lo";
uint8_t packet[] = {
/* arp packet */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x08, 0x06, 0x00, 0x01,
0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
0x00, 0x00,
};
int main()
{
slankdev::socketfd sock;
sock.open_afpacket(ifname);
sock.write(packet, sizeof(packet));
slankdev::hexdump(stdout, packet, sizeof(packet));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment