corrected copyright notices
[gnutls.git] / lib / gnutls_constate.h
blobb604f42d220898e3147c3b849f69b3aab63ace52
1 /*
2 * Copyright (C) 2000-2012 Free Software Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GnuTLS.
8 * The GnuTLS is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
23 #ifndef GNUTLS_CONSTATE_H
24 #define GNUTLS_CONSTATE_H
26 int _gnutls_epoch_set_cipher_suite (gnutls_session_t session, int epoch_rel,
27 const uint8_t suite[2]);
28 int _gnutls_epoch_set_compression (gnutls_session_t session, int epoch_rel,
29 gnutls_compression_method_t comp_algo);
30 int _gnutls_epoch_get_compression (gnutls_session_t session, int epoch_rel);
31 void _gnutls_epoch_set_null_algos (gnutls_session_t session,
32 record_parameters_st * params);
33 int _gnutls_epoch_set_keys (gnutls_session_t session, uint16_t epoch);
34 int _gnutls_connection_state_init (gnutls_session_t session);
35 int _gnutls_read_connection_state_init (gnutls_session_t session);
36 int _gnutls_write_connection_state_init (gnutls_session_t session);
38 int _gnutls_set_kx (gnutls_session_t session, gnutls_kx_algorithm_t algo);
40 int _gnutls_epoch_get (gnutls_session_t session, unsigned int epoch_rel,
41 record_parameters_st ** params_out);
42 int _gnutls_epoch_alloc (gnutls_session_t session, uint16_t epoch,
43 record_parameters_st ** out);
44 void _gnutls_epoch_gc (gnutls_session_t session);
45 void _gnutls_epoch_free (gnutls_session_t session,
46 record_parameters_st * state);
48 static inline int _gnutls_epoch_is_valid(gnutls_session_t session, int epoch)
50 record_parameters_st * params;
51 int ret;
53 ret = _gnutls_epoch_get( session, epoch, &params);
54 if (ret < 0)
55 return 0;
57 return 1;
61 static inline int _gnutls_epoch_refcount_inc(gnutls_session_t session, int epoch)
63 record_parameters_st * params;
64 int ret;
66 ret = _gnutls_epoch_get( session, epoch, &params);
67 if (ret < 0)
68 return ret;
70 params->usage_cnt++;
72 return params->epoch;
75 static inline int _gnutls_epoch_refcount_dec(gnutls_session_t session, uint16_t epoch)
77 record_parameters_st * params;
78 int ret;
80 ret = _gnutls_epoch_get( session, epoch, &params);
81 if (ret < 0)
82 return ret;
84 params->usage_cnt--;
85 if (params->usage_cnt < 0)
86 return GNUTLS_E_INTERNAL_ERROR;
88 return 0;
91 #endif