-/** @file
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-
-Module Name:
-
- Dhcp4Io.h
-
-Abstract:
-
- The DHCP4 protocol implementation.
-
-
-**/
-
-#ifndef __EFI_DHCP4_IO_H__
-#define __EFI_DHCP4_IO_H__
-
-#include <PiDxe.h>
-
-#include <Protocol/ServiceBinding.h>
-
-#include <Library/NetLib.h>
-#include <Library/UdpIoLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-
-
-enum {
- DHCP_WAIT_OFFER = 3, // Time to wait the offers
- DHCP_DEFAULT_LEASE = 7 *24 *60 *60, // Seven days as default.
- DHCP_SERVER_PORT = 67,
- DHCP_CLIENT_PORT = 68,
-
- //
- // BOOTP header "op" field
- //
- BOOTP_REQUEST = 1,
- BOOTP_REPLY = 2,
-
- //
- // DHCP message types
- //
- DHCP_MSG_DISCOVER = 1,
- DHCP_MSG_OFFER = 2,
- DHCP_MSG_REQUEST = 3,
- DHCP_MSG_DECLINE = 4,
- DHCP_MSG_ACK = 5,
- DHCP_MSG_NAK = 6,
- DHCP_MSG_RELEASE = 7,
- DHCP_MSG_INFORM = 8,
-
- //
- // DHCP notify user type
- //
- DHCP_NOTIFY_COMPLETION = 1,
- DHCP_NOTIFY_RENEWREBIND,
- DHCP_NOTIFY_ALL
-};
-
-#define DHCP_IS_BOOTP(Parameter) (((Parameter) == NULL) || ((Parameter)->DhcpType == 0))
-
-#define DHCP_CONNECTED(State) \
- (((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding))
-
-EFI_STATUS
-DhcpSetState (
- IN DHCP_SERVICE *DhcpSb,
- IN INTN State,
- IN BOOLEAN CallUser
- );
-
-EFI_STATUS
-DhcpSendMessage (
- IN DHCP_SERVICE *DhcpSb,
- IN EFI_DHCP4_PACKET *Seed,
- IN DHCP_PARAMETER *Para,
- IN UINT8 Type,
- IN UINT8 *Msg
- );
-
-VOID
-EFIAPI
-DhcpOnTimerTick (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-VOID
-DhcpInput (
- NET_BUF *UdpPacket,
- UDP_POINTS *Points,
- EFI_STATUS IoStatus,
- VOID *Context
- );
-
-EFI_STATUS
-DhcpInitRequest (
- IN DHCP_SERVICE *DhcpSb
- );
-
-VOID
-DhcpCleanLease (
- IN DHCP_SERVICE *DhcpSb
- );
-
-#endif
+/** @file\r
+ The DHCP4 protocol implementation.\r
+\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef __EFI_DHCP4_IO_H__\r
+#define __EFI_DHCP4_IO_H__\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Protocol/ServiceBinding.h>\r
+\r
+#include <Library/NetLib.h>\r
+#include <Library/UdpIoLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+\r
+\r
+\r
+#define DHCP_WAIT_OFFER 3 // Time to wait the offers\r
+#define DHCP_DEFAULT_LEASE 7 * 24 * 60 * 60 // Seven days as default.\r
+#define DHCP_SERVER_PORT 67\r
+#define DHCP_CLIENT_PORT 68\r
+\r
+//\r
+// BOOTP header "op" field\r
+//\r
+#define BOOTP_REQUEST 1\r
+#define BOOTP_REPLY 2\r
+\r
+//\r
+// DHCP message types\r
+//\r
+#define DHCP_MSG_DISCOVER 1\r
+#define DHCP_MSG_OFFER 2\r
+#define DHCP_MSG_REQUEST 3\r
+#define DHCP_MSG_DECLINE 4\r
+#define DHCP_MSG_ACK 5\r
+#define DHCP_MSG_NAK 6\r
+#define DHCP_MSG_RELEASE 7\r
+#define DHCP_MSG_INFORM 8\r
+\r
+//\r
+// DHCP notify user type\r
+//\r
+#define DHCP_NOTIFY_COMPLETION 1\r
+#define DHCP_NOTIFY_RENEWREBIND 2\r
+#define DHCP_NOTIFY_ALL 3\r
+\r
+#define DHCP_IS_BOOTP(Parameter) (((Parameter) == NULL) || ((Parameter)->DhcpType == 0))\r
+\r
+#define DHCP_CONNECTED(State) \\r
+ (((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding))\r
+\r
+/**\r
+ Set the DHCP state. If CallUser is true, it will try to notify\r
+ the user before change the state by DhcpNotifyUser. It returns\r
+ EFI_ABORTED if the user return EFI_ABORTED, otherwise, it returns\r
+ EFI_SUCCESS. If CallUser is FALSE, it isn't necessary to test\r
+ the return value of this function.\r
+\r
+ @param DhcpSb The DHCP service instance\r
+ @param State The new DHCP state to change to\r
+ @param CallUser Whether we need to call user\r
+\r
+ @retval EFI_SUCCESS The state is changed\r
+ @retval EFI_ABORTED The user asks to abort the DHCP process.\r
+\r
+**/\r
+EFI_STATUS\r
+DhcpSetState (\r
+ IN OUT DHCP_SERVICE *DhcpSb,\r
+ IN INTN State,\r
+ IN BOOLEAN CallUser\r
+ );\r
+\r
+/**\r
+ Build and transmit a DHCP message according to the current states.\r
+ This function implement the Table 5. of RFC 2131. Always transits\r
+ the state (as defined in Figure 5. of the same RFC) before sending\r
+ a DHCP message. The table is adjusted accordingly.\r
+\r
+ @param[in] DhcpSb The DHCP service instance\r
+ @param[in] Seed The seed packet which the new packet is based on\r
+ @param[in] Para The DHCP parameter of the Seed packet\r
+ @param[in] Type The message type to send\r
+ @param[in] Msg The human readable message to include in the packet\r
+ sent.\r
+\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate resources for the packet\r
+ @retval EFI_ACCESS_DENIED Failed to transmit the packet through UDP\r
+ @retval EFI_SUCCESS The message is sent\r
+ @retval other Other error occurs\r
+\r
+**/\r
+EFI_STATUS\r
+DhcpSendMessage (\r
+ IN DHCP_SERVICE *DhcpSb,\r
+ IN EFI_DHCP4_PACKET *Seed,\r
+ IN DHCP_PARAMETER *Para,\r
+ IN UINT8 Type,\r
+ IN UINT8 *Msg\r
+ );\r
+\r
+/**\r
+ Each DHCP service has three timer. Two of them are count down timer.\r
+ One for the packet retransmission. The other is to collect the offers.\r
+ The third timer increaments the lease life which is compared to T1, T2,\r
+ and lease to determine the time to renew and rebind the lease.\r
+ DhcpOnTimerTick will be called once every second.\r
+\r
+ @param[in] Event The timer event\r
+ @param[in] Context The context, which is the DHCP service instance.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DhcpOnTimerTick (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ );\r
+\r
+/**\r
+ Handle the received DHCP packets. This function drives the DHCP\r
+ state machine.\r
+\r
+ @param UdpPacket The UDP packets received.\r
+ @param EndPoint The local/remote UDP access point\r
+ @param IoStatus The status of the UDP receive\r
+ @param Context The opaque parameter to the function.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DhcpInput (\r
+ NET_BUF *UdpPacket,\r
+ UDP_END_POINT *EndPoint,\r
+ EFI_STATUS IoStatus,\r
+ VOID *Context\r
+ );\r
+\r
+/**\r
+ Send an initial DISCOVER or REQUEST message according to the\r
+ DHCP service's current state.\r
+\r
+ @param[in] DhcpSb The DHCP service instance\r
+\r
+ @retval EFI_SUCCESS The request has been sent\r
+ @retval other Some error occurs when sending the request.\r
+\r
+**/\r
+EFI_STATUS\r
+DhcpInitRequest (\r
+ IN DHCP_SERVICE *DhcpSb\r
+ );\r
+\r
+/**\r
+ Clean up the DHCP related states, IoStatus isn't reset.\r
+\r
+ @param DhcpSb The DHCP instance service.\r
+\r
+**/\r
+VOID\r
+DhcpCleanLease (\r
+ IN DHCP_SERVICE *DhcpSb\r
+ );\r
+\r
+/**\r
+ Release the net buffer when packet is sent.\r
+\r
+ @param UdpPacket The UDP packets received.\r
+ @param EndPoint The local/remote UDP access point\r
+ @param IoStatus The status of the UDP receive\r
+ @param Context The opaque parameter to the function.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DhcpOnPacketSent (\r
+ NET_BUF *Packet,\r
+ UDP_END_POINT *EndPoint,\r
+ EFI_STATUS IoStatus,\r
+ VOID *Context\r
+ );\r
+\r
+#endif\r