aboutsummaryrefslogtreecommitdiffstats
path: root/stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h
blob: 3088150ed0e9ce5c16a40e1d994bad609b97dfb2 (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/*
*
* 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_SPL_MSG_H
#define STACKX_SPL_MSG_H
#include "nsfw_msg.h"
#include "stackx_ip_addr.h"
#include "stackx_spl_share.h"
#include "stackx_common_opt.h"
#include <sys/socket.h>
#include <netinet/tcp.h>

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

enum spl_tcpip_msg_type
{
  SPL_TCPIP_NEW_MSG_API,
#if STACKX_TIMER_THREAD_SUPPORT
  SPL_TCPIP_MSG_TIMER,
#endif
#if STACKX_NETIF_API
  SPL_TCPIP_MSG_NETIFAPI,
#endif
  SPL_TCPIP_MSG_CALLBACK,
  SPL_TCPIP_MSG_IP_MODULE,

  SPL_TCPIP_MSG_MAX,            //the number of enum
  SPL_TCPIP_MSG_BOTTOM = MAX_MAJOR_TYPE //the max number of enum
};

enum api_msg_type
{
  SPL_API_DO_NEWCONN = 0,
  SPL_API_DO_DELCON,
  SPL_API_DO_RECV,
  SPL_API_DO_GETADDR,
  SPL_API_DO_BIND,
  SPL_API_DO_CONNECT,
  SPL_API_DO_LISTEN,
  SPL_API_DO_CLOSE,
  SPL_API_DO_SET_SOCK_OPT,
  SPL_API_DO_GET_SOCK_OPT,
  SPL_API_DO_SEND,
  SPL_API_DO_WRITE,
  SPL_API_DO_POST,
  SPL_API_DO_SHOW,
  SPL_API_DO_EXTREN_SOCK_SET,
  SPL_API_DO_ENABLE_TRACE,
  SPL_API_GET_PROTOCOL,
  SPL_API_DO_IOCTL_OPT,
  SPL_API_DO_GETSOCK_NAME,
  SPL_API_DO_DUMP_L4,
  SPL_API_DO_PBUF_FREE,
  SPL_API_DO_APP_TOUCH,         /* app send its version info to nStackMain */

  SPL_API_MSG_MAX,              //the number of enum
  SPL_API_MSG_BOTTOM = MAX_MINOR_TYPE   //the max number of enum
};

/* TODO: move thes to apporpriate file */
#define TCP_RTO_MAX ((unsigned)(120*1000))      /* 120s */
#define TCP_RTO_MIN ((unsigned)(200))   /* 200ms */

#define TCP_TIMEOUT_INIT ((unsigned)(1*1000))   /* RFC6298 2.1 initial RTO value    */
#define CONN_TCP_MEM_MIN_LINE       ((TX_MBUF_POOL_SIZE)/1024)  //conn level : min value of send_buf
#define CONN_TCP_MEM_DEF_LINE  	    ((TX_MBUF_POOL_SIZE)/128)   //conn level : default value of send_buf
#define CONN_TCP_MEM_MAX_LINE       ((TX_MBUF_POOL_SIZE)/12)

#define SOF_DEBUG           0x01U
#define SOF_ACCEPTCONN      0x02U
#define SOF_DONTROUTE       0x10U
#define SOF_USELOOPBACK     0x40U
#define SOF_LINGER          0x80U
#define SOF_OOBINLINE       0x0100U
#define SOF_REUSEPORT       0x0200U

/* General structure for calling APIs*/
typedef struct api_param_t
{
  data_com_msg *m;
  i64 comm_private_data;
} api_param;

/* SPL_API_DO_SEND */
typedef struct
{
  PRIMARY_ADDR struct spl_pbuf *p;
  spl_ip_addr_t local_ip;
  spl_ip_addr_t addr;
  spl_ip_addr_t srcAddr;
  u16 port;
  u16 srcPort;
  u16 toport_chksum;
  u8 tos;
  u8 pad;
  u8 flags;
  i64 extend_member_bit;
} msg_send_buf;

/* SPL_API_DO_BIND */
typedef struct
{
  spl_ip_addr_t ipaddr;
  u16 port;
  i64 extend_member_bit;
} msg_bind;

/* SPL_API_DO_CLOSE */
typedef struct
{
  long time_started;
  u8 shut;
  i64 extend_member_bit;
} msg_close;

/* SPL_API_DO_CONNECT */
typedef struct
{
  spl_ip_addr_t local_ip;
  spl_ip_addr_t ipaddr;
  u16 port;
  i64 extend_member_bit;
} msg_connect;

/* SPL_API_DO_DELCON */
typedef struct
{
  PRIMARY_ADDR struct spl_netconn *conn;
  PRIMARY_ADDR struct spl_pbuf *buf;
  long time_started;
  pid_t pid;
  u8 shut;
  u8 msg_box_ref;               /* use it for priority */
  u8 notify_omc;                /* bool */
  i64 extend_member_bit;
} msg_delete_netconn;

/* SPL_API_DO_WRITE */
typedef struct msg_write_buf_T
{
  PRIMARY_ADDR struct spl_pbuf *p;
  struct msg_write_buf_T *next;
  size_t len;
  u8 apiflags;
  i64 extend_member_bit;
} msg_write_buf;

/* SPL_API_DO_LISTEN */
typedef struct
{
  mring_handle conn_pool;
  u8 backlog;
  i64 extend_member_bit;
} msg_listen;

/* SPL_API_DO_NEWCONN */
typedef struct
{
  PRIMARY_ADDR struct spl_netconn *conn;
  spl_netconn_type_t type;
  u8 proto;
  int socket;
  i64 extend_member_bit;
} msg_new_netconn;

/* SPL_API_DO_RECV */
typedef struct
{
  PRIMARY_ADDR struct spl_pbuf *p;
  u32 len;
  i64 extend_member_bit;
} msg_recv_buf;

/* SPL_API_DO_GETSOCK_NAME */
typedef struct
{
  struct sockaddr sock_addr;
  u8 cmd;
  i64 extend_member_bit;
} msg_getaddrname;

/* SPL_API_DO_GET_SOCK_OPT,SPL_API_DO_SET_SOCK_OPT */
typedef struct
{
  int level;
  int optname;
  PRIMARY_ADDR mring_handle msg_box;    /* IP_TOS, spl will get new msg box for app */
  union
  {
    int int_optval;
    //struct in_addr inaddr_optval;
    //struct linger _linger;
    struct timeval timeval_optval;
    struct tcp_info tpinfo;
    //ipmreq ipmreq_optval;  //Multicast support later
  } optval;

  u32 optlen;
  i64 extend_member_bit;
} msg_setgetsockopt;

/* SPL_API_DO_PBUF_FREE */
typedef struct
{
  PRIMARY_ADDR struct spl_pbuf *buf;
  i64 extend_member_bit;
} msg_free_buf;

/* app send its version info to nStackMain */
#define NSTACK_VERSION_LEN 128
/* SPL_API_DO_APP_TOUCH */
typedef struct
{
  u32_t hostpid;
  char app_version[NSTACK_VERSION_LEN];
} msg_app_touch;

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

#endif