1 /* 2 * Copyright (C) 2024 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 WPA_HDI_UTIL_H 17 #define WPA_HDI_UTIL_H 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /** 24 * @Description Convert [a,b,c,d,e,f] mac address to string type [xx:xx:xx:xx:xx:xx] 25 * 26 * @param mac - mac address 27 * @param macSize - mac size, must be equal to 6 28 * @param macStr - output mac string, type: [xx:xx:xx:xx:xx:xx] 29 * @param strLen - mac string len, must bigger than 17 30 * @return int - convert result. 0 - Failed 1 - Success 31 */ 32 int ConvertMacToStr(const unsigned char *mac, int macSize, char *macStr, int strLen); 33 34 /** 35 * @Description Convert mac string type [xx:xx:xx:xx:xx:xx] to array type 36 * 37 * @param macStr - input mac address, string type like xx:xx:xx:xx:xx:xx 38 * @param mac - output mac array 39 * @param macSize - mac array length, must be equal to 6 40 * @return int - convert result. 0 - Failed 1 - Success 41 */ 42 int ConvertMacToArray(const char *macStr, unsigned char *mac, int macSize); 43 44 /** 45 * @Description Judge input is valid mac string 46 * 47 * @param macStr - input mac string 48 * @return int - -1 - invalid 0 valid 49 */ 50 int CheckMacIsValid(const char *macStr); 51 52 /** 53 * @Description Get the state of interface 54 * @param ifaceName - the name of interface 55 * @return int - 0: down 1: up 56 */ 57 int GetIfaceState(const char *ifaceName); 58 59 /** 60 * @DataAnonymize Anonymize the input data 61 * @param input - the data to anonymize 62 * @param inputlen - the length of the input data 63 * @param output - anonymized data 64 * @param outputSize - the size the output data 65 * @return int - 0: success 1: failied 66 */ 67 int DataAnonymize(const char *input, int inputLen, char* output, int outputSize); 68 69 char IsValidHexCharAndConvert(char c); 70 71 #ifdef __cplusplus 72 } 73 #endif 74 #endif 75