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