1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains global definitions
4 * Created by: Robert French
6 * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of
7 * Technology. For copying and distribution information, see the
8 * file "mit-copyright.h".
11 #ifndef PURPLE_ZEPHYR_ZEPHYR_INTERNAL_H
12 #define PURPLE_ZEPHYR_ZEPHYR_INTERNAL_H
18 #include <sys/types.h>
21 #include <zephyr_err.h>
23 #ifndef IPPROTO_MAX /* Make sure not already included */
25 #include <netinet/in.h>
32 /* this really should be uint32_t */
33 /*typedef unsigned int in_addr_t;
42 #define HM_SVCNAME "zephyr-hm"
43 #define HM_SRV_SVCNAME "zephyr-hm-srv"
44 #define SERVER_SVCNAME "zephyr-clt"
45 #define SERVER_SERVICE "zephyr"
46 #define SERVER_INSTANCE "zephyr"
48 #define ZVERSIONHDR "ZEPH"
49 #define ZVERSIONMAJOR 0
50 #define ZVERSIONMINOR 2
52 #define Z_MAXPKTLEN 1024
53 #define Z_MAXHEADERLEN 800
54 #define Z_MAXOTHERFIELDS 10 /* Max unknown fields in ZNotice_t */
55 #define Z_NUMFIELDS 17
57 /* Authentication levels returned by ZCheckAuthentication */
58 #define ZAUTH_FAILED (-1)
62 typedef char ZPacket_t
[Z_MAXPKTLEN
];
66 UNSAFE
, UNACKED
, ACKED
, HMACK
, HMCTL
, SERVACK
, SERVNAK
, CLIENTACK
, STAT
68 extern const char *ZNoticeKinds
[9];
70 /* Unique ID format */
72 struct in_addr zuid_addr
;
77 typedef unsigned long ZChecksum_t
;
79 /* Notice definition */
83 ZNotice_Kind_t z_kind
;
85 #define z_sender_addr z_uid.zuid_addr
86 struct timeval z_time
;
87 unsigned short z_port
;
91 char *z_ascii_authent
;
93 const char *z_class_inst
;
96 const char *z_recipient
;
97 char *z_default_format
;
99 ZUnique_Id_t z_multiuid
;
100 ZChecksum_t z_checksum
;
101 int z_num_other_fields
;
102 char *z_other_fields
[Z_MAXOTHERFIELDS
];
107 /* Subscription structure */
109 char *zsub_recipient
;
111 char *zsub_classinst
;
114 /* Function return code */
117 /* Locations structure */
128 } ZAsyncLocateData_t
;
132 void (*__Z_debug_print
)(const char *fmt
, va_list args
, void *closure
);
133 void *__Z_debug_print_closure
;
136 int ZCompareUIDPred(ZNotice_t
*, void *);
137 int ZCompareMultiUIDPred(ZNotice_t
*, void *);
139 /* Defines for ZFormatNotice, et al. */
140 typedef Code_t (*Z_AuthProc
)(ZNotice_t
*, char *, int, int *);
141 Code_t
ZMakeAuthentication(ZNotice_t
*, char *, int, int *);
143 char *ZGetSender(void);
144 const gchar
*ZGetVariable(const gchar
*);
145 Code_t
ZSetVariable(char *var
, char *value
);
146 Code_t
ZUnsetVariable(char *var
);
147 int ZGetWGPort(void);
148 Code_t
ZSetDestAddr(struct sockaddr_in
*);
149 Code_t
ZFormatNoticeList(ZNotice_t
*, char **, int, char **, int *, Z_AuthProc
);
150 Code_t
ZParseNotice(char *, int, ZNotice_t
*);
151 Code_t
ZReadAscii(char *, int, unsigned char *, int);
152 Code_t
ZReadAscii32(char *, int, unsigned long *);
153 Code_t
ZReadAscii16(char *, int, unsigned short *);
154 Code_t
ZSendPacket(char *, int, int);
155 Code_t
ZSendList(ZNotice_t
*, char *[], int, Z_AuthProc
);
156 Code_t
ZSrvSendList(ZNotice_t
*, char *[], int, Z_AuthProc
, Code_t (*)());
157 Code_t
ZSendNotice(ZNotice_t
*, Z_AuthProc
);
158 Code_t
ZSrvSendNotice(ZNotice_t
*, Z_AuthProc
, Code_t (*)());
159 Code_t
ZFormatNotice(ZNotice_t
*, char **, int *, Z_AuthProc
);
160 Code_t
ZFormatSmallNotice(ZNotice_t
*, ZPacket_t
, int *, Z_AuthProc
);
161 Code_t
ZFormatRawNoticeList(ZNotice_t
*notice
, char *list
[], int nitems
,
162 char **buffer
, int *ret_len
);
163 Code_t
ZLocateUser(char *, int *, Z_AuthProc
);
164 Code_t
ZRequestLocations(const char *, ZAsyncLocateData_t
*, ZNotice_Kind_t
,
166 Code_t
ZhmStat(struct in_addr
*, ZNotice_t
*);
167 Code_t
ZInitialize(void);
168 Code_t
ZSetServerState(int);
170 Code_t
ZFormatSmallRawNotice(ZNotice_t
*, ZPacket_t
, int *);
171 int ZCompareUID(ZUnique_Id_t
*, ZUnique_Id_t
*);
172 Code_t
ZMakeAscii(char *, int, unsigned char *, int);
173 Code_t
ZMakeAscii32(char *, int, unsigned long);
174 Code_t
ZMakeAscii16(char *, int, unsigned int);
175 Code_t
ZReceivePacket(ZPacket_t
, int *, struct sockaddr_in
*);
176 Code_t
ZCheckAuthentication(ZNotice_t
*, struct sockaddr_in
*);
177 Code_t
ZSetLocation(char *exposure
);
178 Code_t
ZUnsetLocation(void);
179 Code_t
ZFlushMyLocations(void);
180 Code_t
ZFormatRawNotice(ZNotice_t
*, char **, int *);
181 Code_t
ZRetrieveSubscriptions(unsigned short, int *);
182 Code_t
ZOpenPort(unsigned short *port
);
183 Code_t
ZClosePort(void);
184 Code_t
ZFlushLocations(void);
185 Code_t
ZFlushSubscriptions(void);
186 Code_t
ZFreeNotice(ZNotice_t
*notice
);
187 Code_t
ZParseLocations(register ZNotice_t
*notice
,
188 register ZAsyncLocateData_t
*zald
, int *nlocs
,
190 int ZCompareALDPred(ZNotice_t
*notice
, void *zald
);
191 void ZFreeALD(register ZAsyncLocateData_t
*zald
);
192 Code_t
ZCheckIfNotice(ZNotice_t
*notice
, struct sockaddr_in
*from
,
193 register int (*predicate
)(ZNotice_t
*, void *),
195 Code_t
ZPeekPacket(char **buffer
, int *ret_len
, struct sockaddr_in
*from
);
196 Code_t
ZPeekNotice(ZNotice_t
*notice
, struct sockaddr_in
*from
);
197 Code_t
ZIfNotice(ZNotice_t
*notice
, struct sockaddr_in
*from
,
198 int (*predicate
)(ZNotice_t
*, void *), void *args
);
199 Code_t
ZSubscribeTo(ZSubscription_t
*sublist
, int nitems
, unsigned int port
);
200 Code_t
ZSubscribeToSansDefaults(ZSubscription_t
*sublist
, int nitems
,
202 Code_t
ZUnsubscribeTo(ZSubscription_t
*sublist
, int nitems
, unsigned int port
);
203 Code_t
ZCancelSubscriptions(unsigned int port
);
205 Code_t
ZReceiveNotice(ZNotice_t
*notice
, struct sockaddr_in
*from
);
207 void Z_debug(const char *, ...);
211 #define ZNewLocateUser ZLocateUser
213 /* Macros to retrieve Zephyr library values. */
214 extern int __Zephyr_fd
;
215 extern int __Q_CompleteLength
;
216 extern struct sockaddr_in __HM_addr
;
217 extern char __Zephyr_realm
[];
218 #define ZGetFD() __Zephyr_fd
219 #define ZQLength() __Q_CompleteLength
220 #define ZGetDestAddr() __HM_addr
221 #define ZGetRealm() __Zephyr_realm
224 void ZSetDebug(void (*)(const char *, va_list, void *), void *);
225 #define ZSetDebug(proc,closure) (__Z_debug_print=(proc), \
226 __Z_debug_print_closure=(closure), \
229 #define ZSetDebug(proc,closure)
232 /* Maximum queue length */
235 /* Successful function return */
238 /* Hostmanager wait time (in secs) */
241 /* Server wait time (in secs) */
242 #define SRV_TIMEOUT 30
244 #define ZAUTH (ZMakeAuthentication)
245 #define ZNOAUTH ((Z_AuthProc)0)
248 #define ZSRVACK_SENT "SENT" /* SERVACK codes */
249 #define ZSRVACK_NOTSENT "LOST"
250 #define ZSRVACK_FAIL "FAIL"
252 /* Server internal class */
253 #define ZEPHYR_ADMIN_CLASS "ZEPHYR_ADMIN" /* Class */
255 /* Control codes sent to a server */
256 #define ZEPHYR_CTL_CLASS "ZEPHYR_CTL" /* Class */
258 #define ZEPHYR_CTL_CLIENT "CLIENT" /* Inst: From client */
259 #define CLIENT_SUBSCRIBE "SUBSCRIBE" /* Opcode: Subscribe */
260 #define CLIENT_SUBSCRIBE_NODEFS "SUBSCRIBE_NODEFS" /* Opcode: Subscribe */
261 #define CLIENT_UNSUBSCRIBE "UNSUBSCRIBE" /* Opcode: Unsubsubscribe */
262 #define CLIENT_CANCELSUB "CLEARSUB" /* Opcode: Clear all subs */
263 #define CLIENT_GIMMESUBS "GIMME" /* Opcode: Give me subs */
264 #define CLIENT_GIMMEDEFS "GIMMEDEFS" /* Opcode: Give me default
267 #define ZEPHYR_CTL_HM "HM" /* Inst: From HM */
268 #define HM_BOOT "BOOT" /* Opcode: Boot msg */
269 #define HM_FLUSH "FLUSH" /* Opcode: Flush me */
270 #define HM_DETACH "DETACH" /* Opcode: Detach me */
271 #define HM_ATTACH "ATTACH" /* Opcode: Attach me */
273 /* Control codes send to a HostManager */
274 #define HM_CTL_CLASS "HM_CTL" /* Class */
276 #define HM_CTL_SERVER "SERVER" /* Inst: From server */
277 #define SERVER_SHUTDOWN "SHUTDOWN" /* Opcode: Server shutdown */
278 #define SERVER_PING "PING" /* Opcode: PING */
280 #define HM_CTL_CLIENT "CLIENT" /* Inst: From client */
281 #define CLIENT_FLUSH "FLUSH" /* Opcode: Send flush to srv */
282 #define CLIENT_NEW_SERVER "NEWSERV" /* Opcode: Find new server */
285 #define HM_STAT_CLASS "HM_STAT" /* Class */
287 #define HM_STAT_CLIENT "HMST_CLIENT" /* Inst: From client */
288 #define HM_GIMMESTATS "GIMMESTATS" /* Opcode: get stats */
290 /* Login class messages */
291 #define LOGIN_CLASS "LOGIN" /* Class */
293 /* Class Instance is principal of user who is logging in or logging out */
295 #define EXPOSE_NONE "NONE" /* Opcode: Not visible */
296 #define EXPOSE_OPSTAFF "OPSTAFF" /* Opcode: Opstaff visible */
297 #define EXPOSE_REALMVIS "REALM-VISIBLE" /* Opcode: Realm visible */
298 #define EXPOSE_REALMANN "REALM-ANNOUNCED"/* Opcode: Realm announced */
299 #define EXPOSE_NETVIS "NET-VISIBLE" /* Opcode: Net visible */
300 #define EXPOSE_NETANN "NET-ANNOUNCED" /* Opcode: Net announced */
301 #define LOGIN_USER_LOGIN "USER_LOGIN" /* Opcode: user login
303 #define LOGIN_USER_LOGOUT "USER_LOGOUT" /* Opcode: User logout */
304 #define LOGIN_USER_FLUSH "USER_FLUSH" /* Opcode: flush all locs */
306 /* Locate class messages */
307 #define LOCATE_CLASS "USER_LOCATE" /* Class */
309 #define LOCATE_HIDE "USER_HIDE" /* Opcode: Hide me */
310 #define LOCATE_UNHIDE "USER_UNHIDE" /* Opcode: Unhide me */
312 /* Class Instance is principal of user to locate */
313 #define LOCATE_LOCATE "LOCATE" /* Opcode: Locate user */
315 /* WG_CTL class messages */
316 #define WG_CTL_CLASS "WG_CTL" /* Class */
318 #define WG_CTL_USER "USER" /* Inst: User request */
319 #define USER_REREAD "REREAD" /* Opcode: Reread desc file */
320 #define USER_SHUTDOWN "SHUTDOWN" /* Opcode: Go catatonic */
321 #define USER_STARTUP "STARTUP" /* Opcode: Come out of it */
322 #define USER_EXIT "EXIT" /* Opcode: Exit the client */
324 #endif /* PURPLE_ZEPHYR_ZEPHYR_INTERNAL_H */