Changes in uspace/srv/net/include/byteorder.h [007ea776:21580dd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/include/byteorder.h
r007ea776 r21580dd 39 39 40 40 #include <byteorder.h> 41 41 42 #include <sys/types.h> 42 43 44 #ifdef ARCH_IS_BIG_ENDIAN 43 45 44 /** Converts the given short number ( 16 bit ) from the host byte order to the network byte order ( big endian ). 45 * @param[in] number The number in the host byte order to be converted. 46 * @returns The number in the network byte order. 47 */ 48 #define htons( number ) host2uint16_t_be( number ) 46 // Already in the network byte order. 49 47 50 /** Converts the given long number ( 32bit ) from the host byte order to the network byte order ( big endian ).51 * @param[in] number The number in the host byte order to be converted.52 * @returns The number in the network byte order.53 */54 #define htonl( number ) host2uint32_t_be( number )48 /** Converts the given short number ( 16 bit ) from the host byte order to the network byte order ( big endian ). 49 * @param[in] number The number in the host byte order to be converted. 50 * @returns The number in the network byte order. 51 */ 52 #define htons( number ) ( number ) 55 53 56 /** Converts the given short number ( 16 bit ) from the network byte order ( big endian ) to the host byte order.57 * @param[in] number The number in the networkbyte order to be converted.58 * @returns The number in the hostbyte order.59 */60 #define ntohs( number ) uint16_t_be2host( number )54 /** Converts the given long number ( 32 bit ) from the host byte order to the network byte order ( big endian ). 55 * @param[in] number The number in the host byte order to be converted. 56 * @returns The number in the network byte order. 57 */ 58 #define htonl( number ) ( number ) 61 59 62 /** Converts the given long number ( 32 bit ) from the network byte order ( big endian ) to the host byte order. 63 * @param[in] number The number in the network byte order to be converted. 64 * @returns The number in the host byte order. 65 */ 66 #define ntohl( number ) uint32_t_be2host( number ) 60 /** Converts the given short number ( 16 bit ) from the network byte order ( big endian ) to the host byte order. 61 * @param[in] number The number in the network byte order to be converted. 62 * @returns The number in the host byte order. 63 */ 64 #define ntohs( number ) ( number ) 65 66 /** Converts the given long number ( 32 bit ) from the network byte order ( big endian ) to the host byte order. 67 * @param[in] number The number in the network byte order to be converted. 68 * @returns The number in the host byte order. 69 */ 70 #define ntohl( number ) ( number ) 71 72 #else 73 74 // Has to be swapped. 75 76 /** Converts the given short number ( 16 bit ) from the host byte order to the network byte order ( big endian ). 77 * @param[in] number The number in the host byte order to be converted. 78 * @returns The number in the network byte order. 79 */ 80 #define htons( number ) uint16_t_byteorder_swap(( uint16_t )( number )) 81 82 /** Converts the given long number ( 32 bit ) from the host byte order to the network byte order ( big endian ). 83 * @param[in] number The number in the host byte order to be converted. 84 * @returns The number in the network byte order. 85 */ 86 #define htonl( number ) uint32_t_byteorder_swap( number ) 87 88 /** Converts the given short number ( 16 bit ) from the network byte order ( big endian ) to the host byte order. 89 * @param[in] number The number in the network byte order to be converted. 90 * @returns The number in the host byte order. 91 */ 92 #define ntohs( number ) uint16_t_byteorder_swap(( uint16_t )( number )) 93 94 /** Converts the given long number ( 32 bit ) from the network byte order ( big endian ) to the host byte order. 95 * @param[in] number The number in the network byte order to be converted. 96 * @returns The number in the host byte order. 97 */ 98 #define ntohl( number ) uint32_t_byteorder_swap( number ) 99 100 #endif 67 101 68 102 #endif
Note:
See TracChangeset
for help on using the changeset viewer.