• 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 
16 #ifndef NET_OBSERVER_H
17 #define NET_OBSERVER_H
18 
19 #include "net_conn_callback_stub.h"
20 #include "net_handle.h"
21 #include "net_all_capabilities.h"
22 
23 namespace OHOS {
24 namespace NetManagerStandard {
25 
26 enum ErrorNum {
27     ERR_NONE,
28     ERR_FAIL,
29 };
30 
31 class NetInfoObserver final : public NetManagerStandard::NetConnCallbackStub {
32 public:
NetInfoObserver()33     NetInfoObserver() {}
34     int32_t NetCapabilitiesChange(sptr<NetManagerStandard::NetHandle> &netHandle,
35         const sptr<NetManagerStandard::NetAllCapabilities> &netAllCap) override;
36     int32_t NetAvailable(sptr<NetManagerStandard::NetHandle> &netHandle) override;
37     int32_t NetLost(sptr<NetManagerStandard::NetHandle> &netHandle) override;
38     int32_t NetConnectionPropertiesChange(sptr<NetHandle> &netHandle, const sptr<NetLinkInfo> &info) override;
39 
40 private:
41     std::string ifaceName_ = "";
42     int32_t ident_ = -1;
43     uint64_t ifindex_ = 0;
44     std::atomic_bool isNeedUpdate_ = false;
45 };
46 }
47 }
48 #endif