mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Move L4 packet headers to destiny/types.h
This commit is contained in:
parent
c02a097232
commit
f537e19b26
@ -35,6 +35,7 @@
|
||||
|
||||
#include "destiny/in.h"
|
||||
#include "destiny/socket.h"
|
||||
#include "destiny/types.h"
|
||||
|
||||
/**
|
||||
* Initializes transport layer.
|
||||
|
75
sys/net/destiny/include/destiny/types.h
Normal file
75
sys/net/destiny/include/destiny/types.h
Normal file
@ -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 <oliver.gesch@googlemail.com>
|
||||
* @author Martin Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef DESTINY_TYPES_H_
|
||||
#define DESTINY_TYPES_H_
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* UDP packet header length
|
||||
*/
|
||||
#define UDP_HDR_LEN 8
|
||||
|
||||
/**
|
||||
* TCP packet header length
|
||||
*/
|
||||
#define TCP_HDR_LEN 20
|
||||
|
||||
/**
|
||||
* UDP packet header
|
||||
*
|
||||
* @see <a href="http://tools.ietf.org/html/rfc768">RFC 768</a>
|
||||
*/
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint16_t src_port; ///< source port
|
||||
uint16_t dst_port; ///< destination port
|
||||
uint16_t length; ///< payload length
|
||||
/**
|
||||
* internet checksum
|
||||
*
|
||||
* @see <a href="http://tools.ietf.org/html/rfc1071">RFC 1071</a>
|
||||
*/
|
||||
uint16_t checksum;
|
||||
} udp_hdr_t;
|
||||
|
||||
/**
|
||||
* TCP packet header
|
||||
*
|
||||
* @see <a href="http://tools.ietf.org/html/rfc793">RFC 793</a>
|
||||
*/
|
||||
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 <a href="http://tools.ietf.org/html/rfc1071">RFC 1071</a>
|
||||
*/
|
||||
uint16_t checksum;
|
||||
uint16_t urg_pointer; ///< urgent pointer
|
||||
} tcp_hdr_t;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif DESTINY_TYPES_H_
|
@ -9,18 +9,16 @@
|
||||
*
|
||||
* @ingroup destiny
|
||||
* @{
|
||||
* @file tcp.c
|
||||
* @file
|
||||
* @brief TCP data structs and prototypes
|
||||
* @author Oliver Gesch <oliver.gesch@googlemail.com>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#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_ */
|
||||
|
@ -9,36 +9,25 @@
|
||||
*
|
||||
* @ingroup destiny
|
||||
* @{
|
||||
* @file udp.c
|
||||
* @file
|
||||
* @brief UDP data structs and prototypes
|
||||
* @author Oliver Gesch <oliver.gesch@googlemail.com>
|
||||
* @}
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user