tls_bio.h

Go to the documentation of this file.
00001 /* 
00002  * Copyright (C) 2010 iptelorg GmbH
00003  *
00004  * Permission to use, copy, modify, and distribute this software for any
00005  * purpose with or without fee is hereby granted, provided that the above
00006  * copyright notice and this permission notice appear in all copies.
00007  *
00008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
00009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
00011  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00013  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
00014  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00015  */
00016  
00022 /*
00023  * History:
00024  * --------
00025  *  2010-03-25  initial version (andrei)
00026 */
00027 
00028 #ifndef __tls_bio_h
00029 #define __tls_bio_h
00030 
00031 #include <openssl/bio.h>
00032 
00033 /* memory buffer used for tls I/O */
00034 struct tls_mbuf {
00035         unsigned char* buf;
00036         int pos;  
00037         int used; 
00038         int size; 
00039 };
00040 
00041 struct tls_bio_mbuf_data {
00042         struct tls_mbuf* rd;
00043         struct tls_mbuf* wr;
00044 };
00045 
00046 
00047 BIO_METHOD* tls_BIO_mbuf(void);
00048 BIO* tls_BIO_new_mbuf(struct tls_mbuf* rd, struct tls_mbuf* wr);
00049 int tls_BIO_mbuf_set(BIO* b, struct tls_mbuf* rd, struct tls_mbuf* wr);
00050 
00051 
00052 
00059 #define tls_mbuf_init(mb, b, sz) \
00060         do { \
00061                 (mb)->buf = (b); \
00062                 (mb)->size = (sz); \
00063                 (mb)->pos = 0; \
00064                 (mb)->used = 0; \
00065         } while(0)
00066 
00067 
00068 
00069 #endif /*__tls_bio_h*/
00070 
00071 /* vi: set ts=4 sw=4 tw=79:ai:cindent: */