1518678f8Sopenharmony_ci/* 2518678f8Sopenharmony_ci * Copyright (c) 2020-2023 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#ifndef OHOS_DHCP_RESULT_EVENT_H 16518678f8Sopenharmony_ci#define OHOS_DHCP_RESULT_EVENT_H 17518678f8Sopenharmony_ci 18518678f8Sopenharmony_ci#include <netinet/ip.h> 19518678f8Sopenharmony_ci#include <sys/stat.h> 20518678f8Sopenharmony_ci 21518678f8Sopenharmony_ci#ifdef __cplusplus 22518678f8Sopenharmony_ciextern "C" { 23518678f8Sopenharmony_ci#endif 24518678f8Sopenharmony_ci 25518678f8Sopenharmony_ci#define DHCP_MAX_FILE_BYTES 128 26518678f8Sopenharmony_ci#define MAC_ADDR_MAX_LEN 18 27518678f8Sopenharmony_ci#define DHCP_LEASE_FORMAT_SIZE 8 28518678f8Sopenharmony_ci#define DHCP_LEASE_FORMAT_MAX_SIZE 9 29518678f8Sopenharmony_ci#define DHCP_LEASE_MAC_ADDR_POS 0 30518678f8Sopenharmony_ci#define DHCP_LEASE_IP_ADDR_POS 1 31518678f8Sopenharmony_ci#define DHCP_LEASE_HOSTNAME_POS 8 32518678f8Sopenharmony_ci#define DHCP_LEASE_DATA_MAX_LEN 128 33518678f8Sopenharmony_ci#define DHCP_DNS_MAX_NUMBER 10 34518678f8Sopenharmony_ci#define DHCP_DNS_DATA_MAX_LEN 128 35518678f8Sopenharmony_ci 36518678f8Sopenharmony_citypedef struct{ 37518678f8Sopenharmony_ci uint32_t dnsNumber; 38518678f8Sopenharmony_ci char dnsAddr[DHCP_DNS_MAX_NUMBER][DHCP_DNS_DATA_MAX_LEN]; 39518678f8Sopenharmony_ci}DnsList; 40518678f8Sopenharmony_ci 41518678f8Sopenharmony_citypedef struct{ 42518678f8Sopenharmony_ci int iptype; /* 0-ipv4,1-ipv6 */ 43518678f8Sopenharmony_ci bool isOptSuc; /* get result */ 44518678f8Sopenharmony_ci char strOptClientId[DHCP_MAX_FILE_BYTES]; /* your (client) IP */ 45518678f8Sopenharmony_ci char strOptServerId[DHCP_MAX_FILE_BYTES]; /* dhcp server IP */ 46518678f8Sopenharmony_ci char strOptSubnet[DHCP_MAX_FILE_BYTES]; /* your (client) subnet mask */ 47518678f8Sopenharmony_ci char strOptDns1[DHCP_MAX_FILE_BYTES]; /* your (client) DNS server1 */ 48518678f8Sopenharmony_ci char strOptDns2[DHCP_MAX_FILE_BYTES]; /* your (client) DNS server2 */ 49518678f8Sopenharmony_ci char strOptRouter1[DHCP_MAX_FILE_BYTES]; /* your (client) router1 */ 50518678f8Sopenharmony_ci char strOptRouter2[DHCP_MAX_FILE_BYTES]; /* your (client) router2 */ 51518678f8Sopenharmony_ci char strOptVendor[DHCP_MAX_FILE_BYTES]; /* your (client) vendor */ 52518678f8Sopenharmony_ci char strOptLinkIpv6Addr[DHCP_MAX_FILE_BYTES]; /* your (client) link ipv6 addr */ 53518678f8Sopenharmony_ci char strOptRandIpv6Addr[DHCP_MAX_FILE_BYTES]; /* your (client) rand ipv6 addr */ 54518678f8Sopenharmony_ci char strOptLocalAddr1[DHCP_MAX_FILE_BYTES]; /* your (client) unique local ipv6 addr */ 55518678f8Sopenharmony_ci char strOptLocalAddr2[DHCP_MAX_FILE_BYTES]; /* your (client) unique local ipv6 addr */ 56518678f8Sopenharmony_ci uint32_t uOptLeasetime; /* your (client) IP lease time (s) */ 57518678f8Sopenharmony_ci uint32_t uAddTime; /* dhcp result add time */ 58518678f8Sopenharmony_ci uint32_t uGetTime; /* dhcp result get time */ 59518678f8Sopenharmony_ci DnsList dnsList; /* dhcp dns list */ 60518678f8Sopenharmony_ci}DhcpResult; 61518678f8Sopenharmony_ci 62518678f8Sopenharmony_citypedef struct DhcpRange{ 63518678f8Sopenharmony_ci int iptype; /* 0-ipv4,1-ipv6 */ 64518678f8Sopenharmony_ci int leaseHours; /* lease hours */ 65518678f8Sopenharmony_ci char strTagName[DHCP_MAX_FILE_BYTES]; /* dhcp-range tag name */ 66518678f8Sopenharmony_ci char strStartip[INET_ADDRSTRLEN]; /* dhcp-range start ip */ 67518678f8Sopenharmony_ci char strEndip[INET_ADDRSTRLEN]; /* dhcp-range end ip */ 68518678f8Sopenharmony_ci char strSubnet[INET_ADDRSTRLEN]; /* dhcp-range subnet */ 69518678f8Sopenharmony_ci}DhcpRange; 70518678f8Sopenharmony_ci 71518678f8Sopenharmony_citypedef struct DhcpStationInfo{ 72518678f8Sopenharmony_ci char ipAddr[INET_ADDRSTRLEN]; 73518678f8Sopenharmony_ci char macAddr[MAC_ADDR_MAX_LEN]; 74518678f8Sopenharmony_ci char deviceName[DHCP_LEASE_DATA_MAX_LEN]; 75518678f8Sopenharmony_ci}DhcpStationInfo; 76518678f8Sopenharmony_ci 77518678f8Sopenharmony_citypedef struct { 78518678f8Sopenharmony_ci void (*OnIpSuccessChanged)(int status, const char *ifname, DhcpResult *result); 79518678f8Sopenharmony_ci void (*OnIpFailChanged)(int status, const char *ifname, const char *reason); 80518678f8Sopenharmony_ci}ClientCallBack; 81518678f8Sopenharmony_ci 82518678f8Sopenharmony_citypedef struct { 83518678f8Sopenharmony_ci void (*OnDhcpClientReport)(int status, const char *ifname, DhcpResult *result); 84518678f8Sopenharmony_ci}DhcpClientReport; 85518678f8Sopenharmony_ci 86518678f8Sopenharmony_citypedef struct { 87518678f8Sopenharmony_ci void (*OnServerStatusChanged)(int status); 88518678f8Sopenharmony_ci void (*OnServerLeasesChanged)(const char *ifname, const char *leases); 89518678f8Sopenharmony_ci void (*OnSerExitChanged)(const char *ifname); 90518678f8Sopenharmony_ci void (*OnServerSuccess)(const char *ifname, DhcpStationInfo *stationInfos, size_t size); 91518678f8Sopenharmony_ci}ServerCallBack; 92518678f8Sopenharmony_ci 93518678f8Sopenharmony_citypedef struct RouterConfig { 94518678f8Sopenharmony_ci char bssid[MAC_ADDR_MAX_LEN]; 95518678f8Sopenharmony_ci bool prohibitUseCacheIp; 96518678f8Sopenharmony_ci}RouterConfig; 97518678f8Sopenharmony_ci#ifdef __cplusplus 98518678f8Sopenharmony_ci} 99518678f8Sopenharmony_ci#endif 100518678f8Sopenharmony_ci#endif 101