The friendly Operating System for the Internet of Things
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 
22 #ifndef GNRC_TCP_INTERNAL_COMMON_H
23 #define GNRC_TCP_INTERNAL_COMMON_H
24 
25 #include <stdint.h>
26 #include "kernel_types.h"
27 #include "thread.h"
28 #include "mutex.h"
29 #include "net/gnrc/netapi.h"
30 #include "net/gnrc/tcp/tcb.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
41 #define PORT_UNSPEC (0)
42 
47 #define STATUS_PASSIVE (1 << 0)
48 #define STATUS_ALLOW_ANY_ADDR (1 << 1)
49 
55 #define TCP_EVENTLOOP_MSG_QUEUE_SIZE (8U)
56 #define TCP_EVENTLOOP_PRIO (THREAD_PRIORITY_MAIN - 2U)
57 #define TCP_EVENTLOOP_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
58 
64 #define MSK_FIN (0x0001)
65 #define MSK_SYN (0x0002)
66 #define MSK_RST (0x0004)
67 #define MSK_PSH (0x0008)
68 #define MSK_ACK (0x0010)
69 #define MSK_URG (0x0020)
70 #define MSK_FIN_ACK (0x0011)
71 #define MSK_SYN_ACK (0x0012)
72 #define MSK_RST_ACK (0x0014)
73 #define MSK_SYN_FIN_ACK (0x0013)
74 #define MSK_FIN_ACK_PSH (0x0019)
75 #define MSK_CTL (0x003F)
76 #define MSK_OFFSET (0xF000)
77 
83 #define MSG_TYPE_CONNECTION_TIMEOUT (GNRC_NETAPI_MSG_TYPE_ACK + 101)
84 #define MSG_TYPE_PROBE_TIMEOUT (GNRC_NETAPI_MSG_TYPE_ACK + 102)
85 #define MSG_TYPE_USER_SPEC_TIMEOUT (GNRC_NETAPI_MSG_TYPE_ACK + 103)
86 #define MSG_TYPE_RETRANSMISSION (GNRC_NETAPI_MSG_TYPE_ACK + 104)
87 #define MSG_TYPE_TIMEWAIT (GNRC_NETAPI_MSG_TYPE_ACK + 105)
88 #define MSG_TYPE_NOTIFY_USER (GNRC_NETAPI_MSG_TYPE_ACK + 106)
89 
94 #define RTO_UNINITIALIZED (-1)
95 
101 #define LSS_32_BIT(x, y) (((int32_t) (x)) - ((int32_t) (y)) < 0)
102 #define LEQ_32_BIT(x, y) (((int32_t) (x)) - ((int32_t) (y)) <= 0)
103 #define GRT_32_BIT(x, y) (!LEQ_32_BIT(x, y))
104 #define GEQ_32_BIT(x, y) (!LSS_32_BOT(x, y))
105 
110 #define INSIDE_WND(l_ed, seq_num, r_ed) (LEQ_32_BIT(l_ed, seq_num) && LSS_32_BIT(seq_num, r_ed))
111 
115 #define GET_OFFSET( x ) (((x) & MSK_OFFSET) >> 12)
116 
121 
126 
130 extern mutex_t _list_tcb_lock;
131 
132 #ifdef __cplusplus
133 }
134 #endif
135 
136 #endif /* GNRC_TCP_INTERNAL_COMMON_H */
137 
Types used by the kernel.
GNRC TCP transmission control block.
int16_t kernel_pid_t
Unique process identifier.
Definition: kernel_types.h:83
kernel_pid_t gnrc_tcp_pid
PID of tcp event handling thread.
mutex_t _list_tcb_lock
Mutex to protect linked list.
Generic interface to communicate with GNRC modules.
transmission control block of gnrc_tcp
Definition: tcb.h:50
Threading API.
RIOT synchronization API.
Mutex structure.
Definition: mutex.h:36
gnrc_tcp_tcb_t * _list_tcb_head
Head of linked tcb list.