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 OHOS_DHCP_FUNCTION_H 17 #define OHOS_DHCP_FUNCTION_H 18 19 #include <cstring> 20 #include <stdlib.h> 21 #include <stdint.h> 22 #include <stdbool.h> 23 #include <unistd.h> 24 #include <string> 25 26 bool Ip4StrConToInt(const char *strIp, uint32_t *uIp, bool bHost); 27 std::string Ip4IntConvertToStr(uint32_t ip, bool host); 28 bool Ip6StrConToChar(const char *strIp, uint8_t chIp[], size_t chlen); 29 const char *MacChConToMacStr(const unsigned char *pChMac, size_t chLen, char *pStrMac, size_t strLen); 30 int GetLocalInterface(const char *ifname, int *ifindex, unsigned char *hwaddr, uint32_t *ifaddr4); 31 int GetLocalIp(const char *ifname, uint32_t *ifaddr4); 32 int SetLocalInterface(const char *ifname, uint32_t ipAddr, uint32_t netMask); 33 int InitPidfile(const char *pidDir, const char *pidFile, pid_t pid); 34 pid_t GetPID(const char *pidFile); 35 int CreateDirs(const char *dirs, int mode); 36 37 #endif