• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #include <securec.h>
16 #include <hdf_base.h>
17 #include <hdf_log.h>
18 #include <osal_time.h>
19 #include <osal_mem.h>
20 
21 #include "v1_0/iethernet_callback.h"
22 #include "v1_0/iethernet.h"
23 #include "wpa_common_cmd.h"
24 #include "ethernet_impl.h"
25 
26 struct EthernetService {
27     struct IEthernet interface;
28 };
29 
30 #ifdef LOG_TAG
31 #undef LOG_TAG
32 #endif
33 #define LOG_TAG "EthernetService"
34 #ifdef LOG_DOMAIN
35 #undef LOG_DOMAIN
36 #endif
37 #define LOG_DOMAIN 0xD0015b0
38 
EthernetImplGetInstance(void)39 struct IEthernet *EthernetImplGetInstance(void)
40 {
41     HDF_LOGI("%{public}s enter", __func__);
42     struct EthernetService *service = (struct EthernetService *)OsalMemCalloc(sizeof(struct EthernetService));
43     if (service == NULL) {
44         HDF_LOGE("%{public}s: malloc failed!", __func__);
45         return NULL;
46     }
47     service->interface.StartEap = EthStartEap;
48     service->interface.StopEap = EthStopEap;
49     service->interface.RegisterEapEventCallback = EthRegisterEapEventCallback;
50     service->interface.UnregisterEapEventCallback = EthUnregisterEapEventCallback;
51     service->interface.EapShellCmd = EthEapShellCmd;
52     return &service->interface;
53 }
54 
EthernetImplRelease(struct IEthernet * instance)55 void EthernetImplRelease(struct IEthernet *instance)
56 {
57     HDF_LOGI("%{public}s enter", __func__);
58     if (instance == NULL) {
59         return;
60     }
61     OsalMemFree(instance);
62 }
63