Mercurial > pidgin
annotate src/protocols/zephyr/zephyr.h @ 13967:99b9b58b19dd
[gaim-migrate @ 16523]
Fix a crazy MSN crash. Basically it's possible to have more than one
slplink associated with a given switchboard, but our code did not
allow for that. I think it happens when you're in a multi-user
chat and you do stuff with multiple users that involves slplinks.
Like maybe file transfer and buddy icon related stuff.
Tracking this down took an ungodly amount of time, but thanks to
Meebo for letting me do it :-)
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 20 Jul 2006 07:31:15 +0000 |
parents | 7c2e2c4d45a4 |
children |
rev | line source |
---|---|
2086 | 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 <sys/types.h> | |
17 #include <sys/time.h> | |
18 | |
10867 | 19 #include <zephyr_err.h> |
2086 | 20 |
21 #ifndef IPPROTO_MAX /* Make sure not already included */ | |
10867 | 22 #ifndef WIN32 |
2086 | 23 #include <netinet/in.h> |
24 #endif | |
10867 | 25 #endif |
2086 | 26 |
27 /* Use __STDC__ to guess whether we can use stdarg, prototypes, and const. | |
28 * This is a public header file, so autoconf can't help us here. */ | |
29 #ifdef __STDC__ | |
30 # include <stdarg.h> | |
31 # define ZP(x) x | |
32 # define ZCONST const | |
33 #else | |
34 # define ZP(x) () | |
35 # define ZCONST | |
36 #endif | |
37 | |
10867 | 38 #ifdef WIN32 |
39 /* this really should be uint32_t */ | |
40 /*typedef unsigned int in_addr_t; | |
41 struct in_addr | |
42 { | |
43 in_addr_t s_addr; | |
44 }; */ | |
45 #include <winsock2.h> | |
46 #endif | |
47 | |
2086 | 48 /* Service names */ |
49 #define HM_SVCNAME "zephyr-hm" | |
50 #define HM_SRV_SVCNAME "zephyr-hm-srv" | |
51 #define SERVER_SVCNAME "zephyr-clt" | |
52 #define SERVER_SERVICE "zephyr" | |
53 #define SERVER_INSTANCE "zephyr" | |
54 | |
55 #define ZVERSIONHDR "ZEPH" | |
56 #define ZVERSIONMAJOR 0 | |
57 #define ZVERSIONMINOR 2 | |
58 | |
59 #define Z_MAXPKTLEN 1024 | |
60 #define Z_MAXHEADERLEN 800 | |
61 #define Z_MAXOTHERFIELDS 10 /* Max unknown fields in ZNotice_t */ | |
62 #define Z_NUMFIELDS 17 | |
63 | |
64 /* Authentication levels returned by ZCheckAuthentication */ | |
65 #define ZAUTH_FAILED (-1) | |
66 #define ZAUTH_YES 1 | |
67 #define ZAUTH_NO 0 | |
68 | |
69 typedef char ZPacket_t[Z_MAXPKTLEN]; | |
70 | |
71 /* Packet type */ | |
72 typedef enum { | |
73 UNSAFE, UNACKED, ACKED, HMACK, HMCTL, SERVACK, SERVNAK, CLIENTACK, STAT | |
74 } ZNotice_Kind_t; | |
75 extern ZCONST char *ZNoticeKinds[9]; | |
76 | |
77 /* Unique ID format */ | |
78 typedef struct _ZUnique_Id_t { | |
79 struct in_addr zuid_addr; | |
80 struct timeval tv; | |
81 } ZUnique_Id_t; | |
82 | |
83 /* Checksum */ | |
84 typedef unsigned long ZChecksum_t; | |
85 | |
86 /* Notice definition */ | |
87 typedef struct _ZNotice_t { | |
88 char *z_packet; | |
89 char *z_version; | |
90 ZNotice_Kind_t z_kind; | |
91 ZUnique_Id_t z_uid; | |
92 #define z_sender_addr z_uid.zuid_addr | |
93 struct timeval z_time; | |
94 unsigned short z_port; | |
95 int z_auth; | |
96 int z_checked_auth; | |
97 int z_authent_len; | |
98 char *z_ascii_authent; | |
99 char *z_class; | |
12424
7c2e2c4d45a4
[gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents:
11105
diff
changeset
|
100 const char *z_class_inst; |
2086 | 101 char *z_opcode; |
102 char *z_sender; | |
5136 | 103 const char *z_recipient; |
2086 | 104 char *z_default_format; |
105 char *z_multinotice; | |
106 ZUnique_Id_t z_multiuid; | |
107 ZChecksum_t z_checksum; | |
108 int z_num_other_fields; | |
109 char *z_other_fields[Z_MAXOTHERFIELDS]; | |
7475 | 110 void *z_message; |
2086 | 111 int z_message_len; |
112 } ZNotice_t; | |
113 | |
114 /* Subscription structure */ | |
115 typedef struct _ZSubscriptions_t { | |
116 char *zsub_recipient; | |
117 char *zsub_class; | |
118 char *zsub_classinst; | |
119 } ZSubscription_t; | |
120 | |
121 /* Function return code */ | |
122 typedef int Code_t; | |
123 | |
124 /* Locations structure */ | |
125 typedef struct _ZLocations_t { | |
126 char *host; | |
127 char *time; | |
128 char *tty; | |
129 } ZLocations_t; | |
130 | |
131 typedef struct _ZAsyncLocateData_t { | |
132 char *user; | |
133 ZUnique_Id_t uid; | |
134 char *version; | |
135 } ZAsyncLocateData_t; | |
136 | |
137 /* for ZSetDebug */ | |
138 #ifdef Z_DEBUG | |
139 void (*__Z_debug_print) ZP((ZCONST char *fmt, va_list args, void *closure)); | |
140 void *__Z_debug_print_closure; | |
141 #endif | |
142 | |
143 int ZCompareUIDPred ZP((ZNotice_t *, void *)); | |
144 int ZCompareMultiUIDPred ZP((ZNotice_t *, void *)); | |
145 | |
146 /* Defines for ZFormatNotice, et al. */ | |
147 typedef Code_t (*Z_AuthProc) ZP((ZNotice_t*, char *, int, int *)); | |
148 Code_t ZMakeAuthentication ZP((ZNotice_t*, char *,int, int*)); | |
149 | |
150 char *ZGetSender ZP((void)); | |
151 char *ZGetVariable ZP((char *)); | |
152 Code_t ZSetVariable ZP((char *var, char *value)); | |
153 Code_t ZUnsetVariable ZP((char *var)); | |
154 int ZGetWGPort ZP((void)); | |
155 Code_t ZSetDestAddr ZP((struct sockaddr_in *)); | |
156 Code_t ZFormatNoticeList ZP((ZNotice_t*, char**, int, | |
157 char **, int*, Z_AuthProc)); | |
158 Code_t ZParseNotice ZP((char*, int, ZNotice_t *)); | |
159 Code_t ZReadAscii ZP((char*, int, unsigned char*, int)); | |
160 Code_t ZReadAscii32 ZP((char *, int, unsigned long *)); | |
161 Code_t ZReadAscii16 ZP((char *, int, unsigned short *)); | |
162 Code_t ZSendPacket ZP((char*, int, int)); | |
163 Code_t ZSendList ZP((ZNotice_t*, char *[], int, Z_AuthProc)); | |
164 Code_t ZSrvSendList ZP((ZNotice_t*, char*[], int, Z_AuthProc, Code_t (*)())); | |
165 Code_t ZSendNotice ZP((ZNotice_t *, Z_AuthProc)); | |
166 Code_t ZSrvSendNotice ZP((ZNotice_t*, Z_AuthProc, Code_t (*)())); | |
167 Code_t ZFormatNotice ZP((ZNotice_t*, char**, int*, Z_AuthProc)); | |
168 Code_t ZFormatSmallNotice ZP((ZNotice_t*, ZPacket_t, int*, Z_AuthProc)); | |
169 Code_t ZFormatRawNoticeList ZP((ZNotice_t *notice, char *list[], int nitems, | |
170 char **buffer, int *ret_len)); | |
171 Code_t ZLocateUser ZP((char *, int *, Z_AuthProc)); | |
7261 | 172 Code_t ZRequestLocations ZP((const char *, ZAsyncLocateData_t *, |
2086 | 173 ZNotice_Kind_t, Z_AuthProc)); |
2419
7ba69b8e0de5
[gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
174 Code_t ZhmStat ZP((struct in_addr *, ZNotice_t *)); |
2086 | 175 Code_t ZInitialize ZP((void)); |
176 Code_t ZSetServerState ZP((int)); | |
177 Code_t ZSetFD ZP((int)); | |
178 Code_t ZFormatSmallRawNotice ZP((ZNotice_t*, ZPacket_t, int*)); | |
179 int ZCompareUID ZP((ZUnique_Id_t*, ZUnique_Id_t*)); | |
180 Code_t ZMakeAscii ZP((char*, int, unsigned char*, int)); | |
181 Code_t ZMakeAscii32 ZP((char *, int, unsigned long)); | |
182 Code_t ZMakeAscii16 ZP((char *, int, unsigned int)); | |
183 Code_t ZReceivePacket ZP((ZPacket_t, int*, struct sockaddr_in*)); | |
184 Code_t ZCheckAuthentication ZP((ZNotice_t*, struct sockaddr_in*)); | |
2419
7ba69b8e0de5
[gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
185 Code_t ZSetLocation ZP((char *exposure)); |
7ba69b8e0de5
[gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
186 Code_t ZUnsetLocation ZP((void)); |
2086 | 187 Code_t ZFlushMyLocations ZP((void)); |
188 Code_t ZFormatRawNotice ZP((ZNotice_t *, char**, int *)); | |
189 Code_t ZRetrieveSubscriptions ZP((unsigned short, int*)); | |
190 Code_t ZOpenPort ZP((unsigned short *port)); | |
191 Code_t ZClosePort ZP((void)); | |
192 Code_t ZFlushLocations ZP((void)); | |
193 Code_t ZFlushSubscriptions ZP((void)); | |
194 Code_t ZFreeNotice ZP((ZNotice_t *notice)); | |
195 Code_t ZParseLocations ZP((register ZNotice_t *notice, | |
196 register ZAsyncLocateData_t *zald, int *nlocs, | |
197 char **user)); | |
198 int ZCompareALDPred ZP((ZNotice_t *notice, void *zald)); | |
199 void ZFreeALD ZP((register ZAsyncLocateData_t *zald)); | |
200 Code_t ZCheckIfNotice ZP((ZNotice_t *notice, struct sockaddr_in *from, | |
201 register int (*predicate) ZP((ZNotice_t *,void *)), | |
202 void *args)); | |
203 Code_t ZPeekPacket ZP((char **buffer, int *ret_len, | |
204 struct sockaddr_in *from)); | |
205 Code_t ZPeekNotice ZP((ZNotice_t *notice, struct sockaddr_in *from)); | |
206 Code_t ZIfNotice ZP((ZNotice_t *notice, struct sockaddr_in *from, | |
207 int (*predicate) ZP((ZNotice_t *, void *)), void *args)); | |
208 Code_t ZSubscribeTo ZP((ZSubscription_t *sublist, int nitems, | |
209 unsigned int port)); | |
210 Code_t ZSubscribeToSansDefaults ZP((ZSubscription_t *sublist, int nitems, | |
211 unsigned int port)); | |
212 Code_t ZUnsubscribeTo ZP((ZSubscription_t *sublist, int nitems, | |
213 unsigned int port)); | |
214 Code_t ZCancelSubscriptions ZP((unsigned int port)); | |
215 int ZPending ZP((void)); | |
216 Code_t ZReceiveNotice ZP((ZNotice_t *notice, struct sockaddr_in *from)); | |
217 #ifdef Z_DEBUG | |
218 void Z_debug ZP((ZCONST char *, ...)); | |
219 #endif | |
220 | |
221 #undef ZP | |
222 | |
223 /* Compatibility */ | |
224 #define ZNewLocateUser ZLocateUser | |
225 | |
226 /* Macros to retrieve Zephyr library values. */ | |
227 extern int __Zephyr_fd; | |
228 extern int __Q_CompleteLength; | |
229 extern struct sockaddr_in __HM_addr; | |
230 extern char __Zephyr_realm[]; | |
231 #define ZGetFD() __Zephyr_fd | |
232 #define ZQLength() __Q_CompleteLength | |
233 #define ZGetDestAddr() __HM_addr | |
234 #define ZGetRealm() __Zephyr_realm | |
235 | |
236 #ifdef Z_DEBUG | |
237 void ZSetDebug ZP((void (*)(ZCONST 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) */ | |
10867 | 252 #define HM_TIMEOUT 1 |
2086 | 253 |
254 /* Server wait time (in secs) */ | |
255 #define SRV_TIMEOUT 30 | |
256 | |
257 #define ZAUTH (ZMakeAuthentication) | |
258 #define ZNOAUTH ((Z_AuthProc)0) | |
259 | |
260 /* Packet strings */ | |
261 #define ZSRVACK_SENT "SENT" /* SERVACK codes */ | |
262 #define ZSRVACK_NOTSENT "LOST" | |
263 #define ZSRVACK_FAIL "FAIL" | |
264 | |
265 /* Server internal class */ | |
266 #define ZEPHYR_ADMIN_CLASS "ZEPHYR_ADMIN" /* Class */ | |
267 | |
268 /* Control codes sent to a server */ | |
269 #define ZEPHYR_CTL_CLASS "ZEPHYR_CTL" /* Class */ | |
270 | |
271 #define ZEPHYR_CTL_CLIENT "CLIENT" /* Inst: From client */ | |
272 #define CLIENT_SUBSCRIBE "SUBSCRIBE" /* Opcode: Subscribe */ | |
273 #define CLIENT_SUBSCRIBE_NODEFS "SUBSCRIBE_NODEFS" /* Opcode: Subscribe */ | |
274 #define CLIENT_UNSUBSCRIBE "UNSUBSCRIBE" /* Opcode: Unsubsubscribe */ | |
275 #define CLIENT_CANCELSUB "CLEARSUB" /* Opcode: Clear all subs */ | |
276 #define CLIENT_GIMMESUBS "GIMME" /* Opcode: Give me subs */ | |
277 #define CLIENT_GIMMEDEFS "GIMMEDEFS" /* Opcode: Give me default | |
278 * subscriptions */ | |
279 | |
280 #define ZEPHYR_CTL_HM "HM" /* Inst: From HM */ | |
281 #define HM_BOOT "BOOT" /* Opcode: Boot msg */ | |
282 #define HM_FLUSH "FLUSH" /* Opcode: Flush me */ | |
283 #define HM_DETACH "DETACH" /* Opcode: Detach me */ | |
284 #define HM_ATTACH "ATTACH" /* Opcode: Attach me */ | |
285 | |
286 /* Control codes send to a HostManager */ | |
287 #define HM_CTL_CLASS "HM_CTL" /* Class */ | |
288 | |
289 #define HM_CTL_SERVER "SERVER" /* Inst: From server */ | |
290 #define SERVER_SHUTDOWN "SHUTDOWN" /* Opcode: Server shutdown */ | |
291 #define SERVER_PING "PING" /* Opcode: PING */ | |
292 | |
293 #define HM_CTL_CLIENT "CLIENT" /* Inst: From client */ | |
294 #define CLIENT_FLUSH "FLUSH" /* Opcode: Send flush to srv */ | |
295 #define CLIENT_NEW_SERVER "NEWSERV" /* Opcode: Find new server */ | |
296 | |
297 /* HM Statistics */ | |
298 #define HM_STAT_CLASS "HM_STAT" /* Class */ | |
299 | |
300 #define HM_STAT_CLIENT "HMST_CLIENT" /* Inst: From client */ | |
301 #define HM_GIMMESTATS "GIMMESTATS" /* Opcode: get stats */ | |
302 | |
303 /* Login class messages */ | |
304 #define LOGIN_CLASS "LOGIN" /* Class */ | |
305 | |
306 /* Class Instance is principal of user who is logging in or logging out */ | |
307 | |
308 #define EXPOSE_NONE "NONE" /* Opcode: Not visible */ | |
309 #define EXPOSE_OPSTAFF "OPSTAFF" /* Opcode: Opstaff visible */ | |
310 #define EXPOSE_REALMVIS "REALM-VISIBLE" /* Opcode: Realm visible */ | |
311 #define EXPOSE_REALMANN "REALM-ANNOUNCED"/* Opcode: Realm announced */ | |
312 #define EXPOSE_NETVIS "NET-VISIBLE" /* Opcode: Net visible */ | |
313 #define EXPOSE_NETANN "NET-ANNOUNCED" /* Opcode: Net announced */ | |
314 #define LOGIN_USER_LOGIN "USER_LOGIN" /* Opcode: user login | |
315 (from server) */ | |
316 #define LOGIN_USER_LOGOUT "USER_LOGOUT" /* Opcode: User logout */ | |
317 #define LOGIN_USER_FLUSH "USER_FLUSH" /* Opcode: flush all locs */ | |
318 | |
319 /* Locate class messages */ | |
320 #define LOCATE_CLASS "USER_LOCATE" /* Class */ | |
321 | |
322 #define LOCATE_HIDE "USER_HIDE" /* Opcode: Hide me */ | |
323 #define LOCATE_UNHIDE "USER_UNHIDE" /* Opcode: Unhide me */ | |
324 | |
325 /* Class Instance is principal of user to locate */ | |
326 #define LOCATE_LOCATE "LOCATE" /* Opcode: Locate user */ | |
327 | |
328 /* WG_CTL class messages */ | |
329 #define WG_CTL_CLASS "WG_CTL" /* Class */ | |
330 | |
331 #define WG_CTL_USER "USER" /* Inst: User request */ | |
332 #define USER_REREAD "REREAD" /* Opcode: Reread desc file */ | |
333 #define USER_SHUTDOWN "SHUTDOWN" /* Opcode: Go catatonic */ | |
334 #define USER_STARTUP "STARTUP" /* Opcode: Come out of it */ | |
2419
7ba69b8e0de5
[gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
335 #define USER_EXIT "EXIT" /* Opcode: Exit the client */ |
2086 | 336 |
337 #endif /* __ZEPHYR_H__ */ |