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