aboutsummaryrefslogtreecommitdiffstats
path: root/src/framework/common/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/framework/common/include')
-rw-r--r--src/framework/common/include/compile_config.h30
-rw-r--r--src/framework/common/include/compiling_check.h106
-rw-r--r--src/framework/common/include/ephlist.h199
-rw-r--r--src/framework/common/include/eprb_tree.h84
-rw-r--r--src/framework/common/include/list.h181
-rw-r--r--src/framework/common/include/pidinfo.h48
-rw-r--r--src/framework/common/include/sha256.h94
-rw-r--r--src/framework/common/include/types.h97
8 files changed, 839 insertions, 0 deletions
diff --git a/src/framework/common/include/compile_config.h b/src/framework/common/include/compile_config.h
new file mode 100644
index 0000000..2ec5373
--- /dev/null
+++ b/src/framework/common/include/compile_config.h
@@ -0,0 +1,30 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef COMPILE_CONFIG_H
+#define COMPILE_CONFIG_H
+
+#ifndef NSTACK_STATIC
+#ifndef NSTACK_STATIC_CHECK
+#define NSTACK_STATIC static
+#else
+#define NSTACK_STATIC
+#endif
+#endif
+
+#include "compiling_check.h"
+
+#endif /*compile_config.h */
diff --git a/src/framework/common/include/compiling_check.h b/src/framework/common/include/compiling_check.h
new file mode 100644
index 0000000..e4a7538
--- /dev/null
+++ b/src/framework/common/include/compiling_check.h
@@ -0,0 +1,106 @@
+/*
+*
+* 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 COMPILING_CHECK_H
+#define COMPILING_CHECK_H
+
+/* protect the value of macro whose value impacts the version
+ * compatibility, can't be changed!!! */
+#define COMPAT_PROTECT(name, value) \
+static inline char value_of_##name##_equal_to() \
+{ \
+ char __dummy1[(name) - (value)]; \
+ char __dummy2[(value) - (name)]; \
+ return __dummy1[-1] + __dummy2[-1]; \
+}
+
+/* check whether struct size is equal to a special value */
+#define SIZE_OF_TYPE_EQUAL_TO(type, size) \
+static inline char size_of_##type##_equal_to_##size() \
+{ \
+ char __dummy1[sizeof(type) - size]; \
+ char __dummy2[size - sizeof(type)]; \
+ return __dummy1[-1] + __dummy2[-1]; \
+}
+
+/* check whether struct size is not equal to a special value */
+#define SIZE_OF_TYPE_UNEQUAL_TO(type, size) \
+static inline char size_of_##type##_unequal_to_##size() \
+{ \
+ char __dummy1[0==(10/(sizeof(type)-size))]; \
+ return __dummy1[-1]; \
+}
+
+/* check whether struct size is not larger than a special value */
+#define SIZE_OF_TYPE_NOT_LARGER_THAN(type, size) \
+static inline char size_of_##type##_not_larger_than_##size() \
+{ \
+ char __dummy1[size - sizeof(type)]; \
+ return __dummy1[-1]; \
+}
+
+/* check whether struct size + sizeof(void*) is not larger than a special value */
+/* reserve 8 bytes for 64 bits pointers */
+#define SIZE_OF_TYPE_PLUS8_NOT_LARGER_THAN(type, size) \
+static inline char size_of_##type##_not_larger_than_##size() \
+{ \
+ char __dummy1[size - sizeof(type) - sizeof(void*)]; \
+ return __dummy1[-1]; \
+}
+
+/* check whether struct size is not smaller than a special value */
+#define SIZE_OF_TYPE_NOT_SMALLER_THAN(type, size) \
+static inline char size_of_##type##_not_smaller_than_##size() \
+{ \
+ char __dummy1[sizeof(type) - size]; \
+ return __dummy1[-1]; \
+}
+
+/* check whether struct size is smaller than a special value */
+#define SIZE_OF_TYPE_SMALLER_THAN(type, size) \
+ SIZE_OF_TYPE_NOT_LARGER_THAN(type, size) \
+ SIZE_OF_TYPE_UNEQUAL_TO(type, size)
+
+/* check whether struct size is larger than a special value */
+#define SIZE_OF_TYPE_LARGER_THAN(type, size) \
+ SIZE_OF_TYPE_NOT_SMALLER_THAN(type, size) \
+ SIZE_OF_TYPE_UNEQUAL_TO(type, size)
+
+/* check whether struct size is smaller than a special value, version 2 */
+#define SIZE_OF_TYPE_SMALLER_THAN2(type, size) \
+static inline char size_of_##type##_smaller_than2_##size() \
+{ \
+ char __dummy1[size - sizeof(type) - 1]; \
+ return __dummy1[-1]; \
+}
+
+/* check whether struct size is larger than a special value, version 2 */
+#define SIZE_OF_TYPE_LARGER_THAN2(type, size) \
+static inline char size_of_##type##_larger_than2_##size() \
+{ \
+ char __dummy1[sizeof(type) - size - 1]; \
+ return __dummy1[-1]; \
+}
+
+/* check whether struct size is equal to an integer multiple of a special value */
+#define SIZE_OF_TYPE_IS_MULTIPLE_OF(type, size) \
+static inline char size_of_##type##_is_multiple_of_##size() \
+{ \
+ char __dummy1[0 - (sizeof(type) % size)]; \
+ return __dummy1[-1]; \
+}
+
+#endif /*compiling_check.h */
diff --git a/src/framework/common/include/ephlist.h b/src/framework/common/include/ephlist.h
new file mode 100644
index 0000000..90491b0
--- /dev/null
+++ b/src/framework/common/include/ephlist.h
@@ -0,0 +1,199 @@
+/*
+*
+* 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 _EPHLIST_H_
+#define _EPHLIST_H_
+
+#include <stdio.h>
+#include "types.h"
+#include "common_mem_pal.h"
+#include "common_mem_buf.h"
+#include "common_pal_bitwide_adjust.h"
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+struct ep_hlist_node
+{
+ struct ep_hlist_node *next, **pprev;
+};
+
+struct ep_node_list
+{
+ struct ep_hlist_node *head;
+ struct ep_hlist_node *tail;
+};
+
+struct ep_hlist
+{
+ struct ep_hlist_node node;
+ struct ep_hlist_node *head;
+ struct ep_hlist_node *tail;
+};
+
+#define ep_hlist_entry(ptr, type, member) container_of(ptr, type, member)
+
+#define EP_HLIST_INIT_NODE(node) {\
+ (node)->next = NULL;\
+ (node)->pprev = NULL; \
+ }
+
+#define EP_HLIST_INIT(ptr) {\
+ EP_HLIST_INIT_NODE(&((ptr)->node)); \
+ (ptr)->head = (struct ep_hlist_node*)ADDR_LTOSH_EXT(&((ptr)->node)); \
+ (ptr)->tail = (struct ep_hlist_node*)ADDR_LTOSH_EXT(&((ptr)->node)); \
+ }
+
+#define EP_HLIST_PREV(ptr) ((struct ep_hlist_node*)(ADDR_SHTOL((ptr)->pprev)))
+/* list check may below zero check header, because if app crash before
+ do list->size++, it will lead problem */
+#define EP_HLIST_EMPTY(list) (NULL == ((struct ep_hlist_node*)ADDR_SHTOL((list)->head))->next)
+#define EP_HLIST_NODE_LINKED(node) (!(!(node)->pprev))
+
+static __inline void ep_hlist_del (struct ep_hlist *list,
+ struct ep_hlist_node *n);
+static __inline void ep_hlist_add_tail (struct ep_hlist *list,
+ struct ep_hlist_node *node);
+
+/*
+ * list , n are local pointer, don't need to cast
+ */
+static __inline void
+ep_hlist_del (struct ep_hlist *list, struct ep_hlist_node *n)
+{
+ if (!EP_HLIST_NODE_LINKED (n))
+ return;
+ EP_HLIST_PREV (n)->next = n->next;
+ if (n->next)
+ {
+ ((struct ep_hlist_node *) ADDR_SHTOL (n->next))->pprev = n->pprev;
+ }
+ else
+ {
+ list->tail = (struct ep_hlist_node *) (n->pprev);
+ }
+ EP_HLIST_INIT_NODE (n);
+}
+
+/**
+ * list, node are local pointer , don't need to case
+ */
+static __inline void
+ep_hlist_add_tail (struct ep_hlist *list, struct ep_hlist_node *node)
+{
+ struct ep_hlist_node *tail =
+ (struct ep_hlist_node *) ADDR_SHTOL (list->tail);
+ EP_HLIST_INIT_NODE (node);
+ node->pprev = (struct ep_hlist_node **) ADDR_LTOSH_EXT (&tail->next);
+ tail->next = (struct ep_hlist_node *) ADDR_LTOSH_EXT (node);
+ list->tail = (struct ep_hlist_node *) ADDR_LTOSH_EXT (node);
+}
+
+/*#########################################################*/
+struct list_node
+{
+ struct list_node *next;
+};
+
+struct ep_list
+{
+ struct list_node node;
+ struct list_node *head;
+};
+
+#define ep_list_entry(ptr, type, member) container_of(ptr, type, member)
+
+#define EP_LIST_INIT_NODE(node) {\
+ (node)->next = NULL;\
+ }
+
+#define EP_LIST_INIT(ptr) {\
+ EP_LIST_INIT_NODE(&((ptr)->node)); \
+ (ptr)->head = (struct list_node*)ADDR_LTOSH_EXT(&((ptr)->node)); \
+ }
+
+#define EP_LIST_EMPTY(list) (NULL == ((struct list_node*)ADDR_SHTOL((list)->head))->next)
+
+static __inline void ep_list_del (struct ep_list *list, struct list_node *n);
+static __inline void ep_list_add_tail (struct ep_list *list,
+ struct list_node *node);
+
+/*
+ * list , n are local pointer, don't need to cast
+ */
+static __inline void
+ep_list_del (struct ep_list *list, struct list_node *n)
+{
+ if (NULL == n)
+ {
+ return;
+ }
+
+ struct list_node *p_node;
+ struct list_node *p_prev = NULL;
+ p_node = ((struct list_node *) ADDR_SHTOL (list->head));
+ while (NULL != p_node && p_node != n)
+ {
+ p_prev = p_node;
+ p_node = ((struct list_node *) ADDR_SHTOL (p_node->next));
+ }
+
+ if (p_node != n || p_prev == NULL)
+ {
+ return;
+ }
+
+ p_prev->next = n->next;
+
+ EP_LIST_INIT_NODE (n);
+ return;
+}
+
+/**
+ * list, node are local pointer , don't need to case
+ */
+static __inline void
+ep_list_add_tail (struct ep_list *list, struct list_node *node)
+{
+
+ struct list_node *p_node;
+ struct list_node *p_prev = NULL;
+ p_node = ((struct list_node *) ADDR_SHTOL (list->head));
+ while (NULL != p_node)
+ {
+ p_prev = p_node;
+ p_node = ((struct list_node *) ADDR_SHTOL (p_node->next));
+ }
+
+ if (NULL == p_prev)
+ {
+ return;
+ }
+
+ EP_LIST_INIT_NODE (node);
+ p_prev->next = (struct list_node *) ADDR_LTOSH_EXT (node);
+ return;
+}
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif /* _HLIST_H_ */
diff --git a/src/framework/common/include/eprb_tree.h b/src/framework/common/include/eprb_tree.h
new file mode 100644
index 0000000..558ab2d
--- /dev/null
+++ b/src/framework/common/include/eprb_tree.h
@@ -0,0 +1,84 @@
+/*
+*
+* 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 _EPRB_TREE_H_
+#define _EPRB_TREE_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "types.h"
+#include "common_mem_pal.h"
+#include "common_mem_buf.h"
+#include "common_pal_bitwide_adjust.h"
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#define EP_RB_RED 0
+#define EP_RB_BLACK 1
+
+struct ep_rb_node
+{
+ int color;
+
+ struct ep_rb_node *rb_parent;
+ struct ep_rb_node *rb_right;
+ struct ep_rb_node *rb_left;
+};
+
+/* The alignment might seem pointless, but allegedly CRIS needs it */
+
+struct ep_rb_root
+{
+ struct ep_rb_node *rb_node;
+};
+
+#define ep_rb_parent(r) ((struct ep_rb_node *)((r)->rb_parent))
+
+static inline void
+ep_rb_set_parent (struct ep_rb_node *rb, struct ep_rb_node *p)
+{
+ rb->rb_parent = (struct ep_rb_node *) ADDR_LTOSH_EXT (p);
+}
+
+#define ep_rb_entry(ptr, type, member) container_of(ptr, type, member)
+
+extern void ep_rb_insert_color (struct ep_rb_node *, struct ep_rb_root *);
+extern void ep_rb_erase (struct ep_rb_node *, struct ep_rb_root *);
+struct ep_rb_node *ep_rb_first (const struct ep_rb_root *);
+
+static inline void
+ep_rb_link_node (struct ep_rb_node *node,
+ struct ep_rb_node *parent, struct ep_rb_node **rb_link)
+{
+
+ node->rb_parent = (struct ep_rb_node *) ADDR_LTOSH_EXT (parent);
+ node->rb_left = node->rb_right = NULL;
+
+ *rb_link = (struct ep_rb_node *) ADDR_LTOSH_EXT (node);
+ node->color = EP_RB_RED;
+
+}
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif
diff --git a/src/framework/common/include/list.h b/src/framework/common/include/list.h
new file mode 100644
index 0000000..01860bc
--- /dev/null
+++ b/src/framework/common/include/list.h
@@ -0,0 +1,181 @@
+/*
+*
+* 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 LIST_H_
+#define LIST_H_
+
+#include <signal.h>
+#include <stdio.h>
+#include <pthread.h>
+#include <unistd.h>
+
+#include "types.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+struct list_head
+{
+ union
+ {
+ struct list_head *next;
+ };
+
+ union
+ {
+ struct list_head *prev;
+ };
+};
+
+struct hlist_node
+{
+ /**
+ * @pprev: point the previous node's next pointer
+ */
+ union
+ {
+ struct hlist_node *next;
+ };
+
+ union
+ {
+ struct hlist_node **pprev;
+ };
+};
+
+struct hlist_head
+{
+ struct hlist_node *first;
+};
+
+#define list_entry(ptr, type, member) \
+ container_of(ptr, type, member)
+
+#define list_for_each_entry_type(tpos, typeof_tpos,pos, head, member) \
+ for (pos = ((head)->next); \
+ pos && pos != (head) && ({tpos = list_entry(pos, typeof_tpos, member); 1;}); \
+ pos = ((pos)->next))
+
+#define LINT_LIST()
+
+#define list_for_each_entry(tpos, pos, head, member) \
+ for (pos = ((head)->next); \
+ pos && pos != (head) && ({tpos = list_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = ((pos)->next))
+
+#define list_for_each_entry_list_head(tpos, pos, head, member) \
+ for (pos = (struct list_head *)((head)->next); \
+ pos && pos != (struct list_head *)(head) && ({tpos = list_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = (pos)->next)
+#define list_for_each_safe_entry(tpos, pos, n, head, member) \
+ for (pos = (head)->next,n = pos->next; \
+ pos && pos != (head) && ({tpos = list_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = n,n = (pos)->next)
+
+#define INIT_LIST_HEAD(list) {(list)->next = (list); (list)->prev = (list);}
+
+/*
+ * @head: the list to test.
+ */
+inline void list_add (struct list_head *newp, struct list_head *head);
+inline void list_link (struct list_head *newhead, struct list_head *head);
+inline void list_add_tail (struct list_head *newp, struct list_head *head);
+inline int list_empty (const struct list_head *head);
+inline void list_del (struct list_head *entry);
+inline struct list_head *list_get_first (struct list_head *head);
+inline void hlist_del_init (struct hlist_node *n);
+
+struct hlist_tail
+{
+ struct hlist_node *end;
+};
+
+struct hlist_ctl
+{
+ struct hlist_head head;
+ struct hlist_tail tail;
+};
+#define INIT_HLIST_CTRL(ptr) {(ptr)->head.first = NULL; (ptr)->tail.end = NULL;}
+
+inline int hlist_empty (const struct hlist_head *h);
+inline void hlist_add_head (struct hlist_node *n, struct hlist_head *h);
+
+#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
+#define INIT_HLIST_NODE(ptr) {(ptr)->next = NULL; (ptr)->pprev = NULL;}
+#define hlist_entry(ptr, type, member) \
+ container_of(ptr, type, member)
+
+/***
+ * hlist_for_each_entry - iterate over list of given type
+ * @member: the name of the hlist_node within the struct.
+ * @head: the head for your list.
+ * @pos: the &struct hlist_node to use as a loop cursor.
+ * @tpos: the type * to use as a loop cursor.
+ */
+#define hlist_for_each_entry(tpos, pos, head, member) \
+ for (pos = (head)->first; \
+ pos && ({tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = pos->next)
+
+/**
+ * hlist_for_each_entry_type - iterate over list of given type
+ * @member: the name of the hlist_node within the struct.
+ * @head: the head for your list.
+ * @pos: the &struct hlist_node to use as a loop cursor.
+ * @tpos: the type * to use as a loop cursor.
+ */
+#define hlist_for_each_entry_type(tpos, typeof_tpos,pos, head, member) \
+ for (pos = (head)->first; \
+ pos && ({tpos = hlist_entry(pos, typeof_tpos, member); 1;}); \
+ pos = pos->next)
+
+inline void hlist_del_init (struct hlist_node *n);
+
+/**
+ * next must be != NULL
+ * add n node before next node
+ *
+ * @n: new node
+ * @next: node in the hlist
+ */
+inline void hlist_add_before (struct hlist_node *n, struct hlist_node *next);
+
+/**
+ * next must be != NULL
+ * add n node after next node
+ * actual behavior is add after n
+ * @n: node in the hlist
+ * @next: new node
+ */
+inline void hlist_add_after (struct hlist_node *n, struct hlist_node *next);
+
+/* add after the head */
+inline void hlist_add_head (struct hlist_node *n, struct hlist_head *h);
+
+inline int hlist_unhashed (const struct hlist_node *h);
+
+inline int hlist_empty (const struct hlist_head *h);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+};
+/* *INDENT-ON* */
+#endif
+
+#endif /* HASH_H_ */
diff --git a/src/framework/common/include/pidinfo.h b/src/framework/common/include/pidinfo.h
new file mode 100644
index 0000000..7438756
--- /dev/null
+++ b/src/framework/common/include/pidinfo.h
@@ -0,0 +1,48 @@
+/*
+*
+* 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 _PIDINFO_H_
+#define _PIDINFO_H_
+
+#include "types.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#define NSFW_MAX_FORK_NUM 32
+typedef struct
+{
+ u32 used_size;
+ u32 apid[NSFW_MAX_FORK_NUM];
+} nsfw_pidinfo;
+
+inline i32 nsfw_pidinfo_init (nsfw_pidinfo * pidinfo);
+inline int nsfw_add_pid (nsfw_pidinfo * pidinfo, u32 pid);
+inline int nsfw_del_pid (nsfw_pidinfo * pidinfo, u32 pid);
+inline int nsfw_del_last_pid (nsfw_pidinfo * pidinfo, u32 pid);
+inline int nsfw_pid_exist (nsfw_pidinfo * pidinfo, u32 pid);
+inline int nsfw_pidinfo_empty (nsfw_pidinfo * pidinfo);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+};
+/* *INDENT-ON* */
+#endif
+
+#endif /* _PIDINFO_H_ */
diff --git a/src/framework/common/include/sha256.h b/src/framework/common/include/sha256.h
new file mode 100644
index 0000000..b1c7f3c
--- /dev/null
+++ b/src/framework/common/include/sha256.h
@@ -0,0 +1,94 @@
+/*
+*
+* 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 _SHA256_H_
+#define _SHA256_H_
+#include "types.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+/* Note that the following function prototypes are the same */
+/* for both the bit and byte oriented implementations. But */
+/* the length fields are in bytes or bits as is appropriate */
+/* for the version used. Bit sequences are arrays of bytes */
+/* in which bit sequence indexes increase from the most to */
+/* the least significant end of each byte */
+
+#define SHA256_DIGEST_SIZE 32 /* in bytes */
+#define SHA256_BLOCK_SIZE 64 /* in bytes */
+
+typedef struct
+{
+ u32 count[2];
+ u32 hash[8];
+ u32 wbuf[16];
+} SHA256_CTX;
+
+/* SHA256 hash data in an array of bytes into hash buffer */
+/* and call the hash_compile function as required. */
+
+/*===========================================================================*\
+ Function :Sha256_upd
+ Description :
+ Calls :
+ Called by :
+ Return :void -
+ Parameters :
+ SHA256_CTX ctx[1] -
+ const unsigned char data[] -
+ size_t len -
+ Note :
+\*===========================================================================*/
+void Sha256_upd (SHA256_CTX ctx[1], const u8 data[], size_t len);
+
+/* SHA256 Final padding and digest calculation */
+
+/*===========================================================================*\
+ Function :Sha256_set
+ Description :
+ Calls :
+ Called by :
+ Return :void -
+ Parameters :
+ SHA256_CTX ctx[1] -
+ Note :
+\*===========================================================================*/
+void Sha256_set (SHA256_CTX ctx[1]);
+
+/*===========================================================================*\
+ Function :Sha256_fin
+ Description :
+ Calls :
+ Called by :
+ Return :void -
+ Parameters :
+ SHA256_CTX ctx[1] -
+ unsigned char hval[] -
+ Note :
+\*===========================================================================*/
+void Sha256_fin (SHA256_CTX ctx[1], u8 hval[]);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif /* _SHA256_H_ */
diff --git a/src/framework/common/include/types.h b/src/framework/common/include/types.h
new file mode 100644
index 0000000..c7d013c
--- /dev/null
+++ b/src/framework/common/include/types.h
@@ -0,0 +1,97 @@
+/*
+*
+* 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 clib_types_h
+#define clib_types_h
+#include <stddef.h>
+
+/* Standard CLIB types. */
+
+/* Define signed and unsigned 8, 16, 32, and 64 bit types
+ and machine signed/unsigned word for all architectures. */
+typedef char i8;
+typedef short i16;
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+
+typedef int i32;
+typedef long long i64;
+
+typedef unsigned int u32;
+typedef unsigned long long u64;
+
+#ifndef bool
+#define bool int
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef true
+#define true 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef false
+#define false 0
+#endif
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+#define container_of(ptr, type, member) ( \
+ (type *)((char *)(ptr) - offsetof(type,member)) \
+ )
+
+#define PRIMARY_ADDR
+
+typedef struct _nsfw_res
+{
+ u8 alloc_flag;
+ u8 u8Reserve;
+ u16 chk_count;
+ u32 data;
+} nsfw_res;
+
+static inline void
+res_alloc (nsfw_res * res)
+{
+ res->alloc_flag = TRUE;
+ res->chk_count = 0;
+ res->u8Reserve = 0;
+}
+
+static inline int
+res_free (nsfw_res * res)
+{
+ if (TRUE != res->alloc_flag)
+ {
+ return -1;
+ }
+ res->chk_count = 0;
+ res->alloc_flag = FALSE;
+ return 0;
+}
+
+#define NSFW_THREAD __thread
+
+#endif /*clib_types_h */