1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef HDF_EAPOL_H
10 #define HDF_EAPOL_H
11 
12 #include "hdf_netbuf.h"
13 #include "net_device.h"
14 
15 #define EAPOL_MAX_COUNT 10
16 #define EAPOL_MAX_ENQUEUE_TIME 300 /* 300 Second */
17 
18 struct EapolData {
19     bool regFlag;  /* is already registered */
20     uint16_t count; /* eapol frame count in NetBuffQueue. */
21     uint16_t maxCount;
22     int64_t enqueueTime;                       /* record eapol frame time for dfx. */
23     void (*notify)(const char *name, void *context); /* notify eapol frame enqueue message */
24     void *context;
25     NetBufQueue eapolQueue;
26 };
27 
28 struct Eapol {
29     struct EapolInterface *eapolOp;
30 };
31 
32 struct EapolEnable {
33     void (*notify)(const char *name, void *context);
34     void *context;
35 };
36 
37 struct EapolRx {
38     uint8_t *buff;
39     uint32_t len;
40 };
41 
42 struct EapolTx {
43     uint8_t *buff;
44     uint32_t len;
45 };
46 
47 struct EapolInterface {
48     int32_t (*enableEapol)(const struct NetDevice *netDevice, struct EapolEnable *buff);
49     int32_t (*disableEapol)(const struct NetDevice *netDevice);
50     int32_t (*getEapol)(const struct NetDevice *netDevice, struct EapolRx *buff);
51     int32_t (*sendEapol)(struct NetDevice *netDevice, struct EapolTx *buff);
52     int32_t (*writeEapolToQueue)(const struct NetDevice *netDevice, NetBuf *buff);
53 };
54 
55 /* API */
56 const struct Eapol *EapolGetInstance(void);
57 void DestroyEapolData(struct NetDevice *netDevice);
58 int32_t CreateEapolData(struct NetDevice *netDevice);
59 
60 #endif /* HDF_EAPOL_H */