From: Teemu Hukkanen Date: Sat, 16 Mar 2024 16:04:36 +0200 Subject: Document tunnel programming interface Origin: upstream Forwarded: not-needed --- ChangeLog | 5 +++++ tunnel.h | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index b09452a..cbc3287 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-06-12 lars brinkhoff + + * tunnel.h: Improved documentation for tunnel programming + inteface. + 2001-05-10 lars brinkhoff * common.c (log_level): Where possible, use fputs and fputc diff --git a/tunnel.h b/tunnel.h index 628127b..8e770f8 100644 --- a/tunnel.h +++ b/tunnel.h @@ -14,14 +14,13 @@ Tunnel *tunnel_new_client (const char *host, int host_port, Create a new HTTP tunnel client. -Tunnel *tunnel_new_server (const char *host, - int port, +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. + Create a new HTTP tunnel server. If CONTENT_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); @@ -39,8 +38,8 @@ int tunnel_pollin_fd (Tunnel *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. + Read or write to the tunnel. Same semantics as read() and write(). + Watch out for return values less than LENGTH. int tunnel_padding (Tunnel *tunnel, size_t length); @@ -50,12 +49,55 @@ int tunnel_maybe_pad (Tunnel *tunnel, size_t length); Pad to nearest even multiple of LENGTH. +int tunnel_setopt (Tunnel *tunnel, const char *opt, void *data); +int tunnel_getopt (Tunnel *tunnel, const char *opt, void *data); + + Set or get a tunnel option. Valid options are: + + * strict_content_length + + DATA must be a pointer to an int. If the int is nonzero, the + tunnel will always honor Content-Length. Otherwise, less than + Content-Length bytes may be sent in a request. + + * keep_alive + + DATA must be a pointer to an int. If the int is nonzero, + keep-alive bytes will be sent when the connection is idle. + Otherwise, no keep-alive bytes will be sent. + + * max_connection_age + + DATA must be a pointer to an int. The int specifies the maximum + time a connection will be kept open, in seconds. + + * proxy_authorization + + DATA must be a pointer to a char pointer. The char pointer + specifies the proxy authorization string, or NULL if no proxy + authorization string is to be used. When this option is set, the + string will be copied into a newly malloced memory region. + Likewise, when the option is read, the returned string is copied + into a newly malloced memory region which the caller must accept + responsibility to manage. + + * user_agent + + DATA must be a pointer to a char pointer. The char pointer + specifies the User-Agent field to be used in HTTP request headers, + or is NULL is no User-Agent field is to be used. When this option + is set, the string will be copied into a newly malloced memory + region. Likewise, when the option is read, the returned string is + copied into a newly malloced memory region which the caller must + accept responsibility to manage. + int tunnel_close (Tunnel *tunnel); Close the tunnel. void tunnel_destroy (Tunnel *tunnel); -*/ + + Free all resources associated with the tunnel object. */ #ifndef TUNNEL_H #define TUNNEL_H