234{
241 long thetime;
242 long delta;
243 int needfree = 0;
245 int time_valid;
246 int udp_ep = -1, tcp_ep = -1;
248 char ut[64], ipuaddr[64];
251#ifndef __REACTOS__
253#endif
258
261
262
263
264
265
266 if (*uaddr ==
NULL) {
267 if ((srv !=
NULL) && (thost !=
NULL)) {
268 msg(
"both timehost and srv pointer used!");
269 return (0);
270 }
271 if (! srv) {
272 srv =
get_server(netid, thost, &tsrv, teps, 32);
274 msg(
"unable to contruct server data.");
275 return (0);
276 }
277 needfree = 1;
278 }
279
281 epl = srv->
ep.ep_len;
282
283
285 (
i < epl) && ((udp_ep == -1) || (tcp_ep == -1));
i++) {
290 }
291
292
293 if (tcp_ep > -1) {
294 useep = &ep[tcp_ep];
295 useua = ep[tcp_ep].
uaddr;
297 } else if (udp_ep > -1) {
298 useep = &ep[udp_ep];
299 useua = ep[udp_ep].
uaddr;
301 }
302
304 msg(
"no acceptable transport endpoints.");
305 if (needfree)
307 return (0);
308 }
309 }
310
311
312
313
315 useua = *uaddr;
316
317
320 useua = &ipuaddr[0];
321
324 msg(
"unable to translate uaddr to sockaddr.");
325 if (needfree)
327 return (0);
328 }
329
330
331
332
333
334
335
336
339 msg(
"unable to create client handle to rpcbind.");
340 if (needfree)
342 return (0);
343 }
344
345 tv.tv_sec = 5;
346 tv.tv_usec = 0;
347 time_valid = 0;
350
351
352
353
354
356 time_valid = 1;
357 else {
358 int save;
359
360
364 }
365
366
367
368
369
370
371
372
373
376
378 msg(
"cannot convert timeservice uaddr to sockaddr.");
380 }
381
384 msg(
"unable to open fd to network.");
386 }
387
388
389
390
391
397
398 if (
sendto(
s, (
const char *)&thetime,
sizeof(thetime), 0,
400 msg(
"udp : sendto failed.");
402 }
403 do {
415 msg(
"recvfrom failed on udp transport.");
417 }
418 time_valid = 1;
419 } else {
421#ifndef _WIN32
424 alarm(20);
425#else
427
428#endif
431 msg(
"failed to connect to tcp endpoint.");
433 }
435 msg(
"alarm caught it, must be unreachable.");
437 }
438
439 res =
recv(
s, (
char *)&thetime,
sizeof(thetime), 0);
440 if (
res !=
sizeof(thetime)) {
442 msg(
"timed out TCP call.");
443 else
444 msg(
"wrong size of results returned");
445
447 }
448 time_valid = 1;
449 }
454
455 if (time_valid) {
456 thetime =
ntohl(thetime);
458 } else
459 thetime = 0;
460 }
461
463
465
466
467
468
471
474
475#ifdef _WIN32
476
477#else
478 alarm(0);
479 if (oldsig) {
481 }
482#endif
483
484
485
486
487
488 if (time_valid) {
491
492
493 tv.tv_sec += (tv.tv_sec > 500000) ? 1 : 0;
494 delta = (thetime > tv.tv_sec) ? thetime - tv.tv_sec :
495 tv.tv_sec - thetime;
496 td->
tv_sec = (thetime < tv.tv_sec) ? - delta : delta;
498 } else {
499 msg(
"unable to get the server's time.");
500 }
501
502 if (needfree)
504
505 return (time_valid);
506}
bool_t xdr_u_long(XDR *xdrs, u_long *ulp)
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
#define gettimeofday(tv, tz)
static nis_server * get_server(struct sockaddr_in *sin, char *host, nis_server *srv, eps, int maxep)
static void alarm_hndler(int s)
static void free_eps(eps, int num)
static int uaddr_to_sockaddr(char *uaddr, struct sockaddr_in *sin)
#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs)
__BEGIN_DECLS CLIENT * clnttcp_create(struct sockaddr_in *, u_long, u_long, SOCKET *, u_int, u_int)
INT WSAAPI recvfrom(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
INT WSAAPI sendto(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags, IN CONST struct sockaddr *to, IN INT tolen)
GLuint GLuint GLsizei GLenum type
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define sprintf(buf, format,...)
static const struct update_accum a1
static const struct update_accum a2
static const struct update_accum a3
static const struct update_accum a4
int _rpc_dtablesize(void)
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
struct nis_server::@209 ep
int PASCAL FAR WSAGetLastError(void)
bool_t(* xdrproc_t)(XDR *,...)