change some parameters in the library to meet the needs of the website httpbin.org

Fork of MiniTLS-GPL by Donatien Garnier

Committer:
MiniTLS
Date:
Fri Jun 06 10:49:02 2014 +0000
Revision:
0:35aa5be3b78d
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MiniTLS 0:35aa5be3b78d 1 /*
MiniTLS 0:35aa5be3b78d 2 MuTLS - A super trimmed down TLS/SSL Library for embedded devices
MiniTLS 0:35aa5be3b78d 3 Author: Donatien Garnier
MiniTLS 0:35aa5be3b78d 4 Copyright (C) 2013-2014 AppNearMe Ltd
MiniTLS 0:35aa5be3b78d 5
MiniTLS 0:35aa5be3b78d 6 This program is free software; you can redistribute it and/or
MiniTLS 0:35aa5be3b78d 7 modify it under the terms of the GNU General Public License
MiniTLS 0:35aa5be3b78d 8 as published by the Free Software Foundation; either version 2
MiniTLS 0:35aa5be3b78d 9 of the License, or (at your option) any later version.
MiniTLS 0:35aa5be3b78d 10
MiniTLS 0:35aa5be3b78d 11 This program is distributed in the hope that it will be useful,
MiniTLS 0:35aa5be3b78d 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
MiniTLS 0:35aa5be3b78d 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MiniTLS 0:35aa5be3b78d 14 GNU General Public License for more details.
MiniTLS 0:35aa5be3b78d 15
MiniTLS 0:35aa5be3b78d 16 You should have received a copy of the GNU General Public License
MiniTLS 0:35aa5be3b78d 17 along with this program; if not, write to the Free Software
MiniTLS 0:35aa5be3b78d 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
MiniTLS 0:35aa5be3b78d 19 *//**
MiniTLS 0:35aa5be3b78d 20 * \file buffer.h
MiniTLS 0:35aa5be3b78d 21 * \copyright Copyright (c) AppNearMe Ltd 2013
MiniTLS 0:35aa5be3b78d 22 * \author Donatien Garnier
MiniTLS 0:35aa5be3b78d 23 */
MiniTLS 0:35aa5be3b78d 24
MiniTLS 0:35aa5be3b78d 25 #ifndef BUFFER_H_
MiniTLS 0:35aa5be3b78d 26 #define BUFFER_H_
MiniTLS 0:35aa5be3b78d 27
MiniTLS 0:35aa5be3b78d 28 #ifdef __cplusplus
MiniTLS 0:35aa5be3b78d 29 extern "C" {
MiniTLS 0:35aa5be3b78d 30 #endif
MiniTLS 0:35aa5be3b78d 31
MiniTLS 0:35aa5be3b78d 32 #include "core/fwk.h"
MiniTLS 0:35aa5be3b78d 33
MiniTLS 0:35aa5be3b78d 34 typedef struct __buffer
MiniTLS 0:35aa5be3b78d 35 {
MiniTLS 0:35aa5be3b78d 36 uint8_t* bufdata;
MiniTLS 0:35aa5be3b78d 37 size_t size;
MiniTLS 0:35aa5be3b78d 38
MiniTLS 0:35aa5be3b78d 39 uint8_t* start;
MiniTLS 0:35aa5be3b78d 40 size_t first_byte_length; //In bits
MiniTLS 0:35aa5be3b78d 41
MiniTLS 0:35aa5be3b78d 42 uint8_t* end;
MiniTLS 0:35aa5be3b78d 43 size_t last_byte_length; //In bits
MiniTLS 0:35aa5be3b78d 44
MiniTLS 0:35aa5be3b78d 45 struct __buffer* next;
MiniTLS 0:35aa5be3b78d 46
MiniTLS 0:35aa5be3b78d 47 } buffer_t;
MiniTLS 0:35aa5be3b78d 48
MiniTLS 0:35aa5be3b78d 49 void buffer_init(buffer_t* pBuf, uint8_t* bufdata, size_t size);
MiniTLS 0:35aa5be3b78d 50
MiniTLS 0:35aa5be3b78d 51 void buffer_byref(buffer_t* pBuf, uint8_t* bufdata, size_t length); //New buffer by ref on a size_t array, no malloc (useful on PIC for instance)
MiniTLS 0:35aa5be3b78d 52
MiniTLS 0:35aa5be3b78d 53 buffer_t* buffer_new(size_t size); //malloc
MiniTLS 0:35aa5be3b78d 54
MiniTLS 0:35aa5be3b78d 55 uint8_t* buffer_data(buffer_t* pBuf);
MiniTLS 0:35aa5be3b78d 56
MiniTLS 0:35aa5be3b78d 57 void buffer_reset(buffer_t* pBuf);
MiniTLS 0:35aa5be3b78d 58
MiniTLS 0:35aa5be3b78d 59 size_t buffer_size(buffer_t* pBuf);
MiniTLS 0:35aa5be3b78d 60
MiniTLS 0:35aa5be3b78d 61 size_t buffer_length(buffer_t* pBuf);
MiniTLS 0:35aa5be3b78d 62
MiniTLS 0:35aa5be3b78d 63 size_t buffer_space(buffer_t* pBuf);
MiniTLS 0:35aa5be3b78d 64
MiniTLS 0:35aa5be3b78d 65 bool buffer_empty(buffer_t* pBuf);
MiniTLS 0:35aa5be3b78d 66
MiniTLS 0:35aa5be3b78d 67 void buffer_set_length(buffer_t* pBuf, size_t length);
MiniTLS 0:35aa5be3b78d 68
MiniTLS 0:35aa5be3b78d 69 size_t buffer_last_byte_length(buffer_t* pBuf);
MiniTLS 0:35aa5be3b78d 70
MiniTLS 0:35aa5be3b78d 71 void buffer_set_last_byte_length(buffer_t* pBuf, size_t length);
MiniTLS 0:35aa5be3b78d 72
MiniTLS 0:35aa5be3b78d 73 size_t buffer_bits_count(buffer_t* pBuf);
MiniTLS 0:35aa5be3b78d 74
MiniTLS 0:35aa5be3b78d 75 void buffer_write_byte(buffer_t* pBuf, uint8_t b);
MiniTLS 0:35aa5be3b78d 76
MiniTLS 0:35aa5be3b78d 77 void buffer_write_bit(buffer_t* pBuf, uint8_t b);
MiniTLS 0:35aa5be3b78d 78
MiniTLS 0:35aa5be3b78d 79 #if 0
MiniTLS 0:35aa5be3b78d 80 size_t buffer_read_byte(buffer_t* pBuf, uint8_t b);
MiniTLS 0:35aa5be3b78d 81
MiniTLS 0:35aa5be3b78d 82 size_t buffer_read_bit(buffer_t* pBuf, uint8_t b);
MiniTLS 0:35aa5be3b78d 83 #endif
MiniTLS 0:35aa5be3b78d 84
MiniTLS 0:35aa5be3b78d 85 buffer_t* buffer_next(buffer_t* pBuf);
MiniTLS 0:35aa5be3b78d 86
MiniTLS 0:35aa5be3b78d 87 void buffer_set_next(buffer_t* pBuf, buffer_t* pNextBuf);
MiniTLS 0:35aa5be3b78d 88
MiniTLS 0:35aa5be3b78d 89 void buffer_append(buffer_t* pBuf, buffer_t* pAppBuf);
MiniTLS 0:35aa5be3b78d 90
MiniTLS 0:35aa5be3b78d 91 void buffer_unlink(buffer_t* pBuf, buffer_t* pLinkedBuf);
MiniTLS 0:35aa5be3b78d 92
MiniTLS 0:35aa5be3b78d 93 size_t buffer_total_size(buffer_t* pBuf);
MiniTLS 0:35aa5be3b78d 94
MiniTLS 0:35aa5be3b78d 95 size_t buffer_total_length(buffer_t* pBuf);
MiniTLS 0:35aa5be3b78d 96
MiniTLS 0:35aa5be3b78d 97 void buffer_set_total_length(buffer_t* pBuf, size_t length);
MiniTLS 0:35aa5be3b78d 98
MiniTLS 0:35aa5be3b78d 99 void buffer_free(buffer_t* pBuf);
MiniTLS 0:35aa5be3b78d 100
MiniTLS 0:35aa5be3b78d 101 //Debug
MiniTLS 0:35aa5be3b78d 102 void buffer_dump(buffer_t* pBuf);
MiniTLS 0:35aa5be3b78d 103
MiniTLS 0:35aa5be3b78d 104 #ifdef __cplusplus
MiniTLS 0:35aa5be3b78d 105 }
MiniTLS 0:35aa5be3b78d 106 #endif
MiniTLS 0:35aa5be3b78d 107
MiniTLS 0:35aa5be3b78d 108 #endif /* BUFFER_H_ */