]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/Main/HtoNtoH.c
2 Routines for translating between host and network byte-order.
4 Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available
6 under the terms and conditions of the BSD License that accompanies this
7 distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 #include <Library/BaseLib.h>
15 #include <LibConfig.h>
16 #include <sys/endian.h>
18 // Undefine macro versions of the functions to be defined below.
24 /** 32-bit Host to Network byte order conversion.
26 @param[in] Datum The 32-bit value to be converted.
27 @return Datum, converted to network byte order.
34 #if BYTE_ORDER == LITTLE_ENDIAN
35 return SwapBytes32(Datum
);
41 /** 16-bit Host to Network byte order conversion.
43 @param[in] Datum The 16-bit value to be converted.
44 @return Datum, converted to network byte order.
51 #if BYTE_ORDER == LITTLE_ENDIAN
52 return SwapBytes16(Datum
);
58 /** 32-bit Network to Host byte order conversion.
60 @param[in] Datum The 16-bit value to be converted.
61 @return Datum, converted to host byte order.
68 #if BYTE_ORDER == LITTLE_ENDIAN
69 return SwapBytes32(Datum
);
75 /** 16-bit Network to Host byte order conversion.
77 @param[in] Datum The 16-bit value to be converted.
78 @return Datum, converted to host byte order.
85 #if BYTE_ORDER == LITTLE_ENDIAN
86 return SwapBytes16(Datum
);