Dependencies:   NetServices

Dependents:   HvZ

Revision:
0:7e2eb93442e7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/net/udp.h	Sun Dec 12 19:34:41 2010 +0000
@@ -0,0 +1,35 @@
+#ifndef UDP_H
+#define UDP_H
+
+#include "net.h"
+
+/**
+  \file udp.h
+  \brief UDP packet
+  
+  This file contains the memory map and associated functions for UDP packet
+  creation and deconstruction. 
+*/
+
+#define IPPROTO_UDP 0x11
+#define HVZ_PORT 4489
+#define HVZ_HOSTNAME "kylelemons.net"
+
+/// UDP Packet memory map
+typedef struct {
+  u16 source_port;       ///< Source port (1-65535)
+  u16 destination_port;  ///< Destination port (1-65535) 
+  u16 length;            ///< Entire datagram size in bytes
+  u16 checksum;          ///< Checksum
+  u8 data[];             ///< Data memory map
+} 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);
+}
+
+#endif
\ No newline at end of file