This is a low-level network debugging utility that utilizes raw packet i/o to construct and deconstruct tcp, udp, ipv4, arp, and icmp packets over ethernet.
Diff: net/udp.h
- Revision:
- 0:d494b853ce97
- Child:
- 2:e8e09adc41fc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/net/udp.h Tue Oct 12 05:32:59 2010 +0000 @@ -0,0 +1,30 @@ +#ifndef UDP_H +#define UDP_H + +#include "net.h" + +#define IPPROTO_UDP 0x11 +typedef struct { + u16 source_port; + u16 destination_port; + u16 length; // entire datagram in bytes + u16 checksum; + u8 data[]; +} UDP_Packet; + +inline void fix_endian_udp(UDP_Packet *segment) +{ + fix_endian_u16(&segment->source_port); + fix_endian_u16(&segment->destination_port); + fix_endian_u16(&segment->length); +} + +inline void print_udp(UDP_Packet *segment) +{ + main_log.printf("UDP Packet:"); + main_log.printf(" Source: PORT %d", segment->source_port); + main_log.printf(" Dest: PORT %d", segment->destination_port); + main_log.printf(" Length: %d", segment->length); +} + +#endif \ No newline at end of file