mw_channel.h
Go to the documentation of this file.
/*
Meanwhile - Unofficial Lotus Sametime Community Client Library
Copyright (C) 2004 Christopher (siege) O'Brien
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _MW_CHANNEL_H
#define _MW_CHANNEL_H
#include <time.h>
#include "mw_common.h"
#ifdef __cplusplus
extern "C" {
#endif
/* place-holders */
struct mwCipherInstance;
struct mwMsgChannelAccept;
struct mwMsgChannelCreate;
struct mwMsgChannelDestroy;
struct mwMsgChannelSend;
struct mwService;
struct mwSession;
struct mwChannel;
struct mwChannelSet;
#define MW_MASTER_CHANNEL_ID 0x00000000
#define mwChannel_idIsOutgoing(id) \
(! (0x80000000 & (id)))
#define mwChannel_idIsIncoming(id) \
(! mwChannel_idIsOutgoing(id))
#define mwChannel_isOutgoing(chan) \
mwChannel_idIsOutgoing(mwChannel_getId(chan))
#define mwChannel_isIncoming(chan) \
mwChannel_idIsIncoming(mwChannel_getId(chan))
enum mwChannelState {
mwChannel_NEW,
mwChannel_INIT,
mwChannel_WAIT,
mwChannel_OPEN,
mwChannel_DESTROY,
mwChannel_ERROR,
mwChannel_UNKNOWN,
};
#define mwChannel_isState(chan, state) \
(mwChannel_getState(chan) == (state))
enum mwChannelStatField {
mwChannelStat_MSG_SENT,
mwChannelStat_MSG_RECV,
mwChannelStat_U_BYTES_SENT,
mwChannelStat_U_BYTES_RECV,
mwChannelStat_OPENED_AT,
mwChannelStat_CLOSED_AT,
};
enum mwEncryptPolicy {
mwEncrypt_NONE = 0x0000,
mwEncrypt_WHATEVER = 0x0001,
mwEncrypt_ALL = 0x0002,
mwEncrypt_RC2_40 = 0x1000,
mwEncrypt_RC2_128 = 0x2000,
};
struct mwChannelSet *mwChannelSet_new(struct mwSession *);
void mwChannelSet_free(struct mwChannelSet *);
struct mwChannel *mwChannel_newIncoming(struct mwChannelSet *, guint32 id);
struct mwChannel *mwChannel_newOutgoing(struct mwChannelSet *);
struct mwChannel *mwChannel_find(struct mwChannelSet *cs, guint32 chan);
guint32 mwChannel_getId(struct mwChannel *);
struct mwSession *mwChannel_getSession(struct mwChannel *);
guint32 mwChannel_getServiceId(struct mwChannel *);
struct mwService *mwChannel_getService(struct mwChannel *);
void mwChannel_setService(struct mwChannel *chan, struct mwService *srvc);
gpointer mwChannel_getServiceData(struct mwChannel *chan);
void mwChannel_setServiceData(struct mwChannel *chan,
gpointer data, GDestroyNotify clean);
void mwChannel_removeServiceData(struct mwChannel *chan);
guint32 mwChannel_getProtoType(struct mwChannel *chan);
void mwChannel_setProtoType(struct mwChannel *chan, guint32 proto_type);
guint32 mwChannel_getProtoVer(struct mwChannel *chan);
void mwChannel_setProtoVer(struct mwChannel *chan, guint32 proto_ver);
guint16 mwChannel_getEncryptPolicy(struct mwChannel *chan);
guint32 mwChannel_getOptions(struct mwChannel *chan);
void mwChannel_setOptions(struct mwChannel *chan, guint32 options);
struct mwLoginInfo *mwChannel_getUser(struct mwChannel *chan);
struct mwOpaque *mwChannel_getAddtlCreate(struct mwChannel *);
struct mwOpaque *mwChannel_getAddtlAccept(struct mwChannel *);
void mwChannel_populateSupportedCipherInstances(struct mwChannel *chan);
void mwChannel_addSupportedCipherInstance(struct mwChannel *chan,
struct mwCipherInstance *ci);
GList *mwChannel_getSupportedCipherInstances(struct mwChannel *chan);
void mwChannel_selectCipherInstance(struct mwChannel *chan,
struct mwCipherInstance *ci);
struct mwCipherInstance *
mwChannel_getCipherInstance(struct mwChannel *chan);
enum mwChannelState mwChannel_getState(struct mwChannel *);
gpointer mwChannel_getStatistic(struct mwChannel *chan,
enum mwChannelStatField stat);
int mwChannel_create(struct mwChannel *chan);
int mwChannel_accept(struct mwChannel *chan);
int mwChannel_destroy(struct mwChannel *chan, guint32 reason,
struct mwOpaque *data);
int mwChannel_send(struct mwChannel *chan, guint32 msg_type,
struct mwOpaque *msg);
int mwChannel_sendEncrypted(struct mwChannel *chan,
guint32 msg_type, struct mwOpaque *msg,
gboolean encrypt);
void mwChannel_recvCreate(struct mwChannel *chan,
struct mwMsgChannelCreate *msg);
void mwChannel_recvAccept(struct mwChannel *chan,
struct mwMsgChannelAccept *msg);
void mwChannel_recvDestroy(struct mwChannel *chan,
struct mwMsgChannelDestroy *msg);
void mwChannel_recv(struct mwChannel *chan, struct mwMsgChannelSend *msg);
#ifdef __cplusplus
}
#endif
#endif /* _MW_CHANNEL_H */
mwChannel_recvDestroy
void mwChannel_recvDestroy(struct mwChannel *chan, struct mwMsgChannelDestroy *msg)
pass a destroy message to a channel for handling
mwChannel_getService
struct mwService * mwChannel_getService(struct mwChannel *)
get the service for a channel.
mwChannel_recvCreate
void mwChannel_recvCreate(struct mwChannel *chan, struct mwMsgChannelCreate *msg)
pass a create message to a channel for handling
mwChannel_getId
guint32 mwChannel_getId(struct mwChannel *)
get the ID for a channel.
mwChannel_newIncoming
struct mwChannel * mwChannel_newIncoming(struct mwChannelSet *, guint32 id)
Create an incoming channel with the given channel id.
mwChannel_removeServiceData
void mwChannel_removeServiceData(struct mwChannel *chan)
mwChannelState
mwChannelState
channel status
Definition mw_channel.h:131
mwChannel_NEW
@ mwChannel_NEW
channel is newly allocated, in the pool
Definition mw_channel.h:132
mwChannel_UNKNOWN
@ mwChannel_UNKNOWN
unknown state, or error determining state
Definition mw_channel.h:138
mwChannel_ERROR
@ mwChannel_ERROR
channel is being destroyed due to error
Definition mw_channel.h:137
mwChannel_DESTROY
@ mwChannel_DESTROY
channel is being destroyed
Definition mw_channel.h:136
mwChannel_INIT
@ mwChannel_INIT
channel is being prepared, out of the pool
Definition mw_channel.h:133
mwChannel_OPEN
@ mwChannel_OPEN
channel is accepted and open
Definition mw_channel.h:135
mwChannel_WAIT
@ mwChannel_WAIT
channel is waiting for accept
Definition mw_channel.h:134
mwChannelSet_free
void mwChannelSet_free(struct mwChannelSet *)
Clear and deallocate a channel set.
mwChannel_getCipherInstance
struct mwCipherInstance * mwChannel_getCipherInstance(struct mwChannel *chan)
mwChannel_send
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.
mwChannelSet_new
struct mwChannelSet * mwChannelSet_new(struct mwSession *)
Allocate and initialize a channel set for a session.
mwChannel_recv
void mwChannel_recv(struct mwChannel *chan, struct mwMsgChannelSend *msg)
Feed data into a channel.
mwChannel_getAddtlAccept
struct mwOpaque * mwChannel_getAddtlAccept(struct mwChannel *)
direct reference to the accept addtl information for a channel
mwChannel_getStatistic
gpointer mwChannel_getStatistic(struct mwChannel *chan, enum mwChannelStatField stat)
obtain the value for a statistic field as a gpointer
mwChannel_getUser
struct mwLoginInfo * mwChannel_getUser(struct mwChannel *chan)
User at the other end of the channel.
mwChannel_getOptions
guint32 mwChannel_getOptions(struct mwChannel *chan)
mwChannel_setService
void mwChannel_setService(struct mwChannel *chan, struct mwService *srvc)
associate a channel with an owning service
mwChannel_getState
enum mwChannelState mwChannel_getState(struct mwChannel *)
get the state of a channel
mwChannel_addSupportedCipherInstance
void mwChannel_addSupportedCipherInstance(struct mwChannel *chan, struct mwCipherInstance *ci)
add a cipher instance to a channel's list of supported ciphers.
mwChannel_setProtoVer
void mwChannel_setProtoVer(struct mwChannel *chan, guint32 proto_ver)
mwChannel_getServiceId
guint32 mwChannel_getServiceId(struct mwChannel *)
get the ID of the service for a channel.
mwChannel_accept
int mwChannel_accept(struct mwChannel *chan)
Formally accept an incoming channel.
mwChannel_sendEncrypted
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...
mwChannel_getServiceData
gpointer mwChannel_getServiceData(struct mwChannel *chan)
get service-specific data.
mwChannel_getEncryptPolicy
guint16 mwChannel_getEncryptPolicy(struct mwChannel *chan)
Channel encryption policy.
mwChannel_getProtoVer
guint32 mwChannel_getProtoVer(struct mwChannel *chan)
mwChannel_selectCipherInstance
void mwChannel_selectCipherInstance(struct mwChannel *chan, struct mwCipherInstance *ci)
select a cipher instance for a channel.
mwChannel_getSupportedCipherInstances
GList * mwChannel_getSupportedCipherInstances(struct mwChannel *chan)
the list of supported ciphers for a channel.
mwChannel_create
int mwChannel_create(struct mwChannel *chan)
Formally open a channel.
mwChannel_getProtoType
guint32 mwChannel_getProtoType(struct mwChannel *chan)
mwChannel_getSession
struct mwSession * mwChannel_getSession(struct mwChannel *)
get the session for a channel.
mwChannel_destroy
int mwChannel_destroy(struct mwChannel *chan, guint32 reason, struct mwOpaque *data)
Destroy a channel.
mwChannel_find
struct mwChannel * mwChannel_find(struct mwChannelSet *cs, guint32 chan)
Obtain a reference to a channel by its id.
mwChannel_recvAccept
void mwChannel_recvAccept(struct mwChannel *chan, struct mwMsgChannelAccept *msg)
pass an accept message to a channel for handling
mwChannel_populateSupportedCipherInstances
void mwChannel_populateSupportedCipherInstances(struct mwChannel *chan)
automatically adds instances of all ciphers in the session to the list of supported ciphers for a cha...
mwChannel_setProtoType
void mwChannel_setProtoType(struct mwChannel *chan, guint32 proto_type)
mwChannel_setOptions
void mwChannel_setOptions(struct mwChannel *chan, guint32 options)
mwChannel_setServiceData
void mwChannel_setServiceData(struct mwChannel *chan, gpointer data, GDestroyNotify clean)
set service-specific data.
mwChannelStatField
mwChannelStatField
channel statistic fields.
Definition mw_channel.h:148
mwChannelStat_MSG_RECV
@ mwChannelStat_MSG_RECV
total send-on-chan messages received
Definition mw_channel.h:150
mwChannelStat_MSG_SENT
@ mwChannelStat_MSG_SENT
total send-on-chan messages sent
Definition mw_channel.h:149
mwChannelStat_U_BYTES_SENT
@ mwChannelStat_U_BYTES_SENT
total bytes sent, pre-encryption
Definition mw_channel.h:151
mwChannelStat_CLOSED_AT
@ mwChannelStat_CLOSED_AT
time when channel was closed
Definition mw_channel.h:154
mwChannelStat_U_BYTES_RECV
@ mwChannelStat_U_BYTES_RECV
total bytes received, post-decryption
Definition mw_channel.h:152
mwChannelStat_OPENED_AT
@ mwChannelStat_OPENED_AT
time when channel was opened
Definition mw_channel.h:153
mwEncryptPolicy
mwEncryptPolicy
Policy for a channel, dictating what sort of encryption should be used, if any, and when.
Definition mw_channel.h:163
mwEncrypt_WHATEVER
@ mwEncrypt_WHATEVER
encrypt whatever you want
Definition mw_channel.h:165
mwEncrypt_RC2_128
@ mwEncrypt_RC2_128
encrypt all, RC2/128 cipher
Definition mw_channel.h:168
mwEncrypt_ALL
@ mwEncrypt_ALL
encrypt all, any cipher
Definition mw_channel.h:166
mwEncrypt_NONE
@ mwEncrypt_NONE
encrypt none
Definition mw_channel.h:164
mwEncrypt_RC2_40
@ mwEncrypt_RC2_40
encrypt all, RC2/40 cipher
Definition mw_channel.h:167
mwChannel_newOutgoing
struct mwChannel * mwChannel_newOutgoing(struct mwChannelSet *)
Create an outgoing channel.
mwChannel_getAddtlCreate
struct mwOpaque * mwChannel_getAddtlCreate(struct mwChannel *)
direct reference to the create addtl information for a channel
mw_common.h
Common data types and functions for handling those types.
mwChannelSet
Collection of channels.
mwChannel
Represents a channel to a service.
mwCipherInstance
An instance of a cipher.
Definition mw_cipher.h:105
mwLoginInfo
Definition mw_common.h:123
mwMsgChannelAccept
Definition mw_message.h:210
mwMsgChannelCreate
Definition mw_message.h:183
mwMsgChannelDestroy
Definition mw_message.h:238
mwMsgChannelSend
Definition mw_message.h:224
mwOpaque
A length of binary data, not null-terminated.
Definition mw_common.h:79
mwService
A service is the recipient of sendOnCnl messages sent over channels marked with the corresponding ser...
Definition mw_service.h:123
mwSession
Represents a Sametime client session.