1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License.
5094332d3Sopenharmony_ci * You may obtain a copy of the License at
6094332d3Sopenharmony_ci *
7094332d3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8094332d3Sopenharmony_ci *
9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and
13094332d3Sopenharmony_ci * limitations under the License.
14094332d3Sopenharmony_ci */
15094332d3Sopenharmony_ci
16094332d3Sopenharmony_ci#include "hostapd_callback_impl.h"
17094332d3Sopenharmony_ci#include <securec.h>
18094332d3Sopenharmony_ci#include <hdf_base.h>
19094332d3Sopenharmony_ci#include <hdf_log.h>
20094332d3Sopenharmony_ci#include <osal_mem.h>
21094332d3Sopenharmony_ci
22094332d3Sopenharmony_cistatic int32_t HostapdCallbackStaJoin(struct IHostapdCallback *self,
23094332d3Sopenharmony_ci    const struct HdiApCbParm *apCbParm, const char *ifName)
24094332d3Sopenharmony_ci{
25094332d3Sopenharmony_ci    (void)self;
26094332d3Sopenharmony_ci    if (apCbParm == NULL || ifName == NULL) {
27094332d3Sopenharmony_ci        HDF_LOGE("%{public}s: input parameter invalid!", __func__);
28094332d3Sopenharmony_ci        return HDF_ERR_INVALID_PARAM;
29094332d3Sopenharmony_ci    }
30094332d3Sopenharmony_ci    HDF_LOGE("HostapdCallbackStaJoin: content=%{public}s, id=%{public}d", apCbParm->content, apCbParm->id);
31094332d3Sopenharmony_ci    return HDF_SUCCESS;
32094332d3Sopenharmony_ci}
33094332d3Sopenharmony_ci
34094332d3Sopenharmony_cistatic int32_t HostapdCallbackApState(struct IHostapdCallback *self,
35094332d3Sopenharmony_ci    const struct HdiApCbParm *apCbParm, const char *ifName)
36094332d3Sopenharmony_ci{
37094332d3Sopenharmony_ci    (void)self;
38094332d3Sopenharmony_ci    if (apCbParm == NULL || ifName == NULL) {
39094332d3Sopenharmony_ci        HDF_LOGE("%{public}s: input parameter invalid!", __func__);
40094332d3Sopenharmony_ci        return HDF_ERR_INVALID_PARAM;
41094332d3Sopenharmony_ci    }
42094332d3Sopenharmony_ci    HDF_LOGE("HostapdCallbackApState: content=%{public}s, id=%{public}d", apCbParm->content, apCbParm->id);
43094332d3Sopenharmony_ci    return HDF_SUCCESS;
44094332d3Sopenharmony_ci}
45094332d3Sopenharmony_ci
46094332d3Sopenharmony_cistruct IHostapdCallback *HostapdCallbackServiceGet(void)
47094332d3Sopenharmony_ci{
48094332d3Sopenharmony_ci    struct HostapdCallbackService *service =
49094332d3Sopenharmony_ci        (struct HostapdCallbackService *)OsalMemCalloc(sizeof(struct HostapdCallbackService));
50094332d3Sopenharmony_ci    if (service == NULL) {
51094332d3Sopenharmony_ci        HDF_LOGE("%{public}s: malloc HostapdCallbackService obj failed!", __func__);
52094332d3Sopenharmony_ci        return NULL;
53094332d3Sopenharmony_ci    }
54094332d3Sopenharmony_ci
55094332d3Sopenharmony_ci    service->interface.OnEventStaJoin = HostapdCallbackStaJoin;
56094332d3Sopenharmony_ci    service->interface.OnEventApState = HostapdCallbackApState;
57094332d3Sopenharmony_ci    return &service->interface;
58094332d3Sopenharmony_ci}
59094332d3Sopenharmony_ci
60094332d3Sopenharmony_civoid HostapdCallbackServiceRelease(struct IHostapdCallback *instance)
61094332d3Sopenharmony_ci{
62094332d3Sopenharmony_ci    struct HostapdCallbackService *service = (struct HostapdCallbackService *)instance;
63094332d3Sopenharmony_ci    if (service == NULL) {
64094332d3Sopenharmony_ci        return;
65094332d3Sopenharmony_ci    }
66094332d3Sopenharmony_ci    OsalMemFree(service);
67094332d3Sopenharmony_ci}
68