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 * SilcChannelID *silc_channel_get_id_parse(SilcChannelPayload payload);
191 * Return the Channel ID as parsed ID. This is equivalent to the
192 * silc_channel_get_id execpt that the ID is already parsed. The caller
193 * must free the parsed Channel ID.
196 SilcChannelID *silc_channel_get_id_parse(SilcChannelPayload payload);
198 /****f* silccore/SilcChannelAPI/silc_channel_get_mode
202 * SilcUInt32 silc_channel_get_mode(SilcChannelPayload payload);
206 * Return the mode. The mode is arbitrary. It can be the mode of the
207 * channel or perhaps the mode of the client on the channel. The protocol
208 * dictates what the usage of the mode is in different circumstances.
211 SilcUInt32 silc_channel_get_mode(SilcChannelPayload payload);
213 /****f* silccore/SilcChannelAPI/silc_channel_key_payload_parse
217 * SilcChannelKeyPayload
218 * silc_channel_key_payload_parse(const unsigned char *payload,
219 * uin32 payload_len);
223 * Parses channel key payload returning new channel key payload
227 SilcChannelKeyPayload
228 silc_channel_key_payload_parse(const unsigned char *payload,
229 SilcUInt32 payload_len);
231 /****f* silccore/SilcChannelAPI/silc_channel_key_payload_encode
235 * SilcBuffer silc_channel_key_payload_encode(SilcUInt16 id_len,
236 * const unsigned char *id,
237 * SilcUInt16 cipher_len,
238 * const unsigned char *cipher,
239 * SilcUInt16 key_len,
240 * const unsigned char *key);
244 * Encodes channel key payload into a buffer and returns it. This is used
245 * to add channel key payload into a packet.
248 SilcBuffer silc_channel_key_payload_encode(SilcUInt16 id_len,
249 const unsigned char *id,
250 SilcUInt16 cipher_len,
251 const unsigned char *cipher,
253 const unsigned char *key);
255 /****f* silccore/SilcChannelAPI/silc_channel_key_payload_free
259 * void silc_channel_key_payload_free(SilcChannelKeyPayload payload);
263 * Frees the Channel Key Payload and all data in it.
266 void silc_channel_key_payload_free(SilcChannelKeyPayload payload);
268 /****f* silccore/SilcChannelAPI/silc_channel_key_get_id
272 * unsigned char *silc_channel_key_get_id(SilcChannelKeyPayload payload,
273 * SilcUInt32 *id_len);
277 * Return the Channel ID data from the payload. The caller must not
281 unsigned char *silc_channel_key_get_id(SilcChannelKeyPayload payload,
284 /****f* silccore/SilcChannelAPI/silc_channel_key_get_cipher
288 * unsigned char *silc_channel_key_get_cipher(SilcChannelKeyPayload payload,
289 * SilcUInt32 *cipher_len);
293 * Return the name of the cipher from the payload. The caller must not
297 unsigned char *silc_channel_key_get_cipher(SilcChannelKeyPayload payload,
298 SilcUInt32 *cipher_len);
300 /****f* silccore/SilcChannelAPI/silc_channel_key_get_key
304 * unsigned char *silc_channel_key_get_key(SilcChannelKeyPayload payload,
305 * SilcUInt32 *key_len);
309 * Return the raw key material from the payload. The caller must not
313 unsigned char *silc_channel_key_get_key(SilcChannelKeyPayload payload,
314 SilcUInt32 *key_len);