2 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2010
3 * Free Software Foundation, Inc.
5 * Author: Nikos Mavrogiannopoulos
7 * This file is part of GnuTLS.
9 * The GnuTLS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1 of
12 * the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
26 #ifndef GNUTLS_EXTENSIONS_H
27 #define GNUTLS_EXTENSIONS_H
29 #include <gnutls_str.h>
31 typedef int (*gnutls_ext_recv_func
) (gnutls_session_t session
,
32 const unsigned char *data
, size_t len
);
33 typedef int (*gnutls_ext_send_func
) (gnutls_session_t session
,
34 gnutls_buffer_st
*extdata
);
36 int _gnutls_parse_extensions (gnutls_session_t session
,
37 gnutls_ext_parse_type_t parse_type
,
38 const opaque
* data
, int data_size
);
39 int _gnutls_gen_extensions (gnutls_session_t session
, gnutls_buffer_st
* extdata
,
40 gnutls_ext_parse_type_t
);
41 int _gnutls_ext_init (void);
42 void _gnutls_ext_deinit (void);
44 void _gnutls_extension_list_add (gnutls_session_t session
, uint16_t type
);
46 typedef void (*gnutls_ext_deinit_data_func
) (extension_priv_data_t data
);
47 typedef int (*gnutls_ext_pack_func
) (extension_priv_data_t data
,
48 gnutls_buffer_st
* packed_data
);
49 typedef int (*gnutls_ext_unpack_func
) (gnutls_buffer_st
* packed_data
,
50 extension_priv_data_t
* data
);
52 void _gnutls_ext_free_session_data (gnutls_session_t session
);
54 /* functions to be used by extensions internally
56 void _gnutls_ext_unset_session_data (gnutls_session_t session
, uint16_t type
);
57 void _gnutls_ext_set_session_data (gnutls_session_t session
, uint16_t type
,
58 extension_priv_data_t
);
59 int _gnutls_ext_get_session_data (gnutls_session_t session
,
60 uint16_t type
, extension_priv_data_t
*);
61 int _gnutls_ext_get_resumed_session_data (gnutls_session_t session
,
63 extension_priv_data_t
* data
);
65 void _gnutls_ext_restore_resumed_session (gnutls_session_t session
);
67 /* for session packing */
68 int _gnutls_ext_pack (gnutls_session_t session
, gnutls_buffer_st
* packed
);
69 int _gnutls_ext_unpack (gnutls_session_t session
, gnutls_buffer_st
* packed
);
75 gnutls_ext_parse_type_t parse_type
;
77 /* this function must return 0 when Not Applicable
78 * size of extension data if ok
81 gnutls_ext_recv_func recv_func
;
83 /* this function must return 0 when Not Applicable
84 * size of extension data if ok
85 * GNUTLS_E_INT_RET_0 if extension data size is zero
88 gnutls_ext_send_func send_func
;
90 gnutls_ext_deinit_data_func deinit_func
; /* this will be called to deinitialize
93 gnutls_ext_pack_func pack_func
; /* packs internal data to machine independent format */
94 gnutls_ext_unpack_func unpack_func
; /* unpacks internal data */
98 int _gnutls_ext_register (extension_entry_st
*);