updates. New data types.
[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 - 2001 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 #include "silcdlist.h"
25
26 /* Forward declaration for Channel Payload parsed from packet. The
27    actual structure is defined in source file and is private data. */
28 typedef struct SilcChannelPayloadStruct *SilcChannelPayload;
29
30 /* Forward declaration for Channel Message Payload parsed from packet. The
31    actual structure is defined in source file and is private data. */
32 typedef struct SilcChannelMessagePayloadStruct *SilcChannelMessagePayload;
33
34 /* Forward declaration for Channel Key Payload parsed from packet. The
35    actual structure is defined in source file and is private data. */
36 typedef struct SilcChannelKeyPayloadStruct *SilcChannelKeyPayload;
37
38 /* The Message flag type */
39 typedef uint16 SilcMessageFlags;
40
41 /* The message flags (shared by both channel and private messages) */
42 #define SILC_MESSAGE_FLAG_NONE        0x0000
43 #define SILC_MESSAGE_FLAG_AUTOREPLY   0x0001
44 #define SILC_MESSAGE_FLAG_NOREPLY     0x0002
45 #define SILC_MESSAGE_FLAG_ACTION      0x0004
46 #define SILC_MESSAGE_FLAG_NOTICE      0x0008
47 #define SILC_MESSAGE_FLAG_REQUEST     0x0010
48 #define SILC_MESSAGE_FLAG_RESERVED    0x0020 /* to 0x0200 */
49 #define SILC_MESSAGE_FLAG_PRIVATE     0x0400 /* to 0x8000 */
50
51 /* Prototypes */
52 SilcChannelPayload silc_channel_payload_parse(SilcBuffer buffer);
53 SilcDList silc_channel_payload_parse_list(SilcBuffer buffer);
54 SilcBuffer silc_channel_payload_encode(unsigned char *channel_name,
55                                        uint16 channel_name_len,
56                                        unsigned char *channel_id,
57                                        uint32 channel_id_len,
58                                        uint32 mode);
59 void silc_channel_payload_free(SilcChannelPayload payload);
60 void silc_channel_payload_list_free(SilcDList list);
61 unsigned char *silc_channel_get_name(SilcChannelPayload payload,
62                                      uint32 *channel_name_len);
63 unsigned char *silc_channel_get_id(SilcChannelPayload payload,
64                                    uint32 *channel_id_len);
65 SilcChannelID *silc_channel_get_id_parse(SilcChannelPayload payload);
66 uint32 silc_channel_get_mode(SilcChannelPayload payload);
67 int silc_channel_message_payload_decrypt(unsigned char *data,
68                                          size_t data_len,
69                                          SilcCipher cipher,
70                                          SilcHmac hmac);
71 SilcChannelMessagePayload 
72 silc_channel_message_payload_parse(SilcBuffer buffer,
73                                    SilcCipher cipher,
74                                    SilcHmac hmac);
75 SilcBuffer silc_channel_message_payload_encode(uint16 flags,
76                                                uint16 data_len,
77                                                unsigned char *data,
78                                                uint16 iv_len,
79                                                unsigned char *iv,
80                                                SilcCipher cipher,
81                                                SilcHmac hmac);
82 void silc_channel_message_payload_free(SilcChannelMessagePayload payload);
83 uint16 
84 silc_channel_message_get_flags(SilcChannelMessagePayload payload);
85 unsigned char *silc_channel_message_get_data(SilcChannelMessagePayload payload,
86                                      uint32 *data_len);
87 unsigned char *silc_channel_message_get_mac(SilcChannelMessagePayload payload);
88 unsigned char *silc_channel_message_get_iv(SilcChannelMessagePayload payload);
89 SilcChannelKeyPayload silc_channel_key_payload_parse(SilcBuffer buffer);
90 SilcBuffer silc_channel_key_payload_encode(uint16 id_len,
91                                            unsigned char *id,
92                                            uint16 cipher_len,
93                                            unsigned char *cipher,
94                                            uint16 key_len,
95                                            unsigned char *key);
96 void silc_channel_key_payload_free(SilcChannelKeyPayload payload);
97 unsigned char *silc_channel_key_get_id(SilcChannelKeyPayload payload, 
98                                        uint32 *id_len);
99 unsigned char *silc_channel_key_get_cipher(SilcChannelKeyPayload payload,
100                                            uint32 *cipher_len);
101 unsigned char *silc_channel_key_get_key(SilcChannelKeyPayload payload,
102                                         uint32 *key_len);
103
104 #endif