xref: /nrf52832-nimble/rt-thread/components/drivers/wlan/wlan_prot.h (revision 104654410c56c573564690304ae786df310c91fc)
1 /*
2  * Copyright (c) 2006-2018, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2018-08-14     tyx          the first version
9  */
10 
11 #ifndef __WLAN_PROT_H__
12 #define __WLAN_PROT_H__
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #ifndef RT_WLAN_PROT_NAME_LEN
19 #define RT_WLAN_PROT_NAME_LEN  (8)
20 #endif
21 
22 #ifndef RT_WLAN_PROT_MAX
23 #define RT_WLAN_PROT_MAX       (1)
24 #endif
25 
26 #define RT_LWAN_ID_PREFIX      (0x5054)
27 
28 #define RT_WLAN_PROT_LWIP  ("lwip")
29 
30 typedef enum
31 {
32     RT_WLAN_PROT_EVT_INIT_DONE = 0,
33     RT_WLAN_PROT_EVT_CONNECT,
34     RT_WLAN_PROT_EVT_DISCONNECT,
35     RT_WLAN_PROT_EVT_AP_START,
36     RT_WLAN_PROT_EVT_AP_STOP,
37     RT_WLAN_PROT_EVT_AP_ASSOCIATED,
38     RT_WLAN_PROT_EVT_AP_DISASSOCIATED,
39     RT_WLAN_PROT_EVT_MAX,
40 } rt_wlan_prot_event_t;
41 
42 struct rt_wlan_prot;
43 struct rt_wlan_prot_ops
44 {
45     rt_err_t (*prot_recv)(struct rt_wlan_device *wlan, void *buff, int len);
46     struct rt_wlan_prot *(*dev_reg_callback)(struct rt_wlan_prot *prot, struct rt_wlan_device *wlan);
47     void (*dev_unreg_callback)(struct rt_wlan_prot *prot, struct rt_wlan_device *wlan);
48 };
49 
50 struct rt_wlan_prot
51 {
52     char name[RT_WLAN_PROT_NAME_LEN];
53     rt_uint32_t id;
54     const struct rt_wlan_prot_ops *ops;
55 };
56 
57 typedef void (*rt_wlan_prot_event_handler)(struct rt_wlan_prot *port, struct rt_wlan_device *wlan, int event);
58 
59 rt_err_t rt_wlan_prot_attach(const char *dev_name, const char *prot_name);
60 
61 rt_err_t rt_wlan_prot_attach_dev(struct rt_wlan_device *wlan, const char *prot_name);
62 
63 rt_err_t rt_wlan_prot_detach(const char *dev_name);
64 
65 rt_err_t rt_wlan_prot_detach_dev(struct rt_wlan_device *wlan);
66 
67 rt_err_t rt_wlan_prot_regisetr(struct rt_wlan_prot *prot);
68 
69 rt_err_t rt_wlan_prot_transfer_dev(struct rt_wlan_device *wlan, void *buff, int len);
70 
71 rt_err_t rt_wlan_dev_transfer_prot(struct rt_wlan_device *wlan, void *buff, int len);
72 
73 rt_err_t rt_wlan_prot_event_register(struct rt_wlan_prot *prot, rt_wlan_prot_event_t event, rt_wlan_prot_event_handler handler);
74 
75 rt_err_t rt_wlan_prot_event_unregister(struct rt_wlan_prot *prot, rt_wlan_prot_event_t event);
76 
77 int rt_wlan_prot_ready(struct rt_wlan_device *wlan, struct rt_wlan_buff *buff);
78 
79 void rt_wlan_prot_dump(void);
80 
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif
86