![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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.
net/udp.h
- Committer:
- etherealflaim
- Date:
- 2010-10-12
- Revision:
- 2:e8e09adc41fc
- Parent:
- 0:d494b853ce97
- Child:
- 4:88fc7fa58931
File content as of revision 2:e8e09adc41fc:
#ifndef UDP_H #define UDP_H #include "net.h" /// \file UDP packet #define IPPROTO_UDP 0x11 /// UDP Packet memory map typedef struct { u16 source_port; u16 destination_port; u16 length; // entire datagram in bytes u16 checksum; u8 data[]; } UDP_Packet; /// Convert from wire to host or host to wire endianness 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); } /// Print the UDP packet 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