1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains the hostmanager <--> client interaction routines.
4 * Created by: David C. Jedlinsky
8 * Copyright (c) 1987 by the Massachusetts Institute of Technology.
9 * For copying and distribution information, see the file
17 static char rcsid_hm_client_c[] = "$Id$";
21 extern int no_server, nclt, deactivated, noflushflag;
22 extern struct sockaddr_in cli_sin, serv_sin, from;
24 void transmission_tower(ZNotice_t *notice,
30 struct sockaddr_in gsin;
33 if (notice->z_kind == HMCTL) {
34 if (!strcmp(notice->z_opcode, CLIENT_FLUSH)) {
36 syslog(LOG_INFO, "Client requested hm flush (disabled).");
38 send_flush_notice(HM_FLUSH);
41 } else if (!strcmp(notice->z_opcode, CLIENT_NEW_SERVER)) {
42 new_server((char *)NULL);
44 syslog (LOG_INFO, "Bad control notice from client.");
48 if (notice->z_kind != UNSAFE) {
51 gack.z_message_len = 0;
52 gack.z_multinotice = "";
54 gsin.sin_port = from.sin_port;
56 gack.z_port = from.sin_port;
57 DPR2 ("Client Port = %u\n", ntohs(gack.z_port));
58 notice->z_port = gack.z_port;
59 if ((ret = ZSetDestAddr(&gsin)) != ZERR_NONE) {
61 com_err("hm", ret, "setting destination");
63 /* Bounce ACK to library */
64 if ((ret = send_outgoing(&gack)) != ZERR_NONE) {
66 com_err("hm", ret, "sending raw notice");
71 DPR2 ("Server Port = %u\n", ntohs(serv_sin.sin_port));
72 if ((ret = ZSetDestAddr(&serv_sin)) != ZERR_NONE) {
74 com_err("hm", ret, "setting destination");
76 if ((ret = ZSendPacket(packet, pak_len, 0)) != ZERR_NONE) {
78 com_err("hm", ret, "while sending raw notice");
81 if (add_notice_to_queue(notice, packet, &gsin, pak_len) != ZERR_NONE)
82 syslog(LOG_INFO, "Hey! Insufficient memory to add notice to queue!");
86 send_outgoing(ZNotice_t *notice)
92 if (!(packet = (char *) malloc((unsigned)sizeof(ZPacket_t))))
95 if ((retval = ZFormatSmallRawNotice(notice, packet, &length))
100 retval = ZSendPacket(packet, length, 0);