1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
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  */
15 
16 #ifndef NETLINK_ADAPTER_H
17 #define NETLINK_ADAPTER_H
18 
19 #include <netlink/socket.h>
20 #include <netlink/msg.h>
21 #include <pthread.h>
22 
23 enum ThreadStatus {
24     THREAD_INIT,
25     THREAD_STARTING,
26     THREAD_RUN,
27     THREAD_STOPPING,
28     THREAD_STOP,
29 };
30 
31 typedef int32_t (*RespHandler)(struct nl_msg *msg, void *data);
32 
33 struct WifiThreadParam {
34     struct nl_sock *eventSock;
35     struct nl_sock *ctrlSock;
36     int familyId;
37     enum ThreadStatus *status;
38 };
39 int32_t NetlinkSendCmdSync(struct nl_msg *msg, const RespHandler handler, void *data);
40 void *EventThread(void *para);
41 void WifiEventTxStatus(const char *ifName, struct nlattr **attr);
42 
43 #endif /* end of netlink_adapter.h */
44