5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 1997 - 2005 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
20 /****h* silccore/SILC Channel Interface
24 * Implementations of the Channel Payload and Channel Key Payload. The
25 * Channel Payload represents new channel and is used to distribute the
26 * information of the new channel. The Channel Key Payload is used to
27 * distribute a new key to the channel. It is done for example every
28 * time someone joins a channel or the old key expires.
35 #include "silcdlist.h"
37 /****s* silccore/SilcChannelAPI/SilcChannelPayload
41 * typedef struct SilcChannelPayloadStruct *SilcChannelPayload;
45 * This context is the actual Channel Payload and is allocated
46 * by silc_channel_payload_parse and given as argument usually to
47 * all silc_channel_payload_* functions. It is freed by the
48 * silc_channel_payload_free function.
51 typedef struct SilcChannelPayloadStruct *SilcChannelPayload;
53 /****s* silccore/SilcChannelAPI/SilcChannelKeyPayload
57 * typedef struct SilcChannelKeyPayloadStruct *SilcChannelKeyPayload;
61 * This context is the actual Channel Key Payload and is allocated
62 * by silc_channel_key_payload_parse and given as argument usually to
63 * all silc_channel_key_payload_* functions. It is freed by the
64 * silc_channel_key_payload_free function.
67 typedef struct SilcChannelKeyPayloadStruct *SilcChannelKeyPayload;
71 /****f* silccore/SilcChannelAPI/silc_channel_payload_parse
76 * silc_channel_payload_parse(const unsigned char *payload,
77 * SilcUInt32 payload_len);
81 * Parses channel payload returning new channel payload structure. The
82 * `buffer' is the raw payload buffer.
85 SilcChannelPayload silc_channel_payload_parse(const unsigned char *payload,
86 SilcUInt32 payload_len);
88 /****f* silccore/SilcChannelAPI/silc_channel_payload_parse_list
93 * silc_channel_payload_parse_list(const unsigned char *payload,
94 * SilcUInt32 payload_len);
98 * Parses list of channel payloads returning list of payloads. This
99 * is equivalent to the silc_channel_payload_parse except that the `buffer'
100 * now includes multiple Channel Payloads one after the other.
103 SilcDList silc_channel_payload_parse_list(const unsigned char *payload,
104 SilcUInt32 payload_len);
106 /****f* silccore/SilcChannelAPI/silc_channel_payload_encode
110 * SilcBuffer silc_channel_payload_encode(const unsigned char *channel_name,
111 * SilcUInt16 channel_name_len,
112 * const unsigned char *channel_id,
113 * SilcUInt32 channel_id_len,
118 * Encode new channel payload and returns it as buffer.
121 SilcBuffer silc_channel_payload_encode(const unsigned char *channel_name,
122 SilcUInt16 channel_name_len,
123 const unsigned char *channel_id,
124 SilcUInt32 channel_id_len,
127 /****f* silccore/SilcChannelAPI/silc_channel_payload_free
131 * void silc_channel_payload_free(SilcChannelPayload payload);
135 * Frees Channel Payload and all data in it.
138 void silc_channel_payload_free(SilcChannelPayload payload);
140 /****f* silccore/SilcChannelAPI/silc_channel_payload_list_free
144 * void silc_channel_payload_list_free(SilcDList list);
148 * Frees list of Channel Payloads and all data in them.
151 void silc_channel_payload_list_free(SilcDList list);
153 /****f* silccore/SilcChannelAPI/silc_channel_get_name
157 * unsigned char *silc_channel_get_name(SilcChannelPayload payload,
158 * SilcUInt32 *channel_name_len);
162 * Return the channel name from the payload. The caller must not free it.
165 unsigned char *silc_channel_get_name(SilcChannelPayload payload,
166 SilcUInt32 *channel_name_len);
168 /****f* silccore/SilcChannelAPI/silc_channel_get_id
172 * unsigned char *silc_channel_get_id(SilcChannelPayload payload,
173 * SilcUInt32 *channel_id_len);
177 * Return the Channel ID data from the payload. The caller must not free it.
180 unsigned char *silc_channel_get_id(SilcChannelPayload payload,
181 SilcUInt32 *channel_id_len);
183 /****f* silccore/SilcChannelAPI/silc_channel_get_id_parse
187 * SilcBool silc_channel_get_id_parse(SilcChannelPayload payload,
188 * SilcChannelID *ret_channel_id);
192 * Return the Channel ID as parsed ID. This is equivalent to the
193 * silc_channel_get_id execpt that the ID is already parsed.
196 SilcBool silc_channel_get_id_parse(SilcChannelPayload payload,
197 SilcChannelID *ret_channel_id);
199 /****f* silccore/SilcChannelAPI/silc_channel_get_mode
203 * SilcUInt32 silc_channel_get_mode(SilcChannelPayload payload);
207 * Return the mode. The mode is arbitrary. It can be the mode of the
208 * channel or perhaps the mode of the client on the channel. The protocol
209 * dictates what the usage of the mode is in different circumstances.
212 SilcUInt32 silc_channel_get_mode(SilcChannelPayload payload);
214 /****f* silccore/SilcChannelAPI/silc_channel_key_payload_parse
218 * SilcChannelKeyPayload
219 * silc_channel_key_payload_parse(const unsigned char *payload,
220 * uin32 payload_len);
224 * Parses channel key payload returning new channel key payload
228 SilcChannelKeyPayload
229 silc_channel_key_payload_parse(const unsigned char *payload,
230 SilcUInt32 payload_len);
232 /****f* silccore/SilcChannelAPI/silc_channel_key_payload_encode
236 * SilcBuffer silc_channel_key_payload_encode(SilcUInt16 id_len,
237 * const unsigned char *id,
238 * SilcUInt16 cipher_len,
239 * const unsigned char *cipher,
240 * SilcUInt16 key_len,
241 * const unsigned char *key);
245 * Encodes channel key payload into a buffer and returns it. This is used
246 * to add channel key payload into a packet.
249 SilcBuffer silc_channel_key_payload_encode(SilcUInt16 id_len,
250 const unsigned char *id,
251 SilcUInt16 cipher_len,
252 const unsigned char *cipher,
254 const unsigned char *key);
256 /****f* silccore/SilcChannelAPI/silc_channel_key_payload_free
260 * void silc_channel_key_payload_free(SilcChannelKeyPayload payload);
264 * Frees the Channel Key Payload and all data in it.
267 void silc_channel_key_payload_free(SilcChannelKeyPayload payload);
269 /****f* silccore/SilcChannelAPI/silc_channel_key_get_id
273 * unsigned char *silc_channel_key_get_id(SilcChannelKeyPayload payload,
274 * SilcUInt32 *id_len);
278 * Return the Channel ID data from the payload. The caller must not
282 unsigned char *silc_channel_key_get_id(SilcChannelKeyPayload payload,
285 /****f* silccore/SilcChannelAPI/silc_channel_key_get_cipher
289 * unsigned char *silc_channel_key_get_cipher(SilcChannelKeyPayload payload,
290 * SilcUInt32 *cipher_len);
294 * Return the name of the cipher from the payload. The caller must not
298 unsigned char *silc_channel_key_get_cipher(SilcChannelKeyPayload payload,
299 SilcUInt32 *cipher_len);
301 /****f* silccore/SilcChannelAPI/silc_channel_key_get_key
305 * unsigned char *silc_channel_key_get_key(SilcChannelKeyPayload payload,
306 * SilcUInt32 *key_len);
310 * Return the raw key material from the payload. The caller must not
314 unsigned char *silc_channel_key_get_key(SilcChannelKeyPayload payload,
315 SilcUInt32 *key_len);