[lib] Add TIMESTAMP endianess converters
Add the functions owl_hton_timestamp() and owl_ntoh_timestamp().
This commit is contained in:
parent
5d8e907335
commit
94e3701a51
|
@ -165,6 +165,32 @@ uint_fast32_t owl_time_elapsed(TIMESTAMP sup, TIMESTAMP inf)
|
|||
|
||||
|
||||
|
||||
/*
|
||||
* Converts a TIMESTAMP from host endianess to network endianess.
|
||||
*/
|
||||
TIMESTAMP owl_hton_timestamp(TIMESTAMP date)
|
||||
{
|
||||
TIMESTAMP d ;
|
||||
d.tv_sec = htonl(date.tv_sec) ;
|
||||
d.tv_nsec = htonl(date.tv_nsec) ;
|
||||
return d ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Converts a TIMESTAMP from network endianess to host endianess.
|
||||
*/
|
||||
TIMESTAMP owl_ntoh_timestamp(TIMESTAMP date)
|
||||
{
|
||||
TIMESTAMP d ;
|
||||
d.tv_sec = ntohl(date.tv_sec) ;
|
||||
d.tv_nsec = ntohl(date.tv_nsec) ;
|
||||
return d ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Compares two MAC addresses.
|
||||
* Returns TRUE if they are identical, FALSE otherwise.
|
||||
|
|
|
@ -229,6 +229,8 @@ void owl_timestamp_round_to_ms(TIMESTAMP *now) ;
|
|||
TIMESTAMP owl_timeval_to_timestamp(const struct timeval d) ;
|
||||
uint64_t owl_timestamp_to_ms(TIMESTAMP date) ;
|
||||
uint_fast32_t owl_time_elapsed(TIMESTAMP sup, TIMESTAMP inf) ;
|
||||
TIMESTAMP owl_hton_timestamp(TIMESTAMP date) ;
|
||||
TIMESTAMP owl_ntoh_timestamp(TIMESTAMP date) ;
|
||||
|
||||
// Network
|
||||
int owl_create_udp_trx_socket(char *server_address,
|
||||
|
|
Loading…
Reference in New Issue