1 /* 2 * Copyright (C) 2021-2022 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 #include <string> 17 18 #ifndef OHOS_DHCP_ARGUMENT_H 19 #define OHOS_DHCP_ARGUMENT_H 20 21 #define ARGUMENT_NAME_SIZE 32 22 #define ARGUMENT_VALUE_SIZE 256 23 #define INIT_ARGS_SIZE 4 24 25 #define NO_ARG 0 26 #define REQUIRED_ARG 1 27 #define OPTIONAL_ARG 2 28 29 #define USAGE_DESC_MAX_LENGTH 32 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 typedef struct DhcpUsage DhcpUsage; 36 struct DhcpUsage { 37 struct option *opt; 38 const char *params; 39 const char *desc; 40 const char *example; 41 int required; 42 int (*dealOption)(const char *, const char *); 43 }; 44 45 46 typedef struct ArgumentInfo ArgumentInfo; 47 struct ArgumentInfo { 48 char name[ARGUMENT_NAME_SIZE]; 49 char value[ARGUMENT_VALUE_SIZE]; 50 }; 51 52 int InitArguments(void); 53 int HasArgument(const char *argument); 54 ArgumentInfo *GetArgument(const char *name); 55 int PutArgument(const char *argument, const char *val); 56 57 int ParseArguments(const std::string& ifName, const std::string& netMask, const std::string& ipRange, 58 const std::string& localIp); 59 60 void FreeArguments(void); 61 62 #ifdef __cplusplus 63 } 64 #endif 65 66 #endif // OHOS_DHCP_ARGUMENT_H 67