1999-12-09 13:01:21 +00:00
|
|
|
/*
|
|
|
|
* buftvtots - pull a Unix-format (struct timeval) time stamp out of
|
|
|
|
* an octet stream and convert it to a l_fp time stamp.
|
|
|
|
* This is useful when using the clock line discipline.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
#include "ntp_fp.h"
|
2008-08-18 14:26:05 +00:00
|
|
|
#include "ntp_string.h"
|
1999-12-09 13:01:21 +00:00
|
|
|
#include "ntp_unixtime.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
buftvtots(
|
|
|
|
const char *bufp,
|
|
|
|
l_fp *ts
|
|
|
|
)
|
|
|
|
{
|
2001-08-29 14:35:15 +00:00
|
|
|
struct timeval tv;
|
1999-12-09 13:01:21 +00:00
|
|
|
|
2008-08-18 14:26:05 +00:00
|
|
|
/*
|
|
|
|
* copy to adhere to alignment restrictions
|
|
|
|
*/
|
|
|
|
memcpy(&tv, bufp, sizeof(tv));
|
1999-12-09 13:01:21 +00:00
|
|
|
|
2008-08-18 14:26:05 +00:00
|
|
|
/*
|
|
|
|
* and use it
|
|
|
|
*/
|
|
|
|
ts->l_ui = tv.tv_sec + (u_long)JAN_1970;
|
|
|
|
if (tv.tv_usec > 999999)
|
1999-12-09 13:01:21 +00:00
|
|
|
return 0;
|
2008-08-18 14:26:05 +00:00
|
|
|
TVUTOTSF(tv.tv_usec, ts->l_uf);
|
1999-12-09 13:01:21 +00:00
|
|
|
return 1;
|
|
|
|
}
|