1518678f8Sopenharmony_ci/* 2518678f8Sopenharmony_ci * Copyright (C) 2021-2022 Huawei Device Co., Ltd. 3518678f8Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4518678f8Sopenharmony_ci * you may not use this file except in compliance with the License. 5518678f8Sopenharmony_ci * You may obtain a copy of the License at 6518678f8Sopenharmony_ci * 7518678f8Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8518678f8Sopenharmony_ci * 9518678f8Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10518678f8Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11518678f8Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12518678f8Sopenharmony_ci * See the License for the specific language governing permissions and 13518678f8Sopenharmony_ci * limitations under the License. 14518678f8Sopenharmony_ci */ 15518678f8Sopenharmony_ci 16518678f8Sopenharmony_ci#include <string> 17518678f8Sopenharmony_ci 18518678f8Sopenharmony_ci#ifndef OHOS_DHCP_ARGUMENT_H 19518678f8Sopenharmony_ci#define OHOS_DHCP_ARGUMENT_H 20518678f8Sopenharmony_ci 21518678f8Sopenharmony_ci#define ARGUMENT_NAME_SIZE 32 22518678f8Sopenharmony_ci#define ARGUMENT_VALUE_SIZE 256 23518678f8Sopenharmony_ci#define INIT_ARGS_SIZE 4 24518678f8Sopenharmony_ci 25518678f8Sopenharmony_ci#define NO_ARG 0 26518678f8Sopenharmony_ci#define REQUIRED_ARG 1 27518678f8Sopenharmony_ci#define OPTIONAL_ARG 2 28518678f8Sopenharmony_ci 29518678f8Sopenharmony_ci#define USAGE_DESC_MAX_LENGTH 32 30518678f8Sopenharmony_ciconst std::string IP_V4_DEFAULT("192.168.62.1"); 31518678f8Sopenharmony_ci 32518678f8Sopenharmony_ci#ifdef __cplusplus 33518678f8Sopenharmony_ciextern "C" { 34518678f8Sopenharmony_ci#endif 35518678f8Sopenharmony_ci 36518678f8Sopenharmony_citypedef struct DhcpUsage DhcpUsage; 37518678f8Sopenharmony_cistruct DhcpUsage { 38518678f8Sopenharmony_ci struct option *opt; 39518678f8Sopenharmony_ci const char *params; 40518678f8Sopenharmony_ci const char *desc; 41518678f8Sopenharmony_ci const char *example; 42518678f8Sopenharmony_ci int required; 43518678f8Sopenharmony_ci int (*dealOption)(const char *, const char *); 44518678f8Sopenharmony_ci}; 45518678f8Sopenharmony_ci 46518678f8Sopenharmony_ci 47518678f8Sopenharmony_citypedef struct ArgumentInfo ArgumentInfo; 48518678f8Sopenharmony_cistruct ArgumentInfo { 49518678f8Sopenharmony_ci char name[ARGUMENT_NAME_SIZE]; 50518678f8Sopenharmony_ci char value[ARGUMENT_VALUE_SIZE]; 51518678f8Sopenharmony_ci}; 52518678f8Sopenharmony_ci 53518678f8Sopenharmony_ciint InitArguments(void); 54518678f8Sopenharmony_ciint HasArgument(const char *argument); 55518678f8Sopenharmony_ciArgumentInfo *GetArgument(const char *name); 56518678f8Sopenharmony_ciint PutArgument(const char *argument, const char *val); 57518678f8Sopenharmony_ci 58518678f8Sopenharmony_ciint ParseArguments(const std::string& ifName, const std::string& netMask, const std::string& ipRange, 59518678f8Sopenharmony_ci const std::string& localIp); 60518678f8Sopenharmony_ci 61518678f8Sopenharmony_civoid FreeArguments(void); 62518678f8Sopenharmony_ci 63518678f8Sopenharmony_civoid ShowHelp(int argc); 64518678f8Sopenharmony_ci 65518678f8Sopenharmony_civoid PrintRequiredArguments(void); 66518678f8Sopenharmony_ci 67518678f8Sopenharmony_ci#ifdef __cplusplus 68518678f8Sopenharmony_ci} 69518678f8Sopenharmony_ci#endif 70518678f8Sopenharmony_ci 71518678f8Sopenharmony_ci#endif // OHOS_DHCP_ARGUMENT_H 72