1 /*
2  * proxy-polarssl.h - PolarSSL layer for transparent proxy connections
3  *
4  * Based on proxy-bio.c - Original copyright (c) 2012 The Chromium OS Authors.
5  *
6  * This file was adapted by Paul Bakker <p.j.bakker@offspark.com>
7  * All rights reserved.
8  *
9  * Use of this source code is governed by a BSD-style license that can be
10  * found in the LICENSE file.
11  */
12 
13 #ifndef PROXY_POLARSSL_H
14 #define PROXY_POLARSSL_H
15 
16 #include <stdint.h>
17 
18 typedef struct _proxy_polarssl_ctx proxy_polarssl_ctx;
19 
20 struct _proxy_polarssl_ctx {
21   char *host;
22   uint16_t port;
23   int connected;
24 
25   int (*f_recv)(void *, unsigned char *, size_t);
26   int (*f_send)(void *, const unsigned char *, size_t);
27   int (*f_connect)(proxy_polarssl_ctx *);
28 
29   void *p_recv;               /*!< context for reading operations   */
30   void *p_send;               /*!< context for writing operations   */
31 };
32 
33 int proxy_polarssl_init(proxy_polarssl_ctx *proxy);
34 int proxy_polarssl_free(proxy_polarssl_ctx *ctx);
35 
36 void proxy_polarssl_set_bio(proxy_polarssl_ctx *ctx,
37                        int (*f_recv)(void *, unsigned char *, size_t), void *p_recv,
38                        int (*f_send)(void *, const unsigned char *, size_t), void *p_send);
39 int proxy_polarssl_set_scheme(proxy_polarssl_ctx *ctx, const char *scheme);
40 int proxy_polarssl_set_host(proxy_polarssl_ctx *ctx, const char *host);
41 void proxy_polarssl_set_port(proxy_polarssl_ctx *ctx, uint16_t port);
42 
43 int proxy_polarssl_recv(void *ctx, unsigned char *data, size_t len);
44 int proxy_polarssl_send(void *ctx, const unsigned char *data, size_t len);
45 
46 #endif /* !PROXY_POLARSSL_H */
47