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.

Dependencies:   mbed

Committer:
etherealflaim
Date:
Tue Oct 12 05:32:59 2010 +0000
Revision:
0:d494b853ce97
Child:
2:e8e09adc41fc
Initial Publish - Slightly unfinished, but usable

Who changed what in which revision?

UserRevisionLine numberNew contents of line
etherealflaim 0:d494b853ce97 1 #ifndef UDP_H
etherealflaim 0:d494b853ce97 2 #define UDP_H
etherealflaim 0:d494b853ce97 3
etherealflaim 0:d494b853ce97 4 #include "net.h"
etherealflaim 0:d494b853ce97 5
etherealflaim 0:d494b853ce97 6 #define IPPROTO_UDP 0x11
etherealflaim 0:d494b853ce97 7 typedef struct {
etherealflaim 0:d494b853ce97 8 u16 source_port;
etherealflaim 0:d494b853ce97 9 u16 destination_port;
etherealflaim 0:d494b853ce97 10 u16 length; // entire datagram in bytes
etherealflaim 0:d494b853ce97 11 u16 checksum;
etherealflaim 0:d494b853ce97 12 u8 data[];
etherealflaim 0:d494b853ce97 13 } UDP_Packet;
etherealflaim 0:d494b853ce97 14
etherealflaim 0:d494b853ce97 15 inline void fix_endian_udp(UDP_Packet *segment)
etherealflaim 0:d494b853ce97 16 {
etherealflaim 0:d494b853ce97 17 fix_endian_u16(&segment->source_port);
etherealflaim 0:d494b853ce97 18 fix_endian_u16(&segment->destination_port);
etherealflaim 0:d494b853ce97 19 fix_endian_u16(&segment->length);
etherealflaim 0:d494b853ce97 20 }
etherealflaim 0:d494b853ce97 21
etherealflaim 0:d494b853ce97 22 inline void print_udp(UDP_Packet *segment)
etherealflaim 0:d494b853ce97 23 {
etherealflaim 0:d494b853ce97 24 main_log.printf("UDP Packet:");
etherealflaim 0:d494b853ce97 25 main_log.printf(" Source: PORT %d", segment->source_port);
etherealflaim 0:d494b853ce97 26 main_log.printf(" Dest: PORT %d", segment->destination_port);
etherealflaim 0:d494b853ce97 27 main_log.printf(" Length: %d", segment->length);
etherealflaim 0:d494b853ce97 28 }
etherealflaim 0:d494b853ce97 29
etherealflaim 0:d494b853ce97 30 #endif