| 1 |
/* |
| 2 |
tunnel.h |
| 3 |
|
| 4 |
Copyright (C) 1999 Lars Brinkhoff. See COPYING for terms and conditions. |
| 5 |
*/ |
| 6 |
|
| 7 |
/* |
| 8 |
This is the programming interface to the HTTP tunnel. It consists |
| 9 |
of the following functions: |
| 10 |
|
| 11 |
Tunnel *tunnel_new_client (const char *host, int host_port, |
| 12 |
const char *proxy, int proxy_port, |
| 13 |
size_t content_length); |
| 14 |
|
| 15 |
Create a new HTTP tunnel client. |
| 16 |
|
| 17 |
Tunnel *tunnel_new_server (const char *host, |
| 18 |
int port, |
| 19 |
size_t content_length); |
| 20 |
|
| 21 |
Create a new HTTP tunnel server. If LENGTH is 0, the Content-Length |
| 22 |
of the HTTP GET response will be determined automatically in some way. |
| 23 |
If HOST is not NULL, use it to bind the server socket to a specific |
| 24 |
network interface. |
| 25 |
|
| 26 |
int tunnel_connect (Tunnel *tunnel); |
| 27 |
|
| 28 |
Open the tunnel. (Client only.) |
| 29 |
|
| 30 |
int tunnel_accept (Tunnel *tunnel); |
| 31 |
|
| 32 |
Accept a tunnel connection. (Server only.) |
| 33 |
|
| 34 |
int tunnel_pollin_fd (Tunnel *tunnel); |
| 35 |
|
| 36 |
Return a file descriptor that can be used to poll for input from |
| 37 |
the tunnel. |
| 38 |
|
| 39 |
ssize_t tunnel_read (Tunnel *tunnel, void *data, size_t length); |
| 40 |
ssize_t tunnel_write (Tunnel *tunnel, void *data, size_t length); |
| 41 |
|
| 42 |
Read or write to the tunnel. Same semantics as with read() and |
| 43 |
write(). Watch out for return values less than LENGTH. |
| 44 |
|
| 45 |
int tunnel_padding (Tunnel *tunnel, size_t length); |
| 46 |
|
| 47 |
Send LENGTH pad bytes. |
| 48 |
|
| 49 |
int tunnel_maybe_pad (Tunnel *tunnel, size_t length); |
| 50 |
|
| 51 |
Pad to nearest even multiple of LENGTH. |
| 52 |
|
| 53 |
int tunnel_close (Tunnel *tunnel); |
| 54 |
|
| 55 |
Close the tunnel. |
| 56 |
|
| 57 |
void tunnel_destroy (Tunnel *tunnel); |
| 58 |
*/ |
| 59 |
|
| 60 |
#ifndef TUNNEL_H |
| 61 |
#define TUNNEL_H |
| 62 |
|
| 63 |
#include "config.h" |
| 64 |
#include <sys/types.h> |
| 65 |
|
| 66 |
#define DEFAULT_CONNECTION_MAX_TIME 300 |
| 67 |
|
| 68 |
typedef struct tunnel Tunnel; |
| 69 |
|
| 70 |
extern Tunnel *tunnel_new_client (const char *host, int host_port, |
| 71 |
const char *proxy, int proxy_port, |
| 72 |
size_t content_length); |
| 73 |
extern Tunnel *tunnel_new_server (const char *host, int port, |
| 74 |
size_t content_length); |
| 75 |
extern int tunnel_connect (Tunnel *tunnel); |
| 76 |
extern int tunnel_accept (Tunnel *tunnel); |
| 77 |
extern int tunnel_pollin_fd (Tunnel *tunnel); |
| 78 |
extern ssize_t tunnel_read (Tunnel *tunnel, void *data, size_t length); |
| 79 |
extern ssize_t tunnel_write (Tunnel *tunnel, void *data, size_t length); |
| 80 |
extern ssize_t tunnel_padding (Tunnel *tunnel, size_t length); |
| 81 |
extern int tunnel_maybe_pad (Tunnel *tunnel, size_t length); |
| 82 |
extern int tunnel_setopt (Tunnel *tunnel, const char *opt, void *data); |
| 83 |
extern int tunnel_getopt (Tunnel *tunnel, const char *opt, void *data); |
| 84 |
extern int tunnel_close (Tunnel *tunnel); |
| 85 |
extern void tunnel_destroy (Tunnel *tunnel); |
| 86 |
|
| 87 |
#endif /* TUNNEL_H */ |