summaryrefslogtreecommitdiffstats
path: root/src/nSocket/include/nstack_dmm_api.h
diff options
context:
space:
mode:
authorYalei Wang <william.wangyalei@huawei.com>2018-03-12 10:07:58 +0800
committerYalei Wang <william.wangyalei@huawei.com>2018-03-12 10:07:58 +0800
commitc398e6ec613c1f90ffe33608c511208100e7372f (patch)
tree554b2bc400e14e9ae8e838582e7433ea71eb499f /src/nSocket/include/nstack_dmm_api.h
parent71a4e2f34afa8018426f0e830050e50a1de6d375 (diff)
Add the nSocket module for dmm
Change-Id: I8b97fbe50c9c1c479072510b8d799fe711360da7 Signed-off-by: Yalei Wang <william.wangyalei@huawei.com>
Diffstat (limited to 'src/nSocket/include/nstack_dmm_api.h')
-rw-r--r--src/nSocket/include/nstack_dmm_api.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/nSocket/include/nstack_dmm_api.h b/src/nSocket/include/nstack_dmm_api.h
new file mode 100644
index 0000000..4caeb5e
--- /dev/null
+++ b/src/nSocket/include/nstack_dmm_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 __NSOCKET_DMM_API_H__
+#define __NSOCKET_DMM_API_H__
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/epoll.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "nstack_rd_data.h"
+
+/*
+ *Standard api interface definition.
+ *these interface is provided by Protocol stack to nStack
+ */
+typedef struct __nstack_socket_ops
+{
+#undef NSTACK_MK_DECL
+#define NSTACK_MK_DECL(ret, fn, args) ret (*pf##fn) args
+#include "declare_syscalls.h"
+} nstack_socket_ops;
+
+typedef enum
+{
+ STACK_FD_INVALID_CHECK, /*check wether fd is created by this stack */
+ STACK_FD_FUNCALL_CHECK, /*check this stack surpport default call */
+} nstack_fd_check;
+
+typedef enum
+{
+ nstack_ep_triggle_add,
+ nstack_ep_triggle_mod,
+ nstack_ep_triggle_del
+} nstack_ep_triggle_ops_t;
+
+/*
+ *Interactive interface for Protocol stack and nStack defined here
+ *these interface is provided by Protocol stack to nStack
+ */
+typedef struct __nstack_extern_ops
+{
+ int (*module_init) (void); /*stack module init */
+ int (*fork_init_child) (pid_t p, pid_t c); /*after fork, stack child process init again if needed. */
+ void (*fork_parent_fd) (int s, pid_t p); /*after fork, stack parent process proc again if needed. */
+ void (*fork_child_fd) (int s, pid_t p, pid_t c); /*after fork, child record pid for recycle if needed. */
+ void (*fork_free_fd) (int s, pid_t p, pid_t c); /*for SOCK_CLOEXEC when fork if needed. */
+ unsigned int (*ep_ctl) (int epFD, int proFD, int ctl_ops, struct epoll_event * event, void *pdata); /*when fd add to epoll fd, triggle stack to proc if need */
+ unsigned int (*ep_getevt) (int epFD, int profd, unsigned int events); /*check whether some events exist really */
+ int (*ep_prewait_proc) (int epfd);
+ int (*stack_fd_check) (int s, int flag); /*check whether fd belong to stack, if belong, return 1, else return 0 */
+ int (*stack_alloc_fd) (); /*alloc a fd id for epoll */
+ int (*peak) (int s); /*used for stack-x , isource maybe no need */
+} nstack_extern_ops;
+
+/*
+ *The event notify interface provided to the protocol stack by nStack
+ *these interface is provided by nStack to Protocol stack
+ */
+typedef struct __nstack_event_cb
+{
+ void *handle; /*current so file handler */
+ int type; /*nstack is assigned to the protocol stack and needs to be passed to nstack when the event is reported */
+ int (*event_cb) (void *pdata, int events);
+} nstack_event_cb;
+
+typedef struct __nstack_proc_cb
+{
+ nstack_socket_ops socket_ops; /*posix socket api */
+ nstack_extern_ops extern_ops; /*other proc callback */
+} nstack_proc_cb;
+
+typedef int (*nstack_stack_registe_fn) (nstack_proc_cb * proc_fun,
+ nstack_event_cb * event_ops);
+
+#endif