9 #include "include/buffer.h"
11 typedef struct sIPv4Header tIPv4Header;
16 // Spec says Version is first, but stupid bit ordering
17 unsigned HeaderLength: 4; // in 4-byte chunks
18 unsigned Version: 4; // = 4
19 } __attribute__((packed));
20 Uint8 DiffServices; // Differentiated Services
26 unsigned DontFragment: 1;
27 unsigned MoreFragments: 1;
28 unsigned FragOffLow: 5;
29 } __attribute__((packed));
30 Uint8 FragOffHi; // Number of 8-byte blocks from the original start
32 Uint8 TTL; // Max number of hops, effectively
34 Uint16 HeaderChecksum; // One's Complement Sum of the entire header must equal zero
40 } __attribute__((packed));
42 #define IP4PROT_ICMP 1
44 #define IP4PROT_UDP 17
45 #define IPV4_BUFFERS 3 // 1 + Link
47 #define IPV4_ETHERNET_ID 0x0800
50 extern int IPv4_RegisterCallback(int ID, tIPCallback Callback);
51 extern Uint16 IPv4_Checksum(const void *Buf, size_t Length);
52 extern Uint32 IPv4_Netmask(int FixedBits);
53 extern int IPv4_SendPacket(tInterface *Iface, tIPv4 Address, int Protocol, int ID, tIPStackBuffer *Buffer);