1 /* 2 * Copyright (c) 2023 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 WIFI_DIRECT_NETWORK_UTILS_H 16 #define WIFI_DIRECT_NETWORK_UTILS_H 17 18 #include <stdint.h> 19 #include <stddef.h> 20 #include <stdbool.h> 21 #include "wifi_direct_types.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 struct WifiDirectIpv4Info; 28 struct WifiDirectNetWorkUtils { 29 int32_t (*splitString)(char *input, char *splitter, char **outputArray, size_t *outputArraySize); 30 31 int32_t (*channelToFrequency)(int32_t channel); 32 int32_t (*frequencyToChannel)(int32_t frequency); 33 34 int32_t (*channelListToString)(int32_t *channelArray, size_t channelNum, char *outBuffer, size_t inSize); 35 int32_t (*stringToChannelList)(char *channelListString, int32_t *channelArray, size_t *channelArraySize); 36 37 bool (*is2GBand)(int32_t frequency); 38 bool (*is5GBand)(int32_t frequency); 39 bool (*isInChannelList)(int32_t channel, const int32_t *channelArray, size_t channelNum); 40 41 int32_t (*getInterfaceIpString)(const char *interface, char *ipString, int32_t ipStringSize); 42 int32_t (*ipAddrToString)(uint32_t addrArray, char *addrString, size_t addrStringSize); 43 int32_t (*ipStringToAddr)(const char *addrString, uint32_t *addr); 44 int32_t (*ipStringToIntArray)(const char *addrString, uint32_t *addrArray, size_t addrArraySize); 45 46 int32_t (*getInterfaceMacAddr)(const char *ifName, uint8_t *macAddrArray, size_t *macAddrArraySize); 47 int32_t (*macStringToArray)(const char *macString, uint8_t *array, size_t *arraySize); 48 int32_t (*macArrayToString)(const uint8_t *array, size_t arraySize, char *macString, size_t macStringSize); 49 50 int32_t (*getLocalIpv4InfoArray)(struct WifiDirectIpv4Info *info, size_t *size); 51 }; 52 53 struct WifiDirectNetWorkUtils* GetWifiDirectNetWorkUtils(void); 54 55 #ifdef __cplusplus 56 } 57 #endif 58 #endif