| 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 * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of |
|
| 7 * Technology. For copying and distribution information, see the |
|
| 8 * file "mit-copyright.h". |
|
| 9 */ |
|
| 10 |
|
| 11 #ifndef __ZEPHYR_H__ |
|
| 12 #define __ZEPHYR_H__ |
|
| 13 |
|
| 14 #include <config.h> |
|
| 15 |
|
| 16 #include <glib.h> |
|
| 17 |
|
| 18 #include <sys/types.h> |
|
| 19 #include <sys/time.h> |
|
| 20 |
|
| 21 #include <zephyr_err.h> |
|
| 22 |
|
| 23 #ifndef IPPROTO_MAX /* Make sure not already included */ |
|
| 24 #ifndef WIN32 |
|
| 25 #include <netinet/in.h> |
|
| 26 #endif |
|
| 27 #endif |
|
| 28 |
|
| 29 /* Use __STDC__ to guess whether we can use stdarg, prototypes, and const. |
|
| 30 * This is a public header file, so autoconf can't help us here. */ |
|
| 31 #ifdef __STDC__ |
|
| 32 # include <stdarg.h> |
|
| 33 # define ZP(x) x |
|
| 34 # define ZCONST const |
|
| 35 #else |
|
| 36 # define ZP(x) () |
|
| 37 # define ZCONST |
|
| 38 #endif |
|
| 39 |
|
| 40 #ifdef WIN32 |
|
| 41 /* this really should be uint32_t */ |
|
| 42 /*typedef unsigned int in_addr_t; |
|
| 43 struct in_addr |
|
| 44 { |
|
| 45 in_addr_t s_addr; |
|
| 46 }; */ |
|
| 47 #include <winsock2.h> |
|
| 48 #endif |
|
| 49 |
|
| 50 /* Service names */ |
|
| 51 #define HM_SVCNAME "zephyr-hm" |
|
| 52 #define HM_SRV_SVCNAME "zephyr-hm-srv" |
|
| 53 #define SERVER_SVCNAME "zephyr-clt" |
|
| 54 #define SERVER_SERVICE "zephyr" |
|
| 55 #define SERVER_INSTANCE "zephyr" |
|
| 56 |
|
| 57 #define ZVERSIONHDR "ZEPH" |
|
| 58 #define ZVERSIONMAJOR 0 |
|
| 59 #define ZVERSIONMINOR 2 |
|
| 60 |
|
| 61 #define Z_MAXPKTLEN 1024 |
|
| 62 #define Z_MAXHEADERLEN 800 |
|
| 63 #define Z_MAXOTHERFIELDS 10 /* Max unknown fields in ZNotice_t */ |
|
| 64 #define Z_NUMFIELDS 17 |
|
| 65 |
|
| 66 /* Authentication levels returned by ZCheckAuthentication */ |
|
| 67 #define ZAUTH_FAILED (-1) |
|
| 68 #define ZAUTH_YES 1 |
|
| 69 #define ZAUTH_NO 0 |
|
| 70 |
|
| 71 typedef char ZPacket_t[Z_MAXPKTLEN]; |
|
| 72 |
|
| 73 /* Packet type */ |
|
| 74 typedef enum { |
|
| 75 UNSAFE, UNACKED, ACKED, HMACK, HMCTL, SERVACK, SERVNAK, CLIENTACK, STAT |
|
| 76 } ZNotice_Kind_t; |
|
| 77 extern ZCONST char *ZNoticeKinds[9]; |
|
| 78 |
|
| 79 /* Unique ID format */ |
|
| 80 typedef struct _ZUnique_Id_t { |
|
| 81 struct in_addr zuid_addr; |
|
| 82 struct timeval tv; |
|
| 83 } ZUnique_Id_t; |
|
| 84 |
|
| 85 /* Checksum */ |
|
| 86 typedef unsigned long ZChecksum_t; |
|
| 87 |
|
| 88 /* Notice definition */ |
|
| 89 typedef struct _ZNotice_t { |
|
| 90 char *z_packet; |
|
| 91 char *z_version; |
|
| 92 ZNotice_Kind_t z_kind; |
|
| 93 ZUnique_Id_t z_uid; |
|
| 94 #define z_sender_addr z_uid.zuid_addr |
|
| 95 struct timeval z_time; |
|
| 96 unsigned short z_port; |
|
| 97 int z_auth; |
|
| 98 int z_checked_auth; |
|
| 99 int z_authent_len; |
|
| 100 char *z_ascii_authent; |
|
| 101 char *z_class; |
|
| 102 const char *z_class_inst; |
|
| 103 char *z_opcode; |
|
| 104 char *z_sender; |
|
| 105 const char *z_recipient; |
|
| 106 char *z_default_format; |
|
| 107 char *z_multinotice; |
|
| 108 ZUnique_Id_t z_multiuid; |
|
| 109 ZChecksum_t z_checksum; |
|
| 110 int z_num_other_fields; |
|
| 111 char *z_other_fields[Z_MAXOTHERFIELDS]; |
|
| 112 caddr_t z_message; |
|
| 113 int z_message_len; |
|
| 114 } ZNotice_t; |
|
| 115 |
|
| 116 /* Subscription structure */ |
|
| 117 typedef struct _ZSubscriptions_t { |
|
| 118 char *zsub_recipient; |
|
| 119 char *zsub_class; |
|
| 120 char *zsub_classinst; |
|
| 121 } ZSubscription_t; |
|
| 122 |
|
| 123 /* Function return code */ |
|
| 124 typedef int Code_t; |
|
| 125 |
|
| 126 /* Locations structure */ |
|
| 127 typedef struct _ZLocations_t { |
|
| 128 char *host; |
|
| 129 char *time; |
|
| 130 char *tty; |
|
| 131 } ZLocations_t; |
|
| 132 |
|
| 133 typedef struct _ZAsyncLocateData_t { |
|
| 134 char *user; |
|
| 135 ZUnique_Id_t uid; |
|
| 136 char *version; |
|
| 137 } ZAsyncLocateData_t; |
|
| 138 |
|
| 139 /* for ZSetDebug */ |
|
| 140 #ifdef Z_DEBUG |
|
| 141 void (*__Z_debug_print) ZP((ZCONST char *fmt, va_list args, void *closure)); |
|
| 142 void *__Z_debug_print_closure; |
|
| 143 #endif |
|
| 144 |
|
| 145 int ZCompareUIDPred ZP((ZNotice_t *, void *)); |
|
| 146 int ZCompareMultiUIDPred ZP((ZNotice_t *, void *)); |
|
| 147 |
|
| 148 /* Defines for ZFormatNotice, et al. */ |
|
| 149 typedef Code_t (*Z_AuthProc) ZP((ZNotice_t*, char *, int, int *)); |
|
| 150 typedef Code_t (*Z_SendProc) ZP((ZNotice_t *, char *, int, int)); |
|
| 151 Code_t ZMakeAuthentication ZP((ZNotice_t*, char *,int, int*)); |
|
| 152 |
|
| 153 char *ZGetSender ZP((void)); |
|
| 154 char *ZGetVariable ZP((char *)); |
|
| 155 Code_t ZSetVariable ZP((char *var, char *value)); |
|
| 156 Code_t ZUnsetVariable ZP((char *var)); |
|
| 157 int ZGetWGPort ZP((void)); |
|
| 158 Code_t ZSetDestAddr ZP((struct sockaddr_in *)); |
|
| 159 Code_t ZFormatNoticeList ZP((ZNotice_t*, char**, int, |
|
| 160 char **, int*, Z_AuthProc)); |
|
| 161 Code_t ZParseNotice ZP((char*, int, ZNotice_t *)); |
|
| 162 Code_t ZReadAscii ZP((char*, int, unsigned char*, int)); |
|
| 163 Code_t ZReadAscii32 ZP((char *, int, unsigned long *)); |
|
| 164 Code_t ZReadAscii16 ZP((char *, int, unsigned short *)); |
|
| 165 Code_t ZSendPacket ZP((char*, int, int)); |
|
| 166 Code_t ZSendList ZP((ZNotice_t*, char *[], int, Z_AuthProc)); |
|
| 167 Code_t ZSrvSendList ZP((ZNotice_t*, char*[], int, Z_AuthProc, Z_SendProc)); |
|
| 168 Code_t ZSendNotice ZP((ZNotice_t *, Z_AuthProc)); |
|
| 169 Code_t ZSrvSendNotice ZP((ZNotice_t*, Z_AuthProc, Z_SendProc)); |
|
| 170 Code_t ZFormatNotice ZP((ZNotice_t*, char**, int*, Z_AuthProc)); |
|
| 171 Code_t ZFormatSmallNotice ZP((ZNotice_t*, ZPacket_t, int*, Z_AuthProc)); |
|
| 172 Code_t ZFormatRawNoticeList ZP((ZNotice_t *notice, char *list[], int nitems, |
|
| 173 char **buffer, int *ret_len)); |
|
| 174 Code_t ZLocateUser ZP((char *, int *, Z_AuthProc)); |
|
| 175 Code_t ZRequestLocations ZP((const char *, ZAsyncLocateData_t *, |
|
| 176 ZNotice_Kind_t, Z_AuthProc)); |
|
| 177 Code_t ZhmStat ZP((struct in_addr *, ZNotice_t *)); |
|
| 178 Code_t ZInitialize ZP((void)); |
|
| 179 Code_t ZSetServerState ZP((int)); |
|
| 180 Code_t ZSetFD ZP((int)); |
|
| 181 Code_t ZFormatSmallRawNotice ZP((ZNotice_t*, ZPacket_t, int*)); |
|
| 182 int ZCompareUID ZP((ZUnique_Id_t*, ZUnique_Id_t*)); |
|
| 183 Code_t ZMakeAscii ZP((char*, int, unsigned char*, int)); |
|
| 184 Code_t ZMakeAscii32 ZP((char *, int, unsigned long)); |
|
| 185 Code_t ZMakeAscii16 ZP((char *, int, unsigned int)); |
|
| 186 Code_t ZReceivePacket ZP((ZPacket_t, int*, struct sockaddr_in*)); |
|
| 187 Code_t ZCheckAuthentication ZP((ZNotice_t*, struct sockaddr_in*)); |
|
| 188 Code_t ZSetLocation ZP((char *exposure)); |
|
| 189 Code_t ZUnsetLocation ZP((void)); |
|
| 190 Code_t ZFlushMyLocations ZP((void)); |
|
| 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 #ifdef Z_DEBUG |
|
| 240 void ZSetDebug ZP((void (*)(ZCONST char *, va_list, void *), void *)); |
|
| 241 #define ZSetDebug(proc,closure) (__Z_debug_print=(proc), \ |
|
| 242 __Z_debug_print_closure=(closure), \ |
|
| 243 (void) 0) |
|
| 244 #else |
|
| 245 #define ZSetDebug(proc,closure) |
|
| 246 #endif |
|
| 247 |
|
| 248 /* Maximum queue length */ |
|
| 249 #define Z_MAXQLEN 30 |
|
| 250 |
|
| 251 /* Successful function return */ |
|
| 252 #define ZERR_NONE 0 |
|
| 253 |
|
| 254 /* Hostmanager wait time (in secs) */ |
|
| 255 #define HM_TIMEOUT 1 |
|
| 256 |
|
| 257 /* Server wait time (in secs) */ |
|
| 258 #define SRV_TIMEOUT 30 |
|
| 259 |
|
| 260 #define ZAUTH (ZMakeAuthentication) |
|
| 261 #define ZNOAUTH ((Z_AuthProc)0) |
|
| 262 |
|
| 263 /* Packet strings */ |
|
| 264 #define ZSRVACK_SENT "SENT" /* SERVACK codes */ |
|
| 265 #define ZSRVACK_NOTSENT "LOST" |
|
| 266 #define ZSRVACK_FAIL "FAIL" |
|
| 267 |
|
| 268 /* Server internal class */ |
|
| 269 #define ZEPHYR_ADMIN_CLASS "ZEPHYR_ADMIN" /* Class */ |
|
| 270 |
|
| 271 /* Control codes sent to a server */ |
|
| 272 #define ZEPHYR_CTL_CLASS "ZEPHYR_CTL" /* Class */ |
|
| 273 |
|
| 274 #define ZEPHYR_CTL_CLIENT "CLIENT" /* Inst: From client */ |
|
| 275 #define CLIENT_SUBSCRIBE "SUBSCRIBE" /* Opcode: Subscribe */ |
|
| 276 #define CLIENT_SUBSCRIBE_NODEFS "SUBSCRIBE_NODEFS" /* Opcode: Subscribe */ |
|
| 277 #define CLIENT_UNSUBSCRIBE "UNSUBSCRIBE" /* Opcode: Unsubsubscribe */ |
|
| 278 #define CLIENT_CANCELSUB "CLEARSUB" /* Opcode: Clear all subs */ |
|
| 279 #define CLIENT_GIMMESUBS "GIMME" /* Opcode: Give me subs */ |
|
| 280 #define CLIENT_GIMMEDEFS "GIMMEDEFS" /* Opcode: Give me default |
|
| 281 * subscriptions */ |
|
| 282 |
|
| 283 #define ZEPHYR_CTL_HM "HM" /* Inst: From HM */ |
|
| 284 #define HM_BOOT "BOOT" /* Opcode: Boot msg */ |
|
| 285 #define HM_FLUSH "FLUSH" /* Opcode: Flush me */ |
|
| 286 #define HM_DETACH "DETACH" /* Opcode: Detach me */ |
|
| 287 #define HM_ATTACH "ATTACH" /* Opcode: Attach me */ |
|
| 288 |
|
| 289 /* Control codes send to a HostManager */ |
|
| 290 #define HM_CTL_CLASS "HM_CTL" /* Class */ |
|
| 291 |
|
| 292 #define HM_CTL_SERVER "SERVER" /* Inst: From server */ |
|
| 293 #define SERVER_SHUTDOWN "SHUTDOWN" /* Opcode: Server shutdown */ |
|
| 294 #define SERVER_PING "PING" /* Opcode: PING */ |
|
| 295 |
|
| 296 #define HM_CTL_CLIENT "CLIENT" /* Inst: From client */ |
|
| 297 #define CLIENT_FLUSH "FLUSH" /* Opcode: Send flush to srv */ |
|
| 298 #define CLIENT_NEW_SERVER "NEWSERV" /* Opcode: Find new server */ |
|
| 299 |
|
| 300 /* HM Statistics */ |
|
| 301 #define HM_STAT_CLASS "HM_STAT" /* Class */ |
|
| 302 |
|
| 303 #define HM_STAT_CLIENT "HMST_CLIENT" /* Inst: From client */ |
|
| 304 #define HM_GIMMESTATS "GIMMESTATS" /* Opcode: get stats */ |
|
| 305 |
|
| 306 /* Login class messages */ |
|
| 307 #define LOGIN_CLASS "LOGIN" /* Class */ |
|
| 308 |
|
| 309 /* Class Instance is principal of user who is logging in or logging out */ |
|
| 310 |
|
| 311 #define EXPOSE_NONE "NONE" /* Opcode: Not visible */ |
|
| 312 #define EXPOSE_OPSTAFF "OPSTAFF" /* Opcode: Opstaff visible */ |
|
| 313 #define EXPOSE_REALMVIS "REALM-VISIBLE" /* Opcode: Realm visible */ |
|
| 314 #define EXPOSE_REALMANN "REALM-ANNOUNCED"/* Opcode: Realm announced */ |
|
| 315 #define EXPOSE_NETVIS "NET-VISIBLE" /* Opcode: Net visible */ |
|
| 316 #define EXPOSE_NETANN "NET-ANNOUNCED" /* Opcode: Net announced */ |
|
| 317 #define LOGIN_USER_LOGIN "USER_LOGIN" /* Opcode: user login |
|
| 318 (from server) */ |
|
| 319 #define LOGIN_USER_LOGOUT "USER_LOGOUT" /* Opcode: User logout */ |
|
| 320 #define LOGIN_USER_FLUSH "USER_FLUSH" /* Opcode: flush all locs */ |
|
| 321 |
|
| 322 /* Locate class messages */ |
|
| 323 #define LOCATE_CLASS "USER_LOCATE" /* Class */ |
|
| 324 |
|
| 325 #define LOCATE_HIDE "USER_HIDE" /* Opcode: Hide me */ |
|
| 326 #define LOCATE_UNHIDE "USER_UNHIDE" /* Opcode: Unhide me */ |
|
| 327 |
|
| 328 /* Class Instance is principal of user to locate */ |
|
| 329 #define LOCATE_LOCATE "LOCATE" /* Opcode: Locate user */ |
|
| 330 |
|
| 331 /* WG_CTL class messages */ |
|
| 332 #define WG_CTL_CLASS "WG_CTL" /* Class */ |
|
| 333 |
|
| 334 #define WG_CTL_USER "USER" /* Inst: User request */ |
|
| 335 #define USER_REREAD "REREAD" /* Opcode: Reread desc file */ |
|
| 336 #define USER_SHUTDOWN "SHUTDOWN" /* Opcode: Go catatonic */ |
|
| 337 #define USER_STARTUP "STARTUP" /* Opcode: Come out of it */ |
|
| 338 #define USER_EXIT "EXIT" /* Opcode: Exit the client */ |
|
| 339 |
|
| 340 #endif /* __ZEPHYR_H__ */ |
|