Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
dhcp.h
00001 /** 00002 * @file 00003 * DHCP client API 00004 */ 00005 00006 /* 00007 * Copyright (c) 2001-2004 Leon Woestenberg <leon.woestenberg@gmx.net> 00008 * Copyright (c) 2001-2004 Axon Digital Design B.V., The Netherlands. 00009 * All rights reserved. 00010 * 00011 * Redistribution and use in source and binary forms, with or without modification, 00012 * are permitted provided that the following conditions are met: 00013 * 00014 * 1. Redistributions of source code must retain the above copyright notice, 00015 * this list of conditions and the following disclaimer. 00016 * 2. Redistributions in binary form must reproduce the above copyright notice, 00017 * this list of conditions and the following disclaimer in the documentation 00018 * and/or other materials provided with the distribution. 00019 * 3. The name of the author may not be used to endorse or promote products 00020 * derived from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00023 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00024 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00025 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00026 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00027 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00028 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00029 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00030 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00031 * OF SUCH DAMAGE. 00032 * 00033 * This file is part of the lwIP TCP/IP stack. 00034 * 00035 * Author: Leon Woestenberg <leon.woestenberg@gmx.net> 00036 * 00037 */ 00038 #ifndef LWIP_HDR_DHCP_H 00039 #define LWIP_HDR_DHCP_H 00040 00041 #include "lwip/opt.h" 00042 00043 #if LWIP_DHCP /* don't build if not configured for use in lwipopts.h */ 00044 00045 #include "lwip/netif.h" 00046 #include "lwip/udp.h" 00047 00048 #ifdef __cplusplus 00049 extern "C" { 00050 #endif 00051 00052 /** period (in seconds) of the application calling dhcp_coarse_tmr() */ 00053 #define DHCP_COARSE_TIMER_SECS 60 00054 /** period (in milliseconds) of the application calling dhcp_coarse_tmr() */ 00055 #define DHCP_COARSE_TIMER_MSECS (DHCP_COARSE_TIMER_SECS * 1000UL) 00056 /** period (in milliseconds) of the application calling dhcp_fine_tmr() */ 00057 #define DHCP_FINE_TIMER_MSECS 500 00058 00059 #define DHCP_BOOT_FILE_LEN 128U 00060 00061 /* AutoIP cooperation flags (struct dhcp.autoip_coop_state) */ 00062 typedef enum { 00063 DHCP_AUTOIP_COOP_STATE_OFF = 0, 00064 DHCP_AUTOIP_COOP_STATE_ON = 1 00065 } dhcp_autoip_coop_state_enum_t; 00066 00067 struct dhcp 00068 { 00069 /** transaction identifier of last sent request */ 00070 u32_t xid; 00071 /** track PCB allocation state */ 00072 u8_t pcb_allocated; 00073 /** current DHCP state machine state */ 00074 u8_t state; 00075 /** retries of current request */ 00076 u8_t tries; 00077 #if LWIP_DHCP_AUTOIP_COOP 00078 u8_t autoip_coop_state; 00079 #endif 00080 u8_t subnet_mask_given; 00081 00082 u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */ 00083 u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */ 00084 u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */ 00085 u16_t t1_renew_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next renew try */ 00086 u16_t t2_rebind_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next rebind try */ 00087 u16_t lease_used; /* #ticks with period DHCP_COARSE_TIMER_SECS since last received DHCP ack */ 00088 u16_t t0_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for lease time */ 00089 ip_addr_t server_ip_addr; /* dhcp server address that offered this lease (ip_addr_t because passed to UDP) */ 00090 ip4_addr_t offered_ip_addr; 00091 ip4_addr_t offered_sn_mask; 00092 ip4_addr_t offered_gw_addr; 00093 00094 u32_t offered_t0_lease; /* lease period (in seconds) */ 00095 u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */ 00096 u32_t offered_t2_rebind; /* recommended rebind time (usually 87.5 of lease period) */ 00097 #if LWIP_DHCP_BOOTP_FILE 00098 ip4_addr_t offered_si_addr; 00099 char boot_file_name[DHCP_BOOT_FILE_LEN]; 00100 #endif /* LWIP_DHCP_BOOTPFILE */ 00101 }; 00102 00103 00104 void dhcp_set_struct(struct netif *netif, struct dhcp *dhcp); 00105 /** Remove a struct dhcp previously set to the netif using dhcp_set_struct() */ 00106 #define dhcp_remove_struct(netif) netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, NULL) 00107 void dhcp_cleanup(struct netif *netif); 00108 err_t dhcp_start(struct netif *netif); 00109 err_t dhcp_renew(struct netif *netif); 00110 err_t dhcp_release(struct netif *netif); 00111 void dhcp_stop(struct netif *netif); 00112 void dhcp_release_and_stop(struct netif *netif); 00113 void dhcp_inform(struct netif *netif); 00114 void dhcp_network_changed(struct netif *netif); 00115 #if DHCP_DOES_ARP_CHECK 00116 void dhcp_arp_reply(struct netif *netif, const ip4_addr_t *addr); 00117 #endif 00118 u8_t dhcp_supplied_address(const struct netif *netif); 00119 /* to be called every minute */ 00120 void dhcp_coarse_tmr(void); 00121 /* to be called every half second */ 00122 void dhcp_fine_tmr(void); 00123 00124 #if LWIP_DHCP_GET_NTP_SRV 00125 /** This function must exist, in other to add offered NTP servers to 00126 * the NTP (or SNTP) engine. 00127 * See LWIP_DHCP_MAX_NTP_SERVERS */ 00128 extern void dhcp_set_ntp_servers(u8_t num_ntp_servers, const ip4_addr_t* ntp_server_addrs); 00129 #endif /* LWIP_DHCP_GET_NTP_SRV */ 00130 00131 #define netif_dhcp_data(netif) ((struct dhcp*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP)) 00132 00133 #ifdef __cplusplus 00134 } 00135 #endif 00136 00137 #endif /* LWIP_DHCP */ 00138 00139 #endif /*LWIP_HDR_DHCP_H*/
Generated on Tue Jul 12 2022 13:54:16 by
