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>
18 #include <sys/socket.h>
20 #include <zephyr/zephyr_err.h>
22 #ifndef IPPROTO_MAX /* Make sure not already included */
23 #include <netinet/in.h>
29 #define HM_SVCNAME "zephyr-hm"
30 #define HM_SRV_SVCNAME "zephyr-hm-srv"
31 #define SERVER_SVCNAME "zephyr-clt"
32 #define SERVER_SERVICE "zephyr"
33 #define SERVER_INSTANCE "zephyr"
34 #define SERVER_KRB5_SERVICE "zephyr"
36 #define ZVERSIONHDR "ZEPH"
37 #define ZVERSIONMAJOR 0
38 #define ZVERSIONMINOR 2
40 #define Z_MAXPKTLEN 1024
41 #define Z_MAXHEADERLEN 800
42 #define Z_MAXOTHERFIELDS 10 /* Max unknown fields in ZNotice_t */
43 #define Z_NUMFIELDS 17
45 /* Authentication levels returned by ZCheckAuthentication */
46 #define ZAUTH_FAILED (-1)
50 typedef char ZPacket_t[Z_MAXPKTLEN];
54 UNSAFE, UNACKED, ACKED, HMACK, HMCTL, SERVACK, SERVNAK, CLIENTACK, STAT
56 extern const char *ZNoticeKinds[9];
63 /* Unique ID format */
64 typedef struct _ZUnique_Id_t {
65 struct in_addr zuid_addr;
70 typedef unsigned int ZChecksum_t;
72 /* Notice definition */
73 typedef struct _ZNotice_t {
76 ZNotice_Kind_t z_kind;
80 struct sockaddr_in ip4;
81 struct sockaddr_in6 ip6;
83 /* heavily deprecated: */
84 #define z_sender_addr z_sender_sockaddr.ip4.sin_addr
85 /* probably a bad idea?: */
86 #define z_port z_sender_sockaddr.ip4.sin_port
87 struct _ZTimeval z_time;
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)(const char *fmt, va_list args, void *closure);
135 void *__Z_debug_print_closure;
138 int ZCompareUIDPred(ZNotice_t *, void *);
139 int ZCompareMultiUIDPred(ZNotice_t *, void *);
141 /* Defines for ZFormatNotice, et al. */
142 typedef Code_t (*Z_AuthProc)(ZNotice_t*, char *, int, int *);
143 Code_t ZMakeAuthentication(ZNotice_t*, char *,int, int*);
144 Code_t ZMakeZcodeAuthentication(ZNotice_t*, char *,int, int*);
145 Code_t ZMakeZcodeRealmAuthentication(ZNotice_t*, char *,int, int*, char*);
147 char *ZGetSender(void);
148 char *ZGetVariable(char *);
149 Code_t ZSetVariable(char *var, char *value);
150 Code_t ZUnsetVariable(char *var);
151 int ZGetWGPort(void);
152 Code_t ZSetDestAddr(struct sockaddr_in *);
153 Code_t ZFormatNoticeList(ZNotice_t*, char**, int,
154 char **, int*, Z_AuthProc);
155 Code_t ZParseNotice(char*, int, ZNotice_t *);
156 Code_t ZReadAscii(char*, int, unsigned char*, int);
157 Code_t ZReadAscii32(char *, int, unsigned long *);
158 Code_t ZReadAscii16(char *, int, unsigned short *);
159 Code_t ZReadZcode(unsigned char*, unsigned char*, int, int *);
160 Code_t ZSendPacket(char*, int, int);
161 Code_t ZSendList(ZNotice_t*, char *[], int, Z_AuthProc);
162 Code_t ZSrvSendList(ZNotice_t*, char*[], int, Z_AuthProc,
163 Code_t (*)(ZNotice_t *, char *, int, int));
164 Code_t ZSendNotice(ZNotice_t *, Z_AuthProc);
165 Code_t ZSrvSendNotice(ZNotice_t*, Z_AuthProc,
166 Code_t (*)(ZNotice_t *, char *, int, int));
167 Code_t ZFormatNotice(ZNotice_t*, char**, int*, Z_AuthProc);
168 Code_t ZFormatSmallNotice(ZNotice_t*, ZPacket_t, int*, Z_AuthProc);
169 Code_t ZFormatRawNoticeList(ZNotice_t *, char *[], int, char **, int *);
170 Code_t ZFormatSmallRawNotice(ZNotice_t *, ZPacket_t, int *);
171 Code_t ZNewFormatSmallRawNotice(ZNotice_t *, ZPacket_t, int *);
172 Code_t ZLocateUser(char *, int *, Z_AuthProc);
173 Code_t ZRequestLocations(char *, ZAsyncLocateData_t *,
174 ZNotice_Kind_t, Z_AuthProc);
175 Code_t ZhmStat(struct in_addr *, ZNotice_t *);
176 Code_t ZInitialize(void);
177 Code_t ZSetServerState(int);
179 Code_t ZFormatSmallRawNotice(ZNotice_t*, ZPacket_t, int*);
180 int ZCompareUID(ZUnique_Id_t*, ZUnique_Id_t*);
181 Code_t ZSrvSendRawList(ZNotice_t*, char*[], int,
182 Code_t (*)(ZNotice_t *, char *, int, int));
183 Code_t ZMakeAscii(char*, int, unsigned char*, int);
184 Code_t ZMakeAscii32(char *, int, unsigned long);
185 Code_t ZMakeAscii16(char *, int, unsigned int);
186 Code_t ZMakeZcode(char*, int, unsigned char*, int);
187 Code_t ZMakeZcode32(char *, int, unsigned long);
188 Code_t ZReceivePacket(ZPacket_t, int*, struct sockaddr_in*);
189 Code_t ZCheckAuthentication(ZNotice_t*, struct sockaddr_in*);
190 Code_t ZCheckZcodeAuthentication(ZNotice_t*, struct sockaddr_in*);
191 Code_t ZCheckZcodeRealmAuthentication(ZNotice_t*, struct sockaddr_in*, char *realm);
192 Code_t ZInitLocationInfo(char *hostname, char *tty);
193 Code_t ZSetLocation(char *exposure);
194 Code_t ZUnsetLocation(void);
195 Code_t ZFlushMyLocations(void);
196 char *ZParseExposureLevel(char *text);
197 Code_t ZFormatRawNotice(ZNotice_t *, char**, int *);
198 Code_t ZRetrieveSubscriptions(unsigned short, int*);
199 Code_t ZRetrieveDefaultSubscriptions(int *);
200 Code_t ZGetSubscriptions(ZSubscription_t *, int *);
201 Code_t ZOpenPort(unsigned short *port);
202 Code_t ZClosePort(void);
203 Code_t ZFlushLocations(void);
204 Code_t ZFlushSubscriptions(void);
205 Code_t ZFreeNotice(ZNotice_t *notice);
206 Code_t ZGetLocations(ZLocations_t *, int *);
207 Code_t ZParseLocations(register ZNotice_t *notice,
208 register ZAsyncLocateData_t *zald, int *nlocs,
210 int ZCompareALDPred(ZNotice_t *notice, void *zald);
211 void ZFreeALD(register ZAsyncLocateData_t *zald);
212 Code_t ZCheckIfNotice(ZNotice_t *notice, struct sockaddr_in *from,
213 register int (*predicate)(ZNotice_t *,void *),
215 Code_t ZPeekPacket(char **buffer, int *ret_len,
216 struct sockaddr_in *from);
217 Code_t ZPeekNotice(ZNotice_t *notice, struct sockaddr_in *from);
218 Code_t ZIfNotice(ZNotice_t *notice, struct sockaddr_in *from,
219 int (*predicate)(ZNotice_t *, void *), void *args);
220 Code_t ZSubscribeTo(ZSubscription_t *sublist, int nitems,
222 Code_t ZSubscribeToSansDefaults(ZSubscription_t *sublist, int nitems,
224 Code_t ZUnsubscribeTo(ZSubscription_t *sublist, int nitems,
226 Code_t ZCancelSubscriptions(unsigned int port);
228 Code_t ZReceiveNotice(ZNotice_t *notice, struct sockaddr_in *from);
230 void Z_debug(const char *, ...);
234 #define ZNewLocateUser ZLocateUser
236 /* Not macros to retrieve Zephyr library values. */
237 const char *ZGetRealm(void);
240 struct sockaddr_in ZGetDestAddr (void);
244 void ZSetDebug ZP((void (*)(const char *, va_list, void *), void *));
245 #define ZSetDebug(proc,closure) (__Z_debug_print=(proc), \
246 __Z_debug_print_closure=(closure), \
249 #define ZSetDebug(proc,closure)
252 /* Maximum queue length */
255 /* Successful function return */
258 /* Hostmanager wait time (in secs) */
259 #define HM_TIMEOUT 10
261 /* Server wait time (in secs) */
262 #define SRV_TIMEOUT 30
264 #define ZAUTH (ZMakeAuthentication)
265 #define ZCAUTH (ZMakeZcodeAuthentication)
266 #define ZNOAUTH ((Z_AuthProc)0)
269 #define ZSRVACK_SENT "SENT" /* SERVACK codes */
270 #define ZSRVACK_NOTSENT "LOST"
271 #define ZSRVACK_FAIL "FAIL"
273 /* Server internal class */
274 #define ZEPHYR_ADMIN_CLASS "ZEPHYR_ADMIN" /* Class */
276 /* Control codes sent to a server */
277 #define ZEPHYR_CTL_CLASS "ZEPHYR_CTL" /* Class */
279 #define ZEPHYR_CTL_REALM "REALM" /* Inst: From realm */
280 #define REALM_ADD_SUBSCRIBE "ADD_SUBSCRIBE" /* Opcode: Add subs */
281 #define REALM_REQ_SUBSCRIBE "REQ_SUBSCRIBE" /* Opcode: Request subs */
282 #define REALM_SUBSCRIBE "RLM_SUBSCRIBE" /* Opcode: Subscribe realm */
283 #define REALM_UNSUBSCRIBE "RLM_UNSUBSCRIBE" /* Opcode: Unsub realm */
285 #define ZEPHYR_CTL_CLIENT "CLIENT" /* Inst: From client */
286 #define CLIENT_SUBSCRIBE "SUBSCRIBE" /* Opcode: Subscribe */
287 #define CLIENT_SUBSCRIBE_NODEFS "SUBSCRIBE_NODEFS" /* Opcode: Subscribe */
288 #define CLIENT_UNSUBSCRIBE "UNSUBSCRIBE" /* Opcode: Unsubsubscribe */
289 #define CLIENT_CANCELSUB "CLEARSUB" /* Opcode: Clear all subs */
290 #define CLIENT_GIMMESUBS "GIMME" /* Opcode: Give me subs */
291 #define CLIENT_GIMMEDEFS "GIMMEDEFS" /* Opcode: Give me default
294 #define ZEPHYR_CTL_HM "HM" /* Inst: From HM */
295 #define HM_BOOT "BOOT" /* Opcode: Boot msg */
296 #define HM_FLUSH "FLUSH" /* Opcode: Flush me */
297 #define HM_DETACH "DETACH" /* Opcode: Detach me */
298 #define HM_ATTACH "ATTACH" /* Opcode: Attach me */
300 /* Control codes send to a HostManager */
301 #define HM_CTL_CLASS "HM_CTL" /* Class */
303 #define HM_CTL_SERVER "SERVER" /* Inst: From server */
304 #define SERVER_SHUTDOWN "SHUTDOWN" /* Opcode: Server shutdown */
305 #define SERVER_PING "PING" /* Opcode: PING */
307 #define HM_CTL_CLIENT "CLIENT" /* Inst: From client */
308 #define CLIENT_FLUSH "FLUSH" /* Opcode: Send flush to srv */
309 #define CLIENT_NEW_SERVER "NEWSERV" /* Opcode: Find new server */
312 #define HM_STAT_CLASS "HM_STAT" /* Class */
314 #define HM_STAT_CLIENT "HMST_CLIENT" /* Inst: From client */
315 #define HM_GIMMESTATS "GIMMESTATS" /* Opcode: get stats */
317 /* Login class messages */
318 #define LOGIN_CLASS "LOGIN" /* Class */
320 /* Class Instance is principal of user who is logging in or logging out */
322 #define EXPOSE_NONE "NONE" /* Opcode: Not visible */
323 #define EXPOSE_OPSTAFF "OPSTAFF" /* Opcode: Opstaff visible */
324 #define EXPOSE_REALMVIS "REALM-VISIBLE" /* Opcode: Realm visible */
325 #define EXPOSE_REALMANN "REALM-ANNOUNCED"/* Opcode: Realm announced */
326 #define EXPOSE_NETVIS "NET-VISIBLE" /* Opcode: Net visible */
327 #define EXPOSE_NETANN "NET-ANNOUNCED" /* Opcode: Net announced */
328 #define LOGIN_USER_LOGIN "USER_LOGIN" /* Opcode: user login
330 #define LOGIN_USER_LOGOUT "USER_LOGOUT" /* Opcode: User logout */
331 #define LOGIN_USER_FLUSH "USER_FLUSH" /* Opcode: flush all locs */
333 /* Locate class messages */
334 #define LOCATE_CLASS "USER_LOCATE" /* Class */
336 #define LOCATE_HIDE "USER_HIDE" /* Opcode: Hide me */
337 #define LOCATE_UNHIDE "USER_UNHIDE" /* Opcode: Unhide me */
339 /* Class Instance is principal of user to locate */
340 #define LOCATE_LOCATE "LOCATE" /* Opcode: Locate user */
342 /* WG_CTL class messages */
343 #define WG_CTL_CLASS "WG_CTL" /* Class */
345 #define WG_CTL_USER "USER" /* Inst: User request */
346 #define USER_REREAD "REREAD" /* Opcode: Reread desc file */
347 #define USER_SHUTDOWN "SHUTDOWN" /* Opcode: Go catatonic */
348 #define USER_STARTUP "STARTUP" /* Opcode: Come out of it */
349 #define USER_EXIT "EXIT" /* Opcode: Exit the client */
351 #endif /* __ZEPHYR_H__ */