From 51427e1947ddc07b4ce8ad9dcb04846125170f83 Mon Sep 17 00:00:00 2001 From: Hoi-Ho Chan Date: Wed, 5 May 2010 22:30:46 +0200 Subject: PolarSSL: initial support added This is Hoi-Ho Chan's patch with some minor fixes by me. There are some potential issues in this, but none worse than we can sort out on the list and over time. --- lib/polarssl.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 lib/polarssl.h (limited to 'lib/polarssl.h') diff --git a/lib/polarssl.h b/lib/polarssl.h new file mode 100644 index 000000000..7d406ef70 --- /dev/null +++ b/lib/polarssl.h @@ -0,0 +1,67 @@ +#ifndef __POLARSSL_H +#define __POLARSSL_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2010, Hoi-Ho Chan, + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id: polarssl.h,v 1.10 2009-02-12 20:48:43 danf Exp $ + ***************************************************************************/ + +#ifdef USE_POLARSSL + +CURLcode Curl_polarssl_connect(struct connectdata *conn, int sockindex); + +/* tell PolarSSL to close down all open information regarding connections (and + thus session ID caching etc) */ +void Curl_polarssl_close_all(struct SessionHandle *data); + + /* close a SSL connection */ +void Curl_polarssl_close(struct connectdata *conn, int sockindex); + +/* return number of sent (non-SSL) bytes */ +ssize_t Curl_polarssl_send(struct connectdata *conn, int sockindex, + const void *mem, size_t len, int *curlcode); +ssize_t Curl_polarssl_recv(struct connectdata *conn, /* connection data */ + int num, /* socketindex */ + char *buf, /* store read data here */ + size_t buffersize, /* max amount to read */ + int *curlcode); +void Curl_polarssl_session_free(void *ptr); +size_t Curl_polarssl_version(char *buffer, size_t size); +int Curl_polarssl_shutdown(struct connectdata *conn, int sockindex); + +/* API setup for PolarSSL */ +#define curlssl_init() (1) +#define curlssl_cleanup() +#define curlssl_connect Curl_polarssl_connect +#define curlssl_session_free(x) Curl_polarssl_session_free(x) +#define curlssl_close_all Curl_polarssl_close_all +#define curlssl_close Curl_polarssl_close +#define curlssl_shutdown(x,y) 0 +#define curlssl_set_engine(x,y) (x=x, y=y, CURLE_FAILED_INIT) +#define curlssl_set_engine_default(x) (x=x, CURLE_FAILED_INIT) +#define curlssl_engines_list(x) (x=x, (struct curl_slist *)NULL) +#define curlssl_send Curl_polarssl_send +#define curlssl_recv Curl_polarssl_recv +#define curlssl_version Curl_polarssl_version +#define curlssl_check_cxn(x) (x=x, -1) +#define curlssl_data_pending(x,y) (x=x, y=y, 0) + +#endif /* USE_POLARSSL */ +#endif -- cgit v1.2.1 From d64bd82bdcb169d0647a80f00068cedd761f8163 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 7 May 2010 15:05:34 +0200 Subject: sendrecv: split the I/O handling into private handler Howard Chu brought the bulk work of this patch that properly moves out the sending and recving of data to the parts of the code that are properly responsible for the various ways of doing so. Daniel Stenberg assisted with polishing a few bits and fixed some minor flaws in the original patch. Another upside of this patch is that we now abuse CURLcodes less with the "magic" -1 return codes and instead use CURLE_AGAIN more consistently. --- lib/polarssl.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'lib/polarssl.h') diff --git a/lib/polarssl.h b/lib/polarssl.h index 7d406ef70..be905987e 100644 --- a/lib/polarssl.h +++ b/lib/polarssl.h @@ -34,14 +34,6 @@ void Curl_polarssl_close_all(struct SessionHandle *data); /* close a SSL connection */ void Curl_polarssl_close(struct connectdata *conn, int sockindex); -/* return number of sent (non-SSL) bytes */ -ssize_t Curl_polarssl_send(struct connectdata *conn, int sockindex, - const void *mem, size_t len, int *curlcode); -ssize_t Curl_polarssl_recv(struct connectdata *conn, /* connection data */ - int num, /* socketindex */ - char *buf, /* store read data here */ - size_t buffersize, /* max amount to read */ - int *curlcode); void Curl_polarssl_session_free(void *ptr); size_t Curl_polarssl_version(char *buffer, size_t size); int Curl_polarssl_shutdown(struct connectdata *conn, int sockindex); @@ -57,8 +49,6 @@ int Curl_polarssl_shutdown(struct connectdata *conn, int sockindex); #define curlssl_set_engine(x,y) (x=x, y=y, CURLE_FAILED_INIT) #define curlssl_set_engine_default(x) (x=x, CURLE_FAILED_INIT) #define curlssl_engines_list(x) (x=x, (struct curl_slist *)NULL) -#define curlssl_send Curl_polarssl_send -#define curlssl_recv Curl_polarssl_recv #define curlssl_version Curl_polarssl_version #define curlssl_check_cxn(x) (x=x, -1) #define curlssl_data_pending(x,y) (x=x, y=y, 0) -- cgit v1.2.1 From 077125e4a2a77384c88b51ffd88c985cabf95193 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 2 Jun 2010 14:13:02 +0200 Subject: include libcurl standard internal headers --- lib/polarssl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/polarssl.h') diff --git a/lib/polarssl.h b/lib/polarssl.h index be905987e..964af1728 100644 --- a/lib/polarssl.h +++ b/lib/polarssl.h @@ -1,5 +1,5 @@ -#ifndef __POLARSSL_H -#define __POLARSSL_H +#ifndef HEADER_CURL_POLARSSL_H +#define HEADER_CURL_POLARSSL_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -54,4 +54,4 @@ int Curl_polarssl_shutdown(struct connectdata *conn, int sockindex); #define curlssl_data_pending(x,y) (x=x, y=y, 0) #endif /* USE_POLARSSL */ -#endif +#endif /* HEADER_CURL_POLARSSL_H */ -- cgit v1.2.1 From 01f05d0c758795e5bb02c6245fc73b8458eb397a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 5 Apr 2011 15:14:02 +0200 Subject: return code cleanup: build, init and run-time errors Stop the abuse of CURLE_FAILED_INIT as return code for things not being init related by introducing two new return codes: CURLE_NOT_BUILT_IN and CURLE_UNKNOWN_OPTION CURLE_NOT_BUILT_IN replaces return code 4 that has been obsoleted for several years. It is used for returning error when something is attempted to be used but the feature/option was not enabled or explictitly disabled at build-time. Getting this error mostly means that libcurl needs to be rebuilt. CURLE_FAILED_INIT is now saved and used strictly for init failures. Getting this problem means something went seriously wrong, like a resource shortage or similar. CURLE_UNKNOWN_OPTION is the option formerly known as CURLE_UNKNOWN_TELNET_OPTION (and the old name is still present, separately defined to be removed in a very distant future). This error code is meant to be used to return when an option is given to libcurl that isn't known. This problem would mostly indicate a problem in the program that uses libcurl. --- lib/polarssl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/polarssl.h') diff --git a/lib/polarssl.h b/lib/polarssl.h index 964af1728..9e983aac9 100644 --- a/lib/polarssl.h +++ b/lib/polarssl.h @@ -46,8 +46,8 @@ int Curl_polarssl_shutdown(struct connectdata *conn, int sockindex); #define curlssl_close_all Curl_polarssl_close_all #define curlssl_close Curl_polarssl_close #define curlssl_shutdown(x,y) 0 -#define curlssl_set_engine(x,y) (x=x, y=y, CURLE_FAILED_INIT) -#define curlssl_set_engine_default(x) (x=x, CURLE_FAILED_INIT) +#define curlssl_set_engine(x,y) (x=x, y=y, CURLE_NOT_BUILT_IN) +#define curlssl_set_engine_default(x) (x=x, CURLE_NOT_BUILT_IN) #define curlssl_engines_list(x) (x=x, (struct curl_slist *)NULL) #define curlssl_version Curl_polarssl_version #define curlssl_check_cxn(x) (x=x, -1) -- cgit v1.2.1 From c6e3081090a08f0e2a2ef2dc4c45327b22912796 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 4 Jul 2011 22:04:04 +0200 Subject: polarssl.h: remove CVS leftover --- lib/polarssl.h | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/polarssl.h') diff --git a/lib/polarssl.h b/lib/polarssl.h index 9e983aac9..92234e20e 100644 --- a/lib/polarssl.h +++ b/lib/polarssl.h @@ -20,7 +20,6 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * - * $Id: polarssl.h,v 1.10 2009-02-12 20:48:43 danf Exp $ ***************************************************************************/ #ifdef USE_POLARSSL -- cgit v1.2.1 From 6b75d2c2df7209919a70a29a4479625b62fb3c28 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 3 Sep 2011 16:06:10 +0200 Subject: fix a bunch of MSVC compiler warnings --- lib/polarssl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/polarssl.h') diff --git a/lib/polarssl.h b/lib/polarssl.h index 92234e20e..91f63afbf 100644 --- a/lib/polarssl.h +++ b/lib/polarssl.h @@ -21,6 +21,7 @@ * KIND, either express or implied. * ***************************************************************************/ +#include "setup.h" #ifdef USE_POLARSSL @@ -39,7 +40,7 @@ int Curl_polarssl_shutdown(struct connectdata *conn, int sockindex); /* API setup for PolarSSL */ #define curlssl_init() (1) -#define curlssl_cleanup() +#define curlssl_cleanup() Curl_nop_stmt #define curlssl_connect Curl_polarssl_connect #define curlssl_session_free(x) Curl_polarssl_session_free(x) #define curlssl_close_all Curl_polarssl_close_all -- cgit v1.2.1 From 5e852ab9d158e8400f3b3ea53828237ed0570730 Mon Sep 17 00:00:00 2001 From: Dag Ekengren Date: Tue, 27 Mar 2012 14:10:32 +0200 Subject: PolarSSL: add support for asynchronous connect --- lib/polarssl.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/polarssl.h') diff --git a/lib/polarssl.h b/lib/polarssl.h index 91f63afbf..ad655465e 100644 --- a/lib/polarssl.h +++ b/lib/polarssl.h @@ -27,6 +27,10 @@ CURLcode Curl_polarssl_connect(struct connectdata *conn, int sockindex); +CURLcode Curl_polarssl_connect_nonblocking(struct connectdata *conn, + int sockindex, + bool *done); + /* tell PolarSSL to close down all open information regarding connections (and thus session ID caching etc) */ void Curl_polarssl_close_all(struct SessionHandle *data); @@ -42,6 +46,7 @@ int Curl_polarssl_shutdown(struct connectdata *conn, int sockindex); #define curlssl_init() (1) #define curlssl_cleanup() Curl_nop_stmt #define curlssl_connect Curl_polarssl_connect +#define curlssl_connect_nonblocking Curl_polarssl_connect_nonblocking #define curlssl_session_free(x) Curl_polarssl_session_free(x) #define curlssl_close_all Curl_polarssl_close_all #define curlssl_close Curl_polarssl_close -- cgit v1.2.1