Changeset 007ea776 in mainline
 Timestamp:
 20100217T07:51:33Z (14 years ago)
 Branches:
 lfn, master, serial, ticket/834toolchainupdate, topic/msimupgrade, topic/simplifydevexport
 Children:
 101d9f4
 Parents:
 f430f58
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

uspace/srv/net/include/byteorder.h
rf430f58 r007ea776 39 39 40 40 #include <byteorder.h> 41 42 41 #include <sys/types.h> 43 42 44 #ifdef ARCH_IS_BIG_ENDIAN45 43 46 // Already in the network byte order. 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 ) 47 49 48 /** Converts the given short number ( 16bit ) from the host byte order to the network byte order ( big endian ).49 50 51 52 #define htons( number )( number )50 /** Converts the given long number ( 32 bit ) 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 ) 53 55 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 hostbyte order to be converted.56 * @returns The number in the networkbyte order.57 58 #define htonl( number )( number )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 network byte order to be converted. 58 * @returns The number in the host byte order. 59 */ 60 #define ntohs( number ) uint16_t_be2host( number ) 59 61 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 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 ) 101 67 102 68 #endif
Note:
See TracChangeset
for help on using the changeset viewer.