+++ /dev/null
-/** @File\r
- Routines for translating between host and network byte-order.\r
-\r
- Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
- This program and the accompanying materials are licensed and made available\r
- under the terms and conditions of the BSD License that accompanies this\r
- distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-#include <Library/BaseLib.h>\r
-#include <LibConfig.h>\r
-#include <sys/endian.h>\r
-\r
-// Undefine macro versions of the functions to be defined below.\r
-#undef htonl\r
-#undef htons\r
-#undef ntohl\r
-#undef ntohs\r
-\r
-/** 32-bit Host to Network byte order conversion.\r
-\r
- @param[in] Datum The 32-bit value to be converted.\r
- @return Datum, converted to network byte order.\r
-**/\r
-uint32_t\r
-htonl(\r
- IN uint32_t Datum\r
- )\r
-{\r
-#if BYTE_ORDER == LITTLE_ENDIAN\r
- return SwapBytes32(Datum);\r
-#else\r
- return Datum;\r
-#endif\r
-}\r
-\r
-/** 16-bit Host to Network byte order conversion.\r
-\r
- @param[in] Datum The 16-bit value to be converted.\r
- @return Datum, converted to network byte order.\r
-**/\r
-uint16_t\r
-htons(\r
- IN uint16_t Datum\r
- )\r
-{\r
-#if BYTE_ORDER == LITTLE_ENDIAN\r
- return SwapBytes16(Datum);\r
-#else\r
- return Datum;\r
-#endif\r
-}\r
-\r
-/** 32-bit Network to Host byte order conversion.\r
-\r
- @param[in] Datum The 16-bit value to be converted.\r
- @return Datum, converted to host byte order.\r
-**/\r
-uint32_t\r
-ntohl(\r
- IN uint32_t Datum\r
- )\r
-{\r
-#if BYTE_ORDER == LITTLE_ENDIAN\r
- return SwapBytes32(Datum);\r
-#else\r
- return Datum;\r
-#endif\r
-}\r
-\r
-/** 16-bit Network to Host byte order conversion.\r
-\r
- @param[in] Datum The 16-bit value to be converted.\r
- @return Datum, converted to host byte order.\r
-**/\r
-uint16_t\r
-ntohs(\r
- IN uint16_t Datum\r
- )\r
-{\r
-#if BYTE_ORDER == LITTLE_ENDIAN\r
- return SwapBytes16(Datum);\r
-#else\r
- return Datum;\r
-#endif\r
-}\r