00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _MW_MESSAGE_H
00022 #define _MW_MESSAGE_H
00023
00024
00025 #include <glib/glist.h>
00026 #include "mw_common.h"
00027
00028
00031 #define MW_MESSAGE(msg) (&msg->head)
00032
00033
00035 enum mwMessageType {
00036 mwMessage_HANDSHAKE = 0x0000,
00037 mwMessage_HANDSHAKE_ACK = 0x8000,
00038 mwMessage_LOGIN = 0x0001,
00039 mwMessage_LOGIN_ACK = 0x8001,
00040 mwMessage_LOGIN_REDIRECT = 0x0018,
00041 mwMessage_LOGIN_CONTINUE = 0x0016,
00043 mwMessage_CHANNEL_CREATE = 0x0002,
00044 mwMessage_CHANNEL_DESTROY = 0x0003,
00045 mwMessage_CHANNEL_SEND = 0x0004,
00046 mwMessage_CHANNEL_ACCEPT = 0x0006,
00048 mwMessage_SET_USER_STATUS = 0x0009,
00049 mwMessage_SET_PRIVACY_LIST = 0x000b,
00050 mwMessage_SENSE_SERVICE = 0x0011,
00051 mwMessage_ADMIN = 0x0019,
00052 mwMessage_ANNOUNCE = 0x0022,
00053 };
00054
00055
00056 enum mwMessageOption {
00057 mwMessageOption_ENCRYPT = 0x4000,
00058 mwMessageOption_HAS_ATTRIBS = 0x8000,
00059 };
00060
00061
00063 #define MW_MESSAGE_HAS_OPTION(msg, opt) \
00064 ((msg)->options & (opt))
00065
00066
00067 struct mwMessage {
00068 guint16 type;
00069 guint16 options;
00070 guint32 channel;
00071 struct mwOpaque attribs;
00072 };
00073
00074
00075
00077 struct mwMessage *mwMessage_new(enum mwMessageType type);
00078
00079
00081 struct mwMessage *mwMessage_get(struct mwGetBuffer *b);
00082
00083
00084 void mwMessage_put(struct mwPutBuffer *b, struct mwMessage *msg);
00085
00086
00087 void mwMessage_free(struct mwMessage *msg);
00088
00089
00090
00091
00092
00093
00094 struct mwMsgHandshake {
00095 struct mwMessage head;
00096 guint16 major;
00097 guint16 minor;
00098 guint32 srvrcalc_addr;
00099 guint16 login_type;
00100 guint32 loclcalc_addr;
00101 guint16 unknown_a;
00102 guint32 unknown_b;
00103 char *local_host;
00104 };
00105
00106
00107
00108
00109 struct mwMsgHandshakeAck {
00110 struct mwMessage head;
00111 guint16 major;
00112 guint16 minor;
00113 guint32 srvrcalc_addr;
00114 guint32 magic;
00115 struct mwOpaque data;
00116 };
00117
00118
00119
00120
00121 enum mwAuthType {
00122 mwAuthType_PLAIN = 0x0000,
00123 mwAuthType_TOKEN = 0x0001,
00124 mwAuthType_ENCRYPT = 0x0002,
00125 mwAuthType_RC2_40 = 0x0002,
00126 mwAuthType_RC2_128 = 0x0004,
00127 };
00128
00129
00130
00131
00132 struct mwMsgLogin {
00133 struct mwMessage head;
00134 guint16 login_type;
00135 char *name;
00136 guint16 auth_type;
00137 struct mwOpaque auth_data;
00138 };
00139
00140
00141
00142
00143 struct mwMsgLoginAck {
00144 struct mwMessage head;
00145 struct mwLoginInfo login;
00146 struct mwPrivacyInfo privacy;
00147 struct mwUserStatus status;
00148 };
00149
00150
00151
00152
00153 struct mwMsgLoginContinue {
00154 struct mwMessage head;
00155 };
00156
00157
00158
00159
00160 struct mwMsgLoginRedirect {
00161 struct mwMessage head;
00162 char *host;
00163 char *server_id;
00164 };
00165
00166
00167
00168
00170 struct mwEncryptOffer {
00171 guint16 mode;
00172 GList *items;
00173 guint16 extra;
00174 gboolean flag;
00175 };
00176
00177
00178 struct mwMsgChannelCreate {
00179 struct mwMessage head;
00180 guint32 reserved;
00181 guint32 channel;
00182 struct mwIdBlock target;
00183 guint32 service;
00184 guint32 proto_type;
00185 guint32 proto_ver;
00186 guint32 options;
00187 struct mwOpaque addtl;
00188 gboolean creator_flag;
00189 struct mwLoginInfo creator;
00190 struct mwEncryptOffer encrypt;
00191 };
00192
00193
00194
00195
00197 struct mwEncryptAccept {
00198 guint16 mode;
00199 struct mwEncryptItem *item;
00200 guint16 extra;
00201 gboolean flag;
00202 };
00203
00204
00205 struct mwMsgChannelAccept {
00206 struct mwMessage head;
00207 guint32 service;
00208 guint32 proto_type;
00209 guint32 proto_ver;
00210 struct mwOpaque addtl;
00211 gboolean acceptor_flag;
00212 struct mwLoginInfo acceptor;
00213 struct mwEncryptAccept encrypt;
00214 };
00215
00216
00217
00218
00219 struct mwMsgChannelSend {
00220 struct mwMessage head;
00221
00224 guint16 type;
00225
00227 struct mwOpaque data;
00228 };
00229
00230
00231
00232
00233 struct mwMsgChannelDestroy {
00234 struct mwMessage head;
00235 guint32 reason;
00236 struct mwOpaque data;
00237 };
00238
00239
00240
00241
00242 struct mwMsgSetUserStatus {
00243 struct mwMessage head;
00244 struct mwUserStatus status;
00245 };
00246
00247
00248
00249
00250 struct mwMsgSetPrivacyList {
00251 struct mwMessage head;
00252 struct mwPrivacyInfo privacy;
00253 };
00254
00255
00256
00257
00261 struct mwMsgSenseService {
00262 struct mwMessage head;
00263 guint32 service;
00264 };
00265
00266
00267
00268
00270 struct mwMsgAdmin {
00271 struct mwMessage head;
00272 char *text;
00273 };
00274
00275
00276
00277
00279 struct mwMsgAnnounce {
00280 struct mwMessage head;
00281 gboolean sender_present;
00282 struct mwLoginInfo sender;
00283 guint16 unknown_a;
00284 gboolean may_reply;
00285 char *text;
00290 GList *recipients;
00291 };
00292
00293
00294 #endif
00295