Update Studio Integration DLL, to include package logging.
[pub/USBasp.git] / Projects / Webserver / Lib / DHCPClientApp.h
index 702f797..afdc3bd 100644 (file)
-/*\r
-             LUFA Library\r
-     Copyright (C) Dean Camera, 2010.\r
-              \r
-  dean [at] fourwalledcubicle [dot] com\r
-      www.fourwalledcubicle.com\r
-*/\r
-\r
-/*\r
-  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
-  Permission to use, copy, modify, distribute, and sell this \r
-  software and its documentation for any purpose is hereby granted\r
-  without fee, provided that the above copyright notice appear in \r
-  all copies and that both that the copyright notice and this\r
-  permission notice and warranty disclaimer appear in supporting \r
-  documentation, and that the name of the author not be used in \r
-  advertising or publicity pertaining to distribution of the \r
-  software without specific, written prior permission.\r
-\r
-  The author disclaim all warranties with regard to this\r
-  software, including all implied warranties of merchantability\r
-  and fitness.  In no event shall the author be liable for any\r
-  special, indirect or consequential damages or any damages\r
-  whatsoever resulting from loss of use, data or profits, whether\r
-  in an action of contract, negligence or other tortious action,\r
-  arising out of or in connection with the use or performance of\r
-  this software.\r
-*/\r
-\r
-/** \file\r
- *\r
- *  Header file for DHCPClientApp.c.\r
- */\r
-\r
-#ifndef _DHCPCLIENT_APP_H_\r
-#define _DHCPCLIENT_APP_H_\r
-\r
-       /* Includes: */\r
-               #include <stdio.h>\r
-               \r
-               #include <uip.h>\r
-               \r
-               #include "../Webserver.h"\r
-               \r
-       /* Macros: */\r
-               /** UDP listen port for a BOOTP server */\r
-               #define DHCPC_SERVER_PORT         67\r
-\r
-               /** UDP listen port for a BOOTP client */\r
-               #define DHCPC_CLIENT_PORT         68\r
-\r
-               /** BOOTP message type for a BOOTP REQUEST message */\r
-               #define DHCP_OP_BOOTREQUEST       0x01\r
-\r
-               /** BOOTP message type for a BOOTP REPLY message */\r
-               #define DHCP_OP_BOOTREPLY         0x02\r
-\r
-               /** BOOTP flag for a BOOTP broadcast message */\r
-               #define BOOTP_BROADCAST           0x8000\r
-               \r
-               /** Magic DHCP cookie for a BOOTP message to identify it as a DHCP message */\r
-               #define DHCP_MAGIC_COOKIE         0x63538263\r
-               \r
-               /** Unique transaction ID used to identify DHCP responses to the client */\r
-               #define DHCP_TRANSACTION_ID       0x13245466\r
-\r
-               /** DHCP message type for a DISCOVER message */\r
-               #define DHCP_DISCOVER             1\r
-\r
-               /** DHCP message type for an OFFER message */\r
-               #define DHCP_OFFER                2\r
-\r
-               /** DHCP message type for a REQUEST message */\r
-               #define DHCP_REQUEST              3\r
-\r
-               /** DHCP message type for a DECLINE message */\r
-               #define DHCP_DECLINE              4\r
-\r
-               /** DHCP message type for an ACK message */\r
-               #define DHCP_ACK                  5\r
-\r
-               /** DHCP message type for a NAK message */\r
-               #define DHCP_NAK                  6\r
-\r
-               /** DHCP message type for a RELEASE message */\r
-               #define DHCP_RELEASE              7\r
-\r
-               /** DHCP medium type for standard Ethernet */\r
-               #define DHCP_HTYPE_ETHERNET       1\r
-\r
-               /** DHCP message option for the network subnet mask */\r
-               #define DHCP_OPTION_SUBNET_MASK   1\r
-\r
-               /** DHCP message option for the network gateway IP */\r
-               #define DHCP_OPTION_ROUTER        3\r
-\r
-               /** DHCP message option for the network DNS server */\r
-               #define DHCP_OPTION_DNS_SERVER    6\r
-\r
-               /** DHCP message option for the requested client IP address */\r
-               #define DHCP_OPTION_REQ_IPADDR    50\r
-\r
-               /** DHCP message option for the IP address lease time */\r
-               #define DHCP_OPTION_LEASE_TIME    51\r
-\r
-               /** DHCP message option for the DHCP message type */\r
-               #define DHCP_OPTION_MSG_TYPE      53\r
-               \r
-               /** DHCP message option for the DHCP server IP */               \r
-               #define DHCP_OPTION_SERVER_ID     54\r
-\r
-               /** DHCP message option for the list of required options from the server */\r
-               #define DHCP_OPTION_REQ_LIST      55\r
-\r
-               /** DHCP message option for the options list terminator */\r
-               #define DHCP_OPTION_END           255\r
-\r
-       /* Type Defines: */\r
-               /** Type define for a DHCP packet inside an Ethernet frame. */\r
-               typedef struct\r
-               {\r
-                       uint8_t  Operation; /**< DHCP operation, either DHCP_OP_BOOTREQUEST or DHCP_OP_BOOTREPLY */\r
-                       uint8_t  HardwareType; /**< Hardware carrier type constant */\r
-                       uint8_t  HardwareAddressLength;  /**< Length in bytes of a hardware (MAC) address on the network */\r
-                       uint8_t  Hops; /**< Number of hops required to reach the server, unused */\r
-\r
-                       uint32_t TransactionID; /**< Unique ID of the DHCP packet, for positive matching between sent and received packets */\r
-\r
-                       uint16_t ElapsedSeconds; /**< Elapsed seconds since the request was made */\r
-                       uint16_t Flags; /**< BOOTP packet flags */\r
-                       \r
-                       uip_ipaddr_t ClientIP; /**< Client IP address, if already leased an IP */\r
-                       uip_ipaddr_t YourIP; /**< Client IP address */\r
-                       uip_ipaddr_t NextServerIP; /**< Legacy BOOTP protocol field, unused for DHCP */\r
-                       uip_ipaddr_t RelayAgentIP; /**< Legacy BOOTP protocol field, unused for DHCP */\r
-                       \r
-                       uint8_t ClientHardwareAddress[16]; /**< Hardware (MAC) address of the client making a request to the DHCP server */\r
-                       uint8_t ServerHostnameString[64]; /**< Legacy BOOTP protocol field, unused for DHCP */\r
-                       uint8_t BootFileName[128]; /**< Legacy BOOTP protocol field, unused for DHCP */\r
-                       \r
-                       uint32_t Cookie; /**< Magic BOOTP protocol cookie to indicate a valid packet */\r
-                       \r
-                       uint8_t  Options[]; /** DHCP message options */\r
-               } DHCP_Header_t;\r
-\r
-       /* Enums: */\r
-               /** States for each DHCP connection to a DHCP client. */\r
-               enum DHCP_States_t\r
-               {\r
-                       DHCP_STATE_SendDiscover,  /**< Send DISCOVER packet to retrieve DHCP lease offers */\r
-                       DHCP_STATE_WaitForOffer,  /**< Waiting for OFFER packet giving available DHCP leases */\r
-                       DHCP_STATE_SendRequest,   /**< Send REQUEST packet to request a DHCP lease */\r
-                       DHCP_STATE_WaitForACK,    /**< Wait for ACK packet to complete the DHCP lease */\r
-                       DHCP_STATE_AddressLeased, /**< DHCP address has been leased from a DHCP server */\r
-               };\r
-\r
-       /* Function Prototypes: */\r
-               void DHCPClientApp_Init(void);\r
-               void DHCPClientApp_Callback(void);\r
-               \r
-               #if defined(INCLUDE_FROM_DHCPCLIENTAPP_C)\r
-                       static uint16_t DHCPClientApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageType,\r
-                                                                    uip_udp_appstate_t* AppState);\r
-                       static uint8_t  DHCPClientApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen,\r
-                                                               void* OptionData);\r
-                       static bool     DHCPClientApp_GetOption(uint8_t* DHCPOptionList, uint8_t Option, void* Destination);\r
-               #endif\r
-#endif\r
+/*
+             LUFA Library
+     Copyright (C) Dean Camera, 2015.
+
+  dean [at] fourwalledcubicle [dot] com
+           www.lufa-lib.org
+*/
+
+/*
+  Copyright 2015  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+  Permission to use, copy, modify, distribute, and sell this
+  software and its documentation for any purpose is hereby granted
+  without fee, provided that the above copyright notice appear in
+  all copies and that both that the copyright notice and this
+  permission notice and warranty disclaimer appear in supporting
+  documentation, and that the name of the author not be used in
+  advertising or publicity pertaining to distribution of the
+  software without specific, written prior permission.
+
+  The author disclaims all warranties with regard to this
+  software, including all implied warranties of merchantability
+  and fitness.  In no event shall the author be liable for any
+  special, indirect or consequential damages or any damages
+  whatsoever resulting from loss of use, data or profits, whether
+  in an action of contract, negligence or other tortious action,
+  arising out of or in connection with the use or performance of
+  this software.
+*/
+
+/** \file
+ *
+ *  Header file for DHCPClientApp.c.
+ */
+
+#ifndef _DHCPCLIENT_APP_H_
+#define _DHCPCLIENT_APP_H_
+
+       /* Includes: */
+               #include <stdio.h>
+
+               #include <uip.h>
+
+               #include "Config/AppConfig.h"
+               #include "../Webserver.h"
+               #include "DHCPCommon.h"
+
+       /* Enums: */
+               /** States for each DHCP connection to a DHCP client. */
+               enum DHCP_Client_States_t
+               {
+                       DHCP_STATE_SendDiscover,  /**< Send DISCOVER packet to retrieve DHCP lease offers */
+                       DHCP_STATE_WaitForOffer,  /**< Waiting for OFFER packet giving available DHCP leases */
+                       DHCP_STATE_SendRequest,   /**< Send REQUEST packet to request a DHCP lease */
+                       DHCP_STATE_WaitForACK,    /**< Wait for ACK packet to complete the DHCP lease */
+                       DHCP_STATE_AddressLeased, /**< DHCP address has been leased from a DHCP server */
+               };
+
+       /* Function Prototypes: */
+               void DHCPClientApp_Init(void);
+               void DHCPClientApp_Callback(void);
+
+               #if defined(INCLUDE_FROM_DHCPCLIENTAPP_C)
+                       static uint16_t DHCPClientApp_FillDHCPHeader(DHCP_Header_t* const DHCPHeader,
+                                                                    const uint8_t DHCPMessageType,
+                                                                    uip_udp_appstate_t* const AppState);
+               #endif
+#endif
+