aboutsummaryrefslogtreecommitdiffstats
path: root/stacks/lwip_stack/lwip_src/include/stackx
diff options
context:
space:
mode:
authorSwarup Nayak <swarupnpvt@gmail.com>2018-08-13 19:23:34 +0530
committerSwarup Nayak <swarupnpvt@gmail.com>2018-08-13 19:25:27 +0530
commit7dc65518819f2b453fd2837e92c115592d8832ec (patch)
treef9119bb3624ff11af480981c9904b84c172a607c /stacks/lwip_stack/lwip_src/include/stackx
parentbd6e75c243db1b384ba0882ecaf9063ec4cd70bd (diff)
Feat : LWIP integration part1
Change-Id: Ia26c092d16579c6f845a021ba66bde106363883a Signed-off-by: Swarup Nayak <swarupnpvt@gmail.com>
Diffstat (limited to 'stacks/lwip_stack/lwip_src/include/stackx')
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/internal_msg.h90
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_api.h276
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_api_msg.h129
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_err.h40
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_instance.h30
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_netbuf.h52
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h173
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_sbr.h33
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_sockets.h252
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_tcpip.h80
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_timers.h108
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/stackx_instance.h91
12 files changed, 1354 insertions, 0 deletions
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/internal_msg.h b/stacks/lwip_stack/lwip_src/include/stackx/internal_msg.h
new file mode 100644
index 0000000..584ab06
--- /dev/null
+++ b/stacks/lwip_stack/lwip_src/include/stackx/internal_msg.h
@@ -0,0 +1,90 @@
+/*
+*
+* 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 __internal_msg_h__
+#define __internal_msg_h__
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#include "nsfw_msg.h"
+#include "netif.h"
+#include "lwip/netifapi.h"
+#include "ip_module_api.h"
+
+enum netif_msg_type
+{
+ NETIF_DO_ADD,
+ NETIF_MSG_API_MAX = MAX_MINOR_TYPE
+};
+
+/* NETIF_DO_ADD */
+typedef struct msg_add_netif_T
+{
+ void (*function) (struct msg_add_netif_T * m);
+ struct netif *netif;
+ spl_ip_addr_t *ipaddr;
+ spl_ip_addr_t *netmask;
+ spl_ip_addr_t *gw;
+ void *state;
+ netif_init_fn init;
+ netif_input_fn input;
+ netifapi_void_fn voidfunc;
+ /* no need to extend member */
+} msg_add_netif;
+
+typedef struct
+{
+ ip_module_type type;
+ ip_module_operate_type operate_type;
+ void *arg;
+} msg_ip_module;
+
+typedef struct msg_internal_callback_T
+{
+ void (*function) (void *ctx);
+ void *ctx;
+} msg_internal_callback;
+
+enum timer_msg_type
+{
+ TIMER_MSG_TIMEOUT,
+ TIMER_MSG_CLEAR,
+ TIMER_MSG_MAX = MAX_MINOR_TYPE
+};
+
+typedef struct msg_timer_T
+{
+ void *act;
+ void *arg;
+} msg_timer;
+
+enum mt_msg_type
+{
+ MT_MSG_VER_MGR,
+ MT_MSG_MAX = MAX_MINOR_TYPE
+};
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif /* __internal_msg_h__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_api.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_api.h
new file mode 100644
index 0000000..ea63e90
--- /dev/null
+++ b/stacks/lwip_stack/lwip_src/include/stackx/spl_api.h
@@ -0,0 +1,276 @@
+/*
+*
+* 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 __SPL_API_H__
+#define __SPL_API_H__
+
+#include "opt.h"
+#include "common_mem_base_type.h"
+#include <stddef.h> /* for size_t */
+#include "arch/queue.h"
+#include "arch/sys_arch.h"
+#include "arch/atomic_32.h"
+#include "stackx_common_opt.h"
+#include "stackx_spl_share.h"
+
+/* From lwip */
+#include "api.h"
+#include "sys.h"
+#include "sys_arch.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#define MAX_WAIT_TIMEOUT 0x7FFFFFFF
+
+/* Throughout this file, IPaddresses and port numbers are expected to be in
+ * the same byte order as in the corresponding pcb.
+ */
+
+/* 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 NETCONN_FLAG_CHECK_WRITESPACE 0x10
+
+enum stackx_model
+{
+ SOCKET_STACKX = 0,
+ CALLBACK_STACKX
+};
+
+enum callback_type
+{
+ API_ACCEPT_EVENT = 0xF0,
+ API_RECV_EVENT,
+ API_SEND_EVENT,
+ API_CLOSE_EVENT
+};
+#if 1
+/** Use to inform the callback function about changes */
+enum spl_netconn_evt
+{
+ SPL_NETCONN_EVT_RCVPLUS,
+ SPL_NETCONN_EVT_RCVMINUS,
+ SPL_NETCONN_EVT_SENDPLUS,
+ SPL_NETCONN_EVT_SENDMINUS,
+ SPL_NETCONN_EVT_ERROR,
+ SPL_NETCONN_EVT_HUP,
+ SPL_NETCONN_EVT_RDHUP,
+ SPL_NETCONN_EVT_AGAIN,
+ SPL_NETCONN_EVT_ACCEPT
+};
+#endif
+enum
+{
+ INET_ECN_NOT_ECT = 0,
+ INET_ECN_ECT_1 = 1,
+ INET_ECN_ECT_0 = 2,
+ INET_ECN_CE = 3,
+ INET_ECN_MASK = 3,
+};
+
+#define SPL_NETCONNTYPE_GROUP(t) (t & 0xF0)
+#define SPL_NETCONNTYPE_DATAGRAM(t) (t & 0xE0)
+
+/* forward-declare some structs to avoid to include their headers */
+typedef struct common_pcb
+{
+ enum stackx_model model;
+
+ int socket;
+
+ /** type of the netconn (TCP, UDP or RAW) */
+ enum spl_netconn_type type;
+
+ /* share memory between sbr and stackx */
+ spl_netconn_t *conn;
+
+ u16 bind_thread_index;
+ u8 close_progress;
+ u8 recv_ring_not_empty;
+
+ /** TCP: when data passed to netconn_write doesn't fit into the send buffer,
+ this temporarily stores the message.
+ Also used during connect and close.
+ */
+ data_com_msg *current_msg;
+
+ msg_write_buf *msg_head;
+ msg_write_buf *msg_tail;
+
+ size_t write_offset;
+
+ /** timeout to wait for new data to be received
+ (or connections to arrive for listening netconns) */
+ int recv_timeout;
+
+ /* timeout to wait for send buffer writtable */
+ int send_timeout;
+
+ int sk_rcvlowat;
+
+ //DFX stat for connection packet
+ /* dfx_conn_t dfx; */
+
+ /*store the hostpid info for release */
+ uint32_t hostpid;
+ u8_t l4_tick; /* if is odd number, use l4 ring first */
+ u8_t dataSentFlag;
+
+ nsfw_res res_chk;
+} common_pcb;
+
+/** A callback prototype to inform about events for a netconn */
+//typedef void (*netconn_callback)(struct spl_netconn *, enum netconn_evt, u16_t len);
+
+/* Though these callback pointers are not set and referenced in nStack Core, still
+the padding is required since the structure will be used in netconn and it needs
+padding across 32-bit and 64-bit architecture */
+typedef struct
+{
+ union
+ {
+ int (*accept_event) (struct spl_netconn * conn);
+ PTR_ALIGN_TYPE accept_event_a;
+ };
+
+ union
+ {
+ int (*recv_event) (struct spl_netconn * conn);
+ PTR_ALIGN_TYPE recv_event_a;
+ };
+ union
+ {
+ int (*send_event) (struct spl_netconn * conn);
+ PTR_ALIGN_TYPE send_event_a;
+ };
+ union
+ {
+ int (*close_event) (struct spl_netconn * conn);
+ PTR_ALIGN_TYPE close_event_a;
+ };
+} callback_funcation;
+
+union ring_addr_u
+{
+ void *ring_addr;
+ PTR_ALIGN_TYPE ring_addr_a;
+};
+
+struct mem_manage
+{
+ volatile uint32_t current_read;
+ volatile uint32_t current_write;
+ union ring_addr_u ring_addr[RECV_MAX_POOL];
+ union ring_addr_u l4_ring; /* recv ring for l4 */
+ //void *ring_addr[RECV_MAX_POOL];
+};
+
+/* Pbuf free should be done in network stack */
+struct spl_netconn_recvbuf_recoder
+{
+ struct spl_pbuf *head;
+ struct spl_pbuf *tail;
+ int totalLen;
+};
+
+/** Register an Network connection event */
+void spl_event_callback (spl_netconn_t * conn, enum spl_netconn_evt evt,
+ int postFlag);
+
+#define SPL_API_EVENT(c, e, p) spl_event_callback(c, e, p)
+
+/** Set conn->last_err to err but don't overwrite fatal errors */
+#define SPL_NETCONN_SET_SAFE_ERR(conn, err) do { \
+ SYS_ARCH_PROTECT(lev); \
+ if (!ERR_IS_FATAL((conn)->last_err)) { \
+ (conn)->last_err = err; \
+ } \
+ SYS_ARCH_UNPROTECT(lev); \
+ } while (0);
+
+/** Set the blocking status of netconn calls (@todo: write/send is missing) */
+#define spl_netconn_set_nonblocking(conn, val) do { if (val) { \
+ (conn)->flags |= SPL_NETCONN_FLAG_NON_BLOCKING; \
+ } else { \
+ (conn)->flags &= ~SPL_NETCONN_FLAG_NON_BLOCKING; }} while (0)
+
+/** Get the blocking status of netconn calls (@todo: write/send is missing) */
+#define spl_netconn_is_nonblocking(conn) (((conn)->flags & SPL_NETCONN_FLAG_NON_BLOCKING) != 0)
+
+/** TCP: Set the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */
+#define spl_netconn_set_noautorecved(conn, val) do { if (val) { \
+ (conn)->flags |= SPL_NETCONN_FLAG_NO_AUTO_RECVED; \
+ } else { \
+ (conn)->flags &= ~SPL_NETCONN_FLAG_NO_AUTO_RECVED; }} while (0)
+
+/** TCP: Get the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */
+#define spl_netconn_get_noautorecved(conn) (((conn)->flags & SPL_NETCONN_FLAG_NO_AUTO_RECVED) != 0)
+
+/** Set the receive timeout in milliseconds */
+#define spl_netconn_set_recvtimeout(cpcb, timeout) ((cpcb)->recv_timeout = (timeout))
+
+/** Get the receive timeout in milliseconds */
+#define spl_netconn_get_recvtimeout(cpcb) ((cpcb)->recv_timeout)
+
+/** Set the send timeout in milliseconds */
+#define spl_netconn_set_sendtimeout(cpcb, timeout) ((cpcb)->send_timeout = (timeout))
+
+/** Get the send timeout in milliseconds */
+#define spl_netconn_get_sendtimeout(cpcb) ((cpcb)->send_timeout)
+
+#define spl_netconn_set_sendbufsize(conn, sendbufsize) ((conn)->send_bufsize = (sendbufsize))
+
+/* "man 7 socket" information
+ SO_SNDBUF
+ Sets or _gets the maximum socket send buffer in bytes. The kernel doubles
+ this value (to allow space for bookkeeping overhead) when it is set using
+ setsockopt(2), and this doubled value is returned by getsockopt(2).
+*/
+#define spl_netconn_get_sendbufsize(conn) (2 *((conn)->send_bufsize))
+
+#define spl_netconn_set_reclowbufsize(cpcb, recvlowbufsize) ((cpcb)->sk_rcvlowat = ((recvlowbufsize) > 0) ? recvlowbufsize : 1)
+#define spl_netconn_get_reclowbufsize(cpcb) ((cpcb)->sk_rcvlowat)
+
+extern int spl_post_msg (u16 mod, u16 maj, u16 min, u16 op, char *data,
+ u16 data_len, u32 src_pid);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif /* __LWIP_API_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_api_msg.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_api_msg.h
new file mode 100644
index 0000000..94b681e
--- /dev/null
+++ b/stacks/lwip_stack/lwip_src/include/stackx/spl_api_msg.h
@@ -0,0 +1,129 @@
+/*
+*
+* 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 __LWIP_API_MSG_H__
+#define __LWIP_API_MSG_H__
+
+#include <stddef.h>
+#include <net/if.h>
+#include <sys/ioctl.h>
+
+#include "nsfw_msg.h"
+#include "spl_opt.h"
+#include "spl_ip_addr.h"
+#include "spl_err.h"
+#include "spl_api.h"
+//#include "sockets.h"
+#include "stackx_spl_share.h"
+#include "stackx_spl_msg.h"
+
+/* From lwip */
+#include "tcp.h"
+#include "udp.h"
+#include "sys.h"
+
+#ifdef HAL_LIB
+#else
+#include "rte_memcpy.h"
+#endif
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+/* For the netconn API, these values are use as a bitmask! */
+#define NETCONN_SHUT_RD 1
+#define NETCONN_SHUT_WR 2
+#define NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR)
+
+struct callback_fn
+{
+ tcp_sent_fn sent_fn;
+ tcp_recv_fn recv_fn;
+ tcp_connected_fn connected_fn;
+ tcp_poll_fn poll_fn;
+ tcp_err_fn err_fn;
+ tcp_err_fn close_fn;
+ tcp_accept_fn accept_fn;
+};
+
+#ifdef HAL_LIB
+#else
+typedef enum _mbuf_recyle_flg
+{
+ MBUF_UNUSED = 0,
+ MBUF_HLD_BY_APP = 1,
+ MBUF_HLD_BY_SPL = 2,
+} mbuf_recycle_flg;
+#endif
+
+err_t sp_enqueue (struct common_pcb *cpcb, void *p);
+err_t accept_dequeue (spl_netconn_t * lconn, void **new_buf,
+ u32_t timeout /*miliseconds */ );
+err_t accept_enqueue (spl_netconn_t * conn, void *p);
+void free_conn_by_spl (spl_netconn_t * conn);
+void unlink_pcb (struct common_pcb *cpcb);
+void do_try_delconn (void *close_data, u32 delay_sec);
+void do_delconn (struct common_pcb *cpcb, msg_delete_netconn * msg);
+void do_bind (struct common_pcb *cpcb, msg_bind * msg);
+void do_pbuf_free (struct spl_pbuf *buf);
+void do_connect (struct common_pcb *cpcb, msg_connect * msg);
+void do_listen (struct common_pcb *cpcb, msg_listen * msg);
+void do_send (struct common_pcb *cpcb, msg_send_buf * msg);
+void do_recv (struct common_pcb *cpcb, msg_recv_buf * msg);
+void do_write (struct common_pcb *cpcb, msg_write_buf * msg);
+void do_getaddr (struct common_pcb *cpcb, msg_getaddrname * msg);
+void do_close (struct common_pcb *cpcb, msg_close * msg);
+void do_getsockopt_internal (struct common_pcb *cpcb,
+ msg_setgetsockopt * smsg);
+void do_setsockopt_internal (struct common_pcb *cpcb,
+ msg_setgetsockopt * smsg);
+void do_getsockname (struct common_pcb *cpcb, msg_getaddrname * amsg);
+int netconn_drain (enum spl_netconn_type t, spl_netconn_t * conn);
+int spl_pcb_new (msg_new_netconn * m);
+void do_app_touch (msg_app_touch * smsg);
+int do_close_finished (struct common_pcb *cpcb, u8_t close_finished,
+ u8_t shut, err_t err, int OpShutDown);
+err_t do_writemore (struct spl_netconn *conn);
+err_t do_close_internal (struct common_pcb *cpcb, int OpShutDown);
+
+u8 get_shut_op (data_com_msg * m);
+int ks_to_stk_opt (int opt);
+void update_tcp_state (spl_netconn_t * conn, enum tcp_state state);
+
+err_t spl_poll_tcp (void *arg, struct tcp_pcb *pcb);
+err_t spl_recv_tcp (void *arg, struct tcp_pcb *pcb, struct pbuf *p,
+ err_t err);
+err_t spl_sent_tcp (void *arg, struct tcp_pcb *pcb, u16_t len);
+void spl_err_tcp (void *arg, err_t err);
+err_t spl_tcp_recv_null (void *arg, struct tcp_pcb *pcb, struct pbuf *p,
+ err_t err);
+err_t spl_do_connected (void *arg, struct tcp_pcb *pcb, err_t err);
+err_t spl_accept_function (void *arg, struct tcp_pcb *newpcb, err_t err);
+
+struct common_pcb *alloc_common_pcb ();
+void free_common_pcb (struct common_pcb *cpcb);
+int common_pcb_init (struct common_pcb *cpcb);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif /* __LWIP_API_MSG_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_err.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_err.h
new file mode 100644
index 0000000..a0188be
--- /dev/null
+++ b/stacks/lwip_stack/lwip_src/include/stackx/spl_err.h
@@ -0,0 +1,40 @@
+/*
+*
+* 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_ERR_H__
+#define __STACKX_ERR_H__
+
+#include "spl_opt.h"
+#include "lwip/arch.h"
+#include "stackx_err.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+typedef s8_t err_t;
+
+/* Definitions for error constants. */
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif /* __LWIP_ERR_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_instance.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_instance.h
new file mode 100644
index 0000000..697c67d
--- /dev/null
+++ b/stacks/lwip_stack/lwip_src/include/stackx/spl_instance.h
@@ -0,0 +1,30 @@
+/*
+*
+* 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 _SPL_INSTANCE_H_
+#define _SPL_INSTANCE_H_
+#include "nsfw_msg_api.h"
+#include "stackx_instance.h"
+
+extern stackx_instance *p_def_stack_instance;
+
+int spl_process (data_com_msg * m);
+
+void add_disp_netif (struct netif *netif);
+void do_update_pcbstate ();
+void init_stackx_lwip ();
+
+#endif /* _SPL_INSTANCE_H_ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_netbuf.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_netbuf.h
new file mode 100644
index 0000000..cd2e1bf
--- /dev/null
+++ b/stacks/lwip_stack/lwip_src/include/stackx/spl_netbuf.h
@@ -0,0 +1,52 @@
+/*
+*
+* 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 __LWIP_NETBUF_H__
+#define __LWIP_NETBUF_H__
+
+#include "spl_opt.h"
+#include "spl_pbuf.h"
+#include "spl_ip_addr.h"
+#include "common_mem_base_type.h"
+#include "common_mem_pal.h"
+#include "common_pal_bitwide_adjust.h"
+#include "stackx_netbuf.h"
+#include <sys/uio.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <errno.h>
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+/** This spl_netbuf has dest-addr/port set */
+#define NETBUF_FLAG_DESTADDR 0x01
+
+/** This spl_netbuf includes a checksum */
+#define NETBUF_FLAG_CHKSUM 0x02
+
+void spl_netbuf_delete (struct spl_netbuf *buf);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif /* __LWIP_NETBUF_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h
new file mode 100644
index 0000000..01fe242
--- /dev/null
+++ b/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h
@@ -0,0 +1,173 @@
+/*
+*
+* 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_PBUF_H__
+#define __STACKX_PBUF_H__
+
+#include "cc.h"
+
+#include "common_mem_base_type.h"
+#include "stackx_pbuf_comm.h"
+#include "common_mem_mbuf.h"
+
+#ifdef HAL_LIB
+#else
+#include "common_pal_bitwide_adjust.h"
+#endif
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+extern u16_t g_offSetArry[SPL_PBUF_MAX_LAYER];
+
+/** indicates this pbuf is loop buf .*/
+#define PBUF_FLAG_LOOPBUF 0x08U
+
+#define PBUF_SET_LOOP_FLAG(buf) ((buf)->flags |= PBUF_FLAG_LOOPBUF)
+#define PBUF_IS_LOOP_BUF(buf) ((buf)->flags & PBUF_FLAG_LOOPBUF)
+
+/*Add 1 parameter, the last one, indicating which dpdk_malloc
+ *should be allocated from the pool; non-PBUF_ALLOC type regardless of this parameter*/
+struct spl_pbuf *spl_pbuf_alloc_hugepage (spl_pbuf_layer l, u16_t length,
+ spl_pbuf_type type,
+ u16_t thread_index, void *net_conn);
+struct pbuf *spl_convert_spl_pbuf_to_pbuf (struct spl_pbuf *p_from);
+err_t pbuf_to_splpbuf_copy (struct spl_pbuf *p_to, struct pbuf *p_from);
+err_t splpbuf_to_pbuf_copy (struct pbuf *p_to, struct spl_pbuf *p_from);
+spl_pbuf_layer get_pbuf_layer_from_pbuf_payload (struct pbuf *buf);
+void print_pbuf_payload_info (struct pbuf *buf, bool send);
+
+static inline u8_t
+spl_pbuf_header (struct spl_pbuf *p, s16_t header_size_increment)
+{
+ u8_t pbuf_ret;
+ /* header max len is tcp len+ ip len: 0xf*4+PBUF_IP_HLEN */
+ if (unlikely
+ (((header_size_increment) < 0 && (-(header_size_increment)) > p->len)
+ || (header_size_increment > 0
+ && (header_size_increment) >= (0xf * 4 + SPL_PBUF_IP_HLEN))))
+ {
+ pbuf_ret = 1;
+ }
+ else
+ {
+ p->payload_a = p->payload_a - (header_size_increment);
+ p->len += (header_size_increment);
+ p->tot_len += (header_size_increment);
+ pbuf_ret = 0;
+ }
+ return pbuf_ret;
+}
+
+void spl_pbuf_realloc (struct spl_pbuf *p, u32_t size);
+
+void spl_pbuf_cat (struct spl_pbuf *head, struct spl_pbuf *tail);
+void spl_pbuf_free (struct spl_pbuf *p);
+
+#define pbuf_free_safe(x)\
+{\
+ spl_pbuf_free((x));\
+ (x) = NULL;\
+}
+
+/**
+ * Count number of pbufs in a chain
+ *
+ * @param p first pbuf of chain
+ * @return the number of pbufs in a chain
+ */
+static inline u16_t
+spl_pbuf_clen (struct spl_pbuf *p)
+{
+ u16_t len = 0;
+ while (p != NULL)
+ {
+ ++len;
+ p = (struct spl_pbuf *) ADDR_SHTOL (p->next_a);
+ }
+ return len;
+}
+
+static inline u16_t
+mbuf_count (struct spl_pbuf *p)
+{
+ u16_t count = 0;
+ struct spl_pbuf *buf = p;
+ struct common_mem_mbuf *mbuf;
+ while (buf)
+ {
+ mbuf =
+ (struct common_mem_mbuf *) ((char *) buf -
+ sizeof (struct common_mem_mbuf));
+ while (mbuf)
+ {
+ count++;
+#ifdef HAL_LIB
+#else
+ mbuf = mbuf->next;
+#endif
+ }
+ buf = (struct spl_pbuf *) ADDR_SHTOL (buf->next_a); //buf->next;
+ }
+ return count;
+}
+
+static inline u16_t
+mbuf_count_in_one_pbuf (struct spl_pbuf *p)
+{
+
+ u16_t cnt = 0;
+ struct common_mem_mbuf *mbuf;
+ if (NULL == p)
+ {
+ NSPOL_LOGERR ("Invalid param : p(null) !");
+ return 0;
+ }
+
+ mbuf =
+ (struct common_mem_mbuf *) ((char *) p - sizeof (struct common_mem_mbuf));
+
+ /* no need to check mbuf itself */
+#ifdef HAL_LIB
+#else
+ if (!mbuf->next)
+#endif
+ return 1;
+
+ while (mbuf)
+ {
+ ++cnt;
+#ifdef HAL_LIB
+#else
+ mbuf = mbuf->next;
+#endif
+ }
+
+ return cnt;
+}
+
+inline int pbuf_internal_copy (struct spl_pbuf *dst, struct spl_pbuf *src);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif /* __STACKX_PBUF_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_sbr.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_sbr.h
new file mode 100644
index 0000000..a4d6ccc
--- /dev/null
+++ b/stacks/lwip_stack/lwip_src/include/stackx/spl_sbr.h
@@ -0,0 +1,33 @@
+/*
+*
+* 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 _SPL_SBR_H_
+#define _SPL_SBR_H_
+#include "nsfw_msg_api.h"
+#include "tcp.h"
+#include "udp.h"
+//#include "stackx/raw.h"
+#define COMM_PRIVATE_PTR(m) \
+ ((m->param.receiver) ? ((struct common_pcb *)m->param.comm_receiver) : 0)
+#define TCP_PRIVATE_PTR(m) \
+ ((m->param.receiver) ? (*(struct tcp_pcb **)m->param.receiver) : 0)
+#define UDP_PRIVATE_PTR(m) \
+ ((m->param.receiver) ? (*(struct udp_pcb **)m->param.receiver) : 0)
+/*#define RAW_PRIVATE_PTR(m) \
+ ((m->param.receiver) ? (*(void *)m->param.receiver) : 0) */
+
+int spl_sbr_process (data_com_msg * m);
+#endif /* _SPL_SBR_H_ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_sockets.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_sockets.h
new file mode 100644
index 0000000..278bb02
--- /dev/null
+++ b/stacks/lwip_stack/lwip_src/include/stackx/spl_sockets.h
@@ -0,0 +1,252 @@
+/*
+*
+* 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_SOCKETS_H__
+#define __STACKX_SOCKETS_H__
+
+#include <errno.h>
+#include <stddef.h> /* for size_t */
+#include "arch/sys_arch.h"
+#include "sys/socket.h"
+#include <errno.h>
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#ifndef socklen_t
+#define socklen_t u32_t
+#endif
+
+#define SET_STACKP_ERRNO(err) (errno = (err)) //thread-local errno
+
+#ifndef set_errno
+#define set_errno(err) SET_STACKP_ERRNO(err)
+#endif
+
+#define sock_set_errno(sk, e) do { \
+ (sk)->err = (e); \
+ if ((sk)->err != 0) \
+ set_errno((sk)->err); \
+ } while (0)
+
+#ifndef __BITS_SOCKET_H
+/* Socket protocol types (TCP/UDP/RAW) */
+#define SOCK_STREAM 1
+#define SOCK_DGRAM 2
+#define SOCK_RAW 3
+/*
+ * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c)
+ */
+#define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info storing */
+#define SO_REUSEADDR 0x0002
+#endif
+
+#define SO_DONTROUTE 5 //0x0010 /* Unimplemented: just use interface addresses */
+#define SO_BROADCAST 6 //0x0020 /* permit to send and to receive broad cast messages*/
+#define SO_KEEPALIVE 9 //0x0008 gaussdb /* keep connections alive */
+#define SO_OOBINLINE 10 //0x0100 /* Unimplemented: leave received OOB data in line */
+#define SO_LINGER 13 //0x0080 /* linger on close if data present */
+#define SO_REUSEPORT 15 /* Unimplemented: allow local address & port reuse */
+#define SO_ACCEPTCONN 30 //0x0002 /* socket has had listen() */
+#define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */
+
+#define SO_DONTLINGER ((int)(~SO_LINGER))
+
+/*
+ * Additional options, not kept in so_options.
+ */
+#define SO_TYPE 3 /* get socket type */
+#define SO_ERROR 4
+#define SO_SNDBUF 7 /* send buffer size */
+#define SO_RCVBUF 8 /* receive buffer size */
+#define SO_NO_CHECK 11 /* don't create UDP checksum */
+#define SO_RCVLOWAT 18 /* receive low-water mark */
+#define SO_SNDLOWAT 19 /* send low-water mark */
+#define SO_RCVTIMEO 20 /* receive timeout */
+#define SO_SNDTIMEO 21 /* Unimplemented: send timeout */
+
+#define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */
+
+/*
+ * Level number for (get/set)sockopt() to apply to socket itself.
+ */
+#define SOL_SOCKET 1 //0xfff
+
+#ifndef __BITS_SOCKET_H
+
+#define AF_UNSPEC 0
+#define PF_UNSPEC AF_UNSPEC
+#define AF_INET 2
+#define PF_INET AF_INET
+
+#define IPPROTO_TCP 6
+#define IPPROTO_UDP 17
+#define IPPROTO_UDPLITE 136
+
+#define IPPROTO_IP 0
+
+#define MSG_PEEK 0x02
+#define MSG_WAITALL 0x100
+#define MSG_OOB 0x01
+#define MSG_DONTWAIT 0x40
+#define MSG_MORE 0x8000
+#endif
+
+#define IP_TOS 1
+#define IP_TTL 2
+
+#define RCV_WND 0x21
+#define RCV_ANN_WND 0x22
+#define INIT_CWND 0x23
+#define THRESHOLD_FACTOR 0x24
+#define TMR_INTERVAL 0x25
+
+/*
+ * Options and types for UDP multicast traffic handling
+ */
+#ifndef __BITS_SOCKET_H
+#define IP_ADD_MEMBERSHIP 3
+#define IP_DROP_MEMBERSHIP 4
+#define IP_MULTICAST_TTL 5
+#define IP_MULTICAST_IF 6
+#define IP_MULTICAST_LOOP 7
+#endif
+
+/*
+ * The Type of Service provides an indication of the abstract
+ * parameters of the quality of service desired. These parameters are
+ * to be used to guide the selection of the actual service parameters
+ * when transmitting a datagram through a particular network. Several
+ * networks offer service precedence, which somehow treats high
+ * precedence traffic as more important than other traffic (generally
+ * by accepting only traffic above a certain precedence at time of high
+ * load). The major choice is a three way tradeoff between low-delay,
+ * high-reliability, and high-throughput.
+ * The use of the Delay, Throughput, and Reliability indications may
+ * increase the cost (in some sense) of the service. In many networks
+ * better performance for one of these parameters is coupled with worse
+ * performance on another. Except for very unusual cases at most two
+ * of these three indications should be set.
+ */
+#define IPTOS_LOWCOST 0x02
+#define IPTOS_RELIABILITY 0x04
+#define IPTOS_THROUGHPUT 0x08
+#define IPTOS_LOWDELAY 0x10
+#define IPTOS_TOS_MASK 0x1E
+#define IPTOS_MINCOST IPTOS_LOWCOST
+#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
+
+/*
+ * The Network Control precedence designation is intended to be used
+ * within a network only. The actual use and control of that
+ * designation is up to each network. The Internetwork Control
+ * designation is intended for use by gateway control originators only.
+ * If the actual use of these precedence designations is of concern to
+ * a particular network, it is the responsibility of that network to
+ * control the access to, and use of, those precedence designations.
+ */
+#define IPTOS_PREC_ROUTINE 0x00
+#define IPTOS_PREC_PRIORITY 0x20
+#define IPTOS_PREC_IMMEDIATE 0x40
+#define IPTOS_PREC_FLASH 0x60
+#define IPTOS_PREC_FLASHOVERRIDE 0x80
+#define IPTOS_PREC_CRITIC_ECP 0xa0
+#define IPTOS_PREC_INTERNETCONTROL 0xc0
+#define IPTOS_PREC_MASK 0xe0
+#define IPTOS_PREC_NETCONTROL 0xe0
+#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
+
+#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 /* !defined(FIONREAD) || !defined(FIONBIO) */
+
+#ifndef FIONREAD
+#define FIONREAD _IOR('f', 127, unsigned long)
+#endif
+#ifndef FIONBIO
+#define FIONBIO _IOW('f', 126, unsigned long)
+#endif
+
+/*unimplemented */
+#ifndef SIOCSHIWAT
+#define SIOCSHIWAT _IOW('s', 0, unsigned long)
+#define SIOCGHIWAT _IOR('s', 1, unsigned long)
+#define SIOCSLOWAT _IOW('s', 2, unsigned long)
+#define SIOCGLOWAT _IOR('s', 3, unsigned long)
+#ifndef __BITS_SOCKET_H
+#define SIOCATMARK _IOR('s', 7, unsigned long)
+#endif
+#endif
+
+/* commands for fnctl */
+#ifndef F_GETFL
+#define F_GETFL 3
+#endif
+#ifndef F_SETFL
+#define F_SETFL 4
+#endif
+
+/* File status flags and file access modes for fnctl,
+ these are bits in an int. */
+#ifndef O_NONBLOCK
+#define O_NONBLOCK 0X800 /* nonblocking I/O */
+#endif
+#ifndef O_NDELAY
+#define O_NDELAY O_NONBLOCK /* same as O_NONBLOCK, for compatibility */
+#endif
+
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0x80000 /* set close_on_exec */
+#endif
+#ifndef __BITS_SOCKET_H
+#define SOCK_CLOEXEC O_CLOEXEC
+#endif
+#ifndef FD_CLOEXEC
+#define FD_CLOEXEC 1
+#endif
+#ifndef SHUT_RD
+#define SHUT_RD 0
+#define SHUT_WR 1
+#define SHUT_RDWR 2
+#endif
+
+struct pollfd
+{
+
+ int fd; /* file descriptor */
+ short events; /* wait event */
+ short revents; /* actual event happened */
+};
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif /* __STACKX_SOCKETS_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_tcpip.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_tcpip.h
new file mode 100644
index 0000000..0f885d6
--- /dev/null
+++ b/stacks/lwip_stack/lwip_src/include/stackx/spl_tcpip.h
@@ -0,0 +1,80 @@
+/*
+*
+* 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_TCPIP_H__
+#define __STACKX_TCPIP_H__
+
+#include "spl_opt.h"
+#include "stackx/spl_ip_addr.h"
+#include "tcp.h"
+
+#define USEAGE_LOW 60
+#define USEAGE_HIGHT 80
+#define USEAGE_INVALID 0xFF
+
+/*** Put into stackx_instance *********
+
+************************************/
+#include "stackx/spl_api_msg.h"
+#include "netifapi.h"
+#include "stackx/spl_pbuf.h"
+#include "stackx/spl_api.h"
+#include "sys.h"
+#include "netif.h"
+#include "ip_module_api.h"
+#include "internal_msg.h"
+#include "pbuf.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+/** Function prototype for send timeout message */
+err_t ltt_apimsg (sys_timeout_handler h, void *arg);
+
+/** Function prototype for the init_done function passed to tcpip_init */
+typedef void (*tcpip_init_done_fn) (void *arg);
+
+/** Function prototype for functions passed to tcpip_callback() */
+typedef void (*tcpip_callback_fn) (void *ctx);
+
+int init_by_main_thread ();
+int init_by_tcpip_thread ();
+err_t spl_tcpip_input (struct pbuf *p, struct netif *inp);
+
+int post_ip_module_msg (void *arg, ip_module_type type,
+ ip_module_operate_type operate_type);
+int process_ip_module_msg (void *arg, ip_module_type type,
+ ip_module_operate_type operate_type);
+int init_new_network_configuration ();
+
+#if STACKX_NETIF_API
+err_t tcpip_netif_add (msg_add_netif * tmp);
+#endif /* STACKX_NETIF_API */
+
+err_t ltt_clearTmrmsg (void *pcb, void *arg);
+
+sys_mbox_t get_primary_box ();
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif /* __STACKX_TCPIP_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_timers.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_timers.h
new file mode 100644
index 0000000..4809b2b
--- /dev/null
+++ b/stacks/lwip_stack/lwip_src/include/stackx/spl_timers.h
@@ -0,0 +1,108 @@
+/*
+*
+* 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 __SPL_TIMERS_H__
+#define __SPL_TIMERS_H__
+
+#include "opt.h"
+#include "common_mem_base_type.h"
+
+typedef void (*sys_timeout_handler) (void *arg);
+
+#include "rb_tree.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+/** Function prototype for a timeout callback function. Register such a function
+ * using sys_timeout().
+ *
+ * @param arg Additional argument to pass to the function - set up by sys_timeout()
+ */
+
+/*
+ * *************************************************************************
+ * PTIMER defined 2013/3/15
+ * *************************************************************************
+ */
+#define PTIMER_DEFAULT 0x00 /* periodic mode */
+#define PTIMER_ONESHOT 0x01
+#define PTIMER_USER_DEF 0x02
+
+enum msg_type
+{
+ SYS_PTIMEROUT_MSG,
+ SYS_UNPTIMEROUT_MSG,
+};
+
+struct msg_context
+{
+ unsigned long msec;
+ union
+ {
+ sys_timeout_handler handle;
+ } action;
+#define _act_category action.act_category
+#define _phandle action.handle
+ u32_t flags; /* oneshot|user_def|... */
+ void *ctx; /* pcb ptr */
+};
+
+struct ptimer_node
+{
+ struct rb_node node;
+ unsigned long abs_nsec;
+ struct msg_context info;
+ unsigned long state;
+ u16_t index; /* store a lwip thread message box id */
+};
+
+struct ptimer_msg
+{
+ enum msg_type msg_type;
+ struct ptimer_node *node;
+ struct ptimer_msg *next, *prev;
+};
+
+struct ptimer_base
+{
+ struct rb_root active;
+ struct rb_node *first; /* point the recently timeout */
+ pthread_mutex_t lock;
+ pthread_cond_t cond;
+ struct ptimer_msg *head, *tail;
+};
+
+/*
+ * *****************************************************
+ * ptimer E-N-D
+ * *****************************************************
+ */
+void ptimer_thread (void *arg);
+void timeout_phandler (void *act, void *arg);
+void regedit_ptimer (enum msg_type type, sys_timeout_handler handler,
+ struct ptimer_node *node);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif /* __LWIP_TIMERS_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/stackx_instance.h b/stacks/lwip_stack/lwip_src/include/stackx/stackx_instance.h
new file mode 100644
index 0000000..679d2ac
--- /dev/null
+++ b/stacks/lwip_stack/lwip_src/include/stackx/stackx_instance.h
@@ -0,0 +1,91 @@
+/*
+*
+* 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_INSTANCE_H__
+#define __STACKX_INSTANCE_H__
+
+#include "stackx/spl_tcpip.h"
+#include "netif.h"
+#include "lwip/ip4_frag.h"
+#include "stackx/spl_pbuf.h"
+#include "arch/sys_arch.h"
+#include "arch/queue.h"
+#include "stackx_tx_box.h"
+#include "nsfw_msg.h"
+#include "stackx_app_res.h"
+#include "ip_module_api.h"
+#include "tcp.h"
+#include "udp.h"
+
+#define PKT_BURST 32
+
+#define TASK_BURST 16
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#define MAX_NETBUFS 1024*2 //define for C10M
+
+#define TOTAL_MSG_QUEUE_NUM (MSG_PRIO_QUEUE_NUM+1) /* three priority queue and one primary queue */
+
+struct stackx_stat
+{
+ struct rti_queue primary_stat; //primary box stat
+ u64_t extend_member_bit;
+};
+
+struct stackx_stack
+{
+ struct queue primary_mbox;
+ struct queue priority_mbox[MSG_PRIO_QUEUE_NUM]; //0-highest; 1-medium; 2-lowest
+ //stackx_apis stackx_api;
+};
+
+struct disp_netif_list
+{
+ struct disp_netif_list *next;
+ struct netif *netif;
+};
+
+typedef struct stackx_instance
+{
+ uint16_t rss_queue_id;
+
+ mpool_handle mp_tx;
+ //mring_handle mp_seg;
+ mring_handle cpcb_seg;
+ mring_handle lmsg_pool;
+
+ struct stackx_stack lstack;
+ struct stackx_stat lstat; //point to p_stackx_table->lstat[i];
+
+ /**
+ * Header of the input packet currently being processed.
+ */
+ /* global variables */
+ struct disp_netif_list *netif_list;
+} stackx_instance;
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif /* __STACKX_INSTANCE_H__ */