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>
28 #define HM_SVCNAME "zephyr-hm"
29 #define HM_SRV_SVCNAME "zephyr-hm-srv"
30 #define SERVER_SVCNAME "zephyr-clt"
31 #define SERVER_SERVICE "zephyr"
32 #define SERVER_INSTANCE "zephyr"
33 #define SERVER_KRB5_SERVICE "zephyr"
35 #define ZVERSIONHDR "ZEPH"
36 #define ZVERSIONMAJOR 0
37 #define ZVERSIONMINOR 2
39 #define Z_MAXPKTLEN 1024
40 #define Z_MAXHEADERLEN 800
41 #define Z_MAXOTHERFIELDS 10 /* Max unknown fields in ZNotice_t */
42 #define Z_NUMFIELDS 17
44 /* Authentication levels returned by ZCheckAuthentication */
45 #define ZAUTH_FAILED (-1)
49 typedef char ZPacket_t[Z_MAXPKTLEN];
53 UNSAFE, UNACKED, ACKED, HMACK, HMCTL, SERVACK, SERVNAK, CLIENTACK, STAT
55 extern const char *ZNoticeKinds[9];
62 /* Unique ID format */
63 typedef struct _ZUnique_Id_t {
64 struct in_addr zuid_addr;
69 typedef unsigned int ZChecksum_t;
71 /* Notice definition */
72 typedef struct _ZNotice_t {
75 ZNotice_Kind_t z_kind;
77 #define z_sender_addr z_uid.zuid_addr
78 struct _ZTimeval z_time;
79 unsigned short z_port;
83 char *z_ascii_authent;
89 char *z_default_format;
91 ZUnique_Id_t z_multiuid;
92 ZChecksum_t z_checksum;
93 char *z_ascii_checksum;
94 int z_num_other_fields;
95 char *z_other_fields[Z_MAXOTHERFIELDS];
100 /* Subscription structure */
101 typedef struct _ZSubscriptions_t {
102 char *zsub_recipient;
104 char *zsub_classinst;
107 /* Function return code */
110 /* Locations structure */
111 typedef struct _ZLocations_t {
117 typedef struct _ZAsyncLocateData_t {
121 } ZAsyncLocateData_t;
125 void (*__Z_debug_print)(const char *fmt, va_list args, void *closure);
126 void *__Z_debug_print_closure;
129 int ZCompareUIDPred(ZNotice_t *, void *);
130 int ZCompareMultiUIDPred(ZNotice_t *, void *);
132 /* Defines for ZFormatNotice, et al. */
133 typedef Code_t (*Z_AuthProc)(ZNotice_t*, char *, int, int *);
134 Code_t ZMakeAuthentication(ZNotice_t*, char *,int, int*);
135 Code_t ZMakeZcodeAuthentication(ZNotice_t*, char *,int, int*);
136 Code_t ZMakeZcodeRealmAuthentication(ZNotice_t*, char *,int, int*, char*);
138 char *ZGetSender(void);
139 char *ZGetVariable(char *);
140 Code_t ZSetVariable(char *var, char *value);
141 Code_t ZUnsetVariable(char *var);
142 int ZGetWGPort(void);
143 Code_t ZSetDestAddr(struct sockaddr_in *);
144 Code_t ZFormatNoticeList(ZNotice_t*, char**, int,
145 char **, int*, Z_AuthProc);
146 Code_t ZParseNotice(char*, int, ZNotice_t *);
147 Code_t ZReadAscii(char*, int, unsigned char*, int);
148 Code_t ZReadAscii32(char *, int, unsigned long *);
149 Code_t ZReadAscii16(char *, int, unsigned short *);
150 Code_t ZReadZcode(unsigned char*, unsigned char*, int, int *);
151 Code_t ZSendPacket(char*, int, int);
152 Code_t ZSendList(ZNotice_t*, char *[], int, Z_AuthProc);
153 Code_t ZSrvSendList(ZNotice_t*, char*[], int, Z_AuthProc,
154 Code_t (*)(ZNotice_t *, char *, int, int));
155 Code_t ZSendNotice(ZNotice_t *, Z_AuthProc);
156 Code_t ZSrvSendNotice(ZNotice_t*, Z_AuthProc,
157 Code_t (*)(ZNotice_t *, char *, int, int));
158 Code_t ZFormatNotice(ZNotice_t*, char**, int*, Z_AuthProc);
159 Code_t ZFormatSmallNotice(ZNotice_t*, ZPacket_t, int*, Z_AuthProc);
160 Code_t ZFormatRawNoticeList(ZNotice_t *notice, char *list[], int nitems,
161 char **buffer, int *ret_len);
162 Code_t ZLocateUser(char *, int *, Z_AuthProc);
163 Code_t ZRequestLocations(char *, ZAsyncLocateData_t *,
164 ZNotice_Kind_t, Z_AuthProc);
165 Code_t ZhmStat(struct in_addr *, ZNotice_t *);
166 Code_t ZInitialize(void);
167 Code_t ZSetServerState(int);
169 Code_t ZFormatSmallRawNotice(ZNotice_t*, ZPacket_t, int*);
170 int ZCompareUID(ZUnique_Id_t*, ZUnique_Id_t*);
171 Code_t ZSrvSendRawList(ZNotice_t*, char*[], int,
172 Code_t (*)(ZNotice_t *, char *, int, int));
173 Code_t ZMakeAscii(char*, int, unsigned char*, int);
174 Code_t ZMakeAscii32(char *, int, unsigned long);
175 Code_t ZMakeAscii16(char *, int, unsigned int);
176 Code_t ZMakeZcode(char*, int, unsigned char*, int);
177 Code_t ZMakeZcode32(char *, int, unsigned long);
178 Code_t ZReceivePacket(ZPacket_t, int*, struct sockaddr_in*);
179 Code_t ZCheckAuthentication(ZNotice_t*, struct sockaddr_in*);
180 Code_t ZCheckZcodeAuthentication(ZNotice_t*, struct sockaddr_in*);
181 Code_t ZCheckZcodeRealmAuthentication(ZNotice_t*, struct sockaddr_in*, char *realm);
182 Code_t ZInitLocationInfo(char *hostname, char *tty);
183 Code_t ZSetLocation(char *exposure);
184 Code_t ZUnsetLocation(void);
185 Code_t ZFlushMyLocations(void);
186 char *ZParseExposureLevel(char *text);
187 Code_t ZFormatRawNotice(ZNotice_t *, char**, int *);
188 Code_t ZRetrieveSubscriptions(unsigned short, int*);
189 Code_t ZRetrieveDefaultSubscriptions(int *);
190 Code_t ZGetSubscriptions(ZSubscription_t *, int *);
191 Code_t ZOpenPort(unsigned short *port);
192 Code_t ZClosePort(void);
193 Code_t ZFlushLocations(void);
194 Code_t ZFlushSubscriptions(void);
195 Code_t ZFreeNotice(ZNotice_t *notice);
196 Code_t ZParseLocations(register ZNotice_t *notice,
197 register ZAsyncLocateData_t *zald, int *nlocs,
199 int ZCompareALDPred(ZNotice_t *notice, void *zald);
200 void ZFreeALD(register ZAsyncLocateData_t *zald);
201 Code_t ZCheckIfNotice(ZNotice_t *notice, struct sockaddr_in *from,
202 register int (*predicate)(ZNotice_t *,void *),
204 Code_t ZPeekPacket(char **buffer, int *ret_len,
205 struct sockaddr_in *from);
206 Code_t ZPeekNotice(ZNotice_t *notice, struct sockaddr_in *from);
207 Code_t ZIfNotice(ZNotice_t *notice, struct sockaddr_in *from,
208 int (*predicate)(ZNotice_t *, void *), void *args);
209 Code_t ZSubscribeTo(ZSubscription_t *sublist, int nitems,
211 Code_t ZSubscribeToSansDefaults(ZSubscription_t *sublist, int nitems,
213 Code_t ZUnsubscribeTo(ZSubscription_t *sublist, int nitems,
215 Code_t ZCancelSubscriptions(unsigned int port);
217 Code_t ZReceiveNotice(ZNotice_t *notice, struct sockaddr_in *from);
219 void Z_debug(const char *, ...);
223 #define ZNewLocateUser ZLocateUser
225 /* Macros to retrieve Zephyr library values. */
226 extern int __Zephyr_fd;
227 extern int __Q_CompleteLength;
228 extern struct sockaddr_in __HM_addr;
229 extern char __Zephyr_realm[];
230 #define ZGetFD() __Zephyr_fd
231 #define ZQLength() __Q_CompleteLength
232 #define ZGetDestAddr() __HM_addr
233 #define ZGetRealm() __Zephyr_realm
237 void ZSetDebug ZP((void (*)(const char *, va_list, void *), void *));
238 #define ZSetDebug(proc,closure) (__Z_debug_print=(proc), \
239 __Z_debug_print_closure=(closure), \
242 #define ZSetDebug(proc,closure)
245 /* Maximum queue length */
248 /* Successful function return */
251 /* Hostmanager wait time (in secs) */
252 #define HM_TIMEOUT 10
254 /* Server wait time (in secs) */
255 #define SRV_TIMEOUT 30
257 #define ZAUTH (ZMakeAuthentication)
258 #define ZCAUTH (ZMakeZcodeAuthentication)
259 #define ZNOAUTH ((Z_AuthProc)0)
262 #define ZSRVACK_SENT "SENT" /* SERVACK codes */
263 #define ZSRVACK_NOTSENT "LOST"
264 #define ZSRVACK_FAIL "FAIL"
266 /* Server internal class */
267 #define ZEPHYR_ADMIN_CLASS "ZEPHYR_ADMIN" /* Class */
269 /* Control codes sent to a server */
270 #define ZEPHYR_CTL_CLASS "ZEPHYR_CTL" /* Class */
272 #define ZEPHYR_CTL_REALM "REALM" /* Inst: From realm */
273 #define REALM_ADD_SUBSCRIBE "ADD_SUBSCRIBE" /* Opcode: Add subs */
274 #define REALM_REQ_SUBSCRIBE "REQ_SUBSCRIBE" /* Opcode: Request subs */
275 #define REALM_SUBSCRIBE "RLM_SUBSCRIBE" /* Opcode: Subscribe realm */
276 #define REALM_UNSUBSCRIBE "RLM_UNSUBSCRIBE" /* Opcode: Unsub realm */
278 #define ZEPHYR_CTL_CLIENT "CLIENT" /* Inst: From client */
279 #define CLIENT_SUBSCRIBE "SUBSCRIBE" /* Opcode: Subscribe */
280 #define CLIENT_SUBSCRIBE_NODEFS "SUBSCRIBE_NODEFS" /* Opcode: Subscribe */
281 #define CLIENT_UNSUBSCRIBE "UNSUBSCRIBE" /* Opcode: Unsubsubscribe */
282 #define CLIENT_CANCELSUB "CLEARSUB" /* Opcode: Clear all subs */
283 #define CLIENT_GIMMESUBS "GIMME" /* Opcode: Give me subs */
284 #define CLIENT_GIMMEDEFS "GIMMEDEFS" /* Opcode: Give me default
287 #define ZEPHYR_CTL_HM "HM" /* Inst: From HM */
288 #define HM_BOOT "BOOT" /* Opcode: Boot msg */
289 #define HM_FLUSH "FLUSH" /* Opcode: Flush me */
290 #define HM_DETACH "DETACH" /* Opcode: Detach me */
291 #define HM_ATTACH "ATTACH" /* Opcode: Attach me */
293 /* Control codes send to a HostManager */
294 #define HM_CTL_CLASS "HM_CTL" /* Class */
296 #define HM_CTL_SERVER "SERVER" /* Inst: From server */
297 #define SERVER_SHUTDOWN "SHUTDOWN" /* Opcode: Server shutdown */
298 #define SERVER_PING "PING" /* Opcode: PING */
300 #define HM_CTL_CLIENT "CLIENT" /* Inst: From client */
301 #define CLIENT_FLUSH "FLUSH" /* Opcode: Send flush to srv */
302 #define CLIENT_NEW_SERVER "NEWSERV" /* Opcode: Find new server */
305 #define HM_STAT_CLASS "HM_STAT" /* Class */
307 #define HM_STAT_CLIENT "HMST_CLIENT" /* Inst: From client */
308 #define HM_GIMMESTATS "GIMMESTATS" /* Opcode: get stats */
310 /* Login class messages */
311 #define LOGIN_CLASS "LOGIN" /* Class */
313 /* Class Instance is principal of user who is logging in or logging out */
315 #define EXPOSE_NONE "NONE" /* Opcode: Not visible */
316 #define EXPOSE_OPSTAFF "OPSTAFF" /* Opcode: Opstaff visible */
317 #define EXPOSE_REALMVIS "REALM-VISIBLE" /* Opcode: Realm visible */
318 #define EXPOSE_REALMANN "REALM-ANNOUNCED"/* Opcode: Realm announced */
319 #define EXPOSE_NETVIS "NET-VISIBLE" /* Opcode: Net visible */
320 #define EXPOSE_NETANN "NET-ANNOUNCED" /* Opcode: Net announced */
321 #define LOGIN_USER_LOGIN "USER_LOGIN" /* Opcode: user login
323 #define LOGIN_USER_LOGOUT "USER_LOGOUT" /* Opcode: User logout */
324 #define LOGIN_USER_FLUSH "USER_FLUSH" /* Opcode: flush all locs */
326 /* Locate class messages */
327 #define LOCATE_CLASS "USER_LOCATE" /* Class */
329 #define LOCATE_HIDE "USER_HIDE" /* Opcode: Hide me */
330 #define LOCATE_UNHIDE "USER_UNHIDE" /* Opcode: Unhide me */
332 /* Class Instance is principal of user to locate */
333 #define LOCATE_LOCATE "LOCATE" /* Opcode: Locate user */
335 /* WG_CTL class messages */
336 #define WG_CTL_CLASS "WG_CTL" /* Class */
338 #define WG_CTL_USER "USER" /* Inst: User request */
339 #define USER_REREAD "REREAD" /* Opcode: Reread desc file */
340 #define USER_SHUTDOWN "SHUTDOWN" /* Opcode: Go catatonic */
341 #define USER_STARTUP "STARTUP" /* Opcode: Come out of it */
342 #define USER_EXIT "EXIT" /* Opcode: Exit the client */
344 #endif /* __ZEPHYR_H__ */