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