From ce1cfcb7a6a0956c3101f5a6eb20961024e55d84 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 3 Oct 2007 08:45:00 +0000 Subject: Alexey Pesternikov introduced CURLOPT_OPENSOCKETFUNCTION and CURLOPT_OPENSOCKETDATA to set a callback that allows an application to replace the socket() call used by libcurl. It basically allows the app to change address, protocol or whatever of the socket. (I also did some whitespace indent/cleanups in lib/url.c which kind of hides some of these changes, sorry for mixing those in.) --- include/curl/curl.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/curl/curl.h b/include/curl/curl.h index 52acc564a..37058254d 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -246,6 +246,19 @@ typedef int (*curl_sockopt_callback)(void *clientp, curl_socket_t curlfd, curlsocktype purpose); +struct Curl_sockaddr { + int family; + int socktype; + int protocol; + socklen_t addrlen; + struct sockaddr addr; +}; + +typedef curl_socket_t +(*curl_opensocket_callback)(void* clentp, + curlsocktype purpose, + struct Curl_sockaddr* address); + #ifndef CURL_NO_OLDIES /* not used since 7.10.8, will be removed in a future release */ typedef int (*curl_passwd_callback)(void *clientp, @@ -1135,6 +1148,13 @@ typedef enum { /* used by scp/sftp to verify the host's public key */ CINIT(SSH_HOST_PUBLIC_KEY_MD5, OBJECTPOINT, 162), + /* Callback function for opening socket (instead of socket(2)). Optionally, + callback is able change the address or refuse to connect returning + CURL_SOCKET_BAD. The callback should have type + curl_opensocket_callback */ + CINIT(OPENSOCKETFUNCTION, FUNCTIONPOINT, 163), + CINIT(OPENSOCKETDATA, OBJECTPOINT, 164), + CURLOPT_LASTENTRY /* the last unused */ } CURLoption; -- cgit v1.2.3