]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - zephyr/h/zephyr/zephyr.h
Import new release
[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: zephyr.h,v 1.54 1999/01/22 23:18:59 ghudson Exp $
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 /* Unique ID format */
66 typedef struct _ZUnique_Id_t {
67     struct      in_addr zuid_addr;
68     struct      timeval tv;
69 } ZUnique_Id_t;
70
71 /* Checksum */
72 typedef unsigned long ZChecksum_t;
73
74 /* Notice definition */
75 typedef struct _ZNotice_t {
76     char                *z_packet;
77     char                *z_version;
78     ZNotice_Kind_t      z_kind;
79     ZUnique_Id_t        z_uid;
80 #define z_sender_addr   z_uid.zuid_addr
81     struct              timeval z_time;
82     unsigned short      z_port;
83     int                 z_auth;
84     int                 z_checked_auth;
85     int                 z_authent_len;
86     char                *z_ascii_authent;
87     char                *z_class;
88     char                *z_class_inst;
89     char                *z_opcode;
90     char                *z_sender;
91     char                *z_recipient;
92     char                *z_default_format;
93     char                *z_multinotice;
94     ZUnique_Id_t        z_multiuid;
95     ZChecksum_t         z_checksum;
96     int                 z_num_other_fields;
97     char                *z_other_fields[Z_MAXOTHERFIELDS];
98     caddr_t             z_message;
99     int                 z_message_len;
100 } ZNotice_t;
101
102 /* Subscription structure */
103 typedef struct _ZSubscriptions_t {
104     char        *zsub_recipient;
105     char        *zsub_class;
106     char        *zsub_classinst;
107 } ZSubscription_t;
108
109 /* Function return code */
110 typedef int Code_t;
111
112 /* Locations structure */
113 typedef struct _ZLocations_t {
114     char        *host;
115     char        *time;
116     char        *tty;
117 } ZLocations_t;
118
119 typedef struct _ZAsyncLocateData_t {
120     char                *user;
121     ZUnique_Id_t        uid;
122     char                *version;
123 } ZAsyncLocateData_t;
124
125 /* for ZSetDebug */
126 #ifdef Z_DEBUG
127 void (*__Z_debug_print) ZP((ZCONST char *fmt, va_list args, void *closure));
128 void *__Z_debug_print_closure;
129 #endif
130
131 int ZCompareUIDPred ZP((ZNotice_t *, void *));
132 int ZCompareMultiUIDPred ZP((ZNotice_t *, void *));
133
134 /* Defines for ZFormatNotice, et al. */
135 typedef Code_t (*Z_AuthProc) ZP((ZNotice_t*, char *, int, int *));
136 Code_t ZMakeAuthentication ZP((ZNotice_t*, char *,int, int*));
137
138 char *ZGetSender ZP((void));
139 char *ZGetVariable ZP((char *));
140 Code_t ZSetVariable ZP((char *var, char *value));
141 Code_t ZUnsetVariable ZP((char *var));
142 int ZGetWGPort ZP((void));
143 Code_t ZSetDestAddr ZP((struct sockaddr_in *));
144 Code_t ZFormatNoticeList ZP((ZNotice_t*, char**, int,
145                              char **, int*, Z_AuthProc));
146 Code_t ZParseNotice ZP((char*, int, ZNotice_t *));
147 Code_t ZReadAscii ZP((char*, int, unsigned char*, int));
148 Code_t ZReadAscii32 ZP((char *, int, unsigned long *));
149 Code_t ZReadAscii16 ZP((char *, int, unsigned short *));
150 Code_t ZSendPacket ZP((char*, int, int));
151 Code_t ZSendList ZP((ZNotice_t*, char *[], int, Z_AuthProc));
152 Code_t ZSrvSendList ZP((ZNotice_t*, char*[], int, Z_AuthProc, Code_t (*)()));
153 Code_t ZSendNotice ZP((ZNotice_t *, Z_AuthProc));
154 Code_t ZSrvSendNotice ZP((ZNotice_t*, Z_AuthProc, Code_t (*)()));
155 Code_t ZFormatNotice ZP((ZNotice_t*, char**, int*, Z_AuthProc));
156 Code_t ZFormatSmallNotice ZP((ZNotice_t*, ZPacket_t, int*, Z_AuthProc));
157 Code_t ZFormatRawNoticeList ZP((ZNotice_t *notice, char *list[], int nitems,
158                                 char **buffer, int *ret_len));
159 Code_t ZLocateUser ZP((char *, int *, Z_AuthProc));
160 Code_t ZRequestLocations ZP((char *, ZAsyncLocateData_t *,
161                              ZNotice_Kind_t, Z_AuthProc));
162 Code_t ZhmStat ZP((struct in_addr *, ZNotice_t *));
163 Code_t ZInitialize ZP((void));
164 Code_t ZSetServerState ZP((int));
165 Code_t ZSetFD ZP((int));
166 Code_t ZFormatSmallRawNotice ZP((ZNotice_t*, ZPacket_t, int*));
167 int ZCompareUID ZP((ZUnique_Id_t*, ZUnique_Id_t*));
168 Code_t ZSrvSendRawList ZP((ZNotice_t*, char*[], int,
169                            Code_t (*)(ZNotice_t *, char *, int, int)));
170 Code_t ZMakeAscii ZP((char*, int, unsigned char*, int));
171 Code_t ZMakeAscii32 ZP((char *, int, unsigned long));
172 Code_t ZMakeAscii16 ZP((char *, int, unsigned int));
173 Code_t ZReceivePacket ZP((ZPacket_t, int*, struct sockaddr_in*));
174 Code_t ZCheckAuthentication ZP((ZNotice_t*, struct sockaddr_in*));
175 Code_t ZInitLocationInfo ZP((char *hostname, char *tty));
176 Code_t ZSetLocation ZP((char *exposure));
177 Code_t ZUnsetLocation ZP((void));
178 Code_t ZFlushMyLocations ZP((void));
179 char *ZParseExposureLevel ZP((char *text));
180 Code_t ZFormatRawNotice ZP((ZNotice_t *, char**, int *));
181 Code_t ZRetrieveSubscriptions ZP((unsigned short, int*));
182 Code_t ZOpenPort ZP((unsigned short *port));
183 Code_t ZClosePort ZP((void));
184 Code_t ZFlushLocations ZP((void));
185 Code_t ZFlushSubscriptions ZP((void));
186 Code_t ZFreeNotice ZP((ZNotice_t *notice));
187 Code_t ZParseLocations ZP((register ZNotice_t *notice,
188                            register ZAsyncLocateData_t *zald, int *nlocs,
189                            char **user));
190 int ZCompareALDPred ZP((ZNotice_t *notice, void *zald));
191 void ZFreeALD ZP((register ZAsyncLocateData_t *zald));
192 Code_t ZCheckIfNotice ZP((ZNotice_t *notice, struct sockaddr_in *from,
193                           register int (*predicate) ZP((ZNotice_t *,void *)),
194                           void *args));
195 Code_t ZPeekPacket ZP((char **buffer, int *ret_len,
196                        struct sockaddr_in *from));
197 Code_t ZPeekNotice ZP((ZNotice_t *notice, struct sockaddr_in *from));
198 Code_t ZIfNotice ZP((ZNotice_t *notice, struct sockaddr_in *from,
199                      int (*predicate) ZP((ZNotice_t *, void *)), void *args));
200 Code_t ZSubscribeTo ZP((ZSubscription_t *sublist, int nitems,
201                         unsigned int port));
202 Code_t ZSubscribeToSansDefaults ZP((ZSubscription_t *sublist, int nitems,
203                                     unsigned int port));
204 Code_t ZUnsubscribeTo ZP((ZSubscription_t *sublist, int nitems,
205                           unsigned int port));
206 Code_t ZCancelSubscriptions ZP((unsigned int port));
207 int ZPending ZP((void));
208 Code_t ZReceiveNotice ZP((ZNotice_t *notice, struct sockaddr_in *from));
209 #ifdef Z_DEBUG
210 void Z_debug ZP((ZCONST char *, ...));
211 #endif
212
213 #undef ZP
214
215 /* Compatibility */
216 #define ZNewLocateUser ZLocateUser
217
218 /* Macros to retrieve Zephyr library values. */
219 extern int __Zephyr_fd;
220 extern int __Q_CompleteLength;
221 extern struct sockaddr_in __HM_addr;
222 extern char __Zephyr_realm[];
223 #define ZGetFD()        __Zephyr_fd
224 #define ZQLength()      __Q_CompleteLength
225 #define ZGetDestAddr()  __HM_addr
226 #define ZGetRealm()     __Zephyr_realm
227
228
229 #ifdef Z_DEBUG
230 void ZSetDebug ZP((void (*)(ZCONST char *, va_list, void *), void *));
231 #define ZSetDebug(proc,closure)    (__Z_debug_print=(proc), \
232                                     __Z_debug_print_closure=(closure), \
233                                     (void) 0)
234 #else
235 #define ZSetDebug(proc,closure)
236 #endif
237
238 /* Maximum queue length */
239 #define Z_MAXQLEN               30
240
241 /* Successful function return */
242 #define ZERR_NONE               0
243
244 /* Hostmanager wait time (in secs) */
245 #define HM_TIMEOUT              10
246
247 /* Server wait time (in secs) */
248 #define SRV_TIMEOUT             30
249
250 #define ZAUTH (ZMakeAuthentication)
251 #define ZNOAUTH ((Z_AuthProc)0)
252
253 /* Packet strings */
254 #define ZSRVACK_SENT            "SENT"  /* SERVACK codes */
255 #define ZSRVACK_NOTSENT         "LOST"
256 #define ZSRVACK_FAIL            "FAIL"
257
258 /* Server internal class */
259 #define ZEPHYR_ADMIN_CLASS      "ZEPHYR_ADMIN"  /* Class */
260
261 /* Control codes sent to a server */
262 #define ZEPHYR_CTL_CLASS        "ZEPHYR_CTL"    /* Class */
263
264 #define ZEPHYR_CTL_REALM        "REALM"         /* Inst: From realm */
265 #define REALM_ADD_SUBSCRIBE     "ADD_SUBSCRIBE" /* Opcode: Add subs */
266 #define REALM_REQ_SUBSCRIBE     "REQ_SUBSCRIBE" /* Opcode: Request subs */
267 #define REALM_SUBSCRIBE         "RLM_SUBSCRIBE" /* Opcode: Subscribe realm */
268 #define REALM_UNSUBSCRIBE       "RLM_UNSUBSCRIBE" /* Opcode: Unsub realm */
269
270 #define ZEPHYR_CTL_CLIENT       "CLIENT"        /* Inst: From client */
271 #define CLIENT_SUBSCRIBE        "SUBSCRIBE"     /* Opcode: Subscribe */
272 #define CLIENT_SUBSCRIBE_NODEFS "SUBSCRIBE_NODEFS"      /* Opcode: Subscribe */
273 #define CLIENT_UNSUBSCRIBE      "UNSUBSCRIBE"   /* Opcode: Unsubsubscribe */
274 #define CLIENT_CANCELSUB        "CLEARSUB"      /* Opcode: Clear all subs */
275 #define CLIENT_GIMMESUBS        "GIMME"         /* Opcode: Give me subs */
276 #define CLIENT_GIMMEDEFS        "GIMMEDEFS"     /* Opcode: Give me default
277                                                  * subscriptions */
278
279 #define ZEPHYR_CTL_HM           "HM"            /* Inst: From HM */
280 #define HM_BOOT                 "BOOT"          /* Opcode: Boot msg */
281 #define HM_FLUSH                "FLUSH"         /* Opcode: Flush me */
282 #define HM_DETACH               "DETACH"        /* Opcode: Detach me */
283 #define HM_ATTACH               "ATTACH"        /* Opcode: Attach me */
284
285 /* Control codes send to a HostManager */
286 #define HM_CTL_CLASS            "HM_CTL"        /* Class */
287
288 #define HM_CTL_SERVER           "SERVER"        /* Inst: From server */
289 #define SERVER_SHUTDOWN         "SHUTDOWN"      /* Opcode: Server shutdown */
290 #define SERVER_PING             "PING"          /* Opcode: PING */
291
292 #define HM_CTL_CLIENT           "CLIENT"        /* Inst: From client */
293 #define CLIENT_FLUSH            "FLUSH"         /* Opcode: Send flush to srv */
294 #define CLIENT_NEW_SERVER       "NEWSERV"       /* Opcode: Find new server */
295
296 /* HM Statistics */
297 #define HM_STAT_CLASS           "HM_STAT"       /* Class */
298
299 #define HM_STAT_CLIENT          "HMST_CLIENT"   /* Inst: From client */
300 #define HM_GIMMESTATS           "GIMMESTATS"    /* Opcode: get stats */
301
302 /* Login class messages */
303 #define LOGIN_CLASS             "LOGIN"         /* Class */
304
305 /* Class Instance is principal of user who is logging in or logging out */
306
307 #define EXPOSE_NONE             "NONE"          /* Opcode: Not visible */
308 #define EXPOSE_OPSTAFF          "OPSTAFF"       /* Opcode: Opstaff visible */
309 #define EXPOSE_REALMVIS         "REALM-VISIBLE" /* Opcode: Realm visible */
310 #define EXPOSE_REALMANN         "REALM-ANNOUNCED"/* Opcode: Realm announced */
311 #define EXPOSE_NETVIS           "NET-VISIBLE"   /* Opcode: Net visible */
312 #define EXPOSE_NETANN           "NET-ANNOUNCED" /* Opcode: Net announced */
313 #define LOGIN_USER_LOGIN        "USER_LOGIN"    /* Opcode: user login
314                                                    (from server) */
315 #define LOGIN_USER_LOGOUT       "USER_LOGOUT"   /* Opcode: User logout */
316 #define LOGIN_USER_FLUSH        "USER_FLUSH"    /* Opcode: flush all locs */
317
318 /* Locate class messages */
319 #define LOCATE_CLASS            "USER_LOCATE"   /* Class */
320
321 #define LOCATE_HIDE             "USER_HIDE"     /* Opcode: Hide me */
322 #define LOCATE_UNHIDE           "USER_UNHIDE"   /* Opcode: Unhide me */
323
324 /* Class Instance is principal of user to locate */
325 #define LOCATE_LOCATE           "LOCATE"        /* Opcode: Locate user */
326
327 /* WG_CTL class messages */
328 #define WG_CTL_CLASS            "WG_CTL"        /* Class */
329
330 #define WG_CTL_USER             "USER"          /* Inst: User request */
331 #define USER_REREAD             "REREAD"        /* Opcode: Reread desc file */
332 #define USER_SHUTDOWN           "SHUTDOWN"      /* Opcode: Go catatonic */
333 #define USER_STARTUP            "STARTUP"       /* Opcode: Come out of it */
334 #define USER_EXIT               "EXIT"          /* Opcode: Exit the client */
335
336 #endif /* __ZEPHYR_H__ */