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 protocol definitions 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_PROT_DHCP_H 00039 #define LWIP_HDR_PROT_DHCP_H 00040 00041 #include "lwip/opt.h" 00042 #include "lwip/arch.h" 00043 #include "lwip/prot/ip4.h" 00044 00045 #ifdef __cplusplus 00046 extern "C" { 00047 #endif 00048 00049 /* DHCP message item offsets and length */ 00050 #define DHCP_CHADDR_LEN 16U 00051 #define DHCP_SNAME_OFS 44U 00052 #define DHCP_SNAME_LEN 64U 00053 #define DHCP_FILE_OFS 108U 00054 #define DHCP_FILE_LEN 128U 00055 #define DHCP_MSG_LEN 236U 00056 #define DHCP_OPTIONS_OFS (DHCP_MSG_LEN + 4U) /* 4 byte: cookie */ 00057 00058 #ifdef PACK_STRUCT_USE_INCLUDES 00059 # include "arch/bpstruct.h" 00060 #endif 00061 PACK_STRUCT_BEGIN 00062 /** minimum set of fields of any DHCP message */ 00063 struct dhcp_msg 00064 { 00065 PACK_STRUCT_FLD_8(u8_t op); 00066 PACK_STRUCT_FLD_8(u8_t htype); 00067 PACK_STRUCT_FLD_8(u8_t hlen); 00068 PACK_STRUCT_FLD_8(u8_t hops); 00069 PACK_STRUCT_FIELD(u32_t xid); 00070 PACK_STRUCT_FIELD(u16_t secs); 00071 PACK_STRUCT_FIELD(u16_t flags); 00072 PACK_STRUCT_FLD_S(ip4_addr_p_t ciaddr); 00073 PACK_STRUCT_FLD_S(ip4_addr_p_t yiaddr); 00074 PACK_STRUCT_FLD_S(ip4_addr_p_t siaddr); 00075 PACK_STRUCT_FLD_S(ip4_addr_p_t giaddr); 00076 PACK_STRUCT_FLD_8(u8_t chaddr[DHCP_CHADDR_LEN]); 00077 PACK_STRUCT_FLD_8(u8_t sname[DHCP_SNAME_LEN]); 00078 PACK_STRUCT_FLD_8(u8_t file[DHCP_FILE_LEN]); 00079 PACK_STRUCT_FIELD(u32_t cookie); 00080 #define DHCP_MIN_OPTIONS_LEN 68U 00081 /** make sure user does not configure this too small */ 00082 #if ((defined(DHCP_OPTIONS_LEN)) && (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN)) 00083 # undef DHCP_OPTIONS_LEN 00084 #endif 00085 /** allow this to be configured in lwipopts.h, but not too small */ 00086 #if (!defined(DHCP_OPTIONS_LEN)) 00087 /** set this to be sufficient for your options in outgoing DHCP msgs */ 00088 # define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN 00089 #endif 00090 PACK_STRUCT_FLD_8(u8_t options[DHCP_OPTIONS_LEN]); 00091 } PACK_STRUCT_STRUCT; 00092 PACK_STRUCT_END 00093 #ifdef PACK_STRUCT_USE_INCLUDES 00094 # include "arch/epstruct.h" 00095 #endif 00096 00097 00098 /* DHCP client states */ 00099 typedef enum { 00100 DHCP_STATE_OFF = 0, 00101 DHCP_STATE_REQUESTING = 1, 00102 DHCP_STATE_INIT = 2, 00103 DHCP_STATE_REBOOTING = 3, 00104 DHCP_STATE_REBINDING = 4, 00105 DHCP_STATE_RENEWING = 5, 00106 DHCP_STATE_SELECTING = 6, 00107 DHCP_STATE_INFORMING = 7, 00108 DHCP_STATE_CHECKING = 8, 00109 DHCP_STATE_PERMANENT = 9, /* not yet implemented */ 00110 DHCP_STATE_BOUND = 10, 00111 DHCP_STATE_RELEASING = 11, /* not yet implemented */ 00112 DHCP_STATE_BACKING_OFF = 12 00113 } dhcp_state_enum_t; 00114 00115 /* DHCP op codes */ 00116 #define DHCP_BOOTREQUEST 1 00117 #define DHCP_BOOTREPLY 2 00118 00119 /* DHCP message types */ 00120 #define DHCP_DISCOVER 1 00121 #define DHCP_OFFER 2 00122 #define DHCP_REQUEST 3 00123 #define DHCP_DECLINE 4 00124 #define DHCP_ACK 5 00125 #define DHCP_NAK 6 00126 #define DHCP_RELEASE 7 00127 #define DHCP_INFORM 8 00128 00129 #define DHCP_MAGIC_COOKIE 0x63825363UL 00130 00131 /* This is a list of options for BOOTP and DHCP, see RFC 2132 for descriptions */ 00132 00133 /* BootP options */ 00134 #define DHCP_OPTION_PAD 0 00135 #define DHCP_OPTION_SUBNET_MASK 1 /* RFC 2132 3.3 */ 00136 #define DHCP_OPTION_ROUTER 3 00137 #define DHCP_OPTION_DNS_SERVER 6 00138 #define DHCP_OPTION_HOSTNAME 12 00139 #define DHCP_OPTION_IP_TTL 23 00140 #define DHCP_OPTION_MTU 26 00141 #define DHCP_OPTION_BROADCAST 28 00142 #define DHCP_OPTION_TCP_TTL 37 00143 #define DHCP_OPTION_NTP 42 00144 #define DHCP_OPTION_END 255 00145 00146 /* DHCP options */ 00147 #define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */ 00148 #define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */ 00149 #define DHCP_OPTION_OVERLOAD 52 /* RFC2132 9.3, use file and/or sname field for options */ 00150 00151 #define DHCP_OPTION_MESSAGE_TYPE 53 /* RFC 2132 9.6, important for DHCP */ 00152 #define DHCP_OPTION_MESSAGE_TYPE_LEN 1 00153 00154 #define DHCP_OPTION_SERVER_ID 54 /* RFC 2132 9.7, server IP address */ 00155 #define DHCP_OPTION_PARAMETER_REQUEST_LIST 55 /* RFC 2132 9.8, requested option types */ 00156 00157 #define DHCP_OPTION_MAX_MSG_SIZE 57 /* RFC 2132 9.10, message size accepted >= 576 */ 00158 #define DHCP_OPTION_MAX_MSG_SIZE_LEN 2 00159 00160 #define DHCP_OPTION_T1 58 /* T1 renewal time */ 00161 #define DHCP_OPTION_T2 59 /* T2 rebinding time */ 00162 #define DHCP_OPTION_US 60 00163 #define DHCP_OPTION_CLIENT_ID 61 00164 #define DHCP_OPTION_TFTP_SERVERNAME 66 00165 #define DHCP_OPTION_BOOTFILE 67 00166 00167 /* possible combinations of overloading the file and sname fields with options */ 00168 #define DHCP_OVERLOAD_NONE 0 00169 #define DHCP_OVERLOAD_FILE 1 00170 #define DHCP_OVERLOAD_SNAME 2 00171 #define DHCP_OVERLOAD_SNAME_FILE 3 00172 00173 00174 #ifdef __cplusplus 00175 } 00176 #endif 00177 00178 #endif /* LWIP_HDR_PROT_DHCP_H */
Generated on Tue Jul 12 2022 13:54:16 by
