• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef OHOS_FUNCTION_H
16 #define OHOS_FUNCTION_H
17 
18 #include <stdlib.h>
19 #include <stdint.h>
20 #include <stdbool.h>
21 #include <unistd.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 bool Ip4StrConToInt(const char *strIp, uint32_t *uIp, bool bHost);
28 char *Ip4IntConToStr(uint32_t uIp, bool bHost);
29 bool Ip6StrConToChar(const char *strIp, uint8_t chIp[], size_t chlen);
30 const char *MacChConToMacStr(const unsigned char *pChMac, size_t chLen, char *pStrMac, size_t strLen);
31 int GetLocalInterface(const char *ifname, int *ifindex, unsigned char *hwaddr, uint32_t *ifaddr4);
32 int GetLocalIp(const char *ifname, uint32_t *ifaddr4);
33 int SetLocalInterface(const char *ifname, uint32_t ipAddr, uint32_t netMask);
34 int InitPidfile(const char *pidDir, const char *pidFile, pid_t pid);
35 pid_t GetPID(const char *pidFile);
36 int CreateDirs(const char *dirs, int mode);
37 
38 #ifdef __cplusplus
39 }
40 #endif
41 #endif
42