1 /* 2 * buftvtots - pull a Unix-format (struct timeval) time stamp out of 3 * an octet stream and convert it to a l_fp time stamp. 4 * This is useful when using the clock line discipline. 5 */ 6 7 #ifdef HAVE_CONFIG_H 8 #include "config.h" 9 #endif 10 #include "ntp_fp.h" 11 #include "ntp_string.h" 12 #include "ntp_unixtime.h" 13 14 int 15 buftvtots( 16 const char *bufp, 17 l_fp *ts 18 ) 19 { 20 struct timeval tv; 21 22 /* 23 * copy to adhere to alignment restrictions 24 */ 25 memcpy(&tv, bufp, sizeof(tv)); 26 27 /* 28 * and use it 29 */ 30 ts->l_ui = tv.tv_sec + (u_long)JAN_1970; 31 if (tv.tv_usec > 999999) 32 return 0; 33 TVUTOTSF(tv.tv_usec, ts->l_uf); 34 return 1; 35 } 36