byteOrder.h (1620B)
1 /** 2 * @file byteOrder.h 3 * @author Adrian STEINER (steia19@bfh.ch) 4 * @brief Changes the byte order from host to network endian order 5 * @version 0.1 6 * @date 19-02-2025 7 * 8 * @copyright (C) 2025 Adrian STEINER 9 * This program is free software: you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation, either version 3 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program. If not, see <https: //www.gnu.org/licenses/>. 21 * 22 */ 23 24 #ifndef BYTEORDER_H 25 #define BYTEORDER_H 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 #include <stdint.h> 32 33 /** 34 * @brief Changes the host 16 bit value to a netword byte order value 35 * 36 * @param h the host byte order value 37 * @return uint16_t the network byte ordered value 38 */ 39 uint16_t h2n16(uint16_t h); 40 41 /** 42 * @brief Changes the host 32 bit value to a netword byte order value 43 * 44 * @param h the host byte order value 45 * @return uint16_t the network byte ordered value 46 */ 47 uint32_t h2n32(uint32_t h); 48 49 /** 50 * @brief Changes the host 64 bit value to a netword byte order value 51 * 52 * @param h the host byte order value 53 * @return uint16_t the network byte ordered value 54 */ 55 uint64_t h2n64(uint64_t h); 56 57 #ifdef __cplusplus 58 } 59 #endif 60 61 #endif /* BYTEORDER_H*/