1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains global definitions
4 * Created by: Robert French
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"
43 #define ZVERSIONHDR "ZEPH"
44 #define ZVERSIONMAJOR 0
45 #define ZVERSIONMINOR 2
47 #define Z_MAXPKTLEN 1024
48 #define Z_MAXHEADERLEN 800
49 #define Z_MAXOTHERFIELDS 10 /* Max unknown fields in ZNotice_t */
50 #define Z_NUMFIELDS 17
52 /* Authentication levels returned by ZCheckAuthentication */
53 #define ZAUTH_FAILED (-1)
57 typedef char ZPacket_t[Z_MAXPKTLEN];
61 UNSAFE, UNACKED, ACKED, HMACK, HMCTL, SERVACK, SERVNAK, CLIENTACK, STAT
63 extern ZCONST char *ZNoticeKinds[9];
70 /* Unique ID format */
71 typedef struct _ZUnique_Id_t {
72 struct in_addr zuid_addr;
77 typedef unsigned int ZChecksum_t;
79 /* Notice definition */
80 typedef struct _ZNotice_t {
83 ZNotice_Kind_t z_kind;
85 #define z_sender_addr z_uid.zuid_addr
86 struct _ZTimeval z_time;
87 unsigned short z_port;
91 char *z_ascii_authent;
97 char *z_default_format;
99 ZUnique_Id_t z_multiuid;
100 ZChecksum_t z_checksum;
101 int z_num_other_fields;
102 char *z_other_fields[Z_MAXOTHERFIELDS];
107 /* Subscription structure */
108 typedef struct _ZSubscriptions_t {
109 char *zsub_recipient;
111 char *zsub_classinst;
114 /* Function return code */
117 /* Locations structure */
118 typedef struct _ZLocations_t {
124 typedef struct _ZAsyncLocateData_t {
128 } ZAsyncLocateData_t;
132 void (*__Z_debug_print) ZP((ZCONST char *fmt, va_list args, void *closure));
133 void *__Z_debug_print_closure;
136 int ZCompareUIDPred ZP((ZNotice_t *, void *));
137 int ZCompareMultiUIDPred ZP((ZNotice_t *, void *));
139 /* Defines for ZFormatNotice, et al. */
140 typedef Code_t (*Z_AuthProc) ZP((ZNotice_t*, char *, int, int *));
141 Code_t ZMakeAuthentication ZP((ZNotice_t*, char *,int, int*));
143 char *ZGetSender ZP((void));
144 char *ZGetVariable ZP((char *));
145 Code_t ZSetVariable ZP((char *var, char *value));
146 Code_t ZUnsetVariable ZP((char *var));
147 int ZGetWGPort ZP((void));
148 Code_t ZSetDestAddr ZP((struct sockaddr_in *));
149 Code_t ZFormatNoticeList ZP((ZNotice_t*, char**, int,
150 char **, int*, Z_AuthProc));
151 Code_t ZParseNotice ZP((char*, int, ZNotice_t *));
152 Code_t ZReadAscii ZP((char*, int, unsigned char*, int));
153 Code_t ZReadAscii32 ZP((char *, int, unsigned long *));
154 Code_t ZReadAscii16 ZP((char *, int, unsigned short *));
155 Code_t ZSendPacket ZP((char*, int, int));
156 Code_t ZSendList ZP((ZNotice_t*, char *[], int, Z_AuthProc));
157 Code_t ZSrvSendList ZP((ZNotice_t*, char*[], int, Z_AuthProc, Code_t (*)()));
158 Code_t ZSendNotice ZP((ZNotice_t *, Z_AuthProc));
159 Code_t ZSrvSendNotice ZP((ZNotice_t*, Z_AuthProc, Code_t (*)()));
160 Code_t ZFormatNotice ZP((ZNotice_t*, char**, int*, Z_AuthProc));
161 Code_t ZFormatSmallNotice ZP((ZNotice_t*, ZPacket_t, int*, Z_AuthProc));
162 Code_t ZFormatRawNoticeList ZP((ZNotice_t *notice, char *list[], int nitems,
163 char **buffer, int *ret_len));
164 Code_t ZLocateUser ZP((char *, int *, Z_AuthProc));
165 Code_t ZRequestLocations ZP((char *, ZAsyncLocateData_t *,
166 ZNotice_Kind_t, Z_AuthProc));
167 Code_t ZhmStat ZP((struct in_addr *, ZNotice_t *));
168 Code_t ZInitialize ZP((void));
169 Code_t ZSetServerState ZP((int));
170 Code_t ZSetFD ZP((int));
171 Code_t ZFormatSmallRawNotice ZP((ZNotice_t*, ZPacket_t, int*));
172 int ZCompareUID ZP((ZUnique_Id_t*, ZUnique_Id_t*));
173 Code_t ZSrvSendRawList ZP((ZNotice_t*, char*[], int,
174 Code_t (*)(ZNotice_t *, char *, int, int)));
175 Code_t ZMakeAscii ZP((char*, int, unsigned char*, int));
176 Code_t ZMakeAscii32 ZP((char *, int, unsigned long));
177 Code_t ZMakeAscii16 ZP((char *, int, unsigned int));
178 Code_t ZReceivePacket ZP((ZPacket_t, int*, struct sockaddr_in*));
179 Code_t ZCheckAuthentication ZP((ZNotice_t*, struct sockaddr_in*));
180 Code_t ZInitLocationInfo ZP((char *hostname, char *tty));
181 Code_t ZSetLocation ZP((char *exposure));
182 Code_t ZUnsetLocation ZP((void));
183 Code_t ZFlushMyLocations ZP((void));
184 char *ZParseExposureLevel ZP((char *text));
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,
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 *)),
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,
207 Code_t ZSubscribeToSansDefaults ZP((ZSubscription_t *sublist, int nitems,
209 Code_t ZUnsubscribeTo ZP((ZSubscription_t *sublist, int nitems,
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));
215 void Z_debug ZP((ZCONST char *, ...));
221 #define ZNewLocateUser ZLocateUser
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
235 void ZSetDebug ZP((void (*)(ZCONST char *, va_list, void *), void *));
236 #define ZSetDebug(proc,closure) (__Z_debug_print=(proc), \
237 __Z_debug_print_closure=(closure), \
240 #define ZSetDebug(proc,closure)
243 /* Maximum queue length */
246 /* Successful function return */
249 /* Hostmanager wait time (in secs) */
250 #define HM_TIMEOUT 10
252 /* Server wait time (in secs) */
253 #define SRV_TIMEOUT 30
255 #define ZAUTH (ZMakeAuthentication)
256 #define ZNOAUTH ((Z_AuthProc)0)
259 #define ZSRVACK_SENT "SENT" /* SERVACK codes */
260 #define ZSRVACK_NOTSENT "LOST"
261 #define ZSRVACK_FAIL "FAIL"
263 /* Server internal class */
264 #define ZEPHYR_ADMIN_CLASS "ZEPHYR_ADMIN" /* Class */
266 /* Control codes sent to a server */
267 #define ZEPHYR_CTL_CLASS "ZEPHYR_CTL" /* Class */
269 #define ZEPHYR_CTL_REALM "REALM" /* Inst: From realm */
270 #define REALM_ADD_SUBSCRIBE "ADD_SUBSCRIBE" /* Opcode: Add subs */
271 #define REALM_REQ_SUBSCRIBE "REQ_SUBSCRIBE" /* Opcode: Request subs */
272 #define REALM_SUBSCRIBE "RLM_SUBSCRIBE" /* Opcode: Subscribe realm */
273 #define REALM_UNSUBSCRIBE "RLM_UNSUBSCRIBE" /* Opcode: Unsub realm */
275 #define ZEPHYR_CTL_CLIENT "CLIENT" /* Inst: From client */
276 #define CLIENT_SUBSCRIBE "SUBSCRIBE" /* Opcode: Subscribe */
277 #define CLIENT_SUBSCRIBE_NODEFS "SUBSCRIBE_NODEFS" /* Opcode: Subscribe */
278 #define CLIENT_UNSUBSCRIBE "UNSUBSCRIBE" /* Opcode: Unsubsubscribe */
279 #define CLIENT_CANCELSUB "CLEARSUB" /* Opcode: Clear all subs */
280 #define CLIENT_GIMMESUBS "GIMME" /* Opcode: Give me subs */
281 #define CLIENT_GIMMEDEFS "GIMMEDEFS" /* Opcode: Give me default
284 #define ZEPHYR_CTL_HM "HM" /* Inst: From HM */
285 #define HM_BOOT "BOOT" /* Opcode: Boot msg */
286 #define HM_FLUSH "FLUSH" /* Opcode: Flush me */
287 #define HM_DETACH "DETACH" /* Opcode: Detach me */
288 #define HM_ATTACH "ATTACH" /* Opcode: Attach me */
290 /* Control codes send to a HostManager */
291 #define HM_CTL_CLASS "HM_CTL" /* Class */
293 #define HM_CTL_SERVER "SERVER" /* Inst: From server */
294 #define SERVER_SHUTDOWN "SHUTDOWN" /* Opcode: Server shutdown */
295 #define SERVER_PING "PING" /* Opcode: PING */
297 #define HM_CTL_CLIENT "CLIENT" /* Inst: From client */
298 #define CLIENT_FLUSH "FLUSH" /* Opcode: Send flush to srv */
299 #define CLIENT_NEW_SERVER "NEWSERV" /* Opcode: Find new server */
302 #define HM_STAT_CLASS "HM_STAT" /* Class */
304 #define HM_STAT_CLIENT "HMST_CLIENT" /* Inst: From client */
305 #define HM_GIMMESTATS "GIMMESTATS" /* Opcode: get stats */
307 /* Login class messages */
308 #define LOGIN_CLASS "LOGIN" /* Class */
310 /* Class Instance is principal of user who is logging in or logging out */
312 #define EXPOSE_NONE "NONE" /* Opcode: Not visible */
313 #define EXPOSE_OPSTAFF "OPSTAFF" /* Opcode: Opstaff visible */
314 #define EXPOSE_REALMVIS "REALM-VISIBLE" /* Opcode: Realm visible */
315 #define EXPOSE_REALMANN "REALM-ANNOUNCED"/* Opcode: Realm announced */
316 #define EXPOSE_NETVIS "NET-VISIBLE" /* Opcode: Net visible */
317 #define EXPOSE_NETANN "NET-ANNOUNCED" /* Opcode: Net announced */
318 #define LOGIN_USER_LOGIN "USER_LOGIN" /* Opcode: user login
320 #define LOGIN_USER_LOGOUT "USER_LOGOUT" /* Opcode: User logout */
321 #define LOGIN_USER_FLUSH "USER_FLUSH" /* Opcode: flush all locs */
323 /* Locate class messages */
324 #define LOCATE_CLASS "USER_LOCATE" /* Class */
326 #define LOCATE_HIDE "USER_HIDE" /* Opcode: Hide me */
327 #define LOCATE_UNHIDE "USER_UNHIDE" /* Opcode: Unhide me */
329 /* Class Instance is principal of user to locate */
330 #define LOCATE_LOCATE "LOCATE" /* Opcode: Locate user */
332 /* WG_CTL class messages */
333 #define WG_CTL_CLASS "WG_CTL" /* Class */
335 #define WG_CTL_USER "USER" /* Inst: User request */
336 #define USER_REREAD "REREAD" /* Opcode: Reread desc file */
337 #define USER_SHUTDOWN "SHUTDOWN" /* Opcode: Go catatonic */
338 #define USER_STARTUP "STARTUP" /* Opcode: Come out of it */
339 #define USER_EXIT "EXIT" /* Opcode: Exit the client */
341 #endif /* __ZEPHYR_H__ */