Dependencies:   NetServices

Dependents:   HvZ

Committer:
etherealflaim
Date:
Sun Dec 12 19:34:41 2010 +0000
Revision:
0:7e2eb93442e7

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
etherealflaim 0:7e2eb93442e7 1 #ifndef UDP_H
etherealflaim 0:7e2eb93442e7 2 #define UDP_H
etherealflaim 0:7e2eb93442e7 3
etherealflaim 0:7e2eb93442e7 4 #include "net.h"
etherealflaim 0:7e2eb93442e7 5
etherealflaim 0:7e2eb93442e7 6 /**
etherealflaim 0:7e2eb93442e7 7 \file udp.h
etherealflaim 0:7e2eb93442e7 8 \brief UDP packet
etherealflaim 0:7e2eb93442e7 9
etherealflaim 0:7e2eb93442e7 10 This file contains the memory map and associated functions for UDP packet
etherealflaim 0:7e2eb93442e7 11 creation and deconstruction.
etherealflaim 0:7e2eb93442e7 12 */
etherealflaim 0:7e2eb93442e7 13
etherealflaim 0:7e2eb93442e7 14 #define IPPROTO_UDP 0x11
etherealflaim 0:7e2eb93442e7 15 #define HVZ_PORT 4489
etherealflaim 0:7e2eb93442e7 16 #define HVZ_HOSTNAME "kylelemons.net"
etherealflaim 0:7e2eb93442e7 17
etherealflaim 0:7e2eb93442e7 18 /// UDP Packet memory map
etherealflaim 0:7e2eb93442e7 19 typedef struct {
etherealflaim 0:7e2eb93442e7 20 u16 source_port; ///< Source port (1-65535)
etherealflaim 0:7e2eb93442e7 21 u16 destination_port; ///< Destination port (1-65535)
etherealflaim 0:7e2eb93442e7 22 u16 length; ///< Entire datagram size in bytes
etherealflaim 0:7e2eb93442e7 23 u16 checksum; ///< Checksum
etherealflaim 0:7e2eb93442e7 24 u8 data[]; ///< Data memory map
etherealflaim 0:7e2eb93442e7 25 } UDP_Packet;
etherealflaim 0:7e2eb93442e7 26
etherealflaim 0:7e2eb93442e7 27 /// Convert from wire to host or host to wire endianness
etherealflaim 0:7e2eb93442e7 28 inline void fix_endian_udp(UDP_Packet *segment)
etherealflaim 0:7e2eb93442e7 29 {
etherealflaim 0:7e2eb93442e7 30 fix_endian_u16(&segment->source_port);
etherealflaim 0:7e2eb93442e7 31 fix_endian_u16(&segment->destination_port);
etherealflaim 0:7e2eb93442e7 32 fix_endian_u16(&segment->length);
etherealflaim 0:7e2eb93442e7 33 }
etherealflaim 0:7e2eb93442e7 34
etherealflaim 0:7e2eb93442e7 35 #endif