3      Copyright (C) Dean Camera, 2013. 
   5   dean [at] fourwalledcubicle [dot] com 
  10   Copyright 2013  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, distribute, and sell this 
  13   software and its documentation for any purpose is hereby granted 
  14   without fee, provided that the above copyright notice appear in 
  15   all copies and that both that the copyright notice and this 
  16   permission notice and warranty disclaimer appear in supporting 
  17   documentation, and that the name of the author not be used in 
  18   advertising or publicity pertaining to distribution of the 
  19   software without specific, written prior permission. 
  21   The author disclaims all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  33  *  Header file for DHCP.c. 
  43                 #include "EthernetProtocols.h" 
  45                 #include "ProtocolDecoders.h" 
  48                 /** DHCP operation constant, indicating a request from a host to a DHCP server. */ 
  49                 #define DHCP_OP_BOOTREQUEST       0x01 
  51                 /** DHCP operation constant, indicating a reply from a DHCP server to a host. */ 
  52                 #define DHCP_OP_BOOTREPLY         0x02 
  54                 /** Hardware type constant, indicating Ethernet as a carrier. */ 
  55                 #define DHCP_HTYPE_ETHERNET       0x01 
  57                 /** Magic boot protocol "cookie", inserted into all BOOTP packets (BOOTP is the carrier of DHCP). */ 
  58                 #define DHCP_MAGIC_COOKIE         0x63825363 
  60                 /** DHCP option list entry header, indicating that a subnet mask will follow. */ 
  61                 #define DHCP_OPTION_SUBNETMASK    1 
  63                 /** DHCP option list entry header, indicating that the DHCP message type constant will follow. */ 
  64                 #define DHCP_OPTION_MESSAGETYPE   53 
  66                 /** DHCP option list entry header, indicating that the IP address of the DHCP server will follow. */ 
  67                 #define DHCP_OPTION_DHCPSERVER    54 
  69                 /** DHCP option list entry header, used to pad out option data. */ 
  70                 #define DHCP_OPTION_PAD           0 
  72                 /** DHCP option list entry header, indicating the end of option data. */ 
  73                 #define DHCP_OPTION_END           255 
  75                 /** Message type constant, used in the DHCP option data field, requesting that a DHCP server offer an IP address. */ 
  76                 #define DHCP_MESSAGETYPE_DISCOVER 1 
  78                 /** Message type constant, used in the DHCP option data field, indicating that a DHCP server is offering an IP address. */ 
  79                 #define DHCP_MESSAGETYPE_OFFER    2 
  81                 /** Message type constant, used in the DHCP option data field, requesting that a DHCP server lease a given IP address. */ 
  82                 #define DHCP_MESSAGETYPE_REQUEST  3 
  84                 /** Message type constant, used in the DHCP option data field, declining an offered DHCP server IP address lease. */ 
  85                 #define DHCP_MESSAGETYPE_DECLINE  4 
  87                 /** Message type constant, used in the DHCP option data field, ACKing a host IP lease request. */ 
  88                 #define DHCP_MESSAGETYPE_ACK      5 
  90                 /** Message type constant, used in the DHCP option data field, NACKing a host IP lease request. */ 
  91                 #define DHCP_MESSAGETYPE_NACK     6 
  93                 /** Message type constant, used in the DHCP option data field, indicating that a host is releasing a leased IP address. */ 
  94                 #define DHCP_MESSAGETYPE_RELEASE  7 
  97                 /** Type define for a DHCP packet inside an Ethernet frame. */ 
 100                         uint8_t  Operation
; /**< DHCP operation, either DHCP_OP_BOOTREQUEST or DHCP_OP_BOOTREPLY */ 
 101                         uint8_t  HardwareType
; /**< Hardware carrier type constant */ 
 102                         uint8_t  HardwareAddressLength
;  /**< Length in bytes of a hardware (MAC) address on the network */ 
 103                         uint8_t  Hops
; /**< Number of hops required to reach the server, unused */ 
 105                         uint32_t TransactionID
; /**< Unique ID of the DHCP packet, for positive matching between sent and received packets */ 
 107                         uint16_t ElapsedSeconds
; /**< Elapsed seconds since the request was made */ 
 108                         uint16_t Flags
; /**< BOOTP packet flags */ 
 110                         IP_Address_t ClientIP
; /**< Client IP address, if already leased an IP */ 
 111                         IP_Address_t YourIP
; /**< Client IP address */ 
 112                         IP_Address_t NextServerIP
; /**< Legacy BOOTP protocol field, unused for DHCP */ 
 113                         IP_Address_t RelayAgentIP
; /**< Legacy BOOTP protocol field, unused for DHCP */ 
 115                         uint8_t ClientHardwareAddress
[16]; /**< Hardware (MAC) address of the client making a request to the DHCP server */ 
 116                         uint8_t ServerHostnameString
[64]; /**< Legacy BOOTP protocol field, unused for DHCP */ 
 117                         uint8_t BootFileName
[128]; /**< Legacy BOOTP protocol field, unused for DHCP */ 
 119                         uint32_t Cookie
; /**< Magic BOOTP protocol cookie to indicate a valid packet */ 
 122         /* Function Prototypes: */ 
 123                 int16_t DHCP_ProcessDHCPPacket(void* IPHeaderInStart
, 
 124                                                void* DHCPHeaderInStart
, 
 125                                                void* DHCPHeaderOutStart
);