cl_byteswap.h revision 331769
1195098Sed/* 2195098Sed * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved. 3195098Sed * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved. 4195098Sed * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 5195098Sed * 6195098Sed * This software is available to you under a choice of one of two 7195098Sed * licenses. You may choose to be licensed under the terms of the GNU 8195098Sed * General Public License (GPL) Version 2, available from the file 9195098Sed * COPYING in the main directory of this source tree, or the 10195098Sed * OpenIB.org BSD license below: 11198090Srdivacky * 12198090Srdivacky * Redistribution and use in source and binary forms, with or 13195098Sed * without modification, are permitted provided that the following 14198090Srdivacky * conditions are met: 15218893Sdim * 16195340Sed * - Redistributions of source code must retain the above 17198090Srdivacky * copyright notice, this list of conditions and the following 18226633Sdim * disclaimer. 19226633Sdim * 20226633Sdim * - Redistributions in binary form must reproduce the above 21198090Srdivacky * copyright notice, this list of conditions and the following 22195098Sed * disclaimer in the documentation and/or other materials 23226633Sdim * provided with the distribution. 24205407Srdivacky * 25202878Srdivacky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26224145Sdim * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27202878Srdivacky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28198090Srdivacky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29198090Srdivacky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30198090Srdivacky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31202878Srdivacky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32234353Sdim * SOFTWARE. 33218893Sdim * 34195098Sed */ 35195098Sed 36195098Sed/* 37195098Sed * Abstract: 38198090Srdivacky * provides byteswapping utilities. Basic functions are obtained from 39224145Sdim * platform specific implementations from byteswap_osd.h. 40202878Srdivacky */ 41198090Srdivacky 42224145Sdim#ifndef _CL_BYTESWAP_H_ 43205407Srdivacky#define _CL_BYTESWAP_H_ 44212904Sdim 45226633Sdim#include <string.h> 46218893Sdim#include <complib/cl_byteswap_osd.h> 47202878Srdivacky 48202878Srdivacky#ifdef __cplusplus 49203954Srdivacky# define BEGIN_C_DECLS extern "C" { 50203954Srdivacky# define END_C_DECLS } 51203954Srdivacky#else /* !__cplusplus */ 52218893Sdim# define BEGIN_C_DECLS 53221345Sdim# define END_C_DECLS 54234353Sdim#endif /* __cplusplus */ 55203954Srdivacky 56221345SdimBEGIN_C_DECLS 57221345Sdim/****h* Component Library/Byte Swapping 58221345Sdim* NAME 59221345Sdim* Byte Swapping 60221345Sdim* 61218893Sdim* DESCRIPTION 62218893Sdim* The byte swapping functions and macros allow swapping bytes from network 63223017Sdim* byte order to host byte order. 64234353Sdim* 65234353Sdim* All data transmitted between systems should be in network byte order. 66223017Sdim* In order to utilize such data, it must be converted to host byte order 67198090Srdivacky* before use. 68202878Srdivacky* 69221345Sdim* SEE ALSO 70234353Sdim* Functions: 71218893Sdim* cl_ntoh16, cl_hton16, cl_ntoh32, cl_hton32, cl_ntoh64, cl_hton64, 72226633Sdim* cl_ntoh 73218893Sdim* 74205218Srdivacky* Macros: 75218893Sdim* CL_NTOH16, CL_HTON16, CL_NTOH32, CL_HTON32, CL_NTOH64, CL_HTON64 76218893Sdim*********/ 77234353Sdim/* 78234353Sdim * The byteswap_osd.h provides the following macros. 79203954Srdivacky * __LITTLE_ENDIAN 80203954Srdivacky * __BIG_ENDIAN 81203954Srdivacky * __BYTE_ORDER 82198090Srdivacky * 83195098Sed * If the platform provides byte swapping functions, byteswap_osd.h also 84202878Srdivacky * provides the following macros. 85202878Srdivacky * ntoh16, hton16 86202878Srdivacky * ntoh32, hton32 87202878Srdivacky * ntoh64, hton64 88202878Srdivacky */ 89202878Srdivacky#ifndef __BYTE_ORDER 90202878Srdivacky#error "__BYTE_ORDER macro undefined. Missing in endian.h?" 91202878Srdivacky#endif 92202878Srdivacky#if __BYTE_ORDER == __LITTLE_ENDIAN 93203954Srdivacky#define CPU_LE 1 94203954Srdivacky#define CPU_BE 0 95203954Srdivacky#else 96203954Srdivacky#define CPU_LE 0 97218893Sdim#define CPU_BE 1 98206274Srdivacky#endif 99206274Srdivacky/****d* Component Library: Byte Swapping/CL_NTOH16 100203954Srdivacky* NAME 101202878Srdivacky* CL_NTOH16 102202878Srdivacky* 103202878Srdivacky* DESCRIPTION 104202878Srdivacky* The CL_NTOH16 macro converts a 16-bit value from network byte order to 105202878Srdivacky* host byte order. The CL_NTOH16 macro will cause constant values to be 106203954Srdivacky* swapped by the pre-processor. For variables, CL_NTOH16 is less efficient 107203954Srdivacky* than the cl_ntoh16 function. 108203954Srdivacky* 109203954Srdivacky* SYNOPSIS 110202878Srdivacky* CL_NTOH16( val ); 111202878Srdivacky* 112202878Srdivacky* PARAMETERS 113202878Srdivacky* val 114202878Srdivacky* [in] 16-bit value to swap from network byte order to host byte order. 115202878Srdivacky* 116202878Srdivacky* RESULT 117202878Srdivacky* Value of val converted to host byte order. 118203954Srdivacky* 119202878Srdivacky* NOTES 120202878Srdivacky* This macro is analogous to CL_HTON16. 121202878Srdivacky* 122202878Srdivacky* SEE ALSO 123203954Srdivacky* Byte Swapping, CL_HTON16, CL_NTOH32, CL_NTOH64, 124198090Srdivacky* cl_ntoh16, cl_ntoh32, cl_ntoh64, cl_ntoh 125198090Srdivacky*********/ 126195098Sed/****d* Component Library: Byte Swapping/CL_HTON16 127218893Sdim* NAME 128195098Sed* CL_HTON16 129218893Sdim* 130218893Sdim* DESCRIPTION 131218893Sdim* The CL_HTON16 macro converts a 16-bit value from host byte order to 132218893Sdim* network byte order. The CL_HTON16 macro will cause constant values to be 133218893Sdim* swapped by the pre-processor. For variables, CL_HTON16 is less efficient 134218893Sdim* than the cl_hton16 function. 135218893Sdim* 136218893Sdim* SYNOPSIS 137198090Srdivacky* CL_HTON16( val ); 138221345Sdim* 139221345Sdim* PARAMETERS 140202878Srdivacky* val 141239462Sdim* [in] 16-bit value to swap from host byte order to network byte order. 142218893Sdim* 143195098Sed* RESULT 144198090Srdivacky* Value of val converted to network byte order. 145218893Sdim* 146218893Sdim* NOTES 147218893Sdim* This macro is analogous to CL_NTOH16. 148224145Sdim* 149224145Sdim* SEE ALSO 150221345Sdim* Byte Swapping, CL_NTOH16, CL_HTON32, CL_HTON64, 151221345Sdim* cl_hton16, cl_hton32, cl_hton64, cl_ntoh 152195098Sed*********/ 153202878Srdivacky#if CPU_LE 154195098Sed#define CL_NTOH16( x ) (uint16_t)( \ 155198090Srdivacky (((uint16_t)(x) & 0x00FF) << 8) | \ 156208599Srdivacky (((uint16_t)(x) & 0xFF00) >> 8) ) 157208599Srdivacky#else 158208599Srdivacky#define CL_NTOH16( x ) (x) 159208599Srdivacky#endif 160234353Sdim#define CL_HTON16 CL_NTOH16 161203954Srdivacky/****f* Component Library: Byte Swapping/cl_ntoh16 162202878Srdivacky* NAME 163198090Srdivacky* cl_ntoh16 164195098Sed* 165202878Srdivacky* DESCRIPTION 166202878Srdivacky* The cl_ntoh16 function converts a 16-bit value from network byte order to 167202878Srdivacky* host byte order. 168202878Srdivacky* 169226633Sdim* SYNOPSIS 170226633Sdim* uint16_t 171226633Sdim* cl_ntoh16( 172218893Sdim* IN const uint16_t val ); 173198090Srdivacky* 174239462Sdim* PARAMETERS 175195098Sed* val 176208599Srdivacky* [in] Value to swap from network byte order to host byte order. 177208599Srdivacky* 178218893Sdim* RETURN VALUE 179202878Srdivacky* Value of val converted to host byte order. 180195098Sed* 181218893Sdim* NOTES 182221345Sdim* This function is analogous to cl_hton16. 183218893Sdim* 184218893Sdim* SEE ALSO 185218893Sdim* Byte Swapping, cl_hton16, cl_ntoh32, cl_ntoh64, cl_ntoh 186221345Sdim*********/ 187218893Sdim/****f* Component Library: Byte Swapping/cl_hton16 188221345Sdim* NAME 189218893Sdim* cl_hton16 190234353Sdim* 191234353Sdim* DESCRIPTION 192203954Srdivacky* The cl_hton16 function converts a 16-bit value from host byte order to 193195098Sed* network byte order. 194218893Sdim* 195202878Srdivacky* SYNOPSIS 196202878Srdivacky* uint16_t 197202878Srdivacky* cl_hton16( 198198090Srdivacky* IN const uint16_t val ); 199198090Srdivacky* 200198090Srdivacky* PARAMETERS 201195098Sed* val 202204642Srdivacky* [in] Value to swap from host byte order to network byte order . 203204642Srdivacky* 204204642Srdivacky* RETURN VALUE 205234353Sdim* Value of val converted to network byte order. 206198090Srdivacky* 207203954Srdivacky* NOTES 208203954Srdivacky* This function is analogous to cl_ntoh16. 209234353Sdim* 210234353Sdim* SEE ALSO 211218893Sdim* Byte Swapping, cl_ntoh16, cl_hton32, cl_hton64, cl_ntoh 212218893Sdim*********/ 213221345Sdim#ifndef cl_ntoh16 214221345Sdim#define cl_ntoh16 CL_NTOH16 215203954Srdivacky#define cl_hton16 CL_HTON16 216223017Sdim#endif 217221345Sdim/****d* Component Library: Byte Swapping/CL_NTOH32 218221345Sdim* NAME 219221345Sdim* CL_NTOH32 220221345Sdim* 221221345Sdim* DESCRIPTION 222221345Sdim* The CL_NTOH32 macro converts a 32-bit value from network byte order to 223221345Sdim* host byte order. The CL_NTOH32 macro will cause constant values to be 224221345Sdim* swapped by the pre-processor. For variables, CL_NTOH32 is less efficient 225221345Sdim* than the cl_ntoh32 function. 226221345Sdim* 227221345Sdim* SYNOPSIS 228234353Sdim* CL_NTOH32( val ); 229218893Sdim* 230223017Sdim* PARAMETERS 231223017Sdim* val 232223017Sdim* [in] 32-bit value to swap from network byte order to host byte order. 233223017Sdim* 234223017Sdim* RESULT 235223017Sdim* Value of val converted to host byte order. 236223017Sdim* 237223017Sdim* NOTES 238223017Sdim* This macro is analogous to CL_HTON32. 239223017Sdim* 240223017Sdim* SEE ALSO 241223017Sdim* Byte Swapping, CL_HTON32, CL_NTOH16, CL_NTOH64, 242223017Sdim* cl_ntoh16, cl_ntoh32, cl_ntoh64, cl_ntoh 243223017Sdim*********/ 244223017Sdim/****d* Component Library: Byte Swapping/CL_HTON32 245221345Sdim* NAME 246221345Sdim* CL_HTON32 247221345Sdim* 248221345Sdim* DESCRIPTION 249221345Sdim* The CL_HTON32 macro converts a 32-bit value from host byte order to 250221345Sdim* network byte order. The CL_HTON32 macro will cause constant values to be 251221345Sdim* swapped by the pre-processor. For variables, CL_HTON32 is less efficient 252221345Sdim* than the cl_hton32 function. 253221345Sdim* 254221345Sdim* SYNOPSIS 255203954Srdivacky* CL_HTON32( val ); 256218893Sdim* 257218893Sdim* PARAMETERS 258206274Srdivacky* val 259206274Srdivacky* [in] 32-bit value to swap from host byte order to network byte order. 260206274Srdivacky* 261218893Sdim* RESULT 262234353Sdim* Value of val converted to network byte order. 263218893Sdim* 264198090Srdivacky* NOTES 265198090Srdivacky* This macro is analogous to CL_NTOH32. 266195098Sed* 267198090Srdivacky* SEE ALSO 268195098Sed* Byte Swapping, CL_NTOH32, CL_HTON16, CL_HTON64, 269202878Srdivacky* cl_hton16, cl_hton32, cl_hton64, cl_ntoh 270202878Srdivacky*********/ 271202878Srdivacky#if CPU_LE 272202878Srdivacky#define CL_NTOH32( x ) (uint32_t)( \ 273202878Srdivacky (((uint32_t)(x) & 0x000000FF) << 24) | \ 274202878Srdivacky (((uint32_t)(x) & 0x0000FF00) << 8) | \ 275218893Sdim (((uint32_t)(x) & 0x00FF0000) >> 8) | \ 276202878Srdivacky (((uint32_t)(x) & 0xFF000000) >> 24) ) 277202878Srdivacky#else 278218893Sdim#define CL_NTOH32( x ) (x) 279202878Srdivacky#endif 280202878Srdivacky#define CL_HTON32 CL_NTOH32 281202878Srdivacky/****f* Component Library: Byte Swapping/cl_ntoh32 282218893Sdim* NAME 283202878Srdivacky* cl_ntoh32 284202878Srdivacky* 285202878Srdivacky* DESCRIPTION 286202878Srdivacky* The cl_ntoh32 function converts a 32-bit value from network byte order to 287202878Srdivacky* host byte order. 288202878Srdivacky* 289202878Srdivacky* SYNOPSIS 290202878Srdivacky* uint32_t 291202878Srdivacky* cl_ntoh32( 292218893Sdim* IN const uint32_t val ); 293202878Srdivacky* 294202878Srdivacky* PARAMETERS 295218893Sdim* val 296202878Srdivacky* [in] Value to swap from network byte order to host byte order. 297202878Srdivacky* 298202878Srdivacky* RETURN VALUE 299202878Srdivacky* Value of val converted in host byte order. 300202878Srdivacky* 301202878Srdivacky* NOTES 302202878Srdivacky* This function is analogous to cl_hton32. 303218893Sdim* 304202878Srdivacky* SEE ALSO 305202878Srdivacky* Byte Swapping, cl_hton32, cl_ntoh16, cl_ntoh64, cl_ntoh 306218893Sdim*********/ 307202878Srdivacky/****f* Component Library: Byte Swapping/cl_hton32 308202878Srdivacky* NAME 309202878Srdivacky* cl_hton32 310202878Srdivacky* 311202878Srdivacky* DESCRIPTION 312195098Sed* The cl_hton32 function converts a 32-bit value from host byte order to 313195098Sed* network byte order. 314195098Sed* 315195098Sed* SYNOPSIS 316195098Sed* uint32_t 317218893Sdim* cl_hton32( 318198090Srdivacky* IN const uint32_t val ); 319218893Sdim* 320195098Sed* PARAMETERS 321195098Sed* val 322221345Sdim* [in] Value to swap from host byte order to network byte order . 323221345Sdim* 324221345Sdim* RETURN VALUE 325221345Sdim* Value of val converted to network byte order. 326221345Sdim* 327221345Sdim* NOTES 328221345Sdim* This function is analogous to cl_ntoh32. 329221345Sdim* 330221345Sdim* SEE ALSO 331221345Sdim* Byte Swapping, cl_ntoh32, cl_hton16, cl_hton64, cl_ntoh 332221345Sdim*********/ 333221345Sdim#ifndef cl_ntoh32 334221345Sdim#define cl_ntoh32 CL_NTOH32 335221345Sdim#define cl_hton32 CL_HTON32 336221345Sdim#endif 337195098Sed/****d* Component Library: Byte Swapping/CL_NTOH64 338198090Srdivacky* NAME 339221345Sdim* CL_NTOH64 340195098Sed* 341218893Sdim* DESCRIPTION 342202878Srdivacky* The CL_NTOH64 macro converts a 64-bit value from network byte order to 343195098Sed* host byte order. The CL_NTOH64 macro will cause constant values to be 344195098Sed* swapped by the pre-processor. For variables, CL_NTOH64 is less efficient 345202878Srdivacky* than the cl_ntoh64 function. 346198090Srdivacky* 347218893Sdim* SYNOPSIS 348202878Srdivacky* CL_NTOH64( val ); 349226633Sdim* 350226633Sdim* PARAMETERS 351226633Sdim* val 352195098Sed* [in] 64-bit value to swap from network byte order to host byte order. 353202878Srdivacky* 354198090Srdivacky* RESULT 355195098Sed* Value of val converted to host byte order. 356239462Sdim* 357239462Sdim* NOTES 358239462Sdim* This macro is analogous to CL_HTON64. 359239462Sdim* 360239462Sdim* SEE ALSO 361239462Sdim* Byte Swapping, CL_HTON64, CL_NTOH16, CL_NTOH32, 362239462Sdim* cl_ntoh16, cl_ntoh32, cl_ntoh64, cl_ntoh 363239462Sdim*********/ 364239462Sdim/****d* Component Library: Byte Swapping/CL_HTON64 365239462Sdim* NAME 366239462Sdim* CL_HTON64 367239462Sdim* 368239462Sdim* DESCRIPTION 369239462Sdim* The CL_HTON64 macro converts a 64-bit value from host byte order to 370239462Sdim* network byte order. The CL_HTON64 macro will cause constant values to be 371218893Sdim* swapped by the pre-processor. For variables, CL_HTON64 is less efficient 372218893Sdim* than the cl_hton64 function. 373218893Sdim* 374218893Sdim* SYNOPSIS 375223017Sdim* CL_HTON64( val ); 376223017Sdim* 377218893Sdim* PARAMETERS 378218893Sdim* val 379218893Sdim* [in] 64-bit value to swap from host byte order to network byte order. 380218893Sdim* 381198090Srdivacky* RESULT 382202878Srdivacky* Value of val converted to network byte order. 383202878Srdivacky* 384198396Srdivacky* NOTES 385198396Srdivacky* This macro is analogous to CL_NTOH64. 386208599Srdivacky* 387195098Sed* SEE ALSO 388195098Sed* Byte Swapping, CL_NTOH64, CL_HTON16, CL_HTON32, 389218893Sdim* cl_hton16, cl_hton32, cl_hton64, cl_ntoh 390218893Sdim*********/ 391218893Sdim#if CPU_LE 392218893Sdim#define CL_NTOH64( x ) (uint64_t)( \ 393218893Sdim (((uint64_t)(x) & 0x00000000000000FFULL) << 56) | \ 394218893Sdim (((uint64_t)(x) & 0x000000000000FF00ULL) << 40) | \ 395218893Sdim (((uint64_t)(x) & 0x0000000000FF0000ULL) << 24) | \ 396224145Sdim (((uint64_t)(x) & 0x00000000FF000000ULL) << 8 ) | \ 397224145Sdim (((uint64_t)(x) & 0x000000FF00000000ULL) >> 8 ) | \ 398224145Sdim (((uint64_t)(x) & 0x0000FF0000000000ULL) >> 24) | \ 399218893Sdim (((uint64_t)(x) & 0x00FF000000000000ULL) >> 40) | \ 400218893Sdim (((uint64_t)(x) & 0xFF00000000000000ULL) >> 56) ) 401221345Sdim#else 402221345Sdim#define CL_NTOH64( x ) (x) 403221345Sdim#endif 404221345Sdim#define CL_HTON64 CL_NTOH64 405223017Sdim/****f* Component Library: Byte Swapping/cl_ntoh64 406221345Sdim* NAME 407221345Sdim* cl_ntoh64 408221345Sdim* 409221345Sdim* DESCRIPTION 410198396Srdivacky* The cl_ntoh64 function converts a 64-bit value from network byte order to 411202878Srdivacky* host byte order. 412195098Sed* 413234353Sdim* SYNOPSIS 414203954Srdivacky* uint64_t 415203954Srdivacky* cl_ntoh64( 416203954Srdivacky* IN const uint64_t val ); 417203954Srdivacky* 418203954Srdivacky* PARAMETERS 419203954Srdivacky* val 420218893Sdim* [in] Value to swap from network byte order to host byte order. 421203954Srdivacky* 422203954Srdivacky* RETURN VALUE 423203954Srdivacky* Value of val converted in host byte order. 424203954Srdivacky* 425234353Sdim* NOTES 426203954Srdivacky* This function is analogous to cl_hton64. 427203954Srdivacky* 428203954Srdivacky* SEE ALSO 429203954Srdivacky* Byte Swapping, cl_hton64, cl_ntoh16, cl_ntoh32, cl_ntoh 430203954Srdivacky*********/ 431203954Srdivacky/****f* Component Library: Byte Swapping/cl_hton64 432218893Sdim* NAME 433203954Srdivacky* cl_hton64 434203954Srdivacky* 435203954Srdivacky* DESCRIPTION 436203954Srdivacky* The cl_hton64 function converts a 64-bit value from host byte order to 437203954Srdivacky* network byte order. 438221345Sdim* 439203954Srdivacky* SYNOPSIS 440210299Sed* uint64_t 441210299Sed* cl_hton64( 442210299Sed* IN const uint64_t val ); 443210299Sed* 444210299Sed* PARAMETERS 445210299Sed* val 446218893Sdim* [in] Value to swap from host byte order to network byte order . 447221345Sdim* 448221345Sdim* RETURN VALUE 449221345Sdim* Value of val converted to network byte order. 450221345Sdim* 451210299Sed* NOTES 452210299Sed* This function is analogous to cl_ntoh64. 453210299Sed* 454221345Sdim* SEE ALSO 455221345Sdim* Byte Swapping, cl_ntoh64, cl_hton16, cl_hton32, cl_ntoh 456221345Sdim*********/ 457221345Sdim#ifndef cl_ntoh64 458202878Srdivacky#define cl_ntoh64 CL_NTOH64 459202878Srdivacky#define cl_hton64 CL_HTON64 460210299Sed#endif 461195098Sed/****f* Component Library: Byte Swapping/cl_ntoh 462195098Sed* NAME 463202878Srdivacky* cl_ntoh 464202878Srdivacky* 465195098Sed* DESCRIPTION 466195098Sed* The cl_ntoh function converts a value from network byte order to 467198090Srdivacky* host byte order. 468202878Srdivacky* 469202878Srdivacky* SYNOPSIS 470198090Srdivacky*/ 471198090Srdivackystatic inline void 472208599Srdivackycl_ntoh(OUT char *const p_dest, 473208599Srdivacky IN const char *const p_src, IN const uint8_t size) 474208599Srdivacky{ 475208599Srdivacky#if CPU_LE 476208599Srdivacky uint8_t i; 477208599Srdivacky char temp; 478208599Srdivacky 479208599Srdivacky if (p_src == p_dest) { 480208599Srdivacky /* Swap in place if source and destination are the same. */ 481208599Srdivacky for (i = 0; i < size / 2; i++) { 482208599Srdivacky temp = p_dest[i]; 483208599Srdivacky p_dest[i] = p_src[size - 1 - i]; 484208599Srdivacky p_dest[size - 1 - i] = temp; 485208599Srdivacky } 486208599Srdivacky } else { 487208599Srdivacky for (i = 0; i < size; i++) 488208599Srdivacky p_dest[i] = p_src[size - 1 - i]; 489208599Srdivacky } 490208599Srdivacky#else 491208599Srdivacky /* 492234353Sdim * If the source and destination are not the same, copy the source to 493234353Sdim * the destination. 494234353Sdim */ 495234353Sdim if (p_src != p_dest) 496234353Sdim memcpy(p_dest, p_src, size); 497203954Srdivacky#endif 498203954Srdivacky} 499203954Srdivacky 500203954Srdivacky/* 501203954Srdivacky* PARAMETERS 502202878Srdivacky* p_dest 503198090Srdivacky* [in] Pointer to a byte array to contain the converted value of p_src. 504202878Srdivacky* 505203954Srdivacky* p_src 506203954Srdivacky* [in] Pointer to a byte array to be converted from network byte 507202878Srdivacky* ordering. 508202878Srdivacky* 509202878Srdivacky* size 510202878Srdivacky* [in] Number of bytes to swap.p_dest 511202878Srdivacky* 512198090Srdivacky* RETURN VALUE 513198090Srdivacky* This function does not return a value. 514202878Srdivacky* 515202878Srdivacky* NOTES 516202878Srdivacky* cl_ntoh can perform in place swapping if both p_src and p_dest point to 517202878Srdivacky* the same buffer. 518226633Sdim* 519226633Sdim* SEE ALSO 520226633Sdim* Byte Swapping, cl_ntoh16, cl_ntoh32, cl_ntoh64 521226633Sdim*********/ 522202878Srdivacky 523226633SdimEND_C_DECLS 524226633Sdim#endif /* _CL_BYTESWAP_H_ */ 525226633Sdim