]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - zephyr/h/zephyr/zephyr.h
add prototypes to slay warnings
[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 #include <stdarg.h>
26
27 /* Service names */
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"
34
35 #define ZVERSIONHDR     "ZEPH"
36 #define ZVERSIONMAJOR   0
37 #define ZVERSIONMINOR   2
38
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
43
44 /* Authentication levels returned by ZCheckAuthentication */
45 #define ZAUTH_FAILED            (-1)
46 #define ZAUTH_YES               1
47 #define ZAUTH_NO                0
48
49 typedef char ZPacket_t[Z_MAXPKTLEN];
50
51 /* Packet type */
52 typedef enum {
53     UNSAFE, UNACKED, ACKED, HMACK, HMCTL, SERVACK, SERVNAK, CLIENTACK, STAT
54 } ZNotice_Kind_t;
55 extern const char *ZNoticeKinds[9];
56
57 struct _ZTimeval {
58         int tv_sec;
59         int tv_usec;
60 };
61
62 /* Unique ID format */
63 typedef struct _ZUnique_Id_t {
64     struct      in_addr zuid_addr;
65     struct      _ZTimeval       tv;
66 } ZUnique_Id_t;
67
68 /* Checksum */
69 typedef unsigned int ZChecksum_t;
70
71 /* Notice definition */
72 typedef struct _ZNotice_t {
73     char                *z_packet;
74     char                *z_version;
75     ZNotice_Kind_t      z_kind;
76     ZUnique_Id_t        z_uid;
77 #define z_sender_addr   z_uid.zuid_addr
78     struct              _ZTimeval z_time;
79     unsigned short      z_port;
80     int                 z_auth;
81     int                 z_checked_auth;
82     int                 z_authent_len;
83     char                *z_ascii_authent;
84     char                *z_class;
85     char                *z_class_inst;
86     char                *z_opcode;
87     char                *z_sender;
88     char                *z_recipient;
89     char                *z_default_format;
90     char                *z_multinotice;
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];
96     caddr_t             z_message;
97     int                 z_message_len;
98 } ZNotice_t;
99
100 /* Subscription structure */
101 typedef struct _ZSubscriptions_t {
102     char        *zsub_recipient;
103     char        *zsub_class;
104     char        *zsub_classinst;
105 } ZSubscription_t;
106
107 /* Function return code */
108 typedef int Code_t;
109
110 /* Locations structure */
111 typedef struct _ZLocations_t {
112     char        *host;
113     char        *time;
114     char        *tty;
115 } ZLocations_t;
116
117 typedef struct _ZAsyncLocateData_t {
118     char                *user;
119     ZUnique_Id_t        uid;
120     char                *version;
121 } ZAsyncLocateData_t;
122
123 /* for ZSetDebug */
124 #ifdef Z_DEBUG
125 void (*__Z_debug_print)(const char *fmt, va_list args, void *closure);
126 void *__Z_debug_print_closure;
127 #endif
128
129 int ZCompareUIDPred(ZNotice_t *, void *);
130 int ZCompareMultiUIDPred(ZNotice_t *, void *);
131
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*);
137
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);
168 Code_t ZSetFD(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,
198                        char **user);
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 *),
203                       void *args);
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,
210                     unsigned int port);
211 Code_t ZSubscribeToSansDefaults(ZSubscription_t *sublist, int nitems,
212                                 unsigned int port);
213 Code_t ZUnsubscribeTo(ZSubscription_t *sublist, int nitems,
214                       unsigned int port);
215 Code_t ZCancelSubscriptions(unsigned int port);
216 int ZPending(void);
217 Code_t ZReceiveNotice(ZNotice_t *notice, struct sockaddr_in *from);
218 #ifdef Z_DEBUG
219 void Z_debug(const char *, ...);
220 #endif
221
222 /* Compatibility */
223 #define ZNewLocateUser ZLocateUser
224
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
234
235
236 #ifdef Z_DEBUG
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), \
240                                     (void) 0)
241 #else
242 #define ZSetDebug(proc,closure)
243 #endif
244
245 /* Maximum queue length */
246 #define Z_MAXQLEN               30
247
248 /* Successful function return */
249 #define ZERR_NONE               0
250
251 /* Hostmanager wait time (in secs) */
252 #define HM_TIMEOUT              10
253
254 /* Server wait time (in secs) */
255 #define SRV_TIMEOUT             30
256
257 #define ZAUTH (ZMakeAuthentication)
258 #define ZCAUTH (ZMakeZcodeAuthentication)
259 #define ZNOAUTH ((Z_AuthProc)0)
260
261 /* Packet strings */
262 #define ZSRVACK_SENT            "SENT"  /* SERVACK codes */
263 #define ZSRVACK_NOTSENT         "LOST"
264 #define ZSRVACK_FAIL            "FAIL"
265
266 /* Server internal class */
267 #define ZEPHYR_ADMIN_CLASS      "ZEPHYR_ADMIN"  /* Class */
268
269 /* Control codes sent to a server */
270 #define ZEPHYR_CTL_CLASS        "ZEPHYR_CTL"    /* Class */
271
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 */
277
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
285                                                  * subscriptions */
286
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 */
292
293 /* Control codes send to a HostManager */
294 #define HM_CTL_CLASS            "HM_CTL"        /* Class */
295
296 #define HM_CTL_SERVER           "SERVER"        /* Inst: From server */
297 #define SERVER_SHUTDOWN         "SHUTDOWN"      /* Opcode: Server shutdown */
298 #define SERVER_PING             "PING"          /* Opcode: PING */
299
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 */
303
304 /* HM Statistics */
305 #define HM_STAT_CLASS           "HM_STAT"       /* Class */
306
307 #define HM_STAT_CLIENT          "HMST_CLIENT"   /* Inst: From client */
308 #define HM_GIMMESTATS           "GIMMESTATS"    /* Opcode: get stats */
309
310 /* Login class messages */
311 #define LOGIN_CLASS             "LOGIN"         /* Class */
312
313 /* Class Instance is principal of user who is logging in or logging out */
314
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
322                                                    (from server) */
323 #define LOGIN_USER_LOGOUT       "USER_LOGOUT"   /* Opcode: User logout */
324 #define LOGIN_USER_FLUSH        "USER_FLUSH"    /* Opcode: flush all locs */
325
326 /* Locate class messages */
327 #define LOCATE_CLASS            "USER_LOCATE"   /* Class */
328
329 #define LOCATE_HIDE             "USER_HIDE"     /* Opcode: Hide me */
330 #define LOCATE_UNHIDE           "USER_UNHIDE"   /* Opcode: Unhide me */
331
332 /* Class Instance is principal of user to locate */
333 #define LOCATE_LOCATE           "LOCATE"        /* Opcode: Locate user */
334
335 /* WG_CTL class messages */
336 #define WG_CTL_CLASS            "WG_CTL"        /* Class */
337
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 */
343
344 #endif /* __ZEPHYR_H__ */