1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/* This file is part of the Project Athena Zephyr Notification System.
* It contains the hostmanager <--> client interaction routines.
*
* Created by: David C. Jedlinsky
*
* $Id$
*
* Copyright (c) 1987 by the Massachusetts Institute of Technology.
* For copying and distribution information, see the file
* "mit-copyright.h".
*/
#include "zhm.h"
#ifndef lint
#ifndef SABER
static char rcsid_hm_client_c[] = "$Id$";
#endif /* SABER */
#endif /* lint */
extern int noflushflag;
extern struct sockaddr_in cli_sin;
void transmission_tower(notice, from, packet, pak_len)
ZNotice_t *notice;
struct sockaddr_in *from;
char *packet;
int pak_len;
{
int i;
galaxy_info *gi;
ZNotice_t gack;
Code_t ret;
struct sockaddr_in gsin;
if (notice->z_dest_galaxy) {
for (i=0; i<ngalaxies; i++)
if (strcasecmp(galaxy_list[i].galaxy_config.galaxy,
notice->z_dest_galaxy) == 0) {
gi = &galaxy_list[i];
break;
}
if (i == ngalaxies) {
/* XXX I should generate some sort of error here. Fortunately,
only new clients can elicit this error, so I can use a new
error value (message body string, probably) here. For now,
just return and let the sender time out. */
return;
}
} else {
gi = &galaxy_list[0];
}
if (notice->z_kind == HMCTL) {
if (!strcmp(notice->z_opcode, CLIENT_FLUSH)) {
if (noflushflag)
syslog(LOG_INFO, "Client requested hm flush (disabled).");
else
galaxy_flush(gi);
} else if (!strcmp(notice->z_opcode, CLIENT_NEW_SERVER)) {
galaxy_new_server(gi, NULL);
} else {
syslog (LOG_INFO, "Bad control notice from client.");
}
return;
}
if (notice->z_kind != UNSAFE) {
gack = *notice;
gack.z_kind = HMACK;
gack.z_message_len = 0;
gack.z_multinotice = "";
gsin = cli_sin;
gsin.sin_port = from->sin_port;
if (gack.z_port == 0)
gack.z_port = from->sin_port;
notice->z_port = gack.z_port;
/* Bounce ACK to library */
if ((ret = send_outgoing(&gsin, &gack)) != ZERR_NONE) {
Zperr(ret);
com_err("hm", ret, "sending raw notice");
}
}
/* remove the dest galaxy, since the servers aren't prepared for it */
notice->z_dest_galaxy = NULL;
if (gi->current_server != NO_SERVER) {
if ((ret = send_outgoing(&gi->sin, notice)) != ZERR_NONE) {
Zperr(ret);
com_err("hm", ret, "while sending raw notice");
}
}
add_notice_to_galaxy(gi, notice, &gsin, pak_len);
}
Code_t
send_outgoing(sin, notice)
struct sockaddr_in *sin;
ZNotice_t *notice;
{
Code_t retval;
char *packet;
int length;
if ((retval = ZSetDestAddr(sin)) != ZERR_NONE)
return(retval);
if (!(packet = (char *) malloc((unsigned)sizeof(ZPacket_t))))
return(ENOMEM);
if ((retval = ZFormatSmallRawNotice(notice, packet, &length))
!= ZERR_NONE) {
free(packet);
return(retval);
}
retval = ZSendPacket(packet, length, 0);
free(packet);
return(retval);
}
|