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 const 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 extern void send_flush_notice(char *);
25 extern void new_server(char *sugg_serv);
27 void transmission_tower(ZNotice_t *notice,
33 struct sockaddr_in gsin;
36 if (notice->z_kind == HMCTL) {
37 if (!strcmp(notice->z_opcode, CLIENT_FLUSH)) {
39 syslog(LOG_INFO, "Client requested hm flush (disabled).");
41 send_flush_notice(HM_FLUSH);
44 } else if (!strcmp(notice->z_opcode, CLIENT_NEW_SERVER)) {
45 new_server((char *)NULL);
47 syslog (LOG_INFO, "Bad control notice from client.");
51 if (notice->z_kind != UNSAFE) {
54 gack.z_message_len = 0;
55 gack.z_multinotice = "";
57 gsin.sin_port = from.sin_port;
59 gack.z_port = from.sin_port;
60 DPR2 ("Client Port = %u\n", ntohs(gack.z_port));
61 notice->z_port = gack.z_port;
62 if ((ret = ZSetDestAddr(&gsin)) != ZERR_NONE) {
64 com_err("hm", ret, "setting destination");
66 /* Bounce ACK to library */
67 if ((ret = send_outgoing(&gack)) != ZERR_NONE) {
69 com_err("hm", ret, "sending raw notice");
74 DPR2 ("Server Port = %u\n", ntohs(serv_sin.sin_port));
75 if ((ret = ZSetDestAddr(&serv_sin)) != ZERR_NONE) {
77 com_err("hm", ret, "setting destination");
79 if ((ret = ZSendPacket(packet, pak_len, 0)) != ZERR_NONE) {
81 com_err("hm", ret, "while sending raw notice");
84 if (add_notice_to_queue(notice, packet, &gsin, pak_len) != ZERR_NONE)
85 syslog(LOG_INFO, "Hey! Insufficient memory to add notice to queue!");
89 send_outgoing(ZNotice_t *notice)
95 if (!(packet = (char *) malloc((unsigned)sizeof(ZPacket_t))))
98 if ((retval = ZFormatSmallRawNotice(notice, packet, &length))
103 retval = ZSendPacket(packet, length, 0);