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_EAP_HANDLER_H 17 #define NET_EAP_HANDLER_H 18 19 #include <shared_mutex> 20 #include <map> 21 #include "eap_data.h" 22 #include "inet_register_eap_callback.h" 23 #include "inet_eap_postback_callback.h" 24 #ifdef NET_EXTENSIBLE_AUTHENTICATION 25 #include "eth_eap_profile.h" 26 #include "eap_hdi_wpa_manager.h" 27 #endif 28 29 namespace OHOS { 30 namespace NetManagerStandard { 31 class NetEapHandler : public std::enable_shared_from_this<NetEapHandler> { 32 public: 33 NetEapHandler(); 34 ~NetEapHandler() = default; 35 36 static NetEapHandler &GetInstance(); 37 int32_t RegisterCustomEapCallback(const NetType netType, const sptr<INetRegisterEapCallback> &callback); 38 int32_t UnRegisterCustomEapCallback(const NetType netType, const sptr<INetRegisterEapCallback> &callback); 39 int32_t NotifyWpaEapInterceptInfo(const NetType netType, const sptr<EapData> &eapData); 40 int32_t RegCustomEapHandler(NetType netType, const std::string ®Cmd, 41 const sptr<INetEapPostbackCallback> &postBackCb); 42 int32_t ReplyCustomEapData(int result, const sptr<EapData> &eapData); 43 #ifdef NET_EXTENSIBLE_AUTHENTICATION 44 int32_t StartEthEap(int32_t netId, const EthEapProfile& profile); 45 int32_t LogOffEthEap(int32_t netId); 46 #endif 47 48 private: 49 void SetPostbackCallback(const sptr<INetEapPostbackCallback> &postbackCallback); 50 sptr<INetEapPostbackCallback> GetPostbackCallback(); 51 #ifdef NET_EXTENSIBLE_AUTHENTICATION 52 void GetIfaceNameFromNetId(int32_t netId); 53 #endif 54 private: 55 std::map<NetType, int> nTMapMsgId_; 56 std::map<NetType, sptr<INetRegisterEapCallback>> regEapCallBack_; 57 sptr<INetEapPostbackCallback> postbackCallback_; 58 std::mutex callbackMutex_; 59 std::mutex mutex_; 60 #ifdef NET_EXTENSIBLE_AUTHENTICATION 61 std::shared_ptr<EapHdiWpaManager> eapHdiWpaManager_; 62 std::string ethEapIfName_; 63 #endif 64 }; 65 } // namespace NetManagerStandard 66 } // namespace OHOS 67 #endif // NET_EAP_HANDLER_H