Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 007ea776 in mainline


Ignore:
Timestamp:
2010-02-17T07:51:33Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
101d9f4
Parents:
f430f58
Message:

Do not duplicate the byte swapping logic in the net's private byteorder.h.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/include/byteorder.h

    rf430f58 r007ea776  
    3939
    4040#include <byteorder.h>
    41 
    4241#include <sys/types.h>
    4342
    44 #ifdef ARCH_IS_BIG_ENDIAN
    4543
    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 )
    4749
    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 )
     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 )
    5355
    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 )
     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 )
    5961
    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 )
    10167
    10268#endif
Note: See TracChangeset for help on using the changeset viewer.