bd27ab5d7847a0b914ad6580570a3f83adfeca69
[strongswan.git] / src / libtls / tls_compression.h
1 /*
2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup tls_compression tls_compression
18 * @{ @ingroup libtls
19 */
20
21 #ifndef TLS_COMPRESSION_H_
22 #define TLS_COMPRESSION_H_
23
24 typedef struct tls_compression_t tls_compression_t;
25
26 #include <library.h>
27
28 #include "tls.h"
29 #include "tls_fragmentation.h"
30
31 /**
32 * TLS record protocol compression layer.
33 */
34 struct tls_compression_t {
35
36 /**
37 * Process a compressed TLS record, pass it to upper layers.
38 *
39 * @param type type of the TLS record to process
40 * @param data associated TLS record data
41 * @return
42 * - SUCCESS if TLS negotiation complete
43 * - FAILED if TLS handshake failed
44 * - NEED_MORE if more invocations to process/build needed
45 */
46 status_t (*process)(tls_compression_t *this,
47 tls_content_type_t type, chunk_t data);
48
49 /**
50 * Query upper layer for TLS record, build compressed record.
51 *
52 * @param type type of the built TLS record
53 * @param data allocated data of the built TLS record
54 * @return
55 * - SUCCESS if TLS negotiation complete
56 * - FAILED if TLS handshake failed
57 * - NEED_MORE if upper layers have more records to send
58 * - INVALID_STATE if more input records required
59 */
60 status_t (*build)(tls_compression_t *this,
61 tls_content_type_t *type, chunk_t *data);
62
63 /**
64 * Destroy a tls_compression_t.
65 */
66 void (*destroy)(tls_compression_t *this);
67 };
68
69 /**
70 * Create a tls_compression instance.
71 *
72 * @param fragmentation fragmentation layer of TLS stack
73 * @return TLS compression layer.
74 */
75 tls_compression_t *tls_compression_create(tls_fragmentation_t *fragmentation);
76
77 #endif /** TLS_COMPRESSION_H_ @}*/