Kyle Lemons / HvZServerLib

Dependencies:   NetServices

Dependents:   HvZ

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers udp.h Source File

udp.h

Go to the documentation of this file.
00001 #ifndef UDP_H
00002 #define UDP_H
00003 
00004 #include "net.h"
00005 
00006 /**
00007   \file udp.h
00008   \brief UDP packet
00009   
00010   This file contains the memory map and associated functions for UDP packet
00011   creation and deconstruction. 
00012 */
00013 
00014 #define IPPROTO_UDP 0x11
00015 #define HVZ_PORT 4489
00016 #define HVZ_HOSTNAME "kylelemons.net"
00017 
00018 /// UDP Packet memory map
00019 typedef struct {
00020   u16 source_port;       ///< Source port (1-65535)
00021   u16 destination_port;  ///< Destination port (1-65535) 
00022   u16 length;            ///< Entire datagram size in bytes
00023   u16 checksum;          ///< Checksum
00024   u8 data[];             ///< Data memory map
00025 } UDP_Packet;
00026 
00027 /// Convert from wire to host or host to wire endianness
00028 inline void fix_endian_udp(UDP_Packet *segment)
00029 {
00030   fix_endian_u16(&segment->source_port);
00031   fix_endian_u16(&segment->destination_port);
00032   fix_endian_u16(&segment->length);
00033 }
00034 
00035 #endif