1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains the ZhmStat() function.
4 * Created by: Marc Horowitz
6 * Copyright (c) 1996 by the Massachusetts Institute of Technology.
7 * For copying and distribution information, see the file
16 #include <sys/socket.h>
19 #ifndef INADDR_LOOPBACK
20 #define INADDR_LOOPBACK 0x7f000001
23 Code_t
ZhmStat(hostaddr
, notice
)
24 struct in_addr
*hostaddr
;
28 struct sockaddr_in sin
;
34 (void) memset((char *)&sin
, 0, sizeof(struct sockaddr_in
));
36 sp
= getservbyname(HM_SVCNAME
, "udp");
38 sin
.sin_port
= (sp
) ? sp
->s_port
: HM_SVC_FALLBACK
;
39 sin
.sin_family
= AF_INET
;
42 sin
.sin_addr
= *hostaddr
;
44 sin
.sin_addr
.s_addr
= htonl(INADDR_LOOPBACK
);
46 (void) memset((char *)&req
, 0, sizeof(req
));
49 req
.z_class
= HM_STAT_CLASS
;
50 req
.z_class_inst
= HM_STAT_CLIENT
;
51 req
.z_opcode
= HM_GIMMESTATS
;
54 req
.z_default_format
= "";
55 req
.z_message_len
= 0;
57 if ((code
= ZSetDestAddr(&sin
)) != ZERR_NONE
)
60 if ((code
= ZSendNotice(&req
, ZNOAUTH
)) != ZERR_NONE
)
63 /* Wait up to ten seconds for a response. */
65 FD_SET(ZGetFD(), &readers
);
68 code
= select(ZGetFD() + 1, &readers
, NULL
, NULL
, &tv
);
69 if (code
< 0 && errno
!= EINTR
)
71 if (code
== 0 || (code
< 0 && errno
== EINTR
) || ZPending() == 0)
74 return(ZReceiveNotice(notice
, (struct sockaddr_in
*) 0));