• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 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 "dhcp_event_subscriber.h"
17 
18 #ifdef OHOS_ARCH_LITE
19 namespace OHOS {
20 namespace Wifi {
21 #else
22 #include "wifi_logger.h"
23 #include "dhcp_client_service_impl.h"
24 
25 DEFINE_WIFILOG_DHCP_LABEL("DhcpEventSubscriber");
26 
27 using namespace OHOS::EventFwk;
28 
29 namespace OHOS {
30 namespace Wifi {
31 void DhcpEventSubscriber::OnReceiveEvent(const OHOS::EventFwk::CommonEventData &data)
32 {
33     std::lock_guard<std::mutex> lock(onReceivedLock_);
34     int code = data.GetCode();
35     std::string strData = data.GetData();
36     WIFI_LOGI("OnReceiveEvent() GetCode:%{public}d, GetData:%{private}s.", code, strData.c_str());
37     if (DhcpClientServiceImpl::DhcpEventResultHandle(code, strData) != DHCP_OPT_SUCCESS) {
38         WIFI_LOGE("OnReceiveEvent() DhcpEventResultHandle failed!");
39         return;
40     }
41 }
42 #endif
43 }  // namespace Wifi
44 }  // namespace OHOS