Tizen 2.0 Release
[external/libgnutls26.git] / lib / gnutls_extensions.h
1 /*
2  * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2010
3  * Free Software Foundation, Inc.
4  *
5  * Author: Nikos Mavrogiannopoulos
6  *
7  * This file is part of GnuTLS.
8  *
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.
13  *
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.
18  *
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,
22  * USA
23  *
24  */
25
26 #ifndef GNUTLS_EXTENSIONS_H
27 #define GNUTLS_EXTENSIONS_H
28
29 int _gnutls_parse_extensions (gnutls_session_t session,
30                               gnutls_ext_parse_type_t parse_type,
31                               const opaque * data, int data_size);
32 int _gnutls_gen_extensions (gnutls_session_t session, opaque * data,
33                             size_t data_size, gnutls_ext_parse_type_t);
34 int _gnutls_ext_init (void);
35 void _gnutls_ext_deinit (void);
36
37 void _gnutls_extension_list_add (gnutls_session_t session, uint16_t type);
38
39 typedef void (*gnutls_ext_deinit_data_func) (extension_priv_data_t data);
40 typedef int (*gnutls_ext_pack_func) (extension_priv_data_t data,
41                                      gnutls_buffer_st * packed_data);
42 typedef int (*gnutls_ext_unpack_func) (gnutls_buffer_st * packed_data,
43                                        extension_priv_data_t * data);
44
45 void _gnutls_ext_free_session_data (gnutls_session_t session);
46
47 /* functions to be used by extensions internally
48  */
49 void _gnutls_ext_unset_session_data (gnutls_session_t session, uint16_t type);
50 void _gnutls_ext_set_session_data (gnutls_session_t session, uint16_t type,
51                                    extension_priv_data_t);
52 int _gnutls_ext_get_session_data (gnutls_session_t session,
53                                   uint16_t type, extension_priv_data_t *);
54 int _gnutls_ext_get_resumed_session_data (gnutls_session_t session,
55                                           uint16_t type,
56                                           extension_priv_data_t * data);
57
58 void _gnutls_ext_restore_resumed_session (gnutls_session_t session);
59
60 /* for session packing */
61 int _gnutls_ext_pack (gnutls_session_t session, gnutls_buffer_st * packed);
62 int _gnutls_ext_unpack (gnutls_session_t session, gnutls_buffer_st * packed);
63
64 typedef struct
65 {
66   const char *name;
67   uint16_t type;
68   gnutls_ext_parse_type_t parse_type;
69
70   /* this function must return 0 when Not Applicable
71    * size of extension data if ok
72    * < 0 on other error.
73    */
74   gnutls_ext_recv_func recv_func;
75
76   /* this function must return 0 when Not Applicable
77    * size of extension data if ok
78    * GNUTLS_E_INT_RET_0 if extension data size is zero
79    * < 0 on other error.
80    */
81   gnutls_ext_send_func send_func;
82
83   gnutls_ext_deinit_data_func deinit_func;      /* this will be called to deinitialize
84                                                  * internal data 
85                                                  */
86   gnutls_ext_pack_func pack_func;       /* packs internal data to machine independent format */
87   gnutls_ext_unpack_func unpack_func;   /* unpacks internal data */
88
89 } extension_entry_st;
90
91 int _gnutls_ext_register (extension_entry_st *);
92
93 #endif