Simple tools for networking / objects in plain C Snapshot
Classes | Defines | Functions
ENDIAN

normalize the names of endian conversion functions, so that they can be used from macros. More...

Classes

union  QUAD

Defines

#define n2h_uint8_t(val)   (val)
#define n2h_int8_t(val)   (val)
#define n2h_uint16_t(val)   ntohs( val )
#define n2h_int16_t(val)   ntohs( val )
#define n2h_uint32_t(val)   ntohl( val )
#define n2h_int32_t(val)   ntohl( val )
#define n2h_int64_t(val)   n2h_uint64_t( val )
#define h2n_uint8_t(val)   (val)
#define h2n_int8_t(val)   (val)
#define h2n_uint16_t(val)   htons( val )
#define h2n_int16_t(val)   htons( val )
#define h2n_uint32_t(val)   htonl( val )
#define h2n_int32_t(val)   htonl( val )
#define h2n_int64_t(val)   h2n_uint64_t( val )

Functions

M_INLINE uint64_t n2h_uint64_t (uint64_t val)
M_INLINE uint64_t h2n_uint64_t (uint64_t val)

Detailed Description

normalize the names of endian conversion functions, so that they can be used from macros.

n2h_<typename> - convert from network to host byte order h2n_<typename> - convert from host to network byte order.

<typename> := int8_t uint8_t int16_t uint16_t int32_t uint32_t int64_t uint64_ta


Define Documentation

#define h2n_int16_t (   val)    htons( val )

Definition at line 64 of file endutil.h.

#define h2n_int32_t (   val)    htonl( val )

Definition at line 66 of file endutil.h.

#define h2n_int64_t (   val)    h2n_uint64_t( val )

Definition at line 67 of file endutil.h.

#define h2n_int8_t (   val)    (val)

Definition at line 62 of file endutil.h.

#define h2n_uint16_t (   val)    htons( val )

Definition at line 63 of file endutil.h.

#define h2n_uint32_t (   val)    htonl( val )

Definition at line 65 of file endutil.h.

#define h2n_uint8_t (   val)    (val)

Definition at line 61 of file endutil.h.

#define n2h_int16_t (   val)    ntohs( val )

Definition at line 56 of file endutil.h.

#define n2h_int32_t (   val)    ntohl( val )

Definition at line 58 of file endutil.h.

#define n2h_int64_t (   val)    n2h_uint64_t( val )

Definition at line 59 of file endutil.h.

#define n2h_int8_t (   val)    (val)

Definition at line 54 of file endutil.h.

#define n2h_uint16_t (   val)    ntohs( val )

Definition at line 55 of file endutil.h.

#define n2h_uint32_t (   val)    ntohl( val )

Definition at line 57 of file endutil.h.

#define n2h_uint8_t (   val)    (val)

Definition at line 53 of file endutil.h.


Function Documentation

M_INLINE uint64_t h2n_uint64_t ( uint64_t  val)

Definition at line 40 of file endutil.h.

{
  QUAD a,b;
  
  a.n64 = val;

  b.n32.word_a = htonl( a.n32.word_b );
  b.n32.word_b = htonl( a.n32.word_a );

  return b.n64;
}
M_INLINE uint64_t n2h_uint64_t ( uint64_t  val)

Definition at line 28 of file endutil.h.

{
  QUAD a,b;
  
  a.n64 = val;

  b.n32.word_a = ntohl( a.n32.word_b );
  b.n32.word_b = ntohl( a.n32.word_a );

  return b.n64;
}