]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - zephyr/h/zephyr/zephyr.h
finalize -3
[1ts-debian.git] / zephyr / h / zephyr / zephyr.h
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  *      $Id$
7  *
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".
11  */
12
13 #ifndef __ZEPHYR_H__
14 #define __ZEPHYR_H__
15
16 #include <sys/types.h>
17 #include <sys/time.h>
18
19 #include <zephyr/zephyr_err.h>
20
21 #ifndef IPPROTO_MAX     /* Make sure not already included */
22 #include <netinet/in.h>
23 #endif
24
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. */
27 #ifdef __STDC__
28 # include <stdarg.h>
29 # define ZP(x) x
30 # define ZCONST const
31 #else
32 # define ZP(x) ()
33 # define ZCONST
34 #endif
35
36 /* Service names */
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
43 #define ZVERSIONHDR     "ZEPH"
44 #define ZVERSIONMAJOR   0
45 #define ZVERSIONMINOR   2
46
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
51
52 /* Authentication levels returned by ZCheckAuthentication */
53 #define ZAUTH_FAILED            (-1)
54 #define ZAUTH_YES               1
55 #define ZAUTH_NO                0
56
57 typedef char ZPacket_t[Z_MAXPKTLEN];
58
59 /* Packet type */
60 typedef enum {
61     UNSAFE, UNACKED, ACKED, HMACK, HMCTL, SERVACK, SERVNAK, CLIENTACK, STAT
62 } ZNotice_Kind_t;
63 extern ZCONST char *ZNoticeKinds[9];
64
65 struct _ZTimeval {
66         int tv_sec;
67         int tv_usec;
68 };
69
70 /* Unique ID format */
71 typedef struct _ZUnique_Id_t {
72     struct      in_addr zuid_addr;
73     struct      _ZTimeval       tv;
74 } ZUnique_Id_t;
75
76 /* Checksum */
77 typedef unsigned int ZChecksum_t;
78
79 /* Notice definition */
80 typedef struct _ZNotice_t {
81     char                *z_packet;
82     char                *z_version;
83     ZNotice_Kind_t      z_kind;
84     ZUnique_Id_t        z_uid;
85 #define z_sender_addr   z_uid.zuid_addr
86     struct              _ZTimeval z_time;
87     unsigned short      z_port;
88     int                 z_auth;
89     int                 z_checked_auth;
90     int                 z_authent_len;
91     char                *z_ascii_authent;
92     char                *z_class;
93     char                *z_class_inst;
94     char                *z_opcode;
95     char                *z_sender;
96     char                *z_recipient;
97     char                *z_default_format;
98     char                *z_multinotice;
99     ZUnique_Id_t        z_multiuid;
100     ZChecksum_t         z_checksum;
101     int                 z_num_other_fields;
102     char                *z_other_fields[Z_MAXOTHERFIELDS];
103     caddr_t             z_message;
104     int                 z_message_len;
105 } ZNotice_t;
106
107 /* Subscription structure */
108 typedef struct _ZSubscriptions_t {
109     char        *zsub_recipient;
110     char        *zsub_class;
111     char        *zsub_classinst;
112 } ZSubscription_t;
113
114 /* Function return code */
115 typedef int Code_t;
116
117 /* Locations structure */
118 typedef struct _ZLocations_t {
119     char        *host;
120     char        *time;
121     char        *tty;
122 } ZLocations_t;
123
124 typedef struct _ZAsyncLocateData_t {
125     char                *user;
126     ZUnique_Id_t        uid;
127     char                *version;
128 } ZAsyncLocateData_t;
129
130 /* for ZSetDebug */
131 #ifdef Z_DEBUG
132 void (*__Z_debug_print) ZP((ZCONST char *fmt, va_list args, void *closure));
133 void *__Z_debug_print_closure;
134 #endif
135
136 int ZCompareUIDPred ZP((ZNotice_t *, void *));
137 int ZCompareMultiUIDPred ZP((ZNotice_t *, void *));
138
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*));
142
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,
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
234 #ifdef Z_DEBUG
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), \
238                                     (void) 0)
239 #else
240 #define ZSetDebug(proc,closure)
241 #endif
242
243 /* Maximum queue length */
244 #define Z_MAXQLEN               30
245
246 /* Successful function return */
247 #define ZERR_NONE               0
248
249 /* Hostmanager wait time (in secs) */
250 #define HM_TIMEOUT              10
251
252 /* Server wait time (in secs) */
253 #define SRV_TIMEOUT             30
254
255 #define ZAUTH (ZMakeAuthentication)
256 #define ZNOAUTH ((Z_AuthProc)0)
257
258 /* Packet strings */
259 #define ZSRVACK_SENT            "SENT"  /* SERVACK codes */
260 #define ZSRVACK_NOTSENT         "LOST"
261 #define ZSRVACK_FAIL            "FAIL"
262
263 /* Server internal class */
264 #define ZEPHYR_ADMIN_CLASS      "ZEPHYR_ADMIN"  /* Class */
265
266 /* Control codes sent to a server */
267 #define ZEPHYR_CTL_CLASS        "ZEPHYR_CTL"    /* Class */
268
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 */
274
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
282                                                  * subscriptions */
283
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 */
289
290 /* Control codes send to a HostManager */
291 #define HM_CTL_CLASS            "HM_CTL"        /* Class */
292
293 #define HM_CTL_SERVER           "SERVER"        /* Inst: From server */
294 #define SERVER_SHUTDOWN         "SHUTDOWN"      /* Opcode: Server shutdown */
295 #define SERVER_PING             "PING"          /* Opcode: PING */
296
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 */
300
301 /* HM Statistics */
302 #define HM_STAT_CLASS           "HM_STAT"       /* Class */
303
304 #define HM_STAT_CLIENT          "HMST_CLIENT"   /* Inst: From client */
305 #define HM_GIMMESTATS           "GIMMESTATS"    /* Opcode: get stats */
306
307 /* Login class messages */
308 #define LOGIN_CLASS             "LOGIN"         /* Class */
309
310 /* Class Instance is principal of user who is logging in or logging out */
311
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
319                                                    (from server) */
320 #define LOGIN_USER_LOGOUT       "USER_LOGOUT"   /* Opcode: User logout */
321 #define LOGIN_USER_FLUSH        "USER_FLUSH"    /* Opcode: flush all locs */
322
323 /* Locate class messages */
324 #define LOCATE_CLASS            "USER_LOCATE"   /* Class */
325
326 #define LOCATE_HIDE             "USER_HIDE"     /* Opcode: Hide me */
327 #define LOCATE_UNHIDE           "USER_UNHIDE"   /* Opcode: Unhide me */
328
329 /* Class Instance is principal of user to locate */
330 #define LOCATE_LOCATE           "LOCATE"        /* Opcode: Locate user */
331
332 /* WG_CTL class messages */
333 #define WG_CTL_CLASS            "WG_CTL"        /* Class */
334
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 */
340
341 #endif /* __ZEPHYR_H__ */