5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 1997 - 2001 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; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
21 /****h* silccore/SILC Channel Interface
25 * Implementations of the Channel Payload and Channel Key Payload. The
26 * Channel Payload represents new channel and is used to distribute the
27 * information of the new channel. The Channel Key Payload is used to
28 * distribute a new key to the channel. It is done for example every
29 * time someone joins a channel or the old key expires.
36 #include "silcdlist.h"
38 /****s* silccore/SilcChannelAPI/SilcChannelPayload
42 * typedef struct SilcChannelPayloadStruct *SilcChannelPayload;
46 * This context is the actual Channel Payload and is allocated
47 * by silc_channel_payload_parse and given as argument usually to
48 * all silc_channel_payload_* functions. It is freed by the
49 * silc_channel_payload_free function.
52 typedef struct SilcChannelPayloadStruct *SilcChannelPayload;
54 /****s* silccore/SilcChannelAPI/SilcChannelKeyPayload
58 * typedef struct SilcChannelKeyPayloadStruct *SilcChannelKeyPayload;
62 * This context is the actual Channel Key Payload and is allocated
63 * by silc_channel_key_payload_parse and given as argument usually to
64 * all silc_channel_key_payload_* functions. It is freed by the
65 * silc_channel_key_payload_free function.
68 typedef struct SilcChannelKeyPayloadStruct *SilcChannelKeyPayload;
72 /****f* silccore/SilcChannelAPI/silc_channel_payload_parse
77 * silc_channel_payload_parse(const unsigned char *payload,
78 * SilcUInt32 payload_len);
82 * Parses channel payload returning new channel payload structure. The
83 * `buffer' is the raw payload buffer.
86 SilcChannelPayload silc_channel_payload_parse(const unsigned char *payload,
87 SilcUInt32 payload_len);
89 /****f* silccore/SilcChannelAPI/silc_channel_payload_parse_list
94 * silc_channel_payload_parse_list(const unsigned char *payload,
95 * SilcUInt32 payload_len);
99 * Parses list of channel payloads returning list of payloads. This
100 * is equivalent to the silc_channel_payload_parse except that the `buffer'
101 * now includes multiple Channel Payloads one after the other.
104 SilcDList silc_channel_payload_parse_list(const unsigned char *payload,
105 SilcUInt32 payload_len);
107 /****f* silccore/SilcChannelAPI/silc_channel_payload_encode
111 * SilcBuffer silc_channel_payload_encode(const unsigned char *channel_name,
112 * SilcUInt16 channel_name_len,
113 * const unsigned char *channel_id,
114 * SilcUInt32 channel_id_len,
119 * Encode new channel payload and returns it as buffer.
122 SilcBuffer silc_channel_payload_encode(const unsigned char *channel_name,
123 SilcUInt16 channel_name_len,
124 const unsigned char *channel_id,
125 SilcUInt32 channel_id_len,
128 /****f* silccore/SilcChannelAPI/silc_channel_payload_free
132 * void silc_channel_payload_free(SilcChannelPayload payload);
136 * Frees Channel Payload and all data in it.
139 void silc_channel_payload_free(SilcChannelPayload payload);
141 /****f* silccore/SilcChannelAPI/silc_channel_payload_list_free
145 * void silc_channel_payload_list_free(SilcDList list);
149 * Frees list of Channel Payloads and all data in them.
152 void silc_channel_payload_list_free(SilcDList list);
154 /****f* silccore/SilcChannelAPI/silc_channel_get_name
158 * unsigned char *silc_channel_get_name(SilcChannelPayload payload,
159 * SilcUInt32 *channel_name_len);
163 * Return the channel name from the payload. The caller must not free it.
166 unsigned char *silc_channel_get_name(SilcChannelPayload payload,
167 SilcUInt32 *channel_name_len);
169 /****f* silccore/SilcChannelAPI/silc_channel_get_id
173 * unsigned char *silc_channel_get_id(SilcChannelPayload payload,
174 * SilcUInt32 *channel_id_len);
178 * Return the Channel ID data from the payload. The caller must not free it.
181 unsigned char *silc_channel_get_id(SilcChannelPayload payload,
182 SilcUInt32 *channel_id_len);
184 /****f* silccore/SilcChannelAPI/silc_channel_get_id_parse
188 * SilcChannelID *silc_channel_get_id_parse(SilcChannelPayload payload);
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. The caller
194 * must free the parsed Channel ID.
197 SilcChannelID *silc_channel_get_id_parse(SilcChannelPayload payload);
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);