1 /* 2 * Copyright (c) 2021 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_HANDLE_H 17 #define NET_HANDLE_H 18 19 #include <string> 20 #include <list> 21 22 #include "parcel.h" 23 #include "singleton.h" 24 25 #include "inet_addr.h" 26 27 namespace OHOS { 28 namespace NetManagerStandard { 29 class NetHandle : public virtual RefBase { 30 public: NetHandle()31 NetHandle() : netId_(0) {} NetHandle(int32_t netId)32 explicit NetHandle(int32_t netId) : netId_(netId) {} 33 ~NetHandle() override = default; 34 35 int32_t BindSocket(int32_t socketFd); 36 int32_t GetAddressesByName(const std::string &host, std::vector<INetAddr> &addrList); 37 int32_t GetAddressByName(const std::string &host, INetAddr &addr); 38 SetNetId(int32_t netId)39 void SetNetId(int32_t netId) 40 { 41 netId_ = netId; 42 } 43 GetNetId()44 int32_t GetNetId() const 45 { 46 return netId_; 47 } 48 49 private: 50 int32_t netId_; 51 }; 52 } // namespace NetManagerStandard 53 } // namespace OHOS 54 #endif // NET_HANDLE_H