gnrc_tcp_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2017 Simon Brummer
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef GNRC_TCP_COMMON_H
21 #define GNRC_TCP_COMMON_H
22 
23 #include <stdint.h>
24 #include "kernel_types.h"
25 #include "thread.h"
26 #include "mutex.h"
27 #include "evtimer.h"
28 #include "net/gnrc/netapi.h"
29 #include "net/gnrc/tcp/tcb.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
40 #define PORT_UNSPEC (0)
41 
46 #define STATUS_PASSIVE (1 << 0)
47 #define STATUS_ALLOW_ANY_ADDR (1 << 1)
48 #define STATUS_NOTIFY_USER (1 << 2)
49 
55 #define TCP_EVENTLOOP_PRIO (THREAD_PRIORITY_MAIN - 2U)
56 #define TCP_EVENTLOOP_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
57 
63 #define MSK_FIN (0x0001)
64 #define MSK_SYN (0x0002)
65 #define MSK_RST (0x0004)
66 #define MSK_PSH (0x0008)
67 #define MSK_ACK (0x0010)
68 #define MSK_URG (0x0020)
69 #define MSK_FIN_ACK (0x0011)
70 #define MSK_SYN_ACK (0x0012)
71 #define MSK_RST_ACK (0x0014)
72 #define MSK_SYN_FIN_ACK (0x0013)
73 #define MSK_FIN_ACK_PSH (0x0019)
74 #define MSK_CTL (0x003F)
75 #define MSK_OFFSET (0xF000)
76 
82 #define MSG_TYPE_CONNECTION_TIMEOUT (GNRC_NETAPI_MSG_TYPE_ACK + 101)
83 #define MSG_TYPE_PROBE_TIMEOUT (GNRC_NETAPI_MSG_TYPE_ACK + 102)
84 #define MSG_TYPE_USER_SPEC_TIMEOUT (GNRC_NETAPI_MSG_TYPE_ACK + 103)
85 #define MSG_TYPE_RETRANSMISSION (GNRC_NETAPI_MSG_TYPE_ACK + 104)
86 #define MSG_TYPE_TIMEWAIT (GNRC_NETAPI_MSG_TYPE_ACK + 105)
87 #define MSG_TYPE_NOTIFY_USER (GNRC_NETAPI_MSG_TYPE_ACK + 106)
88 
93 #define RTO_UNINITIALIZED (-1)
94 
100 #define LSS_32_BIT(x, y) (((int32_t) (x)) - ((int32_t) (y)) < 0)
101 #define LEQ_32_BIT(x, y) (((int32_t) (x)) - ((int32_t) (y)) <= 0)
102 #define GRT_32_BIT(x, y) (!LEQ_32_BIT(x, y))
103 #define GEQ_32_BIT(x, y) (!LSS_32_BOT(x, y))
104 
109 #define INSIDE_WND(l_ed, seq_num, r_ed) (LEQ_32_BIT(l_ed, seq_num) && LSS_32_BIT(seq_num, r_ed))
110 
114 #define GET_OFFSET( x ) (((x) & MSK_OFFSET) >> 12)
115 
121 #define TCP_DEBUG_ENTER DEBUG("GNRC_TCP: Enter \"%s\", File: %s(%d)\n", \
122  DEBUG_FUNC, RIOT_FILE_RELATIVE, __LINE__)
123 
129 #define TCP_DEBUG_LEAVE DEBUG("GNRC_TCP: Leave \"%s\", File: %s(%d)\n", \
130  DEBUG_FUNC, RIOT_FILE_RELATIVE, __LINE__)
131 
137 #define TCP_DEBUG_ERROR(msg) DEBUG("GNRC_TCP: Error: \"%s\", Func: %s, File: %s(%d)\n", \
138  msg, DEBUG_FUNC, RIOT_FILE_RELATIVE, __LINE__)
139 
145 #define TCP_DEBUG_INFO(msg) DEBUG("GNRC_TCP: Info: \"%s\", Func: %s, File: %s(%d)\n", \
146  msg, DEBUG_FUNC, RIOT_FILE_RELATIVE, __LINE__)
147 
151 typedef struct {
155 
162 
163 #ifdef __cplusplus
164 }
165 #endif
166 
167 #endif /* GNRC_TCP_COMMON_H */
168 
netapi.h
Generic interface to communicate with GNRC modules.
_gnrc_tcp_common_tcb_list_t
TCB list type.
Definition: gnrc_tcp_common.h:151
_gnrc_tcp_common_tcb_list_t::head
gnrc_tcp_tcb_t * head
Head of TCB list.
Definition: gnrc_tcp_common.h:152
_gnrc_tcp_common_tcb_list_t::lock
mutex_t lock
Lock of TCB list.
Definition: gnrc_tcp_common.h:153
_transmission_control_block
Transmission control block of GNRC TCP.
Definition: tcb.h:45
evtimer.h
evtimer API definitions
_gnrc_tcp_common_get_tcb_list
_gnrc_tcp_common_tcb_list_t * _gnrc_tcp_common_get_tcb_list(void)
Function to access to TCB list.
mutex.h
Mutex for thread synchronization.
tcb.h
GNRC TCP transmission control block (TCB)
kernel_types.h
Types used by the kernel.
mutex_t
Mutex structure.
Definition: mutex.h:120