diff --git a/sys/net/destiny/include/destiny.h b/sys/net/destiny/include/destiny.h index 71b7283b3b..e976240707 100644 --- a/sys/net/destiny/include/destiny.h +++ b/sys/net/destiny/include/destiny.h @@ -35,6 +35,7 @@ #include "destiny/in.h" #include "destiny/socket.h" +#include "destiny/types.h" /** * Initializes transport layer. diff --git a/sys/net/destiny/include/destiny/types.h b/sys/net/destiny/include/destiny/types.h new file mode 100644 index 0000000000..70679a3b52 --- /dev/null +++ b/sys/net/destiny/include/destiny/types.h @@ -0,0 +1,75 @@ +/** + * Destiny types header + * + * Copyright (C) 2013 INRIA. + * + * This file subject to the terms and conditions of the GNU Lesser General + * Public License. See the file LICENSE in the top level directory for more + * details. + * + * @ingroup destiny + * @{ + * @file + * @brief Destiny types + * @author Oliver Gesch + * @author Martin Lenders + */ +#ifndef DESTINY_TYPES_H_ +#define DESTINY_TYPES_H_ +#include + +/** + * UDP packet header length + */ +#define UDP_HDR_LEN 8 + +/** + * TCP packet header length + */ +#define TCP_HDR_LEN 20 + +/** + * UDP packet header + * + * @see RFC 768 + */ +typedef struct __attribute__((packed)) { + uint16_t src_port; ///< source port + uint16_t dst_port; ///< destination port + uint16_t length; ///< payload length + /** + * internet checksum + * + * @see RFC 1071 + */ + uint16_t checksum; +} udp_hdr_t; + +/** + * TCP packet header + * + * @see RFC 793 + */ +typedef struct __attribute__((packed)) { + uint16_t src_port; ///< source port + uint16_t dst_port; ///< destination port + uint32_t seq_nr; ///< sequence number + uint32_t ack_nr; ///< acknowledgement number + uint8_t dataOffset_reserved; ///< 4 MSBs data offsets, + ///< 4 LSBs reserved (must be zero) + uint8_t reserved_flags; ///< MSB reserved, rest flags + uint16_t window; ///< receiver window + /** + * internet checksum + * + * @see RFC 1071 + */ + uint16_t checksum; + uint16_t urg_pointer; ///< urgent pointer +} tcp_hdr_t; + +/** + * @} + */ + +#endif DESTINY_TYPES_H_ diff --git a/sys/net/destiny/tcp.h b/sys/net/destiny/tcp.h index 126bdb87fc..6d9563c5cf 100644 --- a/sys/net/destiny/tcp.h +++ b/sys/net/destiny/tcp.h @@ -9,18 +9,16 @@ * * @ingroup destiny * @{ - * @file tcp.c + * @file * @brief TCP data structs and prototypes * @author Oliver Gesch - * @} */ #ifndef TCP_H_ #define TCP_H_ #include "ipv6.h" - -#define TCP_HDR_LEN 20 +#include "destiny/types.h" #define TCP_EOO_OPTION 0x00 // End of option list #define TCP_NOP_OPTION 0x01 // No operation @@ -28,16 +26,6 @@ #define TCP_WSF_OPTION 0x03 // Window scale factor #define TCP_TS_OPTION 0x08 // Timestamp -enum tcp_flags { - TCP_ACK = 0x08, - TCP_URG_PSH = 0x14, - TCP_RST = 0x20, - TCP_SYN = 0x40, - TCP_SYN_ACK = 0x48, - TCP_FIN = 0x80, - TCP_FIN_ACK = 0x88 -}; - enum tcp_states { CLOSED = 0, LISTEN = 1, @@ -111,4 +99,8 @@ uint16_t tcp_csum(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header); void printTCPHeader(tcp_hdr_t *tcp_header); void printArrayRange_tcp(uint8_t *udp_header, uint16_t len); +/** + * @} + */ + #endif /* TCP_H_ */ diff --git a/sys/net/destiny/udp.h b/sys/net/destiny/udp.h index d313f0ce28..5eab7c460e 100644 --- a/sys/net/destiny/udp.h +++ b/sys/net/destiny/udp.h @@ -9,36 +9,25 @@ * * @ingroup destiny * @{ - * @file udp.c + * @file * @brief UDP data structs and prototypes * @author Oliver Gesch - * @} */ -/* - * udp.h - * - * Created on: 05.09.2011 - * Author: Oliver - */ #ifndef UDP_H_ #define UDP_H_ #include "ipv6.h" - -#define UDP_HDR_LEN 8 +#include "destiny/types.h" #define UDP_STACK_SIZE KERNEL_CONF_STACKSIZE_DEFAULT -typedef struct __attribute__((packed)) udp_h_t { - uint16_t src_port; - uint16_t dst_port; - uint16_t length; - uint16_t checksum; -} udp_hdr_t; - uint16_t udp_csum(ipv6_hdr_t *ipv6_header, udp_hdr_t *udp_header); void udp_packet_handler(void); +/** + * @} + */ + #endif /* UDP_H_ */