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 COMMON_H
21 #define COMMON_H
22 
23 #include <stdint.h>
24 #include "assert.h"
25 #include "kernel_types.h"
26 #include "thread.h"
27 #include "mutex.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 #define STATUS_WAIT_FOR_MSG (1 << 3)
50 
56 #define TCP_EVENTLOOP_MSG_QUEUE_SIZE (8U)
57 #define TCP_EVENTLOOP_PRIO (THREAD_PRIORITY_MAIN - 2U)
58 #define TCP_EVENTLOOP_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
59 
65 #define MSK_FIN (0x0001)
66 #define MSK_SYN (0x0002)
67 #define MSK_RST (0x0004)
68 #define MSK_PSH (0x0008)
69 #define MSK_ACK (0x0010)
70 #define MSK_URG (0x0020)
71 #define MSK_FIN_ACK (0x0011)
72 #define MSK_SYN_ACK (0x0012)
73 #define MSK_RST_ACK (0x0014)
74 #define MSK_SYN_FIN_ACK (0x0013)
75 #define MSK_FIN_ACK_PSH (0x0019)
76 #define MSK_CTL (0x003F)
77 #define MSK_OFFSET (0xF000)
78 
84 #define MSG_TYPE_CONNECTION_TIMEOUT (GNRC_NETAPI_MSG_TYPE_ACK + 101)
85 #define MSG_TYPE_PROBE_TIMEOUT (GNRC_NETAPI_MSG_TYPE_ACK + 102)
86 #define MSG_TYPE_USER_SPEC_TIMEOUT (GNRC_NETAPI_MSG_TYPE_ACK + 103)
87 #define MSG_TYPE_RETRANSMISSION (GNRC_NETAPI_MSG_TYPE_ACK + 104)
88 #define MSG_TYPE_TIMEWAIT (GNRC_NETAPI_MSG_TYPE_ACK + 105)
89 #define MSG_TYPE_NOTIFY_USER (GNRC_NETAPI_MSG_TYPE_ACK + 106)
90 
95 #define RTO_UNINITIALIZED (-1)
96 
102 #define LSS_32_BIT(x, y) (((int32_t) (x)) - ((int32_t) (y)) < 0)
103 #define LEQ_32_BIT(x, y) (((int32_t) (x)) - ((int32_t) (y)) <= 0)
104 #define GRT_32_BIT(x, y) (!LEQ_32_BIT(x, y))
105 #define GEQ_32_BIT(x, y) (!LSS_32_BOT(x, y))
106 
111 #define INSIDE_WND(l_ed, seq_num, r_ed) (LEQ_32_BIT(l_ed, seq_num) && LSS_32_BIT(seq_num, r_ed))
112 
116 #define GET_OFFSET( x ) (((x) & MSK_OFFSET) >> 12)
117 
122 
127 
131 extern mutex_t _list_tcb_lock;
132 
133 #ifdef __cplusplus
134 }
135 #endif
136 
137 #endif /* COMMON_H */
138 
Types used by the kernel.
GNRC TCP transmission control block (TCB)
Generic interface to communicate with GNRC modules.
mutex_t _list_tcb_lock
Mutex to protect TCB list.
int16_t kernel_pid_t
Unique process identifier.
Definition: kernel_types.h:83
Transmission control block of GNRC TCP.
Definition: tcb.h:49
Threading API.
POSIX.1-2008 compliant version of the assert macro.
gnrc_tcp_tcb_t * _list_tcb_head
Head of linked TCB list.
Mutex for thread synchronization.
Mutex structure.
Definition: mutex.h:36
kernel_pid_t gnrc_tcp_pid
PID of GNRC TCP event handling thread.