| |
1 /* This file is part of the Project Athena Zephyr Notification System. |
| |
2 * It contains global definitions |
| |
3 * |
| |
4 * Created by: Robert French |
| |
5 * |
| |
6 * $Source$ |
| |
7 * $Author: warmenhoven $ |
| |
8 * $Id: zephyr.h 2096 2001-07-31 01:00:39Z warmenhoven $ |
| |
9 * |
| |
10 * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of |
| |
11 * Technology. For copying and distribution information, see the |
| |
12 * file "mit-copyright.h". |
| |
13 */ |
| |
14 |
| |
15 #ifndef __ZEPHYR_H__ |
| |
16 #define __ZEPHYR_H__ |
| |
17 |
| |
18 #include <config.h> |
| |
19 |
| |
20 #include <sys/types.h> |
| |
21 #include <sys/time.h> |
| |
22 |
| |
23 #include <zephyr/zephyr_err.h> |
| |
24 #ifdef ZEPHYR_USES_KERBEROS |
| |
25 #include <krb.h> |
| |
26 #endif |
| |
27 |
| |
28 #ifndef IPPROTO_MAX /* Make sure not already included */ |
| |
29 #include <netinet/in.h> |
| |
30 #endif |
| |
31 |
| |
32 /* Use __STDC__ to guess whether we can use stdarg, prototypes, and const. |
| |
33 * This is a public header file, so autoconf can't help us here. */ |
| |
34 #ifdef __STDC__ |
| |
35 # include <stdarg.h> |
| |
36 # define ZP(x) x |
| |
37 # define ZCONST const |
| |
38 #else |
| |
39 # define ZP(x) () |
| |
40 # define ZCONST |
| |
41 #endif |
| |
42 |
| |
43 /* Service names */ |
| |
44 #define HM_SVCNAME "zephyr-hm" |
| |
45 #define HM_SRV_SVCNAME "zephyr-hm-srv" |
| |
46 #define SERVER_SVCNAME "zephyr-clt" |
| |
47 #define SERVER_SERVICE "zephyr" |
| |
48 #define SERVER_INSTANCE "zephyr" |
| |
49 |
| |
50 #define ZVERSIONHDR "ZEPH" |
| |
51 #define ZVERSIONMAJOR 0 |
| |
52 #define ZVERSIONMINOR 2 |
| |
53 |
| |
54 #define Z_MAXPKTLEN 1024 |
| |
55 #define Z_MAXHEADERLEN 800 |
| |
56 #define Z_MAXOTHERFIELDS 10 /* Max unknown fields in ZNotice_t */ |
| |
57 #define Z_NUMFIELDS 17 |
| |
58 |
| |
59 /* Authentication levels returned by ZCheckAuthentication */ |
| |
60 #define ZAUTH_FAILED (-1) |
| |
61 #define ZAUTH_YES 1 |
| |
62 #define ZAUTH_NO 0 |
| |
63 |
| |
64 typedef char ZPacket_t[Z_MAXPKTLEN]; |
| |
65 |
| |
66 /* Packet type */ |
| |
67 typedef enum { |
| |
68 UNSAFE, UNACKED, ACKED, HMACK, HMCTL, SERVACK, SERVNAK, CLIENTACK, STAT |
| |
69 } ZNotice_Kind_t; |
| |
70 extern ZCONST char *ZNoticeKinds[9]; |
| |
71 |
| |
72 /* Unique ID format */ |
| |
73 typedef struct _ZUnique_Id_t { |
| |
74 struct in_addr zuid_addr; |
| |
75 struct timeval tv; |
| |
76 } ZUnique_Id_t; |
| |
77 |
| |
78 /* Checksum */ |
| |
79 typedef unsigned long ZChecksum_t; |
| |
80 |
| |
81 /* Notice definition */ |
| |
82 typedef struct _ZNotice_t { |
| |
83 char *z_packet; |
| |
84 char *z_version; |
| |
85 ZNotice_Kind_t z_kind; |
| |
86 ZUnique_Id_t z_uid; |
| |
87 #define z_sender_addr z_uid.zuid_addr |
| |
88 struct timeval z_time; |
| |
89 unsigned short z_port; |
| |
90 int z_auth; |
| |
91 int z_checked_auth; |
| |
92 int z_authent_len; |
| |
93 char *z_ascii_authent; |
| |
94 char *z_class; |
| |
95 char *z_class_inst; |
| |
96 char *z_opcode; |
| |
97 char *z_sender; |
| |
98 char *z_recipient; |
| |
99 char *z_default_format; |
| |
100 char *z_multinotice; |
| |
101 ZUnique_Id_t z_multiuid; |
| |
102 ZChecksum_t z_checksum; |
| |
103 int z_num_other_fields; |
| |
104 char *z_other_fields[Z_MAXOTHERFIELDS]; |
| |
105 caddr_t z_message; |
| |
106 int z_message_len; |
| |
107 } ZNotice_t; |
| |
108 |
| |
109 /* Subscription structure */ |
| |
110 typedef struct _ZSubscriptions_t { |
| |
111 char *zsub_recipient; |
| |
112 char *zsub_class; |
| |
113 char *zsub_classinst; |
| |
114 } ZSubscription_t; |
| |
115 |
| |
116 /* Function return code */ |
| |
117 typedef int Code_t; |
| |
118 |
| |
119 /* Locations structure */ |
| |
120 typedef struct _ZLocations_t { |
| |
121 char *host; |
| |
122 char *time; |
| |
123 char *tty; |
| |
124 } ZLocations_t; |
| |
125 |
| |
126 typedef struct _ZAsyncLocateData_t { |
| |
127 char *user; |
| |
128 ZUnique_Id_t uid; |
| |
129 char *version; |
| |
130 } ZAsyncLocateData_t; |
| |
131 |
| |
132 /* for ZSetDebug */ |
| |
133 #ifdef Z_DEBUG |
| |
134 void (*__Z_debug_print) ZP((ZCONST char *fmt, va_list args, void *closure)); |
| |
135 void *__Z_debug_print_closure; |
| |
136 #endif |
| |
137 |
| |
138 int ZCompareUIDPred ZP((ZNotice_t *, void *)); |
| |
139 int ZCompareMultiUIDPred ZP((ZNotice_t *, void *)); |
| |
140 |
| |
141 /* Defines for ZFormatNotice, et al. */ |
| |
142 typedef Code_t (*Z_AuthProc) ZP((ZNotice_t*, char *, int, int *)); |
| |
143 Code_t ZMakeAuthentication ZP((ZNotice_t*, char *,int, int*)); |
| |
144 |
| |
145 char *ZGetSender ZP((void)); |
| |
146 char *ZGetVariable ZP((char *)); |
| |
147 Code_t ZSetVariable ZP((char *var, char *value)); |
| |
148 Code_t ZUnsetVariable ZP((char *var)); |
| |
149 int ZGetWGPort ZP((void)); |
| |
150 Code_t ZSetDestAddr ZP((struct sockaddr_in *)); |
| |
151 Code_t ZFormatNoticeList ZP((ZNotice_t*, char**, int, |
| |
152 char **, int*, Z_AuthProc)); |
| |
153 Code_t ZParseNotice ZP((char*, int, ZNotice_t *)); |
| |
154 Code_t ZReadAscii ZP((char*, int, unsigned char*, int)); |
| |
155 Code_t ZReadAscii32 ZP((char *, int, unsigned long *)); |
| |
156 Code_t ZReadAscii16 ZP((char *, int, unsigned short *)); |
| |
157 Code_t ZSendPacket ZP((char*, int, int)); |
| |
158 Code_t ZSendList ZP((ZNotice_t*, char *[], int, Z_AuthProc)); |
| |
159 Code_t ZSrvSendList ZP((ZNotice_t*, char*[], int, Z_AuthProc, Code_t (*)())); |
| |
160 Code_t ZSendNotice ZP((ZNotice_t *, Z_AuthProc)); |
| |
161 Code_t ZSrvSendNotice ZP((ZNotice_t*, Z_AuthProc, Code_t (*)())); |
| |
162 Code_t ZFormatNotice ZP((ZNotice_t*, char**, int*, Z_AuthProc)); |
| |
163 Code_t ZFormatSmallNotice ZP((ZNotice_t*, ZPacket_t, int*, Z_AuthProc)); |
| |
164 Code_t ZFormatRawNoticeList ZP((ZNotice_t *notice, char *list[], int nitems, |
| |
165 char **buffer, int *ret_len)); |
| |
166 Code_t ZLocateUser ZP((char *, int *, Z_AuthProc)); |
| |
167 Code_t ZRequestLocations ZP((char *, ZAsyncLocateData_t *, |
| |
168 ZNotice_Kind_t, Z_AuthProc)); |
| |
169 Code_t ZInitialize ZP((void)); |
| |
170 Code_t ZSetServerState ZP((int)); |
| |
171 Code_t ZSetFD ZP((int)); |
| |
172 Code_t ZFormatSmallRawNotice ZP((ZNotice_t*, ZPacket_t, int*)); |
| |
173 int ZCompareUID ZP((ZUnique_Id_t*, ZUnique_Id_t*)); |
| |
174 Code_t ZSrvSendRawList ZP((ZNotice_t*, char*[], int, |
| |
175 Code_t (*)(ZNotice_t *, char *, int, int))); |
| |
176 Code_t ZMakeAscii ZP((char*, int, unsigned char*, int)); |
| |
177 Code_t ZMakeAscii32 ZP((char *, int, unsigned long)); |
| |
178 Code_t ZMakeAscii16 ZP((char *, int, unsigned int)); |
| |
179 Code_t ZReceivePacket ZP((ZPacket_t, int*, struct sockaddr_in*)); |
| |
180 Code_t ZCheckAuthentication ZP((ZNotice_t*, struct sockaddr_in*)); |
| |
181 Code_t ZFlushMyLocations ZP((void)); |
| |
182 #ifdef ZEPHYR_USES_KERBEROS |
| |
183 Code_t ZFormatAuthenticNotice ZP((ZNotice_t*, char*, int, int*, C_Block)); |
| |
184 #endif |
| |
185 Code_t ZFormatRawNotice ZP((ZNotice_t *, char**, int *)); |
| |
186 Code_t ZRetrieveSubscriptions ZP((unsigned short, int*)); |
| |
187 Code_t ZOpenPort ZP((unsigned short *port)); |
| |
188 Code_t ZClosePort ZP((void)); |
| |
189 Code_t ZFlushLocations ZP((void)); |
| |
190 Code_t ZFlushSubscriptions ZP((void)); |
| |
191 Code_t ZFreeNotice ZP((ZNotice_t *notice)); |
| |
192 Code_t ZParseLocations ZP((register ZNotice_t *notice, |
| |
193 register ZAsyncLocateData_t *zald, int *nlocs, |
| |
194 char **user)); |
| |
195 int ZCompareALDPred ZP((ZNotice_t *notice, void *zald)); |
| |
196 void ZFreeALD ZP((register ZAsyncLocateData_t *zald)); |
| |
197 Code_t ZCheckIfNotice ZP((ZNotice_t *notice, struct sockaddr_in *from, |
| |
198 register int (*predicate) ZP((ZNotice_t *,void *)), |
| |
199 void *args)); |
| |
200 Code_t ZPeekPacket ZP((char **buffer, int *ret_len, |
| |
201 struct sockaddr_in *from)); |
| |
202 Code_t ZPeekNotice ZP((ZNotice_t *notice, struct sockaddr_in *from)); |
| |
203 Code_t ZIfNotice ZP((ZNotice_t *notice, struct sockaddr_in *from, |
| |
204 int (*predicate) ZP((ZNotice_t *, void *)), void *args)); |
| |
205 Code_t ZSubscribeTo ZP((ZSubscription_t *sublist, int nitems, |
| |
206 unsigned int port)); |
| |
207 Code_t ZSubscribeToSansDefaults ZP((ZSubscription_t *sublist, int nitems, |
| |
208 unsigned int port)); |
| |
209 Code_t ZUnsubscribeTo ZP((ZSubscription_t *sublist, int nitems, |
| |
210 unsigned int port)); |
| |
211 Code_t ZCancelSubscriptions ZP((unsigned int port)); |
| |
212 int ZPending ZP((void)); |
| |
213 Code_t ZReceiveNotice ZP((ZNotice_t *notice, struct sockaddr_in *from)); |
| |
214 #ifdef Z_DEBUG |
| |
215 void Z_debug ZP((ZCONST char *, ...)); |
| |
216 #endif |
| |
217 |
| |
218 #undef ZP |
| |
219 |
| |
220 /* Compatibility */ |
| |
221 #define ZNewLocateUser ZLocateUser |
| |
222 |
| |
223 /* Macros to retrieve Zephyr library values. */ |
| |
224 extern int __Zephyr_fd; |
| |
225 extern int __Q_CompleteLength; |
| |
226 extern struct sockaddr_in __HM_addr; |
| |
227 extern char __Zephyr_realm[]; |
| |
228 #define ZGetFD() __Zephyr_fd |
| |
229 #define ZQLength() __Q_CompleteLength |
| |
230 #define ZGetDestAddr() __HM_addr |
| |
231 #define ZGetRealm() __Zephyr_realm |
| |
232 |
| |
233 #ifdef ZEPHYR_USES_KERBEROS |
| |
234 /* Session key for last parsed packet - server only */ |
| |
235 extern C_Block __Zephyr_session; |
| |
236 #define ZGetSession() (__Zephyr_session) |
| |
237 #else |
| |
238 #define __Zephyr_realm ("local-realm") |
| |
239 #endif |
| |
240 |
| |
241 |
| |
242 #ifdef Z_DEBUG |
| |
243 void ZSetDebug ZP((void (*)(ZCONST char *, va_list, void *), void *)); |
| |
244 #define ZSetDebug(proc,closure) (__Z_debug_print=(proc), \ |
| |
245 __Z_debug_print_closure=(closure), \ |
| |
246 (void) 0) |
| |
247 #else |
| |
248 #define ZSetDebug(proc,closure) |
| |
249 #endif |
| |
250 |
| |
251 /* Maximum queue length */ |
| |
252 #define Z_MAXQLEN 30 |
| |
253 |
| |
254 /* Successful function return */ |
| |
255 #define ZERR_NONE 0 |
| |
256 |
| |
257 /* Hostmanager wait time (in secs) */ |
| |
258 #define HM_TIMEOUT 10 |
| |
259 |
| |
260 /* Server wait time (in secs) */ |
| |
261 #define SRV_TIMEOUT 30 |
| |
262 |
| |
263 #define ZAUTH (ZMakeAuthentication) |
| |
264 #define ZNOAUTH ((Z_AuthProc)0) |
| |
265 |
| |
266 /* Packet strings */ |
| |
267 #define ZSRVACK_SENT "SENT" /* SERVACK codes */ |
| |
268 #define ZSRVACK_NOTSENT "LOST" |
| |
269 #define ZSRVACK_FAIL "FAIL" |
| |
270 |
| |
271 /* Server internal class */ |
| |
272 #define ZEPHYR_ADMIN_CLASS "ZEPHYR_ADMIN" /* Class */ |
| |
273 |
| |
274 /* Control codes sent to a server */ |
| |
275 #define ZEPHYR_CTL_CLASS "ZEPHYR_CTL" /* Class */ |
| |
276 |
| |
277 #define ZEPHYR_CTL_CLIENT "CLIENT" /* Inst: From client */ |
| |
278 #define CLIENT_SUBSCRIBE "SUBSCRIBE" /* Opcode: Subscribe */ |
| |
279 #define CLIENT_SUBSCRIBE_NODEFS "SUBSCRIBE_NODEFS" /* Opcode: Subscribe */ |
| |
280 #define CLIENT_UNSUBSCRIBE "UNSUBSCRIBE" /* Opcode: Unsubsubscribe */ |
| |
281 #define CLIENT_CANCELSUB "CLEARSUB" /* Opcode: Clear all subs */ |
| |
282 #define CLIENT_GIMMESUBS "GIMME" /* Opcode: Give me subs */ |
| |
283 #define CLIENT_GIMMEDEFS "GIMMEDEFS" /* Opcode: Give me default |
| |
284 * subscriptions */ |
| |
285 |
| |
286 #define ZEPHYR_CTL_HM "HM" /* Inst: From HM */ |
| |
287 #define HM_BOOT "BOOT" /* Opcode: Boot msg */ |
| |
288 #define HM_FLUSH "FLUSH" /* Opcode: Flush me */ |
| |
289 #define HM_DETACH "DETACH" /* Opcode: Detach me */ |
| |
290 #define HM_ATTACH "ATTACH" /* Opcode: Attach me */ |
| |
291 |
| |
292 /* Control codes send to a HostManager */ |
| |
293 #define HM_CTL_CLASS "HM_CTL" /* Class */ |
| |
294 |
| |
295 #define HM_CTL_SERVER "SERVER" /* Inst: From server */ |
| |
296 #define SERVER_SHUTDOWN "SHUTDOWN" /* Opcode: Server shutdown */ |
| |
297 #define SERVER_PING "PING" /* Opcode: PING */ |
| |
298 |
| |
299 #define HM_CTL_CLIENT "CLIENT" /* Inst: From client */ |
| |
300 #define CLIENT_FLUSH "FLUSH" /* Opcode: Send flush to srv */ |
| |
301 #define CLIENT_NEW_SERVER "NEWSERV" /* Opcode: Find new server */ |
| |
302 |
| |
303 /* HM Statistics */ |
| |
304 #define HM_STAT_CLASS "HM_STAT" /* Class */ |
| |
305 |
| |
306 #define HM_STAT_CLIENT "HMST_CLIENT" /* Inst: From client */ |
| |
307 #define HM_GIMMESTATS "GIMMESTATS" /* Opcode: get stats */ |
| |
308 |
| |
309 /* Login class messages */ |
| |
310 #define LOGIN_CLASS "LOGIN" /* Class */ |
| |
311 |
| |
312 /* Class Instance is principal of user who is logging in or logging out */ |
| |
313 |
| |
314 #define EXPOSE_NONE "NONE" /* Opcode: Not visible */ |
| |
315 #define EXPOSE_OPSTAFF "OPSTAFF" /* Opcode: Opstaff visible */ |
| |
316 #define EXPOSE_REALMVIS "REALM-VISIBLE" /* Opcode: Realm visible */ |
| |
317 #define EXPOSE_REALMANN "REALM-ANNOUNCED"/* Opcode: Realm announced */ |
| |
318 #define EXPOSE_NETVIS "NET-VISIBLE" /* Opcode: Net visible */ |
| |
319 #define EXPOSE_NETANN "NET-ANNOUNCED" /* Opcode: Net announced */ |
| |
320 #define LOGIN_USER_LOGIN "USER_LOGIN" /* Opcode: user login |
| |
321 (from server) */ |
| |
322 #define LOGIN_USER_LOGOUT "USER_LOGOUT" /* Opcode: User logout */ |
| |
323 #define LOGIN_USER_FLUSH "USER_FLUSH" /* Opcode: flush all locs */ |
| |
324 |
| |
325 /* Locate class messages */ |
| |
326 #define LOCATE_CLASS "USER_LOCATE" /* Class */ |
| |
327 |
| |
328 #define LOCATE_HIDE "USER_HIDE" /* Opcode: Hide me */ |
| |
329 #define LOCATE_UNHIDE "USER_UNHIDE" /* Opcode: Unhide me */ |
| |
330 |
| |
331 /* Class Instance is principal of user to locate */ |
| |
332 #define LOCATE_LOCATE "LOCATE" /* Opcode: Locate user */ |
| |
333 |
| |
334 /* WG_CTL class messages */ |
| |
335 #define WG_CTL_CLASS "WG_CTL" /* Class */ |
| |
336 |
| |
337 #define WG_CTL_USER "USER" /* Inst: User request */ |
| |
338 #define USER_REREAD "REREAD" /* Opcode: Reread desc file */ |
| |
339 #define USER_SHUTDOWN "SHUTDOWN" /* Opcode: Go catatonic */ |
| |
340 #define USER_STARTUP "STARTUP" /* Opcode: Come out of it */ |
| |
341 |
| |
342 #endif /* __ZEPHYR_H__ */ |