/** * @file * DHCP protocol definitions *//* ... *//* * Copyright (c) 2001-2004 Leon Woestenberg <leon.woestenberg@gmx.net> * Copyright (c) 2001-2004 Axon Digital Design B.V., The Netherlands. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Leon Woestenberg <leon.woestenberg@gmx.net> * *//* ... */#ifndefLWIP_HDR_PROT_DHCP_H#defineLWIP_HDR_PROT_DHCP_H#include"lwip/opt.h"#include"lwip/arch.h"#include"lwip/prot/ip4.h"#ifdef__cplusplusextern"C"{#endif/* DHCP message item offsets and length */#defineDHCP_CHADDR_LEN16U#defineDHCP_SNAME_OFS44U#defineDHCP_SNAME_LEN64U#defineDHCP_FILE_OFS108U#defineDHCP_FILE_LEN128U#defineDHCP_MSG_LEN236U#defineDHCP_OPTIONS_OFS(DHCP_MSG_LEN+4U)/* 4 byte: cookie */7 defines#ifdefPACK_STRUCT_USE_INCLUDES# include"arch/bpstruct.h"#endifPACK_STRUCT_BEGIN/** minimum set of fields of any DHCP message */structdhcp_msg{PACK_STRUCT_FLD_8(u8_top);PACK_STRUCT_FLD_8(u8_thtype);PACK_STRUCT_FLD_8(u8_thlen);PACK_STRUCT_FLD_8(u8_thops);PACK_STRUCT_FIELD(u32_txid);PACK_STRUCT_FIELD(u16_tsecs);PACK_STRUCT_FIELD(u16_tflags);PACK_STRUCT_FLD_S(ip4_addr_p_tciaddr);PACK_STRUCT_FLD_S(ip4_addr_p_tyiaddr);PACK_STRUCT_FLD_S(ip4_addr_p_tsiaddr);PACK_STRUCT_FLD_S(ip4_addr_p_tgiaddr);PACK_STRUCT_FLD_8(u8_tchaddr[DHCP_CHADDR_LEN]);PACK_STRUCT_FLD_8(u8_tsname[DHCP_SNAME_LEN]);PACK_STRUCT_FLD_8(u8_tfile[DHCP_FILE_LEN]);PACK_STRUCT_FIELD(u32_tcookie);#defineDHCP_MIN_OPTIONS_LEN68U/** make sure user does not configure this too small */#if((defined(DHCP_OPTIONS_LEN))&&(DHCP_OPTIONS_LEN<DHCP_MIN_OPTIONS_LEN))# undefDHCP_OPTIONS_LEN#endif/** allow this to be configured in lwipopts.h, but not too small */#if(!defined(DHCP_OPTIONS_LEN))/** set this to be sufficient for your options in outgoing DHCP msgs */# defineDHCP_OPTIONS_LENDHCP_MIN_OPTIONS_LEN/* ... */#endifPACK_STRUCT_FLD_8(u8_toptions[DHCP_OPTIONS_LEN]);...}PACK_STRUCT_STRUCT;PACK_STRUCT_END#ifdefPACK_STRUCT_USE_INCLUDES# include"arch/epstruct.h"#endif/* DHCP client states */typedefenum{DHCP_STATE_OFF=0,DHCP_STATE_REQUESTING=1,DHCP_STATE_INIT=2,DHCP_STATE_REBOOTING=3,DHCP_STATE_REBINDING=4,DHCP_STATE_RENEWING=5,DHCP_STATE_SELECTING=6,DHCP_STATE_INFORMING=7,DHCP_STATE_CHECKING=8,DHCP_STATE_PERMANENT=9,/* not yet implemented */DHCP_STATE_BOUND=10,DHCP_STATE_RELEASING=11,/* not yet implemented */DHCP_STATE_BACKING_OFF=12...}dhcp_state_enum_t;/* DHCP op codes */#defineDHCP_BOOTREQUEST1#defineDHCP_BOOTREPLY2/* DHCP message types */#defineDHCP_DISCOVER1#defineDHCP_OFFER2#defineDHCP_REQUEST3#defineDHCP_DECLINE4#defineDHCP_ACK5#defineDHCP_NAK6#defineDHCP_RELEASE7#defineDHCP_INFORM8#defineDHCP_MAGIC_COOKIE0x63825363UL/* This is a list of options for BOOTP and DHCP, see RFC 2132 for descriptions *//* BootP options */#defineDHCP_OPTION_PAD0#defineDHCP_OPTION_SUBNET_MASK1/* RFC 2132 3.3 */#defineDHCP_OPTION_ROUTER3#defineDHCP_OPTION_DNS_SERVER6#defineDHCP_OPTION_HOSTNAME12#defineDHCP_OPTION_IP_TTL23#defineDHCP_OPTION_MTU26#defineDHCP_OPTION_BROADCAST28#defineDHCP_OPTION_TCP_TTL37#defineDHCP_OPTION_NTP42#defineDHCP_OPTION_END255/* DHCP options */#defineDHCP_OPTION_REQUESTED_IP50/* RFC 2132 9.1, requested IP address */#defineDHCP_OPTION_LEASE_TIME51/* RFC 2132 9.2, time in seconds, in 4 bytes */#defineDHCP_OPTION_OVERLOAD52/* RFC2132 9.3, use file and/or sname field for options */#defineDHCP_OPTION_MESSAGE_TYPE53/* RFC 2132 9.6, important for DHCP */#defineDHCP_OPTION_MESSAGE_TYPE_LEN1#defineDHCP_OPTION_SERVER_ID54/* RFC 2132 9.7, server IP address */#defineDHCP_OPTION_PARAMETER_REQUEST_LIST55/* RFC 2132 9.8, requested option types */#defineDHCP_OPTION_MAX_MSG_SIZE57/* RFC 2132 9.10, message size accepted >= 576 */#defineDHCP_OPTION_MAX_MSG_SIZE_LEN2#defineDHCP_OPTION_T158/* T1 renewal time */#defineDHCP_OPTION_T259/* T2 rebinding time */#defineDHCP_OPTION_US60#defineDHCP_OPTION_CLIENT_ID61#defineDHCP_OPTION_TFTP_SERVERNAME66#defineDHCP_OPTION_BOOTFILE67/* possible combinations of overloading the file and sname fields with options */#defineDHCP_OVERLOAD_NONE0#defineDHCP_OVERLOAD_FILE1#defineDHCP_OVERLOAD_SNAME2#defineDHCP_OVERLOAD_SNAME_FILE341 defines#ifdef__cplusplus}extern "C" { ... }#endif/* ... */#endif/* LWIP_HDR_PROT_DHCP_H */
Details
Show: from
Types: Columns:
All items filtered out
All items filtered out
This file uses the notable symbols shown below. Click anywhere in the file to view more details.