1 /*
2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 * Description: service_list.h 的头文件
15 */
16
17 #ifndef EXT_WIFI_SERVICE_ENVENT_H
18 #define EXT_WIFI_SERVICE_ENVENT_H
19 #include "wifi_event.h"
20
21 #ifdef __cplusplus
22 #if __cplusplus
23 extern "C" {
24 #endif
25 #endif
26 /* Config Methods */
27 #define WPS_USBA 0x0001
28 #define WPS_ETHERNET 0x0002
29 #define WPS_LABEL 0x0004
30 #define WPS_DISPLAY 0x0008
31 #define WPS_EXT_NFC_TOKEN 0x0010
32 #define WPS_INT_NFC_TOKEN 0x0020
33 #define WPS_NFC_INTERFACE 0x0040
34 #define WPS_PUSHBUTTON 0x0080
35 #define WPS_KEYPAD 0x0100
36 #define WPS_VIRT_PUSHBUTTON 0x0280
37 #define WPS_PHY_PUSHBUTTON 0x0480
38 #define WPS_P2PS 0x1000
39 #define WPS_VIRT_DISPLAY 0x2008
40 #define WPS_PHY_DISPLAY 0x4008
41
42 #define off_set_of(type, member) ((unsigned int)&((type *)0)->member)
43
44 #define dl_list_entry(item, type, member) \
45 ((type *)(void *)((char *)(item) - off_set_of(type, member)))
46
47 #define dl_list_for_each_entry(item, list, type, member) \
48 for ((item) = dl_list_entry((list)->next, type, member); \
49 &(item)->member != (list); \
50 (item) = dl_list_entry((item)->member.next, type, member))
51
52 #define dl_list_for_each_entry_safe(item, next, list, type, member) \
53 for ((item) = dl_list_entry((list)->next, type, member), \
54 (next) = dl_list_entry((item)->member.next, type, member); \
55 &(item)->member != (list); \
56 (item) = (next), (next) = dl_list_entry((item)->member.next, type, member))
57
58 #define dl_list_first(object) ((object)->next)
59
60 #define service_error_log0(msg_level, fmt) printf(fmt"\r\n")
61 #define service_error_log1(msg_level, fmt, p1) printf(fmt"\r\n", p1)
62 #define service_error_log2(msg_level, fmt, p1, p2) printf(fmt"\r\n", p1, p2)
63 #define service_error_log3(msg_level, fmt, p1, p2, p3) printf(fmt"\r\n", p1, p2, p3)
64 #define service_error_log4(msg_level, fmt, p1, p2, p3, p4) printf(fmt"\r\n", p1, p2, p3, p4)
65
66 enum {
67 SERVICE_EXCESSIVE, SERVICE_MSGDUMP, SERVICE_DEBUG, SERVICE_INFO, SERVICE_WARNING, SERVICE_ERROR
68 };
69
70 typedef struct dl_list {
71 struct dl_list *prev; /* < Current node's pointer to the previous node */
72 struct dl_list *next; /* < Current node's pointer to the next node */
73 } dl_list;
74
75 typedef struct service_event_cb {
76 dl_list node;
77 wifi_event_stru service_cb;
78 } service_event_cb;
79
list_init(dl_list * list)80 static inline void list_init(dl_list *list)
81 {
82 list->next = list;
83 list->prev = list;
84 }
85
list_delinit(dl_list * list)86 static inline void list_delinit(dl_list *list)
87 {
88 list->next->prev = list->prev;
89 list->prev->next = list->next;
90 list_init(list);
91 }
92
list_add_node(dl_list * list,dl_list * node)93 static inline void list_add_node(dl_list *list, dl_list *node)
94 {
95 node->next = list->next;
96 node->prev = list;
97 list->next->prev = node;
98 list->next = node;
99 }
100
list_delete_node(dl_list * node)101 static inline void list_delete_node(dl_list *node)
102 {
103 node->next->prev = node->prev;
104 node->prev->next = node->next;
105 node->next = NULL;
106 node->prev = NULL;
107 }
108
list_tail_insert(dl_list * list,dl_list * node)109 static inline void list_tail_insert(dl_list *list, dl_list *node)
110 {
111 list_add_node(list->prev, node);
112 }
113
list_empty(const dl_list * list)114 static inline int list_empty(const dl_list *list)
115 {
116 return (list->next == list);
117 }
118 #ifdef __cplusplus
119 #if __cplusplus
120 }
121 #endif
122 #endif
123
124 #endif
125