1 /* 2 * Copyright (c) 2020-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 OHOS_DHCP_RESULT_EVENT_H 16 #define OHOS_DHCP_RESULT_EVENT_H 17 18 #include <netinet/ip.h> 19 #include <sys/stat.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #define DHCP_MAX_FILE_BYTES 128 26 #define MAC_ADDR_MAX_LEN 18 27 #define DHCP_LEASE_FORMAT_SIZE 5 28 #define DHCP_LEASE_MAC_ADDR_POS 0 29 #define DHCP_LEASE_IP_ADDR_POS 1 30 #define DHCP_LEASE_HOSTNAME_POS 2 31 #define DHCP_LEASE_DATA_MAX_LEN 128 32 33 typedef struct{ 34 int iptype; /* 0-ipv4,1-ipv6 */ 35 bool isOptSuc; /* get result */ 36 char strOptClientId[DHCP_MAX_FILE_BYTES]; /* your (client) IP */ 37 char strOptServerId[DHCP_MAX_FILE_BYTES]; /* dhcp server IP */ 38 char strOptSubnet[DHCP_MAX_FILE_BYTES]; /* your (client) subnet mask */ 39 char strOptDns1[DHCP_MAX_FILE_BYTES]; /* your (client) DNS server1 */ 40 char strOptDns2[DHCP_MAX_FILE_BYTES]; /* your (client) DNS server2 */ 41 char strOptRouter1[DHCP_MAX_FILE_BYTES]; /* your (client) router1 */ 42 char strOptRouter2[DHCP_MAX_FILE_BYTES]; /* your (client) router2 */ 43 char strOptVendor[DHCP_MAX_FILE_BYTES]; /* your (client) vendor */ 44 uint32_t uOptLeasetime; /* your (client) IP lease time (s) */ 45 uint32_t uAddTime; /* dhcp result add time */ 46 uint32_t uGetTime; /* dhcp result get time */ 47 }DhcpResult; 48 49 typedef struct DhcpRange{ 50 int iptype; /* 0-ipv4,1-ipv6 */ 51 int leaseHours; /* lease hours */ 52 char strTagName[DHCP_MAX_FILE_BYTES]; /* dhcp-range tag name */ 53 char strStartip[INET_ADDRSTRLEN]; /* dhcp-range start ip */ 54 char strEndip[INET_ADDRSTRLEN]; /* dhcp-range end ip */ 55 char strSubnet[INET_ADDRSTRLEN]; /* dhcp-range subnet */ 56 }DhcpRange; 57 58 typedef struct DhcpStationInfo{ 59 char ipAddr[INET_ADDRSTRLEN]; 60 char macAddr[MAC_ADDR_MAX_LEN]; 61 char deviceName[DHCP_LEASE_DATA_MAX_LEN]; 62 }DhcpStationInfo; 63 64 typedef struct { 65 void (*OnIpSuccessChanged)(int status, const char *ifname, DhcpResult *result); 66 void (*OnIpFailChanged)(int status, const char *ifname, const char *reason); 67 }ClientCallBack; 68 69 typedef struct { 70 void (*OnServerStatusChanged)(int status); 71 void (*OnServerLeasesChanged)(const char *ifname, const char *leases); 72 void (*OnSerExitChanged)(const char *ifname); 73 }ServerCallBack; 74 75 #ifdef __cplusplus 76 } 77 #endif 78 #endif 79