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/>
22 #ifndef GNUTLS_BUFFERS_H
23 #define GNUTLS_BUFFERS_H
25 #define MBUFFER_FLUSH 1
28 _gnutls_record_buffer_put (gnutls_session_t session
,
29 content_type_t type
, uint64
* seq
, mbuffer_st
* bufel
);
32 _gnutls_record_buffer_get_size (gnutls_session_t session
)
34 return session
->internals
.record_buffer
.byte_length
;
38 * record_check_unprocessed:
39 * @session: is a #gnutls_session_t structure.
41 * This function checks if there are unprocessed data
42 * in the gnutls record buffers. Those data might not
43 * be complete records.
45 * Returns: Returns the size of the data or zero.
48 record_check_unprocessed (gnutls_session_t session
)
50 return session
->internals
.record_recv_buffer
.byte_length
;
53 int _gnutls_record_buffer_get (content_type_t type
,
54 gnutls_session_t session
, uint8_t * data
,
55 size_t length
, uint8_t seq
[8]);
56 ssize_t
_gnutls_io_read_buffered (gnutls_session_t
, size_t n
, content_type_t
, unsigned int *ms
);
57 int _gnutls_io_clear_peeked_data (gnutls_session_t session
);
59 ssize_t
_gnutls_io_write_buffered (gnutls_session_t session
,
60 mbuffer_st
* bufel
, unsigned int mflag
);
62 int _gnutls_handshake_io_cache_int (gnutls_session_t
,
63 gnutls_handshake_description_t
,
67 _gnutls_handshake_io_recv_int (gnutls_session_t session
,
68 gnutls_handshake_description_t htype
,
69 handshake_buffer_st
* hsk
, unsigned int optional
);
71 ssize_t
_gnutls_io_write_flush (gnutls_session_t session
);
73 _gnutls_io_check_recv (gnutls_session_t session
, unsigned int ms
);
74 ssize_t
_gnutls_handshake_io_write_flush (gnutls_session_t session
);
76 inline static void _gnutls_handshake_buffer_clear(handshake_buffer_st
* hsk
)
78 _gnutls_buffer_clear(&hsk
->data
);
82 inline static void _gnutls_handshake_buffer_init(handshake_buffer_st
* hsk
)
84 memset(hsk
, 0, sizeof(*hsk
));
85 _gnutls_buffer_init(&hsk
->data
);
89 inline static void _gnutls_handshake_recv_buffer_clear(gnutls_session_t session
)
92 for (i
=0;i
<session
->internals
.handshake_recv_buffer_size
;i
++)
93 _gnutls_handshake_buffer_clear(&session
->internals
.handshake_recv_buffer
[i
]);
94 session
->internals
.handshake_recv_buffer_size
= 0;
97 inline static void _gnutls_handshake_recv_buffer_init(gnutls_session_t session
)
100 for (i
=0;i
<MAX_HANDSHAKE_MSGS
;i
++)
102 _gnutls_handshake_buffer_init(&session
->internals
.handshake_recv_buffer
[i
]);
104 session
->internals
.handshake_recv_buffer_size
= 0;
108 _gnutls_parse_record_buffered_msgs (gnutls_session_t session
);
111 _gnutls_recv_in_buffers (gnutls_session_t session
, content_type_t type
,
112 gnutls_handshake_description_t htype
, unsigned int ms
);
114 #define _gnutls_handshake_io_buffer_clear( session) \
115 _mbuffer_head_clear( &session->internals.handshake_send_buffer); \
116 _gnutls_handshake_recv_buffer_clear( session);