1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains global definitions
4 * Created by: Robert French
6 * $Id: zephyr.h,v 1.54 1999/01/22 23:18:59 ghudson Exp $
8 * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of
9 * Technology. For copying and distribution information, see the
10 * file "mit-copyright.h".
16 #include <sys/types.h>
19 #include <zephyr/zephyr_err.h>
21 #ifndef IPPROTO_MAX /* Make sure not already included */
22 #include <netinet/in.h>
25 /* Use __STDC__ to guess whether we can use stdarg, prototypes, and const.
26 * This is a public header file, so autoconf can't help us here. */
37 #define HM_SVCNAME "zephyr-hm"
38 #define HM_SRV_SVCNAME "zephyr-hm-srv"
39 #define SERVER_SVCNAME "zephyr-clt"
40 #define SERVER_SERVICE "zephyr"
41 #define SERVER_INSTANCE "zephyr"
42 #define SERVER_KRB5_SERVICE "zephyr"
44 #define ZVERSIONHDR "ZEPH"
45 #define ZVERSIONMAJOR 0
46 #define ZVERSIONMINOR 2
48 #define Z_MAXPKTLEN 1024
49 #define Z_MAXHEADERLEN 800
50 #define Z_MAXOTHERFIELDS 10 /* Max unknown fields in ZNotice_t */
51 #define Z_NUMFIELDS 17
53 /* Authentication levels returned by ZCheckAuthentication */
54 #define ZAUTH_FAILED (-1)
58 typedef char ZPacket_t[Z_MAXPKTLEN];
62 UNSAFE, UNACKED, ACKED, HMACK, HMCTL, SERVACK, SERVNAK, CLIENTACK, STAT
64 extern ZCONST char *ZNoticeKinds[9];
71 /* Unique ID format */
72 typedef struct _ZUnique_Id_t {
73 struct in_addr zuid_addr;
78 typedef unsigned int ZChecksum_t;
80 /* Notice definition */
81 typedef struct _ZNotice_t {
84 ZNotice_Kind_t z_kind;
86 #define z_sender_addr z_uid.zuid_addr
87 struct _ZTimeval z_time;
88 unsigned short z_port;
92 char *z_ascii_authent;
98 char *z_default_format;
100 ZUnique_Id_t z_multiuid;
101 ZChecksum_t z_checksum;
102 char *z_ascii_checksum;
103 int z_num_other_fields;
104 char *z_other_fields[Z_MAXOTHERFIELDS];
109 /* Subscription structure */
110 typedef struct _ZSubscriptions_t {
111 char *zsub_recipient;
113 char *zsub_classinst;
116 /* Function return code */
119 /* Locations structure */
120 typedef struct _ZLocations_t {
126 typedef struct _ZAsyncLocateData_t {
130 } ZAsyncLocateData_t;
134 void (*__Z_debug_print) ZP((ZCONST char *fmt, va_list args, void *closure));
135 void *__Z_debug_print_closure;
138 int ZCompareUIDPred ZP((ZNotice_t *, void *));
139 int ZCompareMultiUIDPred ZP((ZNotice_t *, void *));
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 Code_t ZMakeZcodeAuthentication ZP((ZNotice_t*, char *,int, int*));
145 Code_t ZMakeZcodeRealmAuthentication ZP((ZNotice_t*, char *,int, int*, char*));
147 char *ZGetSender ZP((void));
148 char *ZGetVariable ZP((char *));
149 Code_t ZSetVariable ZP((char *var, char *value));
150 Code_t ZUnsetVariable ZP((char *var));
151 int ZGetWGPort ZP((void));
152 Code_t ZSetDestAddr ZP((struct sockaddr_in *));
153 Code_t ZFormatNoticeList ZP((ZNotice_t*, char**, int,
154 char **, int*, Z_AuthProc));
155 Code_t ZParseNotice ZP((char*, int, ZNotice_t *));
156 Code_t ZReadAscii ZP((char*, int, unsigned char*, int));
157 Code_t ZReadAscii32 ZP((char *, int, unsigned long *));
158 Code_t ZReadAscii16 ZP((char *, int, unsigned short *));
159 Code_t ZSendPacket ZP((char*, int, int));
160 Code_t ZSendList ZP((ZNotice_t*, char *[], int, Z_AuthProc));
161 Code_t ZSrvSendList ZP((ZNotice_t*, char*[], int, Z_AuthProc, Code_t (*)()));
162 Code_t ZSendNotice ZP((ZNotice_t *, Z_AuthProc));
163 Code_t ZSrvSendNotice ZP((ZNotice_t*, Z_AuthProc, Code_t (*)()));
164 Code_t ZFormatNotice ZP((ZNotice_t*, char**, int*, Z_AuthProc));
165 Code_t ZFormatSmallNotice ZP((ZNotice_t*, ZPacket_t, int*, Z_AuthProc));
166 Code_t ZFormatRawNoticeList ZP((ZNotice_t *notice, char *list[], int nitems,
167 char **buffer, int *ret_len));
168 Code_t ZLocateUser ZP((char *, int *, Z_AuthProc));
169 Code_t ZRequestLocations ZP((char *, ZAsyncLocateData_t *,
170 ZNotice_Kind_t, Z_AuthProc));
171 Code_t ZhmStat ZP((struct in_addr *, ZNotice_t *));
172 Code_t ZInitialize ZP((void));
173 Code_t ZSetServerState ZP((int));
174 Code_t ZSetFD ZP((int));
175 Code_t ZFormatSmallRawNotice ZP((ZNotice_t*, ZPacket_t, int*));
176 int ZCompareUID ZP((ZUnique_Id_t*, ZUnique_Id_t*));
177 Code_t ZSrvSendRawList ZP((ZNotice_t*, char*[], int,
178 Code_t (*)(ZNotice_t *, char *, int, int)));
179 Code_t ZMakeAscii ZP((char*, int, unsigned char*, int));
180 Code_t ZMakeAscii32 ZP((char *, int, unsigned long));
181 Code_t ZMakeAscii16 ZP((char *, int, unsigned int));
182 Code_t ZReceivePacket ZP((ZPacket_t, int*, struct sockaddr_in*));
183 Code_t ZCheckAuthentication ZP((ZNotice_t*, struct sockaddr_in*));
184 Code_t ZCheckZcodeAuthentication ZP((ZNotice_t*, struct sockaddr_in*));
185 Code_t ZCheckZcodeRealmAuthentication ZP((ZNotice_t*, struct sockaddr_in*, char *realm));
186 Code_t ZInitLocationInfo ZP((char *hostname, char *tty));
187 Code_t ZSetLocation ZP((char *exposure));
188 Code_t ZUnsetLocation ZP((void));
189 Code_t ZFlushMyLocations ZP((void));
190 char *ZParseExposureLevel ZP((char *text));
191 Code_t ZFormatRawNotice ZP((ZNotice_t *, char**, int *));
192 Code_t ZRetrieveSubscriptions ZP((unsigned short, int*));
193 Code_t ZOpenPort ZP((unsigned short *port));
194 Code_t ZClosePort ZP((void));
195 Code_t ZFlushLocations ZP((void));
196 Code_t ZFlushSubscriptions ZP((void));
197 Code_t ZFreeNotice ZP((ZNotice_t *notice));
198 Code_t ZParseLocations ZP((register ZNotice_t *notice,
199 register ZAsyncLocateData_t *zald, int *nlocs,
201 int ZCompareALDPred ZP((ZNotice_t *notice, void *zald));
202 void ZFreeALD ZP((register ZAsyncLocateData_t *zald));
203 Code_t ZCheckIfNotice ZP((ZNotice_t *notice, struct sockaddr_in *from,
204 register int (*predicate) ZP((ZNotice_t *,void *)),
206 Code_t ZPeekPacket ZP((char **buffer, int *ret_len,
207 struct sockaddr_in *from));
208 Code_t ZPeekNotice ZP((ZNotice_t *notice, struct sockaddr_in *from));
209 Code_t ZIfNotice ZP((ZNotice_t *notice, struct sockaddr_in *from,
210 int (*predicate) ZP((ZNotice_t *, void *)), void *args));
211 Code_t ZSubscribeTo ZP((ZSubscription_t *sublist, int nitems,
213 Code_t ZSubscribeToSansDefaults ZP((ZSubscription_t *sublist, int nitems,
215 Code_t ZUnsubscribeTo ZP((ZSubscription_t *sublist, int nitems,
217 Code_t ZCancelSubscriptions ZP((unsigned int port));
218 int ZPending ZP((void));
219 Code_t ZReceiveNotice ZP((ZNotice_t *notice, struct sockaddr_in *from));
221 void Z_debug ZP((ZCONST char *, ...));
227 #define ZNewLocateUser ZLocateUser
229 /* Macros to retrieve Zephyr library values. */
230 extern int __Zephyr_fd;
231 extern int __Q_CompleteLength;
232 extern struct sockaddr_in __HM_addr;
233 extern char __Zephyr_realm[];
234 #define ZGetFD() __Zephyr_fd
235 #define ZQLength() __Q_CompleteLength
236 #define ZGetDestAddr() __HM_addr
237 #define ZGetRealm() __Zephyr_realm
241 void ZSetDebug ZP((void (*)(ZCONST char *, va_list, void *), void *));
242 #define ZSetDebug(proc,closure) (__Z_debug_print=(proc), \
243 __Z_debug_print_closure=(closure), \
246 #define ZSetDebug(proc,closure)
249 /* Maximum queue length */
252 /* Successful function return */
255 /* Hostmanager wait time (in secs) */
256 #define HM_TIMEOUT 10
258 /* Server wait time (in secs) */
259 #define SRV_TIMEOUT 30
261 #define ZAUTH (ZMakeAuthentication)
262 #define ZCAUTH (ZMakeZcodeAuthentication)
263 #define ZNOAUTH ((Z_AuthProc)0)
266 #define ZSRVACK_SENT "SENT" /* SERVACK codes */
267 #define ZSRVACK_NOTSENT "LOST"
268 #define ZSRVACK_FAIL "FAIL"
270 /* Server internal class */
271 #define ZEPHYR_ADMIN_CLASS "ZEPHYR_ADMIN" /* Class */
273 /* Control codes sent to a server */
274 #define ZEPHYR_CTL_CLASS "ZEPHYR_CTL" /* Class */
276 #define ZEPHYR_CTL_REALM "REALM" /* Inst: From realm */
277 #define REALM_ADD_SUBSCRIBE "ADD_SUBSCRIBE" /* Opcode: Add subs */
278 #define REALM_REQ_SUBSCRIBE "REQ_SUBSCRIBE" /* Opcode: Request subs */
279 #define REALM_SUBSCRIBE "RLM_SUBSCRIBE" /* Opcode: Subscribe realm */
280 #define REALM_UNSUBSCRIBE "RLM_UNSUBSCRIBE" /* Opcode: Unsub realm */
282 #define ZEPHYR_CTL_CLIENT "CLIENT" /* Inst: From client */
283 #define CLIENT_SUBSCRIBE "SUBSCRIBE" /* Opcode: Subscribe */
284 #define CLIENT_SUBSCRIBE_NODEFS "SUBSCRIBE_NODEFS" /* Opcode: Subscribe */
285 #define CLIENT_UNSUBSCRIBE "UNSUBSCRIBE" /* Opcode: Unsubsubscribe */
286 #define CLIENT_CANCELSUB "CLEARSUB" /* Opcode: Clear all subs */
287 #define CLIENT_GIMMESUBS "GIMME" /* Opcode: Give me subs */
288 #define CLIENT_GIMMEDEFS "GIMMEDEFS" /* Opcode: Give me default
291 #define ZEPHYR_CTL_HM "HM" /* Inst: From HM */
292 #define HM_BOOT "BOOT" /* Opcode: Boot msg */
293 #define HM_FLUSH "FLUSH" /* Opcode: Flush me */
294 #define HM_DETACH "DETACH" /* Opcode: Detach me */
295 #define HM_ATTACH "ATTACH" /* Opcode: Attach me */
297 /* Control codes send to a HostManager */
298 #define HM_CTL_CLASS "HM_CTL" /* Class */
300 #define HM_CTL_SERVER "SERVER" /* Inst: From server */
301 #define SERVER_SHUTDOWN "SHUTDOWN" /* Opcode: Server shutdown */
302 #define SERVER_PING "PING" /* Opcode: PING */
304 #define HM_CTL_CLIENT "CLIENT" /* Inst: From client */
305 #define CLIENT_FLUSH "FLUSH" /* Opcode: Send flush to srv */
306 #define CLIENT_NEW_SERVER "NEWSERV" /* Opcode: Find new server */
309 #define HM_STAT_CLASS "HM_STAT" /* Class */
311 #define HM_STAT_CLIENT "HMST_CLIENT" /* Inst: From client */
312 #define HM_GIMMESTATS "GIMMESTATS" /* Opcode: get stats */
314 /* Login class messages */
315 #define LOGIN_CLASS "LOGIN" /* Class */
317 /* Class Instance is principal of user who is logging in or logging out */
319 #define EXPOSE_NONE "NONE" /* Opcode: Not visible */
320 #define EXPOSE_OPSTAFF "OPSTAFF" /* Opcode: Opstaff visible */
321 #define EXPOSE_REALMVIS "REALM-VISIBLE" /* Opcode: Realm visible */
322 #define EXPOSE_REALMANN "REALM-ANNOUNCED"/* Opcode: Realm announced */
323 #define EXPOSE_NETVIS "NET-VISIBLE" /* Opcode: Net visible */
324 #define EXPOSE_NETANN "NET-ANNOUNCED" /* Opcode: Net announced */
325 #define LOGIN_USER_LOGIN "USER_LOGIN" /* Opcode: user login
327 #define LOGIN_USER_LOGOUT "USER_LOGOUT" /* Opcode: User logout */
328 #define LOGIN_USER_FLUSH "USER_FLUSH" /* Opcode: flush all locs */
330 /* Locate class messages */
331 #define LOCATE_CLASS "USER_LOCATE" /* Class */
333 #define LOCATE_HIDE "USER_HIDE" /* Opcode: Hide me */
334 #define LOCATE_UNHIDE "USER_UNHIDE" /* Opcode: Unhide me */
336 /* Class Instance is principal of user to locate */
337 #define LOCATE_LOCATE "LOCATE" /* Opcode: Locate user */
339 /* WG_CTL class messages */
340 #define WG_CTL_CLASS "WG_CTL" /* Class */
342 #define WG_CTL_USER "USER" /* Inst: User request */
343 #define USER_REREAD "REREAD" /* Opcode: Reread desc file */
344 #define USER_SHUTDOWN "SHUTDOWN" /* Opcode: Go catatonic */
345 #define USER_STARTUP "STARTUP" /* Opcode: Come out of it */
346 #define USER_EXIT "EXIT" /* Opcode: Exit the client */
348 #endif /* __ZEPHYR_H__ */