1 /*
2  * Copyright (c) 2023 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 #include "hostapd_callback_impl.h"
17 #include <securec.h>
18 #include <hdf_base.h>
19 #include <hdf_log.h>
20 #include <osal_mem.h>
21 
HostapdCallbackStaJoin(struct IHostapdCallback * self,const struct HdiApCbParm * apCbParm,const char * ifName)22 static int32_t HostapdCallbackStaJoin(struct IHostapdCallback *self,
23     const struct HdiApCbParm *apCbParm, const char *ifName)
24 {
25     (void)self;
26     if (apCbParm == NULL || ifName == NULL) {
27         HDF_LOGE("%{public}s: input parameter invalid!", __func__);
28         return HDF_ERR_INVALID_PARAM;
29     }
30     HDF_LOGE("HostapdCallbackStaJoin: content=%{public}s, id=%{public}d", apCbParm->content, apCbParm->id);
31     return HDF_SUCCESS;
32 }
33 
HostapdCallbackApState(struct IHostapdCallback * self,const struct HdiApCbParm * apCbParm,const char * ifName)34 static int32_t HostapdCallbackApState(struct IHostapdCallback *self,
35     const struct HdiApCbParm *apCbParm, const char *ifName)
36 {
37     (void)self;
38     if (apCbParm == NULL || ifName == NULL) {
39         HDF_LOGE("%{public}s: input parameter invalid!", __func__);
40         return HDF_ERR_INVALID_PARAM;
41     }
42     HDF_LOGE("HostapdCallbackApState: content=%{public}s, id=%{public}d", apCbParm->content, apCbParm->id);
43     return HDF_SUCCESS;
44 }
45 
HostapdCallbackServiceGet(void)46 struct IHostapdCallback *HostapdCallbackServiceGet(void)
47 {
48     struct HostapdCallbackService *service =
49         (struct HostapdCallbackService *)OsalMemCalloc(sizeof(struct HostapdCallbackService));
50     if (service == NULL) {
51         HDF_LOGE("%{public}s: malloc HostapdCallbackService obj failed!", __func__);
52         return NULL;
53     }
54 
55     service->interface.OnEventStaJoin = HostapdCallbackStaJoin;
56     service->interface.OnEventApState = HostapdCallbackApState;
57     return &service->interface;
58 }
59 
HostapdCallbackServiceRelease(struct IHostapdCallback * instance)60 void HostapdCallbackServiceRelease(struct IHostapdCallback *instance)
61 {
62     struct HostapdCallbackService *service = (struct HostapdCallbackService *)instance;
63     if (service == NULL) {
64         return;
65     }
66     OsalMemFree(service);
67 }
68