Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#define ETH_P_IP 0x0800
{
/* --- Ethernet Header --- */
0x7e, 0x2e, 0x1a, 0x3b, 0x70, 0x18, # MAC Dest
0xde, 0xde, 0xde, 0xde, 0xde, 0xde, # MAC Source
const16(ETH_P_IP),
/* --- IPv4 Header --- */
0b01000101, 0, /* IPv4 Version, IHL, TOS */
const16(46), /* IPv4 Total Len (UDP len + IP hdr 20 bytes)*/
const16(2), /* IPv4 Ident */
0b01000000, 0, /* IPv4 Flags, Frag Off */
64, /* IPv4 TTL */
17, /* Proto UDP */
csumip(14, 33), /* IPv4 Checksum (IP header from, to) */
/* --- UDP Header --- */
10, 0, 3, 100, /* Source IP */
10, 0, 3, 101, /* Dest IP */
const16(9999), /* UDP Source Port e.g. drnd(2)*/
const16(9999), /* UDP Dest Port */
const16(26), /* UDP length (UDP hdr 8 bytes + payload size */
/* UDP checksum can be dyn calc via csumudp(offset IP, offset TCP)
* which is csumudp(14, 34), but for UDP its allowed to be zero
*/
const16(0),
/*** Payload ***/
fill('B', 18),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment