aboutsummaryrefslogtreecommitdiffstats
path: root/stacks/lwip_stack/lwip_src/common/stackx_common_opt.h
blob: feccc3f3091fca3480eade25da062f5c9903bb63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
*
* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef STACKX_COMMON_OPT_H
#define STACKX_COMMON_OPT_H
#include <sys/ioctl.h>

#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif

#ifndef O_NONBLOCK
#define O_NONBLOCK 0X800        /* nonblocking I/O */
#endif

#if !defined (FIONREAD) || !defined (FIONBIO)
#define IOC_VOID 0x20000000UL   /* no parameters */
#define IOC_OUT 0x40000000UL    /* copy out parameters */
#define IOC_IN 0x80000000UL     /* copy in parameters */
#define IOCPARM_MASK 0x7fU      /* parameters must be < 128 bytes */
#define IOC_INOUT (IOC_IN | IOC_OUT)    /* 0x20000000 distinguishes new & old ioctl's */
#define _IO(x, y) (((x) << 8) | (y) | IOC_VOID)
#define _IOR(x, y, t) (IOC_OUT | (((long)sizeof(t) & IOCPARM_MASK) << 16) | ((x) << 8) | (y))
#define _IOW(x, y, t) (IOC_IN | (((long)sizeof(t) & IOCPARM_MASK) << 16) | ((x) << 8) | (y))
#endif

#ifndef FIONREAD
#define FIONREAD _IOR('f', 127, unsigned long)
#endif

#ifndef FIONBIO
#define FIONBIO _IOW('f', 126, unsigned long)
#endif

#ifndef F_GETFL
#define F_GETFL 3
#endif

#ifndef F_SETFL
#define F_SETFL 4
#endif

#ifndef SPL_SHUT_RD
#define SPL_SHUT_RD 0
#define SPL_SHUT_WR 1
#define SPL_SHUT_RDWR 2
#endif

/* Flags for struct netconn.flags (u8_t) */

/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
    this temporarily stores whether to wake up the original application task
    if data couldn't be sent in the first try. */
#define SPL_NETCONN_FLAG_WRITE_DELAYED 0x01

/** Should this netconn avoid blocking? */
#define SPL_NETCONN_FLAG_NON_BLOCKING 0x02

/** Was the last connect action a non-blocking one? */
#define SPL_NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04

/** If this is set, a TCP netconn must call netconn_recved() to update
    the TCP receive window (done automatically if not set). */
#define SPL_NETCONN_FLAG_NO_AUTO_RECVED 0x08

/** If a nonblocking write has been rejected before, poll_tcp needs to
    check if the netconn is writable again */
#define SPL_NETCONN_FLAG_CHECK_WRITESPACE 0x10

/* For the netconn API, these values are use as a bitmask! */
#define SPL_NETCONN_SHUT_RD 1
#define SPL_NETCONN_SHUT_WR 2
#define SPL_NETCONN_SHUT_RDWR (SPL_NETCONN_SHUT_RD | SPL_NETCONN_SHUT_WR)
#define STACKX_TIMER_THREAD_SUPPORT 1

/* Flags for netconn_write (u8_t) */
#define SPL_NETCONN_NOFLAG 0x00
#define SPL_NETCONN_NOCOPY 0x00
#define SPL_NETCONN_COPY 0x01
#define SPL_NETCONN_MORE 0x02
#define SPL_NETCONN_DONTBLOCK 0x04

#define SPL_TCP_NODELAY 0x01
#define SPL_TCP_KEEPALIVE 0x02
#define SPL_TCP_KEEPIDLE 0x04
#define SPL_TCP_KEEPINTVL 0x05
#define SPL_TCP_KEEPCNT 0x06
#define SPL_TCP_LINGER2 0x08
#define SPL_TCP_DEFER_ACCEPT 0x09
#define SPL_TCP_INFO 0x0B

typedef enum spl_netconn_type
{
  SPL_NETCONN_INVALID = 0,
  SPL_NETCONN_TCP = 0x10,
  SPL_NETCONN_UDP = 0x20,
  SPL_NETCONN_UDPLITE = 0x21,
  SPL_NETCONN_UDPNOCHKSUM = 0x22,
  SPL_NETCONN_RAW = 0x40,
} spl_netconn_type_t;

typedef enum spl_netconn_state
{
  SPL_NETCONN_NONE,
  SPL_NETCONN_WRITE,
  SPL_NETCONN_LISTEN,
  SPL_NETCONN_CONNECT,
  SPL_NETCONN_CLOSE,
} spl_netconn_state_t;

typedef enum spl_tcp_state
{
  SPL_CLOSED = 0,
  SPL_LISTEN = 1,
  SPL_SYN_SENT = 2,
  SPL_SYN_RCVD = 3,
  SPL_ESTABLISHED = 4,
  SPL_FIN_WAIT_1 = 5,
  SPL_FIN_WAIT_2 = 6,
  SPL_CLOSE_WAIT = 7,
  SPL_CLOSING = 8,
  SPL_LAST_ACK = 9,
  SPL_TIME_WAIT = 10
} spl_tcp_state_t;

#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif

#endif