meanwhile 1.1.1
mw_channel.h
Go to the documentation of this file.
1
2/*
3 Meanwhile - Unofficial Lotus Sametime Community Client Library
4 Copyright (C) 2004 Christopher (siege) O'Brien
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public
17 License along with this library; if not, write to the Free
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19*/
20
21#ifndef _MW_CHANNEL_H
22#define _MW_CHANNEL_H
23
24
79#include <time.h>
80#include "mw_common.h"
81
82
83#ifdef __cplusplus
84extern "C" {
85#endif
86
87
88/* place-holders */
89struct mwCipherInstance;
93struct mwMsgChannelSend;
94struct mwService;
95struct mwSession;
96
97
98
101struct mwChannel;
102
103
106struct mwChannelSet;
107
108
110#define MW_MASTER_CHANNEL_ID 0x00000000
111
112
114#define mwChannel_idIsOutgoing(id) \
115 (! (0x80000000 & (id)))
116
118#define mwChannel_idIsIncoming(id) \
119 (! mwChannel_idIsOutgoing(id))
120
122#define mwChannel_isOutgoing(chan) \
123 mwChannel_idIsOutgoing(mwChannel_getId(chan))
124
126#define mwChannel_isIncoming(chan) \
127 mwChannel_idIsIncoming(mwChannel_getId(chan))
128
129
139};
140
141
142#define mwChannel_isState(chan, state) \
143 (mwChannel_getState(chan) == (state))
144
145
155};
156
157
164 mwEncrypt_NONE = 0x0000,
166 mwEncrypt_ALL = 0x0002,
169};
170
171
174
175
179
180
183struct mwChannel *mwChannel_newIncoming(struct mwChannelSet *, guint32 id);
184
185
189
190
193struct mwChannel *mwChannel_find(struct mwChannelSet *cs, guint32 chan);
194
195
198guint32 mwChannel_getId(struct mwChannel *);
199
200
203
204
208
209
213
214
216void mwChannel_setService(struct mwChannel *chan, struct mwService *srvc);
217
218
222gpointer mwChannel_getServiceData(struct mwChannel *chan);
223
224
229 gpointer data, GDestroyNotify clean);
230
231
233
234
235guint32 mwChannel_getProtoType(struct mwChannel *chan);
236
237
238void mwChannel_setProtoType(struct mwChannel *chan, guint32 proto_type);
239
240
241guint32 mwChannel_getProtoVer(struct mwChannel *chan);
242
243
244void mwChannel_setProtoVer(struct mwChannel *chan, guint32 proto_ver);
245
246
256
257
258guint32 mwChannel_getOptions(struct mwChannel *chan);
259
260
261void mwChannel_setOptions(struct mwChannel *chan, guint32 options);
262
263
267
268
271
272
275
276
280
281
285 struct mwCipherInstance *ci);
286
287
291
292
296 struct mwCipherInstance *ci);
297
298
299struct mwCipherInstance *
301
302
305
306
308gpointer mwChannel_getStatistic(struct mwChannel *chan,
309 enum mwChannelStatField stat);
310
311
322int mwChannel_create(struct mwChannel *chan);
323
324
328int mwChannel_accept(struct mwChannel *chan);
329
330
338int mwChannel_destroy(struct mwChannel *chan, guint32 reason,
339 struct mwOpaque *data);
340
341
344int mwChannel_send(struct mwChannel *chan, guint32 msg_type,
345 struct mwOpaque *msg);
346
347
351 guint32 msg_type, struct mwOpaque *msg,
352 gboolean encrypt);
353
354
357 struct mwMsgChannelCreate *msg);
358
359
362 struct mwMsgChannelAccept *msg);
363
364
367 struct mwMsgChannelDestroy *msg);
368
369
371void mwChannel_recv(struct mwChannel *chan, struct mwMsgChannelSend *msg);
372
373
374#ifdef __cplusplus
375}
376#endif
377
378
379#endif /* _MW_CHANNEL_H */
380
void mwChannel_recvDestroy(struct mwChannel *chan, struct mwMsgChannelDestroy *msg)
pass a destroy message to a channel for handling
struct mwService * mwChannel_getService(struct mwChannel *)
get the service for a channel.
void mwChannel_recvCreate(struct mwChannel *chan, struct mwMsgChannelCreate *msg)
pass a create message to a channel for handling
guint32 mwChannel_getId(struct mwChannel *)
get the ID for a channel.
struct mwChannel * mwChannel_newIncoming(struct mwChannelSet *, guint32 id)
Create an incoming channel with the given channel id.
void mwChannel_removeServiceData(struct mwChannel *chan)
mwChannelState
channel status
Definition: mw_channel.h:131
@ mwChannel_NEW
channel is newly allocated, in the pool
Definition: mw_channel.h:132
@ mwChannel_UNKNOWN
unknown state, or error determining state
Definition: mw_channel.h:138
@ mwChannel_ERROR
channel is being destroyed due to error
Definition: mw_channel.h:137
@ mwChannel_DESTROY
channel is being destroyed
Definition: mw_channel.h:136
@ mwChannel_INIT
channel is being prepared, out of the pool
Definition: mw_channel.h:133
@ mwChannel_OPEN
channel is accepted and open
Definition: mw_channel.h:135
@ mwChannel_WAIT
channel is waiting for accept
Definition: mw_channel.h:134
void mwChannelSet_free(struct mwChannelSet *)
Clear and deallocate a channel set.
struct mwCipherInstance * mwChannel_getCipherInstance(struct mwChannel *chan)
int mwChannel_send(struct mwChannel *chan, guint32 msg_type, struct mwOpaque *msg)
Compose a send-on-channel message, encrypt it as per the channel's specification, and send it.
struct mwChannelSet * mwChannelSet_new(struct mwSession *)
Allocate and initialize a channel set for a session.
void mwChannel_recv(struct mwChannel *chan, struct mwMsgChannelSend *msg)
Feed data into a channel.
struct mwOpaque * mwChannel_getAddtlAccept(struct mwChannel *)
direct reference to the accept addtl information for a channel
gpointer mwChannel_getStatistic(struct mwChannel *chan, enum mwChannelStatField stat)
obtain the value for a statistic field as a gpointer
struct mwLoginInfo * mwChannel_getUser(struct mwChannel *chan)
User at the other end of the channel.
guint32 mwChannel_getOptions(struct mwChannel *chan)
void mwChannel_setService(struct mwChannel *chan, struct mwService *srvc)
associate a channel with an owning service
enum mwChannelState mwChannel_getState(struct mwChannel *)
get the state of a channel
void mwChannel_addSupportedCipherInstance(struct mwChannel *chan, struct mwCipherInstance *ci)
add a cipher instance to a channel's list of supported ciphers.
void mwChannel_setProtoVer(struct mwChannel *chan, guint32 proto_ver)
guint32 mwChannel_getServiceId(struct mwChannel *)
get the ID of the service for a channel.
int mwChannel_accept(struct mwChannel *chan)
Formally accept an incoming channel.
int mwChannel_sendEncrypted(struct mwChannel *chan, guint32 msg_type, struct mwOpaque *msg, gboolean encrypt)
Compose a send-on-channel message, and if encrypt is TRUE, encrypt it as per the channel's specificat...
gpointer mwChannel_getServiceData(struct mwChannel *chan)
get service-specific data.
guint16 mwChannel_getEncryptPolicy(struct mwChannel *chan)
Channel encryption policy.
guint32 mwChannel_getProtoVer(struct mwChannel *chan)
void mwChannel_selectCipherInstance(struct mwChannel *chan, struct mwCipherInstance *ci)
select a cipher instance for a channel.
GList * mwChannel_getSupportedCipherInstances(struct mwChannel *chan)
the list of supported ciphers for a channel.
int mwChannel_create(struct mwChannel *chan)
Formally open a channel.
guint32 mwChannel_getProtoType(struct mwChannel *chan)
struct mwSession * mwChannel_getSession(struct mwChannel *)
get the session for a channel.
int mwChannel_destroy(struct mwChannel *chan, guint32 reason, struct mwOpaque *data)
Destroy a channel.
struct mwChannel * mwChannel_find(struct mwChannelSet *cs, guint32 chan)
Obtain a reference to a channel by its id.
void mwChannel_recvAccept(struct mwChannel *chan, struct mwMsgChannelAccept *msg)
pass an accept message to a channel for handling
void mwChannel_populateSupportedCipherInstances(struct mwChannel *chan)
automatically adds instances of all ciphers in the session to the list of supported ciphers for a cha...
void mwChannel_setProtoType(struct mwChannel *chan, guint32 proto_type)
void mwChannel_setOptions(struct mwChannel *chan, guint32 options)
void mwChannel_setServiceData(struct mwChannel *chan, gpointer data, GDestroyNotify clean)
set service-specific data.
mwChannelStatField
channel statistic fields.
Definition: mw_channel.h:148
@ mwChannelStat_MSG_RECV
total send-on-chan messages received
Definition: mw_channel.h:150
@ mwChannelStat_MSG_SENT
total send-on-chan messages sent
Definition: mw_channel.h:149
@ mwChannelStat_U_BYTES_SENT
total bytes sent, pre-encryption
Definition: mw_channel.h:151
@ mwChannelStat_CLOSED_AT
time when channel was closed
Definition: mw_channel.h:154
@ mwChannelStat_U_BYTES_RECV
total bytes received, post-decryption
Definition: mw_channel.h:152
@ mwChannelStat_OPENED_AT
time when channel was opened
Definition: mw_channel.h:153
mwEncryptPolicy
Policy for a channel, dictating what sort of encryption should be used, if any, and when.
Definition: mw_channel.h:163
@ mwEncrypt_WHATEVER
encrypt whatever you want
Definition: mw_channel.h:165
@ mwEncrypt_RC2_128
encrypt all, RC2/128 cipher
Definition: mw_channel.h:168
@ mwEncrypt_ALL
encrypt all, any cipher
Definition: mw_channel.h:166
@ mwEncrypt_NONE
encrypt none
Definition: mw_channel.h:164
@ mwEncrypt_RC2_40
encrypt all, RC2/40 cipher
Definition: mw_channel.h:167
struct mwChannel * mwChannel_newOutgoing(struct mwChannelSet *)
Create an outgoing channel.
struct mwOpaque * mwChannel_getAddtlCreate(struct mwChannel *)
direct reference to the create addtl information for a channel
Common data types and functions for handling those types.
Collection of channels.
Represents a channel to a service.
An instance of a cipher.
Definition: mw_cipher.h:105
Definition: mw_common.h:123
Definition: mw_message.h:210
Definition: mw_message.h:183
Definition: mw_message.h:238
Definition: mw_message.h:224
A length of binary data, not null-terminated.
Definition: mw_common.h:79
A service is the recipient of sendOnCnl messages sent over channels marked with the corresponding ser...
Definition: mw_service.h:123
Represents a Sametime client session.