aboutsummaryrefslogtreecommitdiffstats
path: root/src/framework/include
diff options
context:
space:
mode:
authorqchang <qing.chang1@huawei.com>2018-03-08 17:39:22 -0800
committerqchang <qing.chang1@huawei.com>2018-03-08 17:39:22 -0800
commit697ade6190b23c80e7f60963983786e679759393 (patch)
treedd9782d1e936b8342163b26795e23571d4b1b415 /src/framework/include
parent71a4e2f34afa8018426f0e830050e50a1de6d375 (diff)
dmm initial commit
Change-Id: I049ee277cf4efdb83f9c2ac439365fcd421c159b Signed-off-by: qchang <qing.chang1@huawei.com>
Diffstat (limited to 'src/framework/include')
-rw-r--r--src/framework/include/hal_api.h148
-rw-r--r--src/framework/include/nsfw_fd_timer_api.h64
-rw-r--r--src/framework/include/nsfw_init.h148
-rw-r--r--src/framework/include/nsfw_maintain_api.h320
-rw-r--r--src/framework/include/nsfw_mem_api.h546
-rw-r--r--src/framework/include/nsfw_mgr_com_api.h198
-rw-r--r--src/framework/include/nsfw_ps_api.h134
-rw-r--r--src/framework/include/nsfw_ps_mem_api.h36
-rw-r--r--src/framework/include/nsfw_recycle_api.h92
-rw-r--r--src/framework/include/nsfw_snapshot.h144
-rw-r--r--src/framework/include/nsfw_upgrade.h51
-rw-r--r--src/framework/include/nstack_log.h580
-rw-r--r--src/framework/include/nstack_rd_data.h80
-rw-r--r--src/framework/include/nstack_securec.h145
-rw-r--r--src/framework/include/nstack_trace.h76
15 files changed, 2762 insertions, 0 deletions
diff --git a/src/framework/include/hal_api.h b/src/framework/include/hal_api.h
new file mode 100644
index 0000000..24ed779
--- /dev/null
+++ b/src/framework/include/hal_api.h
@@ -0,0 +1,148 @@
+/*
+*
+* 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 _HAL_API_H_
+#define _HAL_API_H_
+
+#include "common_mem_mbuf.h"
+#include "common_mem_mempool.h"
+#include "common_func.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#define HAL_ETH_MAX_QUEUE_NUM 4
+
+#define HAL_ETH_QUEUE_STAT_CNTRS 16
+
+#define HAL_MAX_NIC_NUM 4096
+COMPAT_PROTECT (HAL_MAX_NIC_NUM, 4096);
+
+#define HAL_MAX_SLAVES_PER_BOND 2
+
+#define HAL_MAX_NIC_NAME_LEN 256
+
+/**
+ * TX offload capabilities of a device.
+ */
+#define HAL_ETH_TX_OFFLOAD_IPV4_CKSUM 0x00000002
+#define HAL_ETH_TX_OFFLOAD_UDP_CKSUM 0x00000004
+#define HAL_ETH_TX_OFFLOAD_TCP_CKSUM 0x00000008
+
+/**
+ * Hal Instance Handler
+ */
+typedef struct hal_hdl
+{
+ int id;
+} hal_hdl_t;
+
+/**
+ * Ethernet device capability
+ */
+typedef struct hal_netif_capa
+{
+ uint32_t tx_offload_capa; /**< Device TX offload capabilities. */
+} hal_netif_capa_t;
+
+/**
+ * A structure used to retrieve statistics for an Ethernet port.
+ */
+typedef struct hal_netif_stats
+{
+ uint64_t ipackets; /**< Total no.of packets that are successfully received . */
+ uint64_t opackets; /**< Total no.of packets that are successfully transmitted .*/
+ uint64_t ibytes; /**< Total no.of bytes that are successfully received . */
+ uint64_t obytes; /**< Total no.of bytes that are successfully transmitted . */
+ uint64_t imissed; /**< Total no.of RX packets that are dropped by the HW. */
+ uint64_t ierrors; /**< Total no.of packets that are received as erroneous. */
+ uint64_t oerrors; /**< Total no.of failed transmitted packets. */
+ uint64_t rx_nombuf; /**< Total no.of RX mbuf allocation failures. */
+
+ uint64_t q_ipackets[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total no.of queue RX packets. */
+ uint64_t q_opackets[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total no.of queue TX packets. */
+ uint64_t q_ibytes[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total no.of successfully received queue bytes. */
+ uint64_t q_obytes[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total no.of successfully transmitted queue bytes. */
+ uint64_t q_errors[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total no.of queue packets received that are dropped. */
+} hal_netif_stats_t;
+
+/**
+ * Ethernet device config
+ */
+typedef struct hal_netif_config
+{
+ struct
+ {
+ uint32_t hw_vlan_filter:1;
+ uint32_t hw_vlan_strip:1;
+ uint32_t rsv30:30;
+ } bit;
+
+ struct
+ {
+ uint32_t queue_num;
+ uint32_t ring_size[HAL_ETH_MAX_QUEUE_NUM];
+ struct common_mem_mempool *ring_pool[HAL_ETH_MAX_QUEUE_NUM];
+ } rx;
+
+ struct
+ {
+ uint32_t queue_num;
+ uint32_t ring_size[HAL_ETH_MAX_QUEUE_NUM];
+ } tx;
+
+} hal_netif_config_t;
+
+int hal_init_global (int argc, char **argv);
+int hal_init_local ();
+hal_hdl_t hal_create (const char *name, hal_netif_config_t * conf);
+hal_hdl_t hal_bond (const char *bond_name, uint8_t slave_num,
+ hal_hdl_t slave_hdl[]);
+
+#define hal_is_valid(hdl) ((hdl.id >= 0) && (hdl.id < HAL_MAX_NIC_NUM))
+
+#define hal_is_equal(hdl_left, hdl_right) (hdl_left.id == hdl_right.id)
+
+int hal_close (hal_hdl_t hdl);
+int hal_stop (hal_hdl_t hdl);
+uint32_t hal_get_mtu (hal_hdl_t hdl);
+void hal_get_macaddr (hal_hdl_t hdl, void *mac_addr);
+void hal_get_capability (hal_hdl_t hdl, hal_netif_capa_t * info);
+uint16_t hal_recv_packet (hal_hdl_t hdl, uint16_t queue_id,
+ struct common_mem_mbuf **rx_pkts, uint16_t nb_pkts);
+uint16_t hal_send_packet (hal_hdl_t hdl, uint16_t queue_id,
+ struct common_mem_mbuf **tx_pkts, uint16_t nb_pkts);
+uint32_t hal_link_status (hal_hdl_t hdl);
+int hal_stats (hal_hdl_t hdl, hal_netif_stats_t * stats);
+void hal_stats_reset (hal_hdl_t hdl);
+int hal_add_mcastaddr (hal_hdl_t hdl, void *mc_addr_set,
+ void *mc_addr, uint32_t nb_mc_addr);
+int hal_del_mcastaddr (hal_hdl_t hdl, void *mc_addr_set,
+ void *mc_addr, uint32_t nb_mc_addr);
+void hal_set_allmulti_mode (hal_hdl_t hdl, uint8_t enable);
+uint32_t hal_is_nic_exist (const char *name);
+hal_hdl_t hal_get_invalid_hdl ();
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif
diff --git a/src/framework/include/nsfw_fd_timer_api.h b/src/framework/include/nsfw_fd_timer_api.h
new file mode 100644
index 0000000..0b42fe0
--- /dev/null
+++ b/src/framework/include/nsfw_fd_timer_api.h
@@ -0,0 +1,64 @@
+/*
+*
+* 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 _NSFW_FD_TIMER_API_H
+#define _NSFW_FD_TIMER_API_H
+
+#include "list.h"
+#include <time.h>
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#define NSFW_TIMER_MODULE "nsfw_timer"
+
+typedef struct _nsfw_timer_init_cfg
+{
+ u32 timer_info_size;
+ void *timer_info_pool;
+ struct list_head timer_head;
+ struct list_head exp_timer_head;
+} nsfw_timer_init_cfg;
+
+typedef int (*nsfw_timer_proc_fun) (u32 timer_type, void *argv);
+typedef struct _nsfw_timer_info
+{
+ struct list_head node;
+ nsfw_timer_proc_fun fun;
+ void *argv;
+ struct timespec time_left;
+ u32 timer_type;
+ u8 alloc_flag;
+} nsfw_timer_info;
+
+extern nsfw_timer_info *nsfw_timer_reg_timer (u32 timer_type, void *data,
+ nsfw_timer_proc_fun fun,
+ struct timespec time_left);
+extern void nsfw_timer_rmv_timer (nsfw_timer_info * tm_info);
+
+extern u8 g_hbt_switch;
+extern int nsfw_timer_module_init (void *param);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#endif /* _NSFW_FD_TIMER_API_H */
diff --git a/src/framework/include/nsfw_init.h b/src/framework/include/nsfw_init.h
new file mode 100644
index 0000000..def97b2
--- /dev/null
+++ b/src/framework/include/nsfw_init.h
@@ -0,0 +1,148 @@
+/*
+*
+* 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 _FW_INIT_H
+#define _FW_INIT_H
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#define NSFW_INIT_PRIORITY_ROOT 101
+#define NSFW_INIT_PRIORITY_BASE 102
+#define NSFW_INIT_PRIORITY_INITFN 103
+
+#define NSFW_INIT_MODULE_PRIORITY_BASE 1
+#define NSFW_INIT_MODULE_PRIORITY(x) (NSFW_INIT_MODULE_PRIORITY_BASE + x)
+
+#define NSFW_SET_INSTANCE_VALUE(_attr, _inst, _value) \
+ nsfw_module_set_instance_##_attr(_inst, _value)
+
+#define NSFW_INIT_CRAETE_LOCAL_INSTANCE() \
+ if (!nsfwLocalInitInst) {\
+ nsfwLocalInitInst = nsfw_module_create_instance(); \
+ nsfw_module_add_instance(nsfwLocalInitInst);\
+ }
+
+#define _NSFW_MODULE_ATTRIBUTE_DEFINE_SURFIX(_attr, _value, _priority, _surfix) \
+ static __attribute__((__constructor__(_priority))) void nsfw_module_attribute_##_attr##_surfix(void){\
+ NSFW_INIT_CRAETE_LOCAL_INSTANCE(); \
+ NSFW_SET_INSTANCE_VALUE(_attr, nsfwLocalInitInst, _value);\
+ } \
+
+#define NSFW_MODULE_ATTRIBUTE_DEFINE_SURFIX(_attr, _value, _priority, _surfix) \
+ _NSFW_MODULE_ATTRIBUTE_DEFINE_SURFIX(_attr, _value, _priority, _surfix)
+
+#define NSFW_MODULE_ATTRIBUTE_DEFINE_UNIQUE(_attr, _value, _priority) \
+ NSFW_MODULE_ATTRIBUTE_DEFINE_SURFIX(_attr, _value, _priority, __LINE__)
+
+#define NSFW_MODULE_ATTRIBUTE_DEFINE(_attr, _value, _priority) \
+ NSFW_MODULE_ATTRIBUTE_DEFINE_UNIQUE(_attr, _value, _priority)
+
+#define NSFW_MODULE_NAME(_name) \
+ NSFW_MODULE_ATTRIBUTE_DEFINE(name, _name, NSFW_INIT_PRIORITY_BASE)
+
+#define NSFW_MODULE_FATHER(_father) \
+ NSFW_MODULE_ATTRIBUTE_DEFINE(father, _father, NSFW_INIT_PRIORITY_BASE)
+
+#define NSFW_MODULE_PRIORITY(_priority) \
+ NSFW_MODULE_ATTRIBUTE_DEFINE(priority, _priority, NSFW_INIT_PRIORITY_BASE)
+
+#define NSFW_MODULE_DEPENDS(_depends) \
+ NSFW_MODULE_ATTRIBUTE_DEFINE(depends, _depends, NSFW_INIT_PRIORITY_BASE)
+
+#define NSFW_MODULE_INIT(_initfn) \
+ NSFW_MODULE_ATTRIBUTE_DEFINE(initfn, _initfn, NSFW_INIT_PRIORITY_INITFN)
+
+#define NSFW_MAX_STRING_LENGTH 128
+
+#define NSFW_DEPENDS_SIZE 8
+typedef struct _nsfw_module_depends
+{
+ char name[NSFW_MAX_STRING_LENGTH];
+ int isReady;
+ struct _nsfw_module_depends *next; /* It is a list, not just only one */
+} nsfw_module_depends_t;
+
+typedef enum
+{
+ NSFW_INST_STAT_CHECKING, /* Not check yet */
+ NSFW_INST_STAT_DEPENDING, /* Blocked, waiting for other module instances */
+ NSFW_INST_STAT_DONE, /* Check done */
+ NSFW_INST_STAT_FAIL /* Check Fail */
+} nsfw_module_instance_stat_t;
+
+typedef int (*nsfw_module_init_fn) (void *);
+
+typedef struct _nsfw_module_instance
+{
+ nsfw_module_init_fn fnInit;
+ char name[NSFW_MAX_STRING_LENGTH];
+ char fatherName[NSFW_MAX_STRING_LENGTH];
+ int priority;
+ nsfw_module_depends_t *depends;
+ nsfw_module_instance_stat_t stat;
+ void *param;
+ struct _nsfw_module_instance *next;
+ struct _nsfw_module_instance *child;
+ struct _nsfw_module_instance *father;
+} nsfw_module_instance_t;
+
+static nsfw_module_instance_t *nsfwLocalInitInst __attribute__ ((unused)) =
+ (void *) 0;
+
+extern nsfw_module_instance_t *nsfw_module_create_instance ();
+extern nsfw_module_instance_t *nsfw_module_getModuleByName (char *);
+extern void nsfw_module_add_instance (nsfw_module_instance_t * inst);
+extern void nsfw_module_del_instance (nsfw_module_instance_t * inst);
+extern void nsfw_module_set_instance_name (nsfw_module_instance_t * inst,
+ char *name);
+extern void nsfw_module_set_instance_father (nsfw_module_instance_t * inst,
+ char *father);
+extern void nsfw_module_set_instance_priority (nsfw_module_instance_t *
+ inst, int priority);
+extern void nsfw_module_set_instance_initfn (nsfw_module_instance_t * inst,
+ nsfw_module_init_fn fn);
+extern void nsfw_module_set_instance_depends (nsfw_module_instance_t * inst,
+ char *name);
+
+/**
+ * @Function nstack_framework_init
+ * @Description This function will do framework initial work, it will involk all initial functions
+ * registed using macro NSFW_MODULE_INIT before
+ * @param none
+ * @return 0 on success, -1 on error
+ */
+extern int nstack_framework_init (void);
+
+/**
+ * @Function nstack_framework_setModuleParam
+ * @Description This function set parameter of module initial function parameter
+ * @param module - name of module
+ * @param param - parameter to set
+ * @return 0 on success, -1 on error
+ */
+extern int nstack_framework_setModuleParam (char *module, void *param);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#endif /* _FW_INIT_H */
diff --git a/src/framework/include/nsfw_maintain_api.h b/src/framework/include/nsfw_maintain_api.h
new file mode 100644
index 0000000..74cedf6
--- /dev/null
+++ b/src/framework/include/nsfw_maintain_api.h
@@ -0,0 +1,320 @@
+/*
+*
+* 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 _NSFW_MEM_STAT_API_H
+#define _NSFW_MEM_STAT_API_H
+
+#include "types.h"
+#include "nsfw_mgr_com_api.h"
+#include "compiling_check.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+/*################MEM_STAT######################*/
+#define NSFW_MEM_MODULE_LEN 32
+#define NSFW_MEM_NAME_LEN 64
+
+#define OMC_PROC_MM "omc_proc_maintain"
+
+#define MEM_STAT(module, mem_name, mem_type, mem_size)\
+ nsfw_mem_stat(module, mem_name, mem_type, mem_size)
+
+extern void nsfw_mem_stat (char *module, char *mem_name, u8 mem_type,
+ u32 mem_size);
+extern void nsfw_mem_stat_print ();
+/*##############################################*/
+
+/*################SRV_CTRL######################*/
+typedef enum _nsfw_srv_ctrl_state
+{
+ NSFW_SRV_CTRL_RESUME = 1,
+ NSFW_SRV_CTRL_SUSPEND = 2
+} nsfw_srv_ctrl_state;
+
+typedef struct _nsfw_srv_ctrl_msg
+{
+ nsfw_srv_ctrl_state srv_state;
+ u16 rsp_code;
+} nsfw_srv_ctrl_msg;
+extern u8 nsfw_srv_ctrl_send (nsfw_srv_ctrl_state state, u8 rsp_flag);
+/*#############################################*/
+
+/*#################RES_MGR######################*/
+#define NSFW_RES_MGR_MODULE "nsfw_res_mgr"
+
+typedef enum _nsfw_res_scan_type
+{
+ NSFW_RES_SCAN_ARRAY = 0,
+ NSFW_RES_SCAN_SPOOL,
+ NSFW_RES_SCAN_MBUF,
+ NSFW_RES_SCAN_MAX
+} nsfw_res_scan_type;
+
+typedef int (*nsfw_res_free_fun) (void *pdata);
+
+typedef struct _nsfw_res_scn_cfg
+{
+ u8 type; /*nsfw_res_scan_type */
+ u8 force_free_percent; /*if the resource free percent below this vlaue, begin to force free the element */
+ u16 force_free_chk_num; /*if the check count beyone this vlaue, call free fun release this element */
+ u16 alloc_speed_factor; /*alloc fast with higher value */
+
+ u32 num_per_cyc; /*define the element number in one scan cycle process and increase chk_count of every element */
+ u32 total_num; /*total number of elements */
+ u32 elm_size; /*element size */
+ u32 res_mem_offset; /*the nsfw_res offset from the element start */
+
+ void *data; /*the array addr or spool addr */
+ void *mgr_ring;
+
+ nsfw_res_free_fun free_fun;
+} nsfw_res_scn_cfg;
+
+typedef struct _nsfw_res_mgr_item_cfg
+{
+ nsfw_res_scn_cfg scn_cfg;
+ u32 cons_head;
+ u32 prod_head;
+ u32 free_percent;
+ u32 last_scn_idx;
+ u64 force_count;
+} nsfw_res_mgr_item_cfg;
+
+#define NSFW_MAX_RES_SCAN_COUNT 256
+
+extern u8 nsfw_res_mgr_reg (nsfw_res_scn_cfg * cfg);
+extern i32 nsfw_proc_start_with_lock (u8 proc_type);
+/*#############################################*/
+
+typedef enum _nsfw_exit_code
+{
+ NSFW_EXIT_SUCCESS = 0,
+ NSFW_EXIT_FAILED = 1,
+ NSFW_EXIT_DST_ERROR = 2,
+ NSFW_EXIT_TIME_OUT = 3,
+
+ NSFW_EXIT_MAX_COM_ERR = 31,
+} nsfw_exit_code;
+
+/*#############################################*/
+
+/*#################SOFT_PARAM##################*/
+#define NSFW_SOFT_PARAM_MODULE "nsfw_soft_param"
+
+typedef struct _nsfw_soft_param_msg
+{
+ u32 param_name;
+ u32 rsp_code;
+ u8 param_value[NSFW_MGR_MSG_BODY_LEN - sizeof (u32) - sizeof (u32)];
+}
+nsfw_soft_param_msg;
+
+typedef enum _nsfw_soft_param
+{
+ NSFW_DBG_MODE_PARAM = 1,
+ NSFW_HBT_TIMER = 2,
+ NSFW_HBT_COUNT_PARAM = 3,
+ NSFW_APP_EXIT_TIMER = 4,
+ NSFW_SRV_RESTORE_TIMER = 5,
+ NSFW_APP_RESEND_TIMER = 6,
+ NSFW_APP_SEND_PER_TIME = 7,
+
+ NSFW_MAX_SOFT_PARAM = 1024
+} nsfw_soft_param;
+
+typedef int (*nsfw_set_soft_fun) (u32 param, char *buf, u32 buf_len);
+extern u8 nsfw_soft_param_reg_fun (u32 param_name, nsfw_set_soft_fun fun);
+extern u8 nsfw_soft_param_reg_int (u32 param_name, u32 size, u32 min,
+ u32 max, u64 * data);
+
+extern void nsfw_set_soft_para (fw_poc_type proc_type, u32 para_name,
+ void *value, u32 size);
+
+extern int nsfw_isdigitstr (const char *str);
+#define NSFW_REG_SOFT_INT(_param,_data,_min, _max) nsfw_soft_param_reg_int(_param,sizeof(_data),_min,_max,(u64*)&_data)
+/*#############################################*/
+
+/*#################LOG_CONFIG##################*/
+#define NSFW_LOG_CFG_MODULE "nsfw_log_cfg"
+
+#define NSFW_MODULE_NAME_LEN 20
+#define NSFW_LOG_LEVEL_LEN 10
+#define NSFW_LOG_VALUE_LEN 256
+
+typedef struct _nsfw_set_log_msg
+{
+ u16 rsp_code;
+ char module[NSFW_MODULE_NAME_LEN];
+ char log_level[NSFW_LOG_VALUE_LEN];
+} nsfw_set_log_msg;
+/*#############################################*/
+
+/*################## DFX ######################*/
+#define MAX_DFX_QRY_RES_LEN 28
+
+#define SPL_DFX_RES_ALL "all"
+#define SPL_DFX_RES_QUEUE "queue"
+#define SPL_DFX_RES_CONN "conn"
+#define SPL_DFX_RES_L2TO4 "l2to4"
+#define SPL_DFX_RES_UNMATCH "version"
+#define SPL_DFX_RES_SOCKT_CB "socketcb"
+#define SPL_DFX_RES_COMM_MEMPOOL "mbufpool"
+#define SPL_DFX_RES_PCBLIST "pcblist"
+#define SPL_DFX_RES_ARPLIST "arplist"
+
+typedef enum
+{
+ DFX_ACTION_SNAPSHOT,
+ DFX_ACTION_RST_STATS,
+ DFX_ACTION_SWITCH,
+ DFX_ACTION_MAX
+} dfx_module_action;
+
+typedef struct _nsfw_dfx_qry_msg
+{
+ dfx_module_action action;
+ char resource[MAX_DFX_QRY_RES_LEN];
+ char flag; //for snapshot print "all"
+} nsfw_dfx_qry_msg;
+
+typedef enum
+{
+ QUERY_ACTION_GET,
+ QUERY_ACTION_MAX
+} query_action;
+
+typedef struct _nsfw_qry_msg
+{
+ query_action action;
+ char resource[MAX_DFX_QRY_RES_LEN];
+} nsfw_get_qry_msg;
+
+/*##################DFX#########################*/
+
+/*#################for tcpdump#####################*/
+
+#ifndef nstack_min
+#define nstack_min(a, b) (a) < (b) ? (a) : (b)
+#endif
+
+#define GET_CUR_TIME(ptime) \
+ (void)clock_gettime(CLOCK_MONOTONIC, ptime);
+
+#define TCPDUMP_MODULE "tcpdump_tool"
+
+#define DUMP_MSG_NUM (64 * 1024)
+COMPAT_PROTECT (DUMP_MSG_NUM, 64 * 1024);
+#define DUMP_MSG_SIZE 128 // can not be less than 14
+COMPAT_PROTECT (DUMP_MSG_SIZE, 128);
+
+#define DEFAULT_DUMP_TIME 600
+#define MAX_DUMP_TIME 86400
+#define MIN_DUMP_TIME 1
+
+#define MAX_DUMP_TASK 16
+#define DUMP_HBT_INTERVAL 2
+#define DUMP_HBT_CHK_INTERVAL 4
+#define DUMP_TASK_HBT_TIME_OUT 30
+
+#define DUMP_SHMEM_RIGN_NAME "tcpdump_ring"
+#define DUMP_SHMEM_POOL_NAME "tcpdump_pool"
+
+enum L2_PROTOCOL
+{
+ PROTOCOL_IP = 0x0800,
+ PROTOCOL_ARP = 0x0806,
+ PROTOCOL_RARP = 0x8035,
+ PROTOCOL_OAM_LACP = 0x8809,
+ INVALID_L2_PROTOCOL = 0xFFFF
+};
+
+enum L3_PROTOCOL
+{
+ PROTOCOL_ICMP = 1,
+ PROTOCOL_TCP = 6,
+ PROTOCOL_UDP = 17,
+ INVALID_L3_PROTOCOL = 0xFF
+};
+
+enum DUMP_MSG_DIRECTION
+{
+ DUMP_SEND = 1,
+ DUMP_RECV = 2,
+ DUMP_SEND_RECV = 3
+};
+
+enum DUMP_MSG_TYPE
+{
+ START_DUMP_REQ,
+ STOP_DUMP_REQ,
+ TOOL_COM_HBT_REQ,
+
+ DUMP_MSG_TYPE_RSP = 0x00010000,
+
+ START_DUMP_RSP = START_DUMP_REQ + DUMP_MSG_TYPE_RSP,
+ STOP_DUMP_RSP = STOP_DUMP_REQ + DUMP_MSG_TYPE_RSP,
+
+ DUMP_MSG_TYPE_INVALID
+};
+
+typedef struct _nsfw_tool_hbt
+{
+ u32 seq;
+ i16 task_id;
+} nsfw_tool_hbt;
+
+typedef struct _nsfw_tool_dump_msg
+{
+ u16 op_type;
+ i16 task_id;
+ u32 task_keep_time;
+} nsfw_tool_dump_msg;
+
+typedef struct _dump_msg_info
+{
+ u32 len;
+ u16 direction; // 1:SEND, 2:RECV
+ u32 dump_sec;
+ u32 dump_usec;
+ nsfw_res res_chk;
+ char buf[1];
+} dump_msg_info;
+
+typedef struct _dump_timer_info
+{
+ u32 seq;
+ i16 task_id;
+ void *interval;
+ void *ptimer;
+} dump_timer_info;
+
+extern void ntcpdump_loop (void *buf, u32 buf_len, u16 direction,
+ void *eth_addr);
+extern void ntcpdump (void *buf, u32 buf_len, u16 direction);
+
+/*##############for tcpdump######################*/
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#endif /* _NSFW_MEM_STAT_API_H */
diff --git a/src/framework/include/nsfw_mem_api.h b/src/framework/include/nsfw_mem_api.h
new file mode 100644
index 0000000..ec78692
--- /dev/null
+++ b/src/framework/include/nsfw_mem_api.h
@@ -0,0 +1,546 @@
+/*
+*
+* 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 _NSFW_MEM_API_H
+#define _NSFW_MEM_API_H
+#include <stdint.h>
+#include <sys/types.h>
+
+#include "types.h"
+#include "nsfw_mgr_com_api.h"
+#include "nstack_log.h"
+
+#define NSFW_MEM_MGR_MODULE "nsfw_mem_mgr"
+
+/*
+ *the max len of memory name is 32bytes, but app just can use max 22bytes, left 10bytes to memory manager module
+ */
+#define NSFW_MEM_NAME_LENTH (32)
+#define NSFW_MEM_APPNAME_LENTH (22)
+
+#define NSFW_SOCKET_ANY (-1)
+#define NSFW_MEM_OK (0)
+#define NSFW_MEM_ERR (-1)
+
+/*
+ *type of memory:
+ *NSFW_SHMEM:shared memory
+ *NSFW_NSHMEM:allocated by calling malloc
+ */
+typedef enum
+{
+ NSFW_SHMEM,
+ NSFW_NSHMEM,
+ NSFW_MEM_TYPEMAX,
+} nsfw_mem_type;
+
+/*type of ring operation*/
+typedef enum
+{
+ NSFW_MRING_SPSC, /*sigle producer sigle consumer ring */
+ NSFW_MRING_MPSC, /*multi producer sigle consumer ring */
+ NSFW_MRING_SPMC, /*sigle producer multi consumer ring */
+ NSFW_MRING_MPMC, /*multi producer multi consumer ring */
+ NSFW_MRING_SPSC_ST, /*single producer single consumer and belong to one thread ring */
+ NSFW_MPOOL_TYPEMAX,
+} nsfw_mpool_type;
+
+typedef void *mpool_handle;
+typedef void *mzone_handle;
+typedef void *mbuf_handle;
+typedef void *mring_handle;
+
+/*initial of param*/
+typedef struct
+{
+ i32 iargsnum;
+ i8 **pargs;
+ fw_poc_type enflag; /*app, nStackMain, Master */
+} nsfw_mem_para;
+
+typedef struct
+{
+ nsfw_mem_type entype;
+ fw_poc_type enowner; /*notes: 1. when calling any shared memory create inferface, the name of memory end with _0 created by nStackMain,
+ * end with null created by nStackMaster, and end with _<pid> created by other.
+ * 2. pname->enowner is available only when call look up shared memory.
+ * 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
+ * the name must be full name.
+ * for examles if the memory was created by nStackMain and pname->enowner is NSFW_PROC_NULL,
+ * must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
+ * _(pid) at the end of name, nstack_123.
+ */
+ i8 aname[NSFW_MEM_NAME_LENTH]; /*the lenth of name must be less than NSFW_MEM_APPNAME_LENTH. */
+} nsfw_mem_name;
+
+typedef struct
+{
+ nsfw_mem_name stname;
+ size_t lenth;
+ i32 isocket_id;
+ i32 ireserv;
+} nsfw_mem_zone;
+
+typedef struct
+{
+ nsfw_mem_name stname;
+ unsigned usnum; /*the really created mbfpool num is (num+1) power of 2 */
+ unsigned uscash_size;
+ unsigned uspriv_size;
+ unsigned usdata_room;
+ i32 isocket_id;
+ nsfw_mpool_type enmptype;
+} nsfw_mem_mbfpool;
+
+typedef struct
+{
+ nsfw_mem_name stname;
+ u32 usnum; /*the really created sppool num is (num+1) power of 2 */
+ u32 useltsize;
+ i32 isocket_id;
+ nsfw_mpool_type enmptype;
+} nsfw_mem_sppool;
+
+typedef struct
+{
+ nsfw_mem_name stname;
+ u32 usnum; /*the really created ring num is (num+1) power of 2 */
+ i32 isocket_id;
+ nsfw_mpool_type enmptype;
+} nsfw_mem_mring;
+
+typedef enum
+{
+ NSFW_MEM_ALLOC_SUCC = 1,
+ NSFW_MEM_ALLOC_FAIL = 2,
+} nsfw_mem_alloc_state;
+
+typedef enum
+{
+ NSFW_MEM_MZONE,
+ NSFW_MEM_MBUF,
+ NSFW_MEM_SPOOL,
+ NSFW_MEM_RING
+} nsfw_mem_struct_type;
+
+typedef enum
+{
+ NSFW_RESERV_REQ_MSG,
+ NSFW_RESERV_ACK_MSG,
+ NSFW_MBUF_REQ_MSG,
+ NSFW_MBUF_ACK_MSG,
+ NSFW_SPPOOL_REQ_MSG,
+ NSFW_SPPOOL_ACK_MSG,
+ NSFW_RING_REQ_MSG,
+ NSFW_RING_ACK_MSG,
+ NSFW_RELEASE_REQ_MSG,
+ NSFW_RELEASE_ACK_MSG,
+ NSFW_MEM_LOOKUP_REQ_MSG,
+ NSFW_MEM_LOOKUP_ACK_MSG,
+ NSFW_MEM_MAX_MSG
+} nsfw_remote_msg;
+
+typedef struct __nsfw_shmem_msg_head
+{
+ unsigned usmsg_type;
+ unsigned uslenth;
+ i32 aidata[0];
+} nsfw_shmem_msg_head;
+
+typedef struct __nsfw_shmem_ack
+{
+ void *pbase_addr;
+ u16 usseq;
+ i8 cstate;
+ i8 creserv;
+ i32 ireserv;
+} nsfw_shmem_ack;
+
+typedef struct __nsfw_shmem_reserv_req
+{
+ i8 aname[NSFW_MEM_NAME_LENTH];
+ u16 usseq;
+ u16 usreserv;
+ i32 isocket_id;
+ size_t lenth;
+ i32 ireserv;
+} nsfw_shmem_reserv_req;
+
+typedef struct __nsfw_shmem_mbuf_req
+{
+ i8 aname[NSFW_MEM_NAME_LENTH];
+ u16 usseq;
+ u16 enmptype;
+ unsigned usnum;
+ unsigned uscash_size;
+ unsigned uspriv_size;
+ unsigned usdata_room;
+ i32 isocket_id;
+ i32 ireserv;
+} nsfw_shmem_mbuf_req;
+
+typedef struct __nsfw_shmem_sppool_req
+{
+ i8 aname[NSFW_MEM_NAME_LENTH];
+ u16 usseq;
+ u16 enmptype;
+ u32 usnum;
+ u32 useltsize;
+ i32 isocket_id;
+ i32 ireserv;
+} nsfw_shmem_sppool_req;
+
+typedef struct __nsfw_shmem_ring_req
+{
+ i8 aname[NSFW_MEM_NAME_LENTH];
+ u16 usseq;
+ u16 enmptype;
+ u32 usnum;
+ i32 isocket_id;
+ i32 ireserv;
+} nsfw_shmem_ring_req;
+
+typedef struct __nsfw_shmem_free_req
+{
+ i8 aname[NSFW_MEM_NAME_LENTH];
+ u16 usseq;
+ u16 ustype; /*structure of memory(memzone,mbuf,mpool,ring) */
+ i32 ireserv;
+} nsfw_shmem_free_req;
+
+typedef struct __nsfw_shmem_lookup_req
+{
+ i8 aname[NSFW_MEM_NAME_LENTH];
+ u16 usseq;
+ u16 ustype; /*structure of memory(memzone,mbuf,mpool,ring) */
+ i32 ireserv;
+} nsfw_shmem_lookup_req;
+
+typedef int (*nsfw_mem_ring_enqueue_fun) (mring_handle ring, void *box);
+typedef int (*nsfw_mem_ring_dequeue_fun) (mring_handle ring, void **box);
+typedef int (*nsfw_mem_ring_dequeuev_fun) (mring_handle ring, void **box,
+ unsigned int n);
+
+typedef struct
+{
+ nsfw_mem_ring_enqueue_fun ring_ops_enqueue;
+ nsfw_mem_ring_dequeue_fun ring_ops_dequeue;
+ nsfw_mem_ring_dequeuev_fun ring_ops_dequeuev;
+} nsfw_ring_ops;
+
+/*
+ * memory module init
+ * para:point to nstak_fwmem_para
+ */
+i32 nsfw_mem_init (void *para);
+
+/*
+ * create a block memory with name
+ * nsfw_mem_zone::stname
+ * nsfw_mem_zone::isize
+ * note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+ */
+mzone_handle nsfw_mem_zone_create (nsfw_mem_zone * pinfo);
+
+/*
+ *create some memory blocks
+ * note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+ */
+i32 nsfw_mem_zone_createv (nsfw_mem_zone * pmeminfo, i32 inum,
+ mzone_handle * paddr_array, i32 iarray_num);
+
+/*
+ *look up a memory
+ * note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+ * 2. if the memory is shared, pname->enowner indicate that who create this memory,
+ * note:
+ * 1. when calling any shared memory create inferface, the name of memory end with _0 created by nStackMain,
+ * end with none created by nStackMaster, and end with _<pid> created by other.
+ * 2. pname->enowner is available only when call look up shared memory.
+ * 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
+ * the name must be full name.
+ * for examles if the memory was created by nStackMain and pname->enowner is NSFW_PROC_NULL,
+ * must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
+ * _(pid) at the end of name, nstack_123.
+ */
+mzone_handle nsfw_mem_zone_lookup (nsfw_mem_name * pname);
+
+/*release a memory*/
+i32 nsfw_mem_zone_release (nsfw_mem_name * pname);
+
+/*
+ *create a mbuf pool
+ */
+mpool_handle nsfw_mem_mbfmp_create (nsfw_mem_mbfpool * pbufinfo);
+
+/*
+ *create some mbuf pools
+ * note: 1. the name of lenth must be less than NSFW_MEM_APPNAME_LENTH.
+ */
+i32 nsfw_mem_mbfmp_createv (nsfw_mem_mbfpool * pmbfname, i32 inum,
+ mpool_handle * phandle_array, i32 iarray_num);
+
+/*
+ *alloc a mbuf from mbuf pool
+ */
+mbuf_handle nsfw_mem_mbf_alloc (mpool_handle mhandle, nsfw_mem_type entype);
+
+/*
+ *put a mbuf backintp mbuf pool
+ */
+i32 nsfw_mem_mbf_free (mbuf_handle mhandle, nsfw_mem_type entype);
+
+/*
+ *look up mbuf mpool
+ * note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+ * 2. if the memory is shared, pname->enowner indicate that who create this memory.
+ * note:
+ * 1. when calling any shared memory create inferface, the name of memory end with _0 created by nStackMain,
+ * end with none created by nStackMaster, and end with _<pid> created by other.
+ * 2. pname->enowner is available only when call look up shared memory.
+ * 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
+ * the name must be full name.
+ * for examles if the memory was created by nStackMain and pname->enowner is NSFW_PROC_NULL,
+ * must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
+ * _(pid) at the end of name, nstack_123.
+ */
+mpool_handle nsfw_mem_mbfmp_lookup (nsfw_mem_name * pmbfname);
+
+/*
+ *release mbuf pool
+ * note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+ */
+i32 nsfw_mem_mbfmp_release (nsfw_mem_name * pname);
+
+/*
+ *create a simple pool
+ *note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+ */
+mring_handle nsfw_mem_sp_create (nsfw_mem_sppool * pmpinfo);
+
+/*
+ *create some simple pools one time
+ *note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+ */
+i32 nsfw_mem_sp_createv (nsfw_mem_sppool * pmpinfo, i32 inum,
+ mring_handle * pringhandle_array, i32 iarray_num);
+
+/*
+ *create a simple pool with many rings
+ *note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+ */
+i32 nsfw_mem_sp_ring_create (nsfw_mem_mring * prpoolinfo,
+ mring_handle * pringhandle_array, i32 iringnum);
+
+/*
+ *release a simple mempool
+ *note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+ */
+i32 nsfw_mem_sp_release (nsfw_mem_name * pname);
+
+/*
+ *look up a simpile ring
+ * note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+ * 2. if the memory is shared, pname->enowner indicate that who create this memory,
+ * note:
+ * 1. when calling any shared memory create inferface, the name of memory end with _0 created by nStackMain,
+ * end with none created by nStackMaster, and end with _<pid> created by other.
+ * 2. pname->enowner is available only when call look up shared memory.
+ * 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
+ * the name must be full name.
+ * for examles if the memory was created by nStackMain and pname->enowner is NSFW_PROC_NULL,
+ * must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
+ * _(pid) at the end of name, nstack_123.
+ */
+mring_handle nsfw_mem_sp_lookup (nsfw_mem_name * pname);
+
+/*
+ *create a ring
+ *note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+ * 2. shared memory ring (NSFW_SHMEM) just can put a pointor into the queue, the queue also point to a shared block memory.
+ * no shared memory ring(NSFW_NSHMEM) is other wise.
+ */
+mring_handle nsfw_mem_ring_create (nsfw_mem_mring * pringinfo);
+
+/*
+ *look up a ring by name
+ * note:1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+ * 2. if the memory is shared, pname->enowner indicate that who create this memory,
+ * note:
+ * 1. when calling any shared memory create inferface, the name of memory end with _0 created by nStackMain,
+ * end with none created by nStackMaster, and end with _<pid> created by other.
+ * 2. pname->enowner is available only when call look up shared memory.
+ * 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
+ * the name must be full name.
+ * for examles if the memory was created by nStackMain and pname->enowner is NSFW_PROC_NULL,
+ * must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
+ * _(pid) at the end of name, nstack_123.
+ */
+mring_handle nsfw_mem_ring_lookup (nsfw_mem_name * pname);
+
+/*
+ * reset the number of producer and consumer, also, the state of ring reset to empty
+ * notes: must be called before doing any operations base on the ring
+ */
+void nsfw_mem_ring_reset (mring_handle mhandle, nsfw_mpool_type entype);
+
+extern nsfw_ring_ops g_ring_ops_arry[NSFW_MEM_TYPEMAX][NSFW_MPOOL_TYPEMAX];
+
+/*****************************************************************************
+* Prototype : nsfw_mem_ring_dequeue
+* Description : get a member from a ring
+* note : if NSFW_SHMEM ring, pdata returned alread a local address
+* Input : mring_handle mhandle
+* void** pdata
+* Output : None
+* Return Value : the num of elment get from the queue, =0: get null, <0: err happen, >0: return num.
+* Calls :
+* Called By :
+*
+*****************************************************************************/
+static inline i32
+nsfw_mem_ring_dequeue (mring_handle mhandle, void **pdata)
+{
+ if (NULL == mhandle || *((u8 *) mhandle) >= NSFW_MEM_TYPEMAX
+ || *((u8 *) mhandle + 1) >= NSFW_MPOOL_TYPEMAX)
+ {
+ NSCOMM_LOGERR ("input para error] mhandle=%p", mhandle);
+ return -1;
+ }
+
+ return
+ g_ring_ops_arry[*((u8 *) mhandle)][*((u8 *) mhandle + 1)].ring_ops_dequeue
+ (mhandle, pdata);
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_ring_dequeuev
+* Description : get some members from a ring
+* note : if NSFW_SHMEM ring, pdata returned alread a local address
+* Input : mring_handle mhandle
+* void** pdata
+* unsigned inum
+* Output : None
+* Return Value : the num of elment get from the queue, =0: get null, <0: err happen, >0: return num.
+* Calls :
+* Called By :
+*
+*****************************************************************************/
+static inline i32
+nsfw_mem_ring_dequeuev (mring_handle mhandle, void **pdata, unsigned int inum)
+{
+ if (NULL == mhandle || *((u8 *) mhandle) >= NSFW_MEM_TYPEMAX
+ || *((u8 *) mhandle + 1) >= NSFW_MPOOL_TYPEMAX)
+ {
+ NSCOMM_LOGERR ("input para error] mhandle=%p", mhandle);
+ return -1;
+ }
+
+ return
+ g_ring_ops_arry[*((u8 *) mhandle)][*
+ ((u8 *) mhandle +
+ 1)].ring_ops_dequeuev (mhandle, pdata,
+ inum);
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_ring_enqueue
+* Description : put a member back into a ring
+* note : pdata must point to a shared block memory when put into the NSFW_SHMEM type memory ring, and the
+* value of pdata must be local address
+* Input : mring_handle mhandle
+* void* pdata
+* Output : None
+* Return Value : the num of elment put into the queue, =0: put null, <0: err happen, >0: return num.
+* Calls :
+* Called By :
+*
+*****************************************************************************/
+static inline i32
+nsfw_mem_ring_enqueue (mring_handle mhandle, void *pdata)
+{
+ if (NULL == mhandle || *((u8 *) mhandle) >= NSFW_MEM_TYPEMAX
+ || *((u8 *) mhandle + 1) >= NSFW_MPOOL_TYPEMAX)
+ {
+ NSCOMM_LOGERR ("input para error] mhandle=%p", mhandle);
+ return -1;
+ }
+
+ return
+ g_ring_ops_arry[*((u8 *) mhandle)][*((u8 *) mhandle + 1)].ring_ops_enqueue
+ (mhandle, pdata);
+}
+
+/*
+ *get the free number of ring
+ */
+u32 nsfw_mem_ring_free_count (mring_handle mhandle);
+
+/*
+ *get the in using number of ring
+ */
+u32 nsfw_mem_ring_using_count (mring_handle mhandle);
+
+/*
+ *get size of ring
+ */
+u32 nsfw_mem_ring_size (mring_handle mhandle);
+
+/*
+ *release a ring memory
+ *note: the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+ */
+i32 nsfw_mem_ring_release (nsfw_mem_name * pname);
+
+/*
+ *statics mbufpool, sppool, ring mem size
+ *return: <=0, err happen, >0 mem size
+ * NSFW_MEM_MZONE: not surport because you already know the lenth when create
+ */
+ssize_t nsfw_mem_get_len (void *handle, nsfw_mem_struct_type type);
+
+/*
+ *recycle mbuf
+ *
+ */
+i32 nsfw_mem_mbuf_pool_recycle (mpool_handle handle);
+
+typedef int (*nsfw_mem_item_fun) (void *data, void *argv);
+
+i32 nsfw_mem_sp_iterator (mpool_handle handle, u32 start, u32 end,
+ nsfw_mem_item_fun fun, void *argv);
+i32 nsfw_mem_mbuf_iterator (mpool_handle handle, u32 start, u32 end,
+ nsfw_mem_item_fun fun, void *argv);
+
+/*****************************************************************************
+* Prototype : nsfw_mem_dfx_ring_print
+* Description : print ring info
+* Input : mring_handle mhandle
+* char *pbuf
+* int lenth
+* Output : None
+* Return Value : i32
+* Calls :
+* Called By :
+*
+*****************************************************************************/
+i32 nsfw_mem_dfx_ring_print (mring_handle mhandle, char *pbuf, int lenth);
+
+#ifdef SYS_MEM_RES_STAT
+u32 nsfw_mem_mbfpool_free_count (mpool_handle mhandle);
+#endif
+
+#endif
diff --git a/src/framework/include/nsfw_mgr_com_api.h b/src/framework/include/nsfw_mgr_com_api.h
new file mode 100644
index 0000000..2499fee
--- /dev/null
+++ b/src/framework/include/nsfw_mgr_com_api.h
@@ -0,0 +1,198 @@
+/*
+*
+* 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.
+*/
+
+/*==============================================*
+ * include header files *
+ *----------------------------------------------*/
+#ifndef _NSFW_MGRCOM_API_H
+#define _NSFW_MGRCOM_API_H
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#define NSFW_MGR_COM_MODULE "nsfw_mgr_com"
+
+#define MRG_RSP(_req_msg) (_req_msg + MGR_MSG_RSP_BASE)
+
+typedef enum _mgr_msg_type
+{
+ MGR_MSG_NULL = 0,
+ /*#############common msg type################# */
+ MGR_MSG_CHK_INIT_REQ = 1,
+ MGR_MSG_INIT_NTY_REQ,
+ MGR_MSG_CHK_HBT_REQ,
+ MGR_MSG_APP_EXIT_REQ,
+ MGR_MSG_SRV_CTL_REQ,
+ MGR_MSG_VER_MGR_REQ,
+ MGR_MSG_SOF_PAR_REQ,
+
+ /*############################################# */
+ MGR_MSG_MEM_ALLOC_REQ = 64, /* memory msg type */
+
+ /*############################################# */
+ MGR_MSG_DFX_QRY_REQ = 96, /* nStackCtrl maitain msg */
+ MGR_MSG_SET_LOG_REQ,
+
+ /*############################################# */
+ MGR_MSG_RCC_END_REQ = 128, /* service msg type */
+
+ /*############################################# */
+ MGR_MSG_TOOL_TCPDUMP_REQ = 256, /* for tools */
+ MGR_MSG_TOOL_HEART_BEAT,
+
+ /*###query message with large rsp message begin## */
+ MGR_MSG_LARGE_QRY_REQ_BEGIN = 384,
+ MGR_MSG_LARGE_STA_QRY_REQ = MGR_MSG_LARGE_QRY_REQ_BEGIN,
+ MGR_MSG_LARGE_MT_QRY_REQ, /* nStackCtrl maitain msg */
+
+ /*############################################# */
+ MGR_MSG_LARGE_ALARM_REQ = 500, /* alarm msg type */
+
+ MGR_MSG_RSP_BASE = 512,
+ /*#############common msg type################# */
+ MGR_MSG_CHK_INIT_RSP = MRG_RSP (MGR_MSG_CHK_INIT_REQ),
+ MGR_MSG_INIT_NTY_RSP = MRG_RSP (MGR_MSG_INIT_NTY_REQ),
+ MGR_MSG_CHK_HBT_RSP = MRG_RSP (MGR_MSG_CHK_HBT_REQ),
+ MGR_MSG_APP_EXIT_RSP = MRG_RSP (MGR_MSG_APP_EXIT_REQ),
+ MGR_MSG_SRV_CTL_RSP = MRG_RSP (MGR_MSG_SRV_CTL_REQ),
+ MGR_MSG_VER_MGR_RSP = MRG_RSP (MGR_MSG_VER_MGR_REQ),
+ MGR_MSG_SOF_PAR_RSP = MRG_RSP (MGR_MSG_SOF_PAR_REQ),
+ /*############################################# */
+
+ MGR_MSG_MEM_ALLOC_RSP = MRG_RSP (MGR_MSG_MEM_ALLOC_REQ),
+
+ MGR_MSG_DFX_QRY_RSP = MRG_RSP (MGR_MSG_DFX_QRY_REQ),
+
+ MGR_MSG_SET_LOG_RSP = MRG_RSP (MGR_MSG_SET_LOG_REQ),
+
+ MGR_MSG_RCC_END_RSP = MRG_RSP (MGR_MSG_RCC_END_REQ),
+
+ /*############################################# */
+ MGR_MSG_TOOL_TCPDUMP_RSP = MRG_RSP (MGR_MSG_TOOL_TCPDUMP_REQ),
+ MGR_MSG_TOOL_HEART_BEAT_RSP = MRG_RSP (MGR_MSG_TOOL_HEART_BEAT),
+
+ /*##############LARGE RSP MESSAGE################## */
+ MGR_MSG_LAG_QRY_RSP_BEGIN = MRG_RSP (MGR_MSG_LARGE_QRY_REQ_BEGIN),
+ MGR_MSG_LAG_STA_QRY_RSP = MRG_RSP (MGR_MSG_LARGE_STA_QRY_REQ),
+ MGR_MSG_LAG_MT_QRY_RSP = MRG_RSP (MGR_MSG_LARGE_MT_QRY_REQ),
+ MGR_MSG_LARGE_ALARM_RSP = MRG_RSP (MGR_MSG_LARGE_ALARM_REQ),
+ MGR_MSG_MAX = 1024
+} mgr_msg_type;
+
+typedef enum _fw_poc_type
+{
+ NSFW_PROC_NULL = 0,
+ NSFW_PROC_MAIN,
+ NSFW_PROC_MASTER,
+ NSFW_PROC_APP,
+ NSFW_PROC_CTRL,
+ NSFW_PROC_TOOLS,
+ NSFW_PROC_ALARM,
+ NSFW_PROC_MAX = 16
+} fw_poc_type;
+
+#define NSFW_DOMAIN_DIR "/var/run"
+#define NSTACK_MAX_PROC_NAME_LEN 20
+
+typedef enum _nsfw_mgr_msg_rsp_code
+{
+ NSFW_MGR_SUCESS,
+ NSFW_MGR_MSG_TYPE_ERROR,
+} mgr_msg_rsp_code;
+
+extern char *nsfw_get_proc_name (u8 proc_type);
+
+#define GET_USER_MSG(_stu, _msg) ((_stu *)(&(_msg)->msg_body[0]))
+
+/*for log print*/
+#define MSGINFO "msg=%p,len=%d,t=%d,sq=%d,st=%d,sp=%d,dt=%d,dp=%d"
+#define PRTMSG(msg) (msg), (msg)->msg_len,(msg)->msg_type,(msg)->seq, (msg)->src_proc_type,(msg)->src_pid,(msg)->dst_proc_type,(msg)->dst_pid
+
+#define NSFW_MGR_MSG_LEN 512
+#define NSFW_MGR_MSG_HDR_LEN 32
+#define NSFW_MGR_MSG_BODY_LEN (NSFW_MGR_MSG_LEN - NSFW_MGR_MSG_HDR_LEN)
+
+#define NSFW_MGR_LARGE_MSG_LEN (256*1024)
+#define NSFW_MGR_LARGE_MSG_BODY_LEN (NSFW_MGR_LARGE_MSG_LEN - NSFW_MGR_MSG_HDR_LEN)
+
+typedef struct _nsfw_mgr_msg
+{
+ u16 msg_type; /* mgr_msg_type */
+ u16 u16Reserve;
+ u32 msg_len;
+
+ u8 alloc_flag:1;
+ u8 fw_flag:1;
+ u8 from_mem:1;
+ u8 more_msg_flag:1;
+ u8 reserve_flag:4;
+ u8 resp_code;
+ u8 src_proc_type; /* fw_poc_type */
+ u8 dst_proc_type;
+ i32 seq;
+
+ u32 src_pid;
+ u32 dst_pid;
+
+ u64 traceid;
+
+ u8 msg_body[NSFW_MGR_MSG_BODY_LEN];
+} nsfw_mgr_msg;
+
+extern nsfw_mgr_msg *nsfw_mgr_msg_alloc (u16 msg_type, u8 dst_proc_type);
+extern void nsfw_mgr_msg_free (nsfw_mgr_msg * msg);
+
+/* for rsp msg alloc*/
+extern nsfw_mgr_msg *nsfw_mgr_null_rspmsg_alloc ();
+extern nsfw_mgr_msg *nsfw_mgr_rsp_msg_alloc (nsfw_mgr_msg * req_msg);
+
+/* for msg proc fun reg*/
+typedef int (*nsfw_mgr_msg_fun) (nsfw_mgr_msg * msg);
+extern u8 nsfw_mgr_reg_msg_fun (u16 msg_type, nsfw_mgr_msg_fun fun);
+
+extern u8 nsfw_mgr_send_msg (nsfw_mgr_msg * msg);
+extern u8 nsfw_mgr_send_req_wait_rsp (nsfw_mgr_msg * req_msg,
+ nsfw_mgr_msg * rsp_msg);
+
+/* for fork clear parent resource*/
+extern void nsfw_mgr_close_dst_proc (u8 proc_type, u32 dst_pid);
+extern u8 nsfw_mgr_clr_fd_lock ();
+
+/* for epoll thread reg other sock proc fun*/
+typedef int (*nsfw_mgr_sock_fun) (i32 epfd, i32 socket, u32 events);
+extern u8 nsfw_mgr_reg_sock_fun (i32 socket, nsfw_mgr_sock_fun fun);
+extern void nsfw_mgr_unreg_sock_fun (i32 socket);
+extern int nsfw_mgr_com_socket_error (i32 fd, nsfw_mgr_sock_fun fun,
+ i32 timer);
+extern u8 nsfw_mgr_ep_start ();
+extern int nsfw_mgr_com_module_init (void *param);
+extern int nsfw_mgr_run_script (const char *cmd, char *result,
+ int result_buf_len);
+
+extern int nsfw_mgr_com_chk_hbt (int v_add);
+extern i32 nsfw_set_close_on_exec (i32 sock);
+extern int nsfw_mgr_comm_fd_init (u32 proc_type);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#endif /* _NSFW_MGRCOM_API_H */
diff --git a/src/framework/include/nsfw_ps_api.h b/src/framework/include/nsfw_ps_api.h
new file mode 100644
index 0000000..69fa992
--- /dev/null
+++ b/src/framework/include/nsfw_ps_api.h
@@ -0,0 +1,134 @@
+/*
+*
+* 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 _NSFW_PS_API_H
+#define _NSFW_PS_API_H
+
+#include "list.h"
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#define NSFW_PS_MODULE "nsfw_ps"
+
+#define NSFW_PS_MAX_CALLBACK 16
+
+#define NSFW_MAX_HBT_CHK_COUNT_DEF 60
+
+typedef enum _nsfw_ps_state
+{
+ NSFW_PS_NULL = 0,
+ NSFW_PS_START,
+ NSFW_PS_RUNNING,
+ NSFW_PS_PARENT_FORK,
+ NSFW_PS_CHILD_FORK,
+ NSFW_PS_HBT_FAILED,
+ NSFW_PS_EXITING,
+ NSFW_PS_EXIT,
+ NSFW_PS_MAX
+} nsfw_ps_state;
+
+/* for state change call back proc*/
+typedef int (*nsfw_ps_proc_fun) (void *pps_info, void *argv);
+typedef struct _nsfw_ps_callback
+{
+ u8 state;
+ nsfw_ps_proc_fun fun;
+ void *argv;
+} nsfw_ps_callback;
+
+/* for value in ps_info get/set*/
+typedef enum _nsfw_ps_user_value
+{
+ NSFW_REC_IDX = 1,
+ NSFW_REC_TIMER = 2,
+ NSFW_PS_UV_MAX = 16
+} nsfw_ps_user_value;
+#define nsfw_ps_set_uv(_pps_info, _type, _value) (_pps_info)->value[(_type)] = (_value)
+#define nsfw_ps_get_uv(_pps_info, _type) ((_pps_info)->value[(_type)])
+
+typedef struct _nsfw_ps_info
+{
+ struct list_head node;
+ u8 alloc_flag;
+ u8 state; /*nsfw_ps_state */
+ u8 proc_type; /*fw_poc_type */
+ u8 rechk_flg;
+ u32 host_pid;
+ u32 parent_pid; /* only use for fork */
+ u32 cur_child_pid; /* only use for fork */
+ void *exit_timer_ptr;
+ void *resend_timer_ptr;
+ void *hbt_timer_ptr;
+ u32 hbt_failed_count;
+ nsfw_ps_callback callback[NSFW_PS_MAX_CALLBACK];
+ void *value[NSFW_PS_UV_MAX];
+} nsfw_ps_info;
+
+typedef struct _nsfw_thread_dogs
+{
+ u8 alloc_flag;
+ i32 count;
+ u32 thread_id;
+} nsfw_thread_dogs;
+
+extern nsfw_ps_info *nsfw_ps_info_alloc (u32 pid, u8 proc_type);
+extern nsfw_ps_info *nsfw_ps_info_get (u32 pid);
+extern void nsfw_ps_info_free (nsfw_ps_info * ps_info);
+
+extern u8 nsfw_ps_reg_fun (nsfw_ps_info * pps_info, u8 ps_state,
+ nsfw_ps_proc_fun fun, void *argv);
+
+/* will auto reg after ps_info alloc*/
+extern u8 nsfw_ps_reg_global_fun (u8 proc_type, u8 ps_state,
+ nsfw_ps_proc_fun fun, void *argv);
+
+typedef struct _nsfw_ps_info_msg
+{
+ u32 host_pid;
+ u32 parent_pid;
+ u64 reserve;
+} nsfw_ps_info_msg;
+extern u8 nsfw_ps_exit_end_notify (u32 pid);
+
+/*for heartbeat check*/
+extern u8 nsfw_ps_check_dst_init (u8 dst_proc_type);
+extern u8 nsfw_thread_chk ();
+extern nsfw_thread_dogs *nsfw_thread_getDog ();
+extern u8 nsfw_thread_chk_unreg ();
+extern u8 nsfw_ps_hbt_start (nsfw_ps_info * ps_info);
+extern u8 nsfw_ps_hbt_stop (nsfw_ps_info * ps_info);
+
+extern u32 nsfw_ps_iterator (nsfw_ps_proc_fun fun, void *argv);
+
+#define MAX_THREAD 16
+extern pthread_t g_all_thread[];
+extern u8 nsfw_reg_trace_thread (pthread_t tid);
+
+typedef int (*nsfw_ps_pid_fun) (u32 pid, u8 proc_type, void *argv);
+extern int nsfw_ps_rechk_pid_exit (nsfw_ps_pid_fun fun, void *argv);
+extern nsfw_ps_info *nsfw_share_ps_info_get (u32 pid);
+extern void nsfw_ps_cfg_set_chk_count (u16 count);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#endif /* _NSFW_PS_API_H */
diff --git a/src/framework/include/nsfw_ps_mem_api.h b/src/framework/include/nsfw_ps_mem_api.h
new file mode 100644
index 0000000..01f9cd3
--- /dev/null
+++ b/src/framework/include/nsfw_ps_mem_api.h
@@ -0,0 +1,36 @@
+/*
+*
+* 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 _NSFW_PS_MEM_API_H
+#define _NSFW_PS_MEM_API_H
+
+#include "nsfw_mem_api.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#define NSFW_PS_MEM_MODULE "nsfw_ps_mem"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#endif /* _NSFW_PS_MEM_API_H */
diff --git a/src/framework/include/nsfw_recycle_api.h b/src/framework/include/nsfw_recycle_api.h
new file mode 100644
index 0000000..fd2bd8f
--- /dev/null
+++ b/src/framework/include/nsfw_recycle_api.h
@@ -0,0 +1,92 @@
+/*
+*
+* 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 _NSFW_RECYCLE_API_H
+#define _NSFW_RECYCLE_API_H
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#define NSFW_RECYCLE_MODULE "nsfw_recycle"
+
+typedef enum _nsfw_recycle_item_type
+{
+ NSFW_REC_TYPE_NULL = 0,
+ NSFW_REC_SBR_START = 1,
+ NSFW_REC_SBR_SOCKET,
+ NSFW_REC_SBR_END = NSFW_REC_SBR_START + 63,
+ NSFW_REC_NSOCKET_START,
+ NSFW_REC_NSOCKET_EPOLL,
+ NSFW_REC_NSOCKET_END = NSFW_REC_NSOCKET_START + 63,
+ NSFW_REC_TYPE_MAX = 512
+} nsfw_recycle_item_type;
+
+typedef enum _nsfw_recycle_priority
+{
+ NSFW_REC_PRO_HIGHTEST = 0,
+ NSFW_REC_PRO_NORMAL = 1,
+ NSFW_REC_PRO_DEFALUT = 2,
+ NSFW_REC_PRO_LOWEST = 3,
+ NSFW_REC_PRO_MAX = 4
+} nsfw_recycle_priority;
+
+typedef enum _nsfw_rcc_stat
+{
+ NSFW_RCC_CONTINUE = 0,
+ NSFW_RCC_SUSPEND = 1,
+ NSFW_RCC_FAILED = 2,
+} nsfw_rcc_stat;
+
+/*work on nStackMain*/
+typedef nsfw_rcc_stat (*nsfw_recycle_fun) (u32 exit_pid, void *pdata,
+ u16 rec_type);
+extern u8 nsfw_recycle_reg_fun (u16 obj_type, nsfw_recycle_fun fun);
+extern u8 nsfw_recycle_obj_end (u32 pid);
+extern u8 nsfw_recycle_lock_rel_fun (nsfw_recycle_fun fun, void *data,
+ u8 proc_type);
+extern int nsfw_recycle_exit_pid_lock (u32 pid, u8 proc_type, void *argv);
+
+#define REGIST_RECYCLE_OBJ_FUN(_obj_type, _fun) \
+ NSTACK_STATIC void regist_ ## _obj_type ## _fun (void) \
+ __attribute__((__constructor__)); \
+ NSTACK_STATIC void regist_ ## _obj_type ## _fun (void) \
+ { \
+ (void)nsfw_recycle_reg_fun(_obj_type, _fun); \
+ }
+
+#define REGIST_RECYCLE_LOCK_REL(_fun, _data, _proc) \
+ NSTACK_STATIC void regist_lock ## _fun (void) \
+ __attribute__((__constructor__)); \
+ NSTACK_STATIC void regist_lock ## _fun (void) \
+ { \
+ (void)nsfw_recycle_lock_rel_fun(_fun, _data,_proc); \
+ }
+
+/*work on nStackApp*/
+extern void *nsfw_recycle_reg_obj (u8 priority, u16 rec_type, void *data);
+extern u8 nsfw_recycle_fork_init ();
+extern int nsfw_recycle_rechk_lock ();
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#endif /* _NSFW_RECYCLE_API_H */
diff --git a/src/framework/include/nsfw_snapshot.h b/src/framework/include/nsfw_snapshot.h
new file mode 100644
index 0000000..8958c64
--- /dev/null
+++ b/src/framework/include/nsfw_snapshot.h
@@ -0,0 +1,144 @@
+/*
+*
+* 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 _FW_SNAPSHOT_H
+#define _FW_SNAPSHOT_H
+
+#include <stdlib.h>
+#include "types.h"
+#include "../snapshot/fw_ss_tlv.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+// object type(7 bits) | member type (7 bits) | is object(1 bit) | is array(1 bit)
+// member type is the type in object structure , it only effects the own object
+/**
+ * type - object , type object of array, type base item
+ */
+
+#define NSFW_SS_TYPE_OBJ(_objType) (0xfe00 & ((_objType) << 9))
+#define NSFW_SS_TYPE_GETOBJ(_objType) ((0xfe00 & (_objType)) >> 9)
+
+#define NSFW_SS_TYPE_MEMBER(_memType) (0x01fc & ((_memType) << 2))
+#define NSFW_SS_TYPE_GET_MEMBER(_memType) ((0x01fc & (_memType)) >> 2)
+
+#define NSFW_SS_TYPE_SET_MEMBER_ITEM(_memType) (NSFW_SS_TYPE_MEMBER((_memType)))
+#define NSFW_SS_TYPE_SET_MEMBER_OBJ(_objType, _memType) \
+ (NSFW_SS_TYPE_OBJ((_objType)) | NSFW_SS_TYPE_SET_MEMBER_ITEM((_memType)) | 0x02)
+#define NSFW_SS_TYPE_SET_MEMBER_OBJ_ARRAY(_objType, _memType) \
+ (NSFW_SS_TYPE_SET_MEMBER_OBJ((_objType), (_memType)) | 0x01)
+
+#define NSFW_SS_TYPE_IS_MEMBER_OBJ(_memType) ((_memType) & 0x02)
+#define NSFW_SS_TYPE_IS_MEMBER_ARRAY(_memType) ((_memType) & 0x01)
+
+/*
+ * This structure tells how to describe one object and its members
+ */
+typedef struct _nsfw_ss_objMemDesc
+{
+ u16 type; // object type(7 bits) | member type (7 bits) | is object(1 bit) | is array(1 bit)
+ u32 length;
+ u8 offset;
+} nsfw_ss_objMemDesc_t;
+
+typedef struct _nsfw_ss_objDesc
+{
+ u16 objType; /* Type number of object */
+ u8 memNum; /* Nubmer of object members */
+ u32 objSize;
+ nsfw_ss_objMemDesc_t *memDesc; /* Member descripe */
+} nsfw_ss_objDesc_t;
+
+#define NSFW_SS_MAX_OBJDESC_NUM 256
+
+/* Traversal, you can save the current value to start the search, do not need to start from the beginning of the search, because the value is generally a sequential */
+
+typedef struct _nsfw_ss_objDescManager
+{
+ nsfw_ss_objDesc_t *g_nsfw_ss_objDescs[NSFW_SS_MAX_OBJDESC_NUM];
+ int g_nsfw_ss_objDesNum;
+} nsfw_ss_objDescManager_t;
+
+extern nsfw_ss_objDescManager_t g_nsfw_ss_objDescManager;
+
+#define nsfw_ss_getObjDescManagerInst() (&g_nsfw_ss_objDescManager)
+
+/**
+ * @Function nsfw_ss_registe_ObjDesc
+ * @Description Registe object description to snapshot
+ * @param objDesc - description of object
+ * @return void
+ */
+extern void nsfw_ss_register_ObjDesc (nsfw_ss_objDesc_t * objDesc);
+
+/**
+ * @Function nsfw_ss_store
+ * @Description store object to memory
+ * @param (in) objType - type of object
+ * @param (in) obj - adderss of object memory
+ * @param (in) storeMem - address of memory to store object data
+ * @param (in) storeMemLen - maximal length of storage memory
+ * @return positive integer means length of memory cost on success. return -1 if error
+ */
+extern int nsfw_ss_store (u16 objType, void *obj, void *storeMem,
+ u32 storeMemLen);
+
+/**
+ * @Function nsfw_ss_restore
+ * @Description restore object from memory
+ * @param (in) objMem - memory of object
+ * @param (in) mem - memory of storage
+ * @param (in) storeMemLen - maximal length of storage memory
+ * @return positive integer stands on object type, -1 on error
+ */
+extern int nsfw_ss_restore (void *objMem, void *mem, u32 storeMemLen);
+
+/**
+ * @Function nsfw_ss_getObjStoreMemLen
+ * @Description Get the maximal memory it needs
+ * @param (in) objType - type of object
+ * @return length of memory needs, -1 if error
+ */
+extern int nsfw_ss_getObjStoreMemLen (int objType);
+
+#define _NSFW_SNAPSHOT_OBJDESC_REGISTER_SURFIX(_value, _surfix) \
+ static __attribute__((__constructor__(121))) void nsfw_snapshot_objdesc_register_constructor##_surfix(void){\
+ nsfw_ss_register_ObjDesc((_value));\
+ }
+
+#define NSFW_SNAPSHOT_OBJDESC_REGISTER_SURFIX(_value, _surfix) \
+ _NSFW_SNAPSHOT_OBJDESC_REGISTER_SURFIX(_value, _surfix)
+
+#define NSFW_SNAPSHOT_OBJDESC_REGISTER_UNIQUE(_value) \
+ NSFW_SNAPSHOT_OBJDESC_REGISTER_SURFIX(_value, __LINE__)
+
+/**
+ * Using this marcro to register object description
+ */
+#define NSFW_SS_REGSITER_OBJDESC(_value) \
+ NSFW_SNAPSHOT_OBJDESC_REGISTER_UNIQUE(_value)
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#endif /* _FW_SNAPSHOT_H */
diff --git a/src/framework/include/nsfw_upgrade.h b/src/framework/include/nsfw_upgrade.h
new file mode 100644
index 0000000..a4e809c
--- /dev/null
+++ b/src/framework/include/nsfw_upgrade.h
@@ -0,0 +1,51 @@
+/*
+*
+* 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 NSFW_UPGRADE_H
+#define NSFW_UPGRADE_H
+#include "types.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#define ENUM_STRUCT(struct) enum enum_upgrade_ ## struct
+
+#define ENUM_MEM(struct, mem) struct ## _ ## mem
+
+#define GET_MEM_BIT(mem_bit, struct, mem) (mem_bit & ((i64)1 << struct ## _ ## mem))
+
+#define USE_MEM_BIT(mem_bit, struct, mem) (mem_bit |= ((i64)1 << struct ## _ ## mem))
+
+#define UPGRADE_MEM_VAL(mem_bit, struct, mem, obj, defalut) { \
+ if (!GET_MEM_BIT(mem_bit, struct, mem)){ \
+ obj->mem = defalut; \
+ } \
+ }
+
+#define CONSTRUCT_UPGRADE_FUN(struct, obj) void upgrade_ ## struct (struct* obj)
+
+#define CALL_UPGRADE_FUN(struct, obj) upgrade_ ## struct (obj)
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif
diff --git a/src/framework/include/nstack_log.h b/src/framework/include/nstack_log.h
new file mode 100644
index 0000000..bb90ec8
--- /dev/null
+++ b/src/framework/include/nstack_log.h
@@ -0,0 +1,580 @@
+/*
+*
+* 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 _NSTACK_LOG_H_
+#define _NSTACK_LOG_H_
+/*==============================================*
+ * include header files *
+ *----------------------------------------------*/
+#pragma GCC diagnostic ignored "-Wcpp"
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <signal.h>
+#include "types.h"
+#include "nstack_trace.h"
+
+#include "glog/nstack_glog.ph"
+#include "glog/nstack_glog_in.h"
+
+#define NSTACK_GETVER_MODULE "nStack"
+#define NSTACK_GETVER_VERSION "VPP2.0 V100R002C10B053"
+#define NSTACK_GETVER_BUILDTIME "[" __DATE__ "]" "[" __TIME__ "]"
+#define NSTACK_VERSION NSTACK_GETVER_VERSION " (" NSTACK_GETVER_MODULE ") " NSTACK_GETVER_BUILDTIME
+
+#define LOG_TIME_STAMP_LEN 17 // "YYYYMMDDHHMMSS";
+
+/*==============================================*
+ * constants or macros define *
+ *----------------------------------------------*/
+typedef enum _LOG_MODULE
+{
+ NSOCKET = 1,
+ STACKX,
+ OPERATION,
+ MASTER,
+ LOGTCP,
+ LOGUDP,
+ LOGIP,
+ LOGCMP,
+ LOGARP,
+ LOGRTE,
+ LOGHAL,
+ LOGDFX,
+ LOGFW,
+ LOGSBR,
+ MAX_LOG_MODULE
+} LOG_MODULE;
+
+enum _LOG_TYPE
+{
+ LOG_TYPE_NSTACK = 0,
+ LOG_TYPE_OPERATION,
+ LOG_TYPE_MASTER,
+ LOG_TYPE_APP,
+ MAX_LOG_TYPE
+};
+
+enum _LOG_PROCESS
+{
+ LOG_PRO_NSTACK = 0,
+ LOG_PRO_MASTER,
+ LOG_PRO_APP,
+ LOG_PRO_OMC_CTRL,
+ LOG_PRO_INVALID
+};
+
+#define LOG_INVALID_VALUE 0xFFFF
+
+#define NSLOG_DBG 0x10
+#define NSLOG_INF 0x08
+#define NSLOG_WAR 0x04
+#define NSLOG_ERR 0x02
+#define NSLOG_EMG 0x01
+#define NSLOG_OFF 0x00
+
+#define LOG_LEVEL_EMG "emg"
+#define LOG_LEVEL_ERR "err"
+#define LOG_LEVEL_WAR "war"
+#define LOG_LEVEL_DBG "dbg"
+#define LOG_LEVEL_INF "inf"
+
+#define GET_FILE_NAME(name_have_path) strrchr(name_have_path,'/')?strrchr(name_have_path,'/')+1:name_have_path
+
+#define NSTACK_LOG_NAME "/product/gpaas/log/nStack"
+
+#define STACKX_LOG_NAME "running.log"
+
+#define OPERATION_LOG_NAME "operation.log"
+
+#define MASTER_LOG_NAME "master.log"
+
+#define OMC_CTRL_LOG_NAME "omc_ctrl.log"
+
+#define FAILURE_LOG_NAME "fail_dump.log"
+
+#define FLUSH_TIME 30
+
+#define APP_LOG_SIZE 30
+#define APP_LOG_COUNT 10
+#define APP_LOG_PATH "/var/log"
+#define APP_LOG_NAME "nStack_nSocket.log"
+
+#define NS_LOG_STACKX_ON 0x80U
+#define NS_LOG_STACKX_TRACE 0x40U
+#define NS_LOG_STACKX_STATE 0x20U
+#define NS_LOG_STACKX_FRESH 0x10U
+#define NS_LOG_STACKX_HALT 0x08U
+#define NS_LOG_STACKX_OFF 0x00U
+
+#define NULL_STRING ""
+#define MODULE_INIT_FORMAT_STRING "module %s]name=[%s]%s"
+#define MODULE_INIT_START "init"
+#define MODULE_INIT_FAIL "start failed"
+#define MODULE_INIT_SUCCESS "start success"
+
+#define PRE_INIT_LOG_LENGTH 128
+
+struct nstack_logs
+{
+ uint32_t level; /**< Log level. */
+ int pad64;
+ int inited;
+ int file_type;
+};
+
+struct log_init_para
+{
+ uint32_t run_log_size;
+ uint32_t run_log_count;
+ char *run_log_path;
+ uint32_t mon_log_size; //master and ctrl both use the parameter to reduce the redundancy
+ uint32_t mon_log_count; //master and ctrl both use the parameter to reduce the redundancy
+ char *mon_log_path; //master and ctrl both use the parameter to reduce the redundancy
+};
+
+enum LOG_CTRL_ID
+{
+ // for socket api
+ LOG_CTRL_SEND = 0,
+ LOG_CTRL_RECV,
+ LOG_CTRL_SENDMSG,
+ LOG_CTRL_RECVMSG,
+ LOG_CTRL_READ,
+ LOG_CTRL_WRITE,
+ LOG_CTRL_READV,
+ LOG_CTRL_WRITEV,
+ LOG_CTRL_GETSOCKNAME,
+ LOG_CTRL_GETPEERNAME,
+ LOG_CTRL_GETSOCKOPT,
+
+ // for nstack service
+ LOG_CTRL_RECV_QUEUE_FULL,
+ LOG_CTRL_L4_RECV_QUEUE_FULL,
+ LOG_CTRL_HUGEPAGE_ALLOC_FAIL,
+ LOG_CTRL_TCP_MEM_NOT_ENOUGH,
+ LOG_CTRL_IPREASS_OVERFLOW,
+ LOG_CTRL_ID_MAX
+};
+
+struct log_ctrl_info
+{
+ u32 expire_time;
+ u32 unprint_count;
+ struct timespec last_log_time;
+};
+
+struct pre_init_info
+{
+ uint32_t level; /**< Log level. */
+ char log_buffer[PRE_INIT_LOG_LENGTH];
+};
+
+#define NS_LOG_STACKX(dbug,_module,_prestr,_level,fmt, ...) \
+{\
+ if ((dbug) & NS_LOG_STACKX_ON)\
+ {\
+ NS_LOGPID(_module,_prestr,_level,fmt,##__VA_ARGS__);\
+ }\
+}\
+
+
+/*****************************************************************************
+* Prototype : nstack_get_log_level
+* Description : get log level
+* Input : int module
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+extern struct nstack_logs g_nstack_logs[MAX_LOG_MODULE];
+static inline int
+nstack_get_log_level (int module)
+{
+ /* validity check for path */
+ if ((MAX_LOG_MODULE <= module) || (module < 0))
+ {
+ return -1;
+ }
+
+ return g_nstack_logs[module].level;
+}
+
+/*****************************************************************************
+* Prototype : level_stoa
+* Description : convert stack log level to app log level
+* Input : unsigned int nstack_level
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+static inline unsigned int
+level_stoa (unsigned int level)
+{
+ unsigned int golg_level;
+ switch (level)
+ {
+ case NSLOG_DBG:
+ golg_level = GLOG_LEVEL_DEBUG;
+ break;
+ case NSLOG_INF:
+ golg_level = GLOG_LEVEL_INFO;
+ break;
+ case NSLOG_WAR:
+ golg_level = GLOG_LEVEL_WARNING;
+ break;
+ case NSLOG_ERR:
+ golg_level = GLOG_LEVEL_ERROR;
+ break;
+ case NSLOG_EMG:
+ golg_level = GLOG_LEVEL_FATAL;
+ break;
+ default:
+ golg_level = GLOG_LEVEL_BUTT;
+ break;
+ }
+ return golg_level;
+}
+
+/* use the glog function to replace old nstack log module */
+
+/* segregate the dump info */
+#define LOG_TYPE(_module, _level) \
+ (((STACKX == _module) && (NSLOG_EMG == _level)) ? GLOG_LEVEL_ERROR : ((OPERATION == _module) ? GLOG_LEVEL_WARNING : GLOG_LEVEL_INFO))
+
+#define log_shooting(_module,_level) \
+ ((NULL == g_log_hook_tag.log_hook) ? (nstack_get_log_level(_module) >= _level) : (level_stoa(_level) >= g_log_hook_tag.level))
+
+/* add the non reentry protection */
+extern __thread unsigned int nstack_log_nonreentry;
+
+/* hanging up version check log need restrain */
+extern int ctrl_log_switch;
+
+#if defined MPTCP_UT
+#define NS_LOGPID(_module,_prestr,_level,fmt, ...)
+#elif !defined FOR_NSTACK_UT
+#define NS_LOGPID(_module,_prestr,_level,fmt, ...) \
+{\
+ if (log_shooting(_module, _level) && (0 == nstack_log_nonreentry) && (0 == ctrl_log_switch))\
+ {\
+ nstack_log_nonreentry = 1;\
+ NSTACK_TRACING(_level, _prestr, fmt,##__VA_ARGS__);\
+ if(nstack_log_info_check(_module, _level))\
+ glog_print(LOG_TYPE(_module,_level),_prestr,level_stoa(_level),-1,GET_FILE_NAME(__FILE__),\
+ __LINE__,__func__,fmt, ##__VA_ARGS__);\
+ nstack_log_nonreentry = 0;\
+ }\
+}
+#else
+static inline void
+ut_log_info (const char *file_name, int line_no, const char *func_name,
+ int _module, const char *_prestr, unsigned int _level, char *fmt,
+ ...)
+{
+ va_list ap;
+
+ if (log_shooting (_module, _level) && (0 == nstack_log_nonreentry)
+ && (0 == ctrl_log_switch))
+ {
+
+ nstack_log_nonreentry = 1;
+ if (nstack_log_info_check (_module, _level))
+ {
+ char pMsgBuf[MAX_LOG_TRANSITIONAL_LEN] = "\0";
+ va_start (ap, fmt);
+ VSNPRINTF_S (pMsgBuf,
+ MAX_LOG_TRANSITIONAL_LEN,
+ MAX_LOG_TRANSITIONAL_LEN - 1, fmt, ap);
+ glog_print (LOG_TYPE (_module, _level), _prestr,
+ level_stoa (_level), -1, GET_FILE_NAME (file_name),
+ line_no, func_name, "%s", pMsgBuf);
+ va_end (ap);
+ }
+ nstack_log_nonreentry = 0;
+
+ }
+}
+
+#define NS_LOGPID(_module,_prestr,_level,fmt, ...) \
+{\
+ ut_log_info(__FILE__,__LINE__, __func__, _module,_prestr,_level,fmt, ##__VA_ARGS__); \
+}
+
+#endif
+
+#ifndef FOR_NSTACK_UT
+#define NS_LOG_CTRL(_id, _module, _prestr, _level, fmt, ...) \
+{\
+ if (log_shooting(_module, _level) && (0 == nstack_log_nonreentry) && check_log_prt_time(_id))\
+ {\
+ nstack_log_nonreentry = 1;\
+ NSTACK_TRACING(_level, _prestr, fmt,##__VA_ARGS__);\
+ if(nstack_log_info_check(_module, _level))\
+ glog_print(LOG_TYPE(_module,_level),_prestr,level_stoa(_level),get_unprt_log_count(_id),\
+ GET_FILE_NAME(__FILE__),__LINE__,__func__,fmt, ##__VA_ARGS__);\
+ clr_unprt_log_count(_id);\
+ nstack_log_nonreentry = 0;\
+ }\
+}
+
+#else
+static inline void
+ut_ctrl_log_info (char *file_name, int line_no, char *func_name, int _id,
+ int _module, char *_prestr, unsigned int _level, char *fmt,
+ ...)
+{
+ va_list ap;
+ if (log_shooting (_module, _level) && (0 == nstack_log_nonreentry)
+ && check_log_prt_time (_id))
+ {
+ nstack_log_nonreentry = 1;
+ if (nstack_log_info_check (_module, _level))
+ {
+ char pMsgBuf[MAX_LOG_TRANSITIONAL_LEN] = "\0";
+ va_start (ap, fmt);
+ VSNPRINTF_S (pMsgBuf,
+ MAX_LOG_TRANSITIONAL_LEN,
+ MAX_LOG_TRANSITIONAL_LEN - 1, fmt, ap);
+ glog_print (LOG_TYPE (_module, _level), _prestr,
+ level_stoa (_level), get_unprt_log_count (_id),
+ GET_FILE_NAME (file_name), line_no, func_name, "%s",
+ pMsgBuf);
+ va_end (ap);
+ }
+ clr_unprt_log_count (_id);
+ nstack_log_nonreentry = 0;
+
+ }
+}
+
+#define NS_LOG_CTRL(_id, _module, _prestr, _level, fmt, ...) \
+{\
+ ut_ctrl_log_info(__FILE__,__LINE__, __func__, _id, _module,_prestr,_level,fmt, ##__VA_ARGS__); \
+}
+
+#endif
+
+#define NS_LOG_CTRL_STACKX(_id, dbug,_module,_prestr,_level,fmt, ...) \
+{\
+ if ((dbug) & NS_LOG_STACKX_ON)\
+ {\
+ NS_LOG_CTRL(_id, _module,_prestr,_level,fmt,##__VA_ARGS__);\
+ }\
+}\
+
+
+/*for every log modules should def marcos below use a sort module name, just like MON means Monitor*/
+#define NSMON_LOGINF(fmt, ...) NS_LOGPID(MASTER,"NSMON",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSMON_LOGDBG(fmt, ...) NS_LOGPID(MASTER,"NSMON",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSMON_LOGWAR(fmt, ...) NS_LOGPID(MASTER,"NSMON",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSMON_LOGERR(fmt, ...) NS_LOGPID(MASTER,"NSMON",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSPOL_LOGINF(debug,fmt, ...)NS_LOG_STACKX(debug,STACKX,"NSPOL",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSPOL_LOGDBG(debug,fmt, ...) NS_LOG_STACKX(debug,STACKX,"NSPOL",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSPOL_LOGWAR(debug,fmt, ...) NS_LOG_STACKX(debug,STACKX,"NSPOL",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSPOL_LOGERR(fmt, ...) NS_LOGPID(STACKX,"NSPOL",NSLOG_ERR,fmt,##__VA_ARGS__)
+#define NSPOL_LOGEMG(fmt, ...) NS_LOGPID(STACKX,"NSPOL",NSLOG_EMG,fmt,##__VA_ARGS__)
+
+#define NSOPR_LOGINF(fmt, ...) NS_LOGPID(OPERATION,"NSOPR",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSOPR_LOGDBG(fmt, ...) NS_LOGPID(OPERATION,"NSOPR",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSOPR_LOGWAR(fmt, ...) NS_LOGPID(OPERATION,"NSOPR",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSOPR_LOGERR(fmt, ...) NS_LOGPID(OPERATION,"orchestration",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSSOC_LOGINF(fmt, ...) NS_LOGPID(NSOCKET,"NSSOC",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSSOC_LOGDBG(fmt, ...) NS_LOGPID(NSOCKET,"NSSOC",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSSOC_LOGWAR(fmt, ...) NS_LOGPID(NSOCKET,"NSSOC",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSSOC_LOGERR(fmt, ...) NS_LOGPID(NSOCKET,"NSSOC",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSSBR_LOGINF(fmt, ...) NS_LOGPID(LOGSBR,"NSSBR",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSSBR_LOGDBG(fmt, ...) NS_LOGPID(LOGSBR,"NSSBR",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSSBR_LOGWAR(fmt, ...) NS_LOGPID(LOGSBR,"NSSBR",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSSBR_LOGERR(fmt, ...) NS_LOGPID(LOGSBR,"NSSBR",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSCOMM_LOGINF(fmt, ...) NS_LOGPID(LOGRTE, "NSRTE",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSCOMM_LOGDBG(fmt, ...) NS_LOGPID(LOGRTE, "NSRTE",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSCOMM_LOGWAR(fmt, ...) NS_LOGPID(LOGRTE, "NSRTE",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSCOMM_LOGERR(fmt, ...) NS_LOGPID(LOGRTE, "NSRTE",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSTCP_LOGINF(fmt, ...) NS_LOGPID(LOGTCP,"NSTCP",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSTCP_LOGDBG(fmt, ...) NS_LOGPID(LOGTCP,"NSTCP",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSTCP_LOGWAR(fmt, ...) NS_LOGPID(LOGTCP,"NSTCP",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSTCP_LOGERR(fmt, ...) NS_LOGPID(LOGTCP,"NSTCP",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSIP_LOGINF(fmt, ...) NS_LOGPID(LOGIP,"NSIP",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSIP_LOGDBG(fmt, ...) NS_LOGPID(LOGIP,"NSIP",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSIP_LOGWAR(fmt, ...) NS_LOGPID(LOGIP,"NSIP",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSIP_LOGERR(fmt, ...) NS_LOGPID(LOGIP,"NSIP",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSUDP_LOGINF(fmt, ...) NS_LOGPID(LOGUDP,"NSUDP",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSUDP_LOGDBG(fmt, ...) NS_LOGPID(LOGUDP,"NSUDP",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSUDP_LOGWAR(fmt, ...) NS_LOGPID(LOGUDP,"NSUDP",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSUDP_LOGERR(fmt, ...) NS_LOGPID(LOGUDP,"NSUDP",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSHAL_LOGINF(fmt, ...) NS_LOGPID(LOGHAL,"NSHAL",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSHAL_LOGDBG(fmt, ...) NS_LOGPID(LOGHAL,"NSHAL",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSHAL_LOGWAR(fmt, ...) NS_LOGPID(LOGHAL,"NSHAL",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSHAL_LOGERR(fmt, ...) NS_LOGPID(LOGHAL,"NSHAL",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSARP_LOGINF(fmt, ...) NS_LOGPID(LOGARP,"NSARP",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSARP_LOGDBG(fmt, ...) NS_LOGPID(LOGARP,"NSARP",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSARP_LOGWAR(fmt, ...) NS_LOGPID(LOGARP,"NSARP",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSARP_LOGERR(fmt, ...) NS_LOGPID(LOGARP,"NSARP",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSDFX_LOGINF(fmt, ...) NS_LOGPID(LOGDFX,"NSDFX",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSDFX_LOGDBG(fmt, ...) NS_LOGPID(LOGDFX,"NSDFX",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSDFX_LOGWAR(fmt, ...) NS_LOGPID(LOGDFX,"NSDFX",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSDFX_LOGERR(fmt, ...) NS_LOGPID(LOGDFX,"NSDFX",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSFW_LOGINF(fmt, ...) NS_LOGPID(LOGFW,"NSFW",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSFW_LOGDBG(fmt, ...) NS_LOGPID(LOGFW,"NSFW",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSFW_LOGERR(fmt, ...) NS_LOGPID(LOGFW,"NSFW",NSLOG_ERR,fmt,##__VA_ARGS__)
+#define NSFW_LOGWAR(fmt, ...) NS_LOGPID(LOGFW,"NSFW",NSLOG_WAR,fmt,##__VA_ARGS__)
+
+#define NSAM_LOGINF(fmt, ...) NS_LOGPID(LOGFW,"NSAM",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSAM_LOGDBG(fmt, ...) NS_LOGPID(LOGFW,"NSAM",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSAM_LOGERR(fmt, ...) NS_LOGPID(LOGFW,"NSAM",NSLOG_ERR,fmt,##__VA_ARGS__)
+#define NSAM_LOGWAR(fmt, ...) NS_LOGPID(LOGFW,"NSAM",NSLOG_WAR,fmt,##__VA_ARGS__)
+
+#define INIT_LOG_ASSEM(log_module,_prestr,_level, init_module , function, errString, errValue, status) \
+ if ((LOG_INVALID_VALUE <= errValue) && (1 == sizeof(errString))) \
+ { \
+ NS_LOGPID(log_module,_prestr, _level,MODULE_INIT_FORMAT_STRING, (char*)status, init_module, function ); \
+ } \
+ else if (LOG_INVALID_VALUE <= errValue)\
+ { \
+ NS_LOGPID(log_module,_prestr, _level,MODULE_INIT_FORMAT_STRING",err_string=%s", (char*)status, init_module, function, errString ); \
+ } \
+ else if (1 == sizeof(errString))\
+ { \
+ NS_LOGPID(log_module,_prestr, _level,MODULE_INIT_FORMAT_STRING",err_value=%d", (char*)status, init_module, function, errValue ); \
+ } \
+ else \
+ { \
+ NS_LOGPID(log_module,_prestr, _level,MODULE_INIT_FORMAT_STRING",err_string=%s,err_value=%d", (char*)status, init_module, function, errString, errValue ); \
+ } \
+
+#define INITPOL_LOGINF(init_module_name, function, err_string, err_value, status) \
+ INIT_LOG_ASSEM(STACKX,"NSPOL",NSLOG_INF,init_module_name , function, err_string, err_value, status)\
+
+#define INITPOL_LOGERR(init_module_name, function, err_string, err_value, status) \
+ INIT_LOG_ASSEM(STACKX,"NSPOL",NSLOG_ERR,init_module_name , function, err_string, err_value, status)\
+
+#define INITTCP_LOGINF(init_module_name , function, err_string, err_value, status) \
+ INIT_LOG_ASSEM(LOGTCP,"NSTCP",NSLOG_INF,init_module_name , function, err_string, err_value, status)\
+
+#define INITTCP_LOGERR(init_module_name , function, err_string, err_value, status) \
+ INIT_LOG_ASSEM(LOGTCP,"NSTCP",NSLOG_ERR,init_module_name , function, err_string, err_value, status)\
+
+#define INITMON_LOGERR(init_module_name , function, err_string, err_value, status) \
+ INIT_LOG_ASSEM(MASTER,"NSMON",NSLOG_ERR,init_module_name , function, err_string, err_value, status)\
+
+#define INITSOC_LOGERR(init_module_name , function, err_string, err_value, status) \
+ INIT_LOG_ASSEM(NSOCKET,"NSSOC",NSLOG_ERR,init_module_name , function, err_string, err_value, status)
+
+#define NSPOL_DUMP_LOGINF(fmt, ...) NSPOL_LOGINF(0x80, fmt, ##__VA_ARGS__)
+#define NSPOL_DUMP_LOGDBG(fmt, ...) NSPOL_LOGDBG(0x80, fmt, ##__VA_ARGS__)
+#define NSPOL_DUMP_LOGERR(fmt, ...) NSPOL_LOGERR(fmt, ##__VA_ARGS__)
+#define NSPOL_DUMP_LOGWAR(fmt, ...) NSPOL_LOGWAR(0x80, fmt, ##__VA_ARGS__)
+
+/*==============================================*
+ * routines' or functions' implementations *
+ *----------------------------------------------*/
+
+void save_pre_init_log (uint32_t level, char *fmt, ...);
+void write_pre_init_log ();
+
+void set_log_init_para (struct log_init_para *para);
+
+void nstack_setlog_level (int module, uint32_t level);
+bool nstack_log_info_check (uint32_t module, uint32_t level);
+int nstack_log_init ();
+void nstack_log_init_app ();
+int get_app_env_log_path (char *app_file_path, unsigned int app_file_size);
+void set_log_proc_type (int log_proc_type);
+
+int setlog_level_value (const char *param, const char *value);
+int get_str_value (const char *arg);
+int check_log_dir_valid (const char *path);
+void nstack_segment_error (int s);
+void init_log_ctrl_info ();
+void set_log_ctrl_time (int id, int ctrl_time);
+
+int cmp_log_path (const char *path);
+
+#ifndef sys_sleep_ns
+#define sys_sleep_ns(_s, _ns)\
+ {\
+ if ((_s) >= 0 && (_ns) >= 0){\
+ struct timespec delay, remain;\
+ delay.tv_sec=(_s);\
+ delay.tv_nsec=(_ns);\
+ while (nanosleep (&delay, &remain) < 0)\
+ {\
+ delay = remain;\
+ }\
+ }\
+ }
+#endif /* sys_sleep_ns */
+
+int check_log_prt_time (int id);
+int get_unprt_log_count (int id);
+void clr_unprt_log_count (int id);
+
+void get_current_time (char *buf, const int len);
+
+#ifdef CPU_CYCLES
+static __inline__ unsigned long long
+nstack_rdtsc (void)
+{
+ unsigned hi, lo;
+ __asm__ __volatile__ ("rdtsc":"=a" (lo), "=d" (hi));
+ return ((unsigned long long) lo) | (((unsigned long long) hi) << 32);
+}
+
+#define CPUB(name) \
+unsigned long long start##name = 0;\
+unsigned long long stop##name = 0;\
+static unsigned long long total##name = 0;\
+static unsigned long long total_cout##name = 0;\
+start##name = nstack_rdtsc();
+
+#define CPUE(name) \
+stop##name = nstack_rdtsc();\
+total##name += (stop##name - start##name);\
+if(++total_cout##name == 1000000)\
+{\
+ NSSOC_LOGINF(#name" cpu %llu-------\n", total##name / total_cout##name);\
+ total##name = 0;\
+ total_cout##name = 0;\
+}
+#else
+#define CPUB(name)
+#define CPUE(name)
+#endif
+
+#endif
diff --git a/src/framework/include/nstack_rd_data.h b/src/framework/include/nstack_rd_data.h
new file mode 100644
index 0000000..3924680
--- /dev/null
+++ b/src/framework/include/nstack_rd_data.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 __NSTACK_RD_DATA_H
+#define __NSTACK_RD_DATA_H
+
+/*choose router base on ip seg*/
+#define STACK_NAME_MAX 32
+#define RD_PLANE_NAMELEN (32)
+#define NSTACK_IP_BIT_MAX (32)
+#define NSTACK_RD_DATA_MAX (2048)
+#define RD_IP_STR_MAX_LEN (32)
+
+typedef enum __rd_data_type
+{
+ RD_DATA_TYPE_IP,
+ RD_DATA_TYPE_PROTO,
+ RD_DATA_TYPE_MAX,
+} rd_data_type;
+
+typedef enum __rd_node_state
+{
+ RD_NODE_USELESS,
+ RD_NODE_USING,
+ RD_NODE_DELETING,
+ RD_NODE_MAX,
+} rd_node_state;
+
+/*route info base on ip*/
+typedef struct __rd_route_ip_data
+{
+ unsigned int addr;
+ unsigned int masklen;
+ unsigned int resev[2];
+} rd_ip_data;
+
+/*route data*/
+typedef struct __rd_route_data
+{
+ /*route info type , for example base on ip */
+ rd_data_type type;
+ char stack_name[RD_PLANE_NAMELEN];
+ union
+ {
+ rd_ip_data ipdata;
+ unsigned int proto_type;
+ /*:::other type to be add */
+ };
+} rd_route_data;
+
+typedef struct __rd_route_node
+{
+ rd_node_state flag;
+ int agetime;
+ rd_route_data data;
+} rd_route_node;
+
+typedef struct __rd_route_table
+{
+ int size;
+ int icnt;
+ rd_route_node node[NSTACK_RD_DATA_MAX];
+} rd_route_table;
+
+#define MASK_V(ipaddr, masklen) ((ipaddr) & (~0 << (NSTACK_IP_BIT_MAX - (masklen))))
+
+#endif
diff --git a/src/framework/include/nstack_securec.h b/src/framework/include/nstack_securec.h
new file mode 100644
index 0000000..c9efb4f
--- /dev/null
+++ b/src/framework/include/nstack_securec.h
@@ -0,0 +1,145 @@
+/*
+*
+* 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 __NSTACK_SECUREC_H__
+#define __NSTACK_SECUREC_H__
+
+/*if you need export the function of this library in Win32 dll, use __declspec(dllexport) */
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+
+#endif /* */
+#ifndef SECUREC_LIB
+#include <stdio.h>
+#include <stdarg.h>
+#include <wchar.h>
+#include <string.h>
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif /*
+ */
+
+/*define error code*/
+#ifndef errno_t
+typedef int errno_t;
+
+#endif /*
+ */
+
+/* success */
+#define EOK (0)
+
+/* invalid parameter */
+#ifndef EINVAL
+#define EINVAL (22)
+#endif /*
+ */
+
+#define EINVAL_AND_RESET (22 | 0X80)
+#define ERANGE_AND_RESET (34 | 0X80)
+
+#define SCANF_S scanf
+#define WSCANF_S wscanf
+#define VSCANF_S vscanf
+#define VWSCANF_S vwscanf
+#define FSCANF_S fscanf
+#define FWSCANF_S fwscanf
+#define VFSCANF_S vfscanf
+#define VFWSCANF_S vfwscanf
+#define SSCANF_S sscanf
+#define SWSCANF_S swscanf
+#define VSSCANF_S vsscanf
+#define VSWSCANF_S vswscanf
+
+#define SPRINTF_S(a, b, ...) sprintf(a, ##__VA_ARGS__)
+#define SWPRINTF_S(a, b, c, ...) swprintf(a, b, c, ##__VA_ARGS__)
+#define VSPRINTF_S(a, b, c, d) vsprintf(a, c, d)
+#define VSWPRINTF_S(a, b, c, d) vswprintf(a, b, c, d)
+#define VSNPRINTF_S(a, b, c, d, e) vsnprintf(a, c, d, e)
+#define SNPRINTF_S(a, b, c, d, ...) snprintf(a, c, d, ##__VA_ARGS__)
+
+#define WMEMCPY_S(a, b, c, d) ((NULL == wmemcpy(a, c, d)) ? EINVAL : EOK)
+#define MEMMOVE_S(a, b, c, d) ((NULL == memmove(a, c, d)) ? EINVAL : EOK)
+#define WMEMMOVE_S(a, b, c, d) ((NULL == wmemmove(a, c, d)) ? EINVAL : EOK)
+#define WCSCPY_S(a, b, c) ((NULL == wcscpy(a, c)) ? EINVAL : EOK)
+#define WCSNCPY_S(a, b, c, d) ((NULL == wcsncpy(a, c, d)) ? EINVAL : EOK)
+#define WCSCAT_S(a, b, c) ((NULL == wcscat(a, c)) ? EINVAL : EOK)
+#define WCSNCAT_S(a, b, c, d) ((NULL == wcsncat(a, c, d)) ? EINVAL : EOK)
+
+#define MEMSET_S(a, b, c, d) ((NULL == memset(a, c, d)) ? EINVAL : EOK)
+#define MEMCPY_S(a, b, c, d) ((NULL == memcpy(a, c, d)) ? EINVAL : EOK)
+#define STRCPY_S(a, b, c) ((NULL == strcpy(a, c )) ? EINVAL : EOK)
+#define STRNCPY_S(a, b, c, d) ((NULL == strncpy(a, c, d)) ? EINVAL : EOK)
+#define STRCAT_S(a, b, c) ((NULL == strcat(a, c)) ? EINVAL : EOK)
+#define STRNCAT_S(a, b, c, d) ((NULL == strncat(a, c, d)) ? EINVAL : EOK)
+
+#define STRTOK_S(a, b, c) strtok(a, b)
+#define WCSTOK_S(a, b, c) wcstok(a, b)
+#define GETS_S(a, b) gets(a)
+
+#else /* */
+#include "securec.h"
+
+#define SCANF_S scanf_s
+#define WSCANF_S wscanf_s
+#define VSCANF_S vscanf_s
+#define VWSCANF_S vwscanf_s
+#define FSCANF_S fscanf_s
+#define FWSCANF_S fwscanf_s
+#define VFSCANF_S vfscanf_s
+#define VFWSCANF_S vfwscanf_s
+#define SSCANF_S sscanf_s
+#define SWSCANF_S swscanf_s
+#define VSSCANF_S vsscanf_s
+#define VSWSCANF_S vswscanf_s
+
+#define SPRINTF_S(a, b, ...) sprintf_s (a, b, ##__VA_ARGS__)
+#define SWPRINTF_S(a, b, c, ...) swprintf_s(a, b, c, ##__VA_ARGS__)
+#define VSPRINTF_S(a, b, c, d) vsprintf_s(a, b, c, d)
+#define VSWPRINTF_S(a, b, c, d) vswprintf_s(a, b, c, d)
+#define VSNPRINTF_S(a, b, c, d, e) vsnprintf_s(a, b, c, d, e)
+#define SNPRINTF_S(a, b, c, d, ...) snprintf_s(a, b, c, d, ##__VA_ARGS__)
+
+#define WMEMCPY_S(a, b, c, d) wmemcpy_s(a, b, c, d)
+#define MEMMOVE_S(a, b, c, d) memmove_s(a, b, c, d)
+#define WMEMMOVE_S(a, b, c, d) wmemmove_s(a, b, c, d)
+#define WCSCPY_S(a, b, c) wcscpy_s(a, b, c)
+#define WCSNCPY_S(a, b, c, d) wcsncpy_s(a, b, c, d)
+#define WCSCAT_S(a, b, c) wcscat_s(a, b, c)
+#define WCSNCAT_S(a, b, c, d) wcsncat_s(a, b, c, d)
+
+#define MEMSET_S(a, b, c, d) memset_s(a, b, c, d)
+#define MEMCPY_S(a, b, c, d) memcpy_s(a, b, c, d)
+#define STRCPY_S(a, b, c) strcpy_s(a, b, c)
+#define STRNCPY_S(a, b, c, d) strncpy_s(a, b, c, d)
+#define STRCAT_S(a, b, c) strcat_s(a, b, c)
+#define STRNCAT_S(a, b, c, d) strncat_s(a, b, c, d)
+
+#define STRTOK_S(a, b, c) strtok_s(a, b, c)
+#define WCSTOK_S(a, b, c) wcstok_s(a, b, c)
+#define GETS_S(a, b) gets_s(a, b)
+#endif /* */
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#endif /* __NSTACK_SECUREC_H__ */
diff --git a/src/framework/include/nstack_trace.h b/src/framework/include/nstack_trace.h
new file mode 100644
index 0000000..0f4f640
--- /dev/null
+++ b/src/framework/include/nstack_trace.h
@@ -0,0 +1,76 @@
+/*
+*
+* 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 __NSTACK_TRACE_H__
+#define __NSTACK_TRACE_H__
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif
+
+/*==============================================*
+ * include header files *
+ *----------------------------------------------*/
+#include "types.h"
+#include "nstack_log.h"
+#include <time.h>
+#define SPAN_NAME_MAX 64
+#define TRACE_NULL 0
+#define NSTACK_TRACE_ON 0
+#define NSTACK_TRACE_OFF 1
+
+typedef struct nst_trace_header
+{
+ u64 trace_id;
+ u64 span_pid;
+ u64 span_id; /*now us */
+ int fd;
+ int thread_id;
+} trace_hread_t;
+
+typedef struct nst_trace_fun
+{
+ u64 (*current_traceid) ();
+ void (*span_raw) (char *msg);
+ void (*tracing_enable) (int enable);
+ void (*tracing_simpling) (int frequency);
+ void (*tracing_cleanup) ();
+ void (*tracing_setup) (u32 process);
+ u64 (*tracing_string_to_traceid) (const char *input, size_t length);
+} trace_fun_t;
+
+extern __thread struct nst_trace_header strace_header;
+
+#define get_trace_header() (&strace_header)
+
+//For Tracing define own tracing feature.
+#define nstack_trace_init( a )
+#define nstack_set_tracing_contex( a,b,c)
+#define nstack_get_tracing_contex(traceid,spanid,spanpid,fd)
+#define nstack_clear_tracing_contex( )
+#define NSTACK_TRACING(level, module_name,famt,...)
+#define nstack_tracing_enalbe()
+#define nstack_get_traceid() (NULL)
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif