1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE 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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "lwip/ip_addr.h"
19 typedef struct dhcps_state{
23 typedef struct dhcps_msg {
24 u8_t op, htype, hlen, hops;
37 /* Defined in esp_misc.h */
44 enum dhcps_offer_option{
51 #define DHCPS_COARSE_TIMER_SECS 1
52 #define DHCPS_MAX_LEASE 0x64
53 #define DHCPS_LEASE_TIME_DEF (120)
61 typedef u32_t dhcps_time_t;
62 typedef u8_t dhcps_offer_t;
65 dhcps_offer_t dhcps_offer;
66 dhcps_offer_t dhcps_dns;
67 dhcps_time_t dhcps_time;
68 dhcps_lease_t dhcps_poll;
71 static inline bool dhcps_router_enabled (dhcps_offer_t offer)
73 return (offer & OFFER_ROUTER) != 0;
76 static inline bool dhcps_dns_enabled (dhcps_offer_t offer)
78 return (offer & OFFER_DNS) != 0;
81 void dhcps_start(struct netif *netif, ip4_addr_t ip);
82 void dhcps_stop(struct netif *netif);
83 void *dhcps_option_info(u8_t op_id, u32_t opt_len);
84 void dhcps_set_option_info(u8_t op_id, void *opt_info, u32_t opt_len);
85 bool dhcp_search_ip_on_mac(u8_t *mac, ip4_addr_t *ip);
86 void dhcps_dns_setserver(const ip_addr_t *dnsserver);
87 ip4_addr_t dhcps_dns_getserver();