Created silcpayload.[ch] for generic payloads.
[silc.git] / lib / silccore / silcchannel.h
1 /*
2
3   silcchannel.h
4
5   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
6
7   Copyright (C) 1997 - 2000 Pekka Riikonen
8
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.
13   
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.
18
19 */
20
21 #ifndef SILCCHANNEL_H
22 #define SILCCHANNEL_H
23
24 /* Forward declaration for Channel Payload parsed from packet. The
25    actual structure is defined in source file and is private data. */
26 typedef struct SilcChannelPayloadStruct *SilcChannelPayload;
27
28 /* Forward declaration for Channel Key Payload parsed from packet. The
29    actual structure is defined in source file and is private data. */
30 typedef struct SilcChannelKeyPayloadStruct *SilcChannelKeyPayload;
31
32 /* Channel modes */
33 #define SILC_CHANNEL_MODE_NONE       0x0000
34 #define SILC_CHANNEL_MODE_PRIVATE    0x0001 /* private channel */
35 #define SILC_CHANNEL_MODE_SECRET     0x0002 /* secret channel */
36 #define SILC_CHANNEL_MODE_PRIVKEY    0x0004 /* channel has private key */
37 #define SILC_CHANNEL_MODE_INVITE     0x0008 /* invite only channel */
38
39 /* User modes on channel */
40 #define SILC_CHANNEL_UMODE_NONE      0x0000
41 #define SILC_CHANNEL_UMODE_CHANFO    0x0001 /* channel founder */
42 #define SILC_CHANNEL_UMODE_CHANOP    0x0002 /* channel operator */
43
44 /* Prototypes */
45 SilcChannelPayload silc_channel_payload_parse(SilcBuffer buffer);
46 SilcBuffer silc_channel_payload_encode(unsigned short data_len,
47                                        unsigned char *data,
48                                        unsigned short iv_len,
49                                        unsigned char *iv,
50                                        SilcRng rng);
51 void silc_channel_payload_free(SilcChannelPayload payload);
52 unsigned char *silc_channel_get_data(SilcChannelPayload payload,
53                                      unsigned int *data_len);
54 unsigned char *silc_channel_get_iv(SilcChannelPayload payload,
55                                    unsigned int *iv_len);
56 SilcChannelKeyPayload silc_channel_key_payload_parse(SilcBuffer buffer);
57 SilcBuffer silc_channel_key_payload_encode(unsigned short id_len,
58                                            unsigned char *id,
59                                            unsigned short cipher_len,
60                                            unsigned char *cipher,
61                                            unsigned short key_len,
62                                            unsigned char *key);
63 void silc_channel_key_payload_free(SilcChannelKeyPayload payload);
64 unsigned char *silc_channel_key_get_id(SilcChannelKeyPayload payload, 
65                                        unsigned int *id_len);
66 unsigned char *silc_channel_key_get_cipher(SilcChannelKeyPayload payload,
67                                            unsigned int *cipher_len);
68 unsigned char *silc_channel_key_get_key(SilcChannelKeyPayload payload,
69                                         unsigned int *key_len);
70
71 #endif