Protocol version 1.2 integrations
[silc.git] / lib / silccore / silcprivate_i.h
1 /*
2
3   silcprivate_i.h 
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 1997 - 2002 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; version 2 of the License.
12
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.
17
18 */
19
20 #ifndef SILCPRIVATE_I_H
21 #define SILCPRIVATE_I_H
22
23 #ifndef SILCPRIVATE_H
24 #error "Do not include internal header file directly"
25 #endif
26
27 /******************************************************************************
28
29                            Private Message Payload
30
31 ******************************************************************************/
32
33 /* Calculates padding length for message payload */
34 #define SILC_PRIVATE_MESSAGE_PAD(__payloadlen) (16 - ((__payloadlen) % 16))
35
36 /* Header length plus maximum padding length */
37 #define SILC_PRIVATE_MESSAGE_HLEN 4 + 16
38
39 /* Returns the data length that fits to the packet.  If data length is too
40    big it will be truncated to fit to the payload. */
41 #define SILC_PRIVATE_MESSAGE_DATALEN(data_len)                          \
42   ((data_len + SILC_PRIVATE_MESSAGE_HLEN) > SILC_PACKET_MAX_LEN ?       \
43    data_len - ((data_len + SILC_PRIVATE_MESSAGE_HLEN) -                 \
44                SILC_PACKET_MAX_LEN) : data_len)
45
46 /* Private Message Payload structure. Contents of this structure is parsed
47    from SILC packets. */
48 struct SilcPrivateMessagePayloadStruct {
49   SilcUInt16 flags;
50   SilcUInt16 message_len;
51   unsigned char *message;
52   unsigned char *pad;
53   unsigned char *mac;
54 };
55
56 #endif /* SILCPRIVATE_I_H */