summaryrefslogtreecommitdiff
path: root/Utilities/cmcurl/lib/getinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/cmcurl/lib/getinfo.c')
-rw-r--r--Utilities/cmcurl/lib/getinfo.c128
1 files changed, 82 insertions, 46 deletions
diff --git a/Utilities/cmcurl/lib/getinfo.c b/Utilities/cmcurl/lib/getinfo.c
index 910f520edc..262cd934fa 100644
--- a/Utilities/cmcurl/lib/getinfo.c
+++ b/Utilities/cmcurl/lib/getinfo.c
@@ -9,7 +9,7 @@
*
* 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.
+ * are also available at https://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
@@ -39,7 +39,7 @@
* This is supposed to be called in the beginning of a perform() session
* and should reset all session-info variables
*/
-CURLcode Curl_initinfo(struct SessionHandle *data)
+CURLcode Curl_initinfo(struct Curl_easy *data)
{
struct Progress *pro = &data->progress;
struct PureInfo *info = &data->info;
@@ -73,7 +73,7 @@ CURLcode Curl_initinfo(struct SessionHandle *data)
return CURLE_OK;
}
-static CURLcode getinfo_char(struct SessionHandle *data, CURLINFO info,
+static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info,
char **param_charp)
{
switch(info) {
@@ -113,13 +113,13 @@ static CURLcode getinfo_char(struct SessionHandle *data, CURLINFO info,
break;
default:
- return CURLE_BAD_FUNCTION_ARGUMENT;
+ return CURLE_UNKNOWN_OPTION;
}
return CURLE_OK;
}
-static CURLcode getinfo_long(struct SessionHandle *data, CURLINFO info,
+static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
long *param_longp)
{
curl_socket_t sockfd;
@@ -198,15 +198,31 @@ static CURLcode getinfo_long(struct SessionHandle *data, CURLINFO info,
case CURLINFO_RTSP_CSEQ_RECV:
*param_longp = data->state.rtsp_CSeq_recv;
break;
+ case CURLINFO_HTTP_VERSION:
+ switch (data->info.httpversion) {
+ case 10:
+ *param_longp = CURL_HTTP_VERSION_1_0;
+ break;
+ case 11:
+ *param_longp = CURL_HTTP_VERSION_1_1;
+ break;
+ case 20:
+ *param_longp = CURL_HTTP_VERSION_2_0;
+ break;
+ default:
+ *param_longp = CURL_HTTP_VERSION_NONE;
+ break;
+ }
+ break;
default:
- return CURLE_BAD_FUNCTION_ARGUMENT;
+ return CURLE_UNKNOWN_OPTION;
}
return CURLE_OK;
}
-static CURLcode getinfo_double(struct SessionHandle *data, CURLINFO info,
+static CURLcode getinfo_double(struct Curl_easy *data, CURLINFO info,
double *param_doublep)
{
switch(info) {
@@ -253,13 +269,13 @@ static CURLcode getinfo_double(struct SessionHandle *data, CURLINFO info,
break;
default:
- return CURLE_BAD_FUNCTION_ARGUMENT;
+ return CURLE_UNKNOWN_OPTION;
}
return CURLE_OK;
}
-static CURLcode getinfo_slist(struct SessionHandle *data, CURLINFO info,
+static CURLcode getinfo_slist(struct Curl_easy *data, CURLINFO info,
struct curl_slist **param_slistp)
{
union {
@@ -281,69 +297,84 @@ static CURLcode getinfo_slist(struct SessionHandle *data, CURLINFO info,
*param_slistp = ptr.to_slist;
break;
case CURLINFO_TLS_SESSION:
+ case CURLINFO_TLS_SSL_PTR:
{
struct curl_tlssessioninfo **tsip = (struct curl_tlssessioninfo **)
param_slistp;
struct curl_tlssessioninfo *tsi = &data->tsi;
struct connectdata *conn = data->easy_conn;
- unsigned int sockindex = 0;
- void *internals = NULL;
*tsip = tsi;
- tsi->backend = CURLSSLBACKEND_NONE;
+ tsi->backend = Curl_ssl_backend();
tsi->internals = NULL;
- if(!conn)
- break;
-
- /* Find the active ("in use") SSL connection, if any */
- while((sockindex < sizeof(conn->ssl) / sizeof(conn->ssl[0])) &&
- (!conn->ssl[sockindex].use))
- sockindex++;
-
- if(sockindex == sizeof(conn->ssl) / sizeof(conn->ssl[0]))
- break; /* no SSL session found */
-
- /* Return the TLS session information from the relevant backend */
-#ifdef USE_OPENSSL
- internals = conn->ssl[sockindex].ctx;
+ if(conn && tsi->backend != CURLSSLBACKEND_NONE) {
+ unsigned int i;
+ for(i = 0; i < (sizeof(conn->ssl) / sizeof(conn->ssl[0])); ++i) {
+ if(conn->ssl[i].use) {
+#if defined(USE_AXTLS)
+ tsi->internals = (void *)conn->ssl[i].ssl;
+#elif defined(USE_CYASSL)
+ tsi->internals = (void *)conn->ssl[i].handle;
+#elif defined(USE_DARWINSSL)
+ tsi->internals = (void *)conn->ssl[i].ssl_ctx;
+#elif defined(USE_GNUTLS)
+ tsi->internals = (void *)conn->ssl[i].session;
+#elif defined(USE_GSKIT)
+ tsi->internals = (void *)conn->ssl[i].handle;
+#elif defined(USE_MBEDTLS)
+ tsi->internals = (void *)&conn->ssl[i].ssl;
+#elif defined(USE_NSS)
+ tsi->internals = (void *)conn->ssl[i].handle;
+#elif defined(USE_OPENSSL)
+ /* Legacy: CURLINFO_TLS_SESSION must return an SSL_CTX pointer. */
+ tsi->internals = ((info == CURLINFO_TLS_SESSION) ?
+ (void *)conn->ssl[i].ctx :
+ (void *)conn->ssl[i].handle);
+#elif defined(USE_POLARSSL)
+ tsi->internals = (void *)&conn->ssl[i].ssl;
+#elif defined(USE_SCHANNEL)
+ tsi->internals = (void *)&conn->ssl[i].ctxt->ctxt_handle;
+#elif defined(USE_SSL)
+#error "SSL backend specific information missing for CURLINFO_TLS_SSL_PTR"
#endif
-#ifdef USE_GNUTLS
- internals = conn->ssl[sockindex].session;
-#endif
-#ifdef USE_NSS
- internals = conn->ssl[sockindex].handle;
-#endif
-#ifdef USE_GSKIT
- internals = conn->ssl[sockindex].handle;
-#endif
- if(internals) {
- tsi->backend = Curl_ssl_backend();
- tsi->internals = internals;
+ break;
+ }
+ }
}
- /* NOTE: For other SSL backends, it is not immediately clear what data
- to return from 'struct ssl_connect_data'; thus, for now we keep the
- backend as CURLSSLBACKEND_NONE in those cases, which should be
- interpreted as "not supported" */
}
break;
default:
- return CURLE_BAD_FUNCTION_ARGUMENT;
+ return CURLE_UNKNOWN_OPTION;
+ }
+
+ return CURLE_OK;
+}
+
+static CURLcode getinfo_socket(struct Curl_easy *data, CURLINFO info,
+ curl_socket_t *param_socketp)
+{
+ switch(info) {
+ case CURLINFO_ACTIVESOCKET:
+ *param_socketp = Curl_getconnectinfo(data, NULL);
+ break;
+ default:
+ return CURLE_UNKNOWN_OPTION;
}
return CURLE_OK;
}
-CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
+CURLcode Curl_getinfo(struct Curl_easy *data, CURLINFO info, ...)
{
va_list arg;
long *param_longp = NULL;
double *param_doublep = NULL;
char **param_charp = NULL;
struct curl_slist **param_slistp = NULL;
+ curl_socket_t *param_socketp = NULL;
int type;
- /* default return code is to error out! */
- CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT;
+ CURLcode result = CURLE_UNKNOWN_OPTION;
if(!data)
return result;
@@ -372,6 +403,11 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
if(param_slistp)
result = getinfo_slist(data, info, param_slistp);
break;
+ case CURLINFO_SOCKET:
+ param_socketp = va_arg(arg, curl_socket_t *);
+ if(param_socketp)
+ result = getinfo_socket(data, info, param_socketp);
+ break;
default:
break;
}