diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:30:32 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:30:32 -0800 |
commit | 8b23a6c7e1aee255004dd19098d4c2462b61b849 (patch) | |
tree | 7a4d682ba51f0ff0364c5ca2509f515bdaf96de9 /proxy/proxy_common.h | |
parent | f721e3ac031f892af46f255a47d7f54a91317b30 (diff) | |
download | external_qemu-8b23a6c7e1aee255004dd19098d4c2462b61b849.zip external_qemu-8b23a6c7e1aee255004dd19098d4c2462b61b849.tar.gz external_qemu-8b23a6c7e1aee255004dd19098d4c2462b61b849.tar.bz2 |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'proxy/proxy_common.h')
-rw-r--r-- | proxy/proxy_common.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/proxy/proxy_common.h b/proxy/proxy_common.h new file mode 100644 index 0000000..78eddd8 --- /dev/null +++ b/proxy/proxy_common.h @@ -0,0 +1,88 @@ +/* Copyright (C) 2007-2008 The Android Open Source Project +** +** This software is licensed under the terms of the GNU General Public +** License version 2, as published by the Free Software Foundation, and +** may be copied, distributed, and modified under those terms. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +*/ +#ifndef _PROXY_COMMON_H_ +#define _PROXY_COMMON_H_ + +#include "sockets.h" + +#ifdef _WIN32 +#include <winsock2.h> +#else +#include <sys/select.h> +#endif + +/* types and definitions used by all proxy connections */ + +typedef enum { + PROXY_EVENT_NONE, + PROXY_EVENT_CONNECTED, + PROXY_EVENT_CONNECTION_REFUSED, + PROXY_EVENT_SERVER_ERROR +} ProxyEvent; + +/* event can't be NONE when this callback is called */ +typedef void (*ProxyEventFunc)( void* opaque, int fd, ProxyEvent event ); + +extern void proxy_set_verbose(int mode); + + +typedef enum { + PROXY_OPTION_AUTH_USERNAME = 1, + PROXY_OPTION_AUTH_PASSWORD, + + PROXY_OPTION_HTTP_NOCACHE = 100, + PROXY_OPTION_HTTP_KEEPALIVE, + PROXY_OPTION_HTTP_USER_AGENT, + + PROXY_OPTION_MAX + +} ProxyOptionType; + + +typedef struct { + ProxyOptionType type; + const char* string; + int string_len; +} ProxyOption; + + +/* add a new proxified socket connection to the manager's list. the event function + * will be called when the connection is established or refused. + * + * only IPv4 is supported at the moment, since our slirp code cannot handle IPv6 + * + * returns 0 on success, or -1 if there is no proxy service for this type of connection + */ +extern int proxy_manager_add( SockAddress* address, + SocketType sock_type, + ProxyEventFunc ev_func, + void* ev_opaque ); + +/* remove an on-going proxified socket connection from the manager's list. + * this is only necessary when the socket connection must be canceled before + * the connection accept/refusal occured + */ +extern void proxy_manager_del( void* ev_opaque ); + +/* this function is called to update the select file descriptor sets + * with those of the proxified connection sockets that are currently managed */ +extern void proxy_manager_select_fill( int *pcount, + fd_set* read_fds, + fd_set* write_fds, + fd_set* err_fds); + +/* this function is called to act on proxified connection sockets when network events arrive */ +extern void proxy_manager_poll( fd_set* read_fds, + fd_set* write_fds, + fd_set* err_fds ); + +#endif /* END */ |