From `lib/a*` to `lib/cs*`.
Closes #19764
}
}
-
static void altsvc_free(struct altsvc *as)
{
curlx_free(as->src.host);
const int versions); /* CURLALTSVC_H* bits */
#else
/* disabled */
-#define Curl_altsvc_save(a,b,c)
+#define Curl_altsvc_save(a, b, c)
#define Curl_altsvc_cleanup(x)
#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_ALTSVC */
#endif /* HEADER_CURL_ALTSVC_H */
* allocates memory also.
*/
-struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
- int port)
+struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, int port)
{
struct Curl_addrinfo *ai = NULL;
struct hostent *h;
}
}
else {
- #ifdef CURLRES_THREADED
+#ifdef CURLRES_THREADED
/* gethostbyname() is not thread safe, so we need to reopen bsdsocket
* on the thread's context
*/
}
CloseLibrary(base);
}
- #else
+#else
/* not using threaded resolver - safe to use this as-is */
h = gethostbyname(hostname);
if(h) {
ai = Curl_he2ai(h, port);
}
- #endif
+#endif
}
return ai;
}
if(SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (ULONG)&errno,
- SBTM_SETVAL(SBTC_LOGTAGPTR), (ULONG)"curl",
- TAG_DONE)) {
+ SBTM_SETVAL(SBTC_LOGTAGPTR), (ULONG)"curl", TAG_DONE)) {
CURL_AMIGA_REQUEST("SocketBaseTags ERROR");
return CURLE_FAILED_INIT;
}
/*
* The telnet options represented as strings
*/
-static const char * const telnetoptions[]=
-{
+static const char * const telnetoptions[] = {
"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD",
"NAME", "STATUS", "TIMING MARK", "RCTE",
"NAOL", "NAOP", "NAOCRD", "NAOHTS",
/*
* Then those numbers represented as strings:
*/
-static const char * const telnetcmds[]=
-{
+static const char * const telnetcmds[] = {
"EOF", "SUSP", "ABORT", "EOR", "SE",
"NOP", "DMARK", "BRK", "IP", "AO",
"AYT", "EC", "EL", "GA", "SB",
#define CURL_TELQUAL_INFO 2
#define CURL_TELQUAL_NAME 3
-#define CURL_TELCMD_OK(x) ( ((unsigned int)(x) >= CURL_TELCMD_MINIMUM) && \
- ((unsigned int)(x) <= CURL_TELCMD_MAXIMUM) )
+#define CURL_TELCMD_OK(x) (((unsigned int)(x) >= CURL_TELCMD_MINIMUM) && \
+ ((unsigned int)(x) <= CURL_TELCMD_MAXIMUM))
#ifndef CURL_DISABLE_VERBOSE_STRINGS
-#define CURL_TELCMD(x) telnetcmds[(x)-CURL_TELCMD_MINIMUM]
+#define CURL_TELCMD(x) telnetcmds[(x) - CURL_TELCMD_MINIMUM]
#else
#define CURL_TELCMD(x) ""
#endif
#endif
}
-
static void sock_state_cb(void *data, ares_socket_t socket_fd,
int readable, int writable)
{
/* Now that we have checked for any last minute results above, see if there
are any responses still pending when the EXPIRE_HAPPY_EYEBALLS_DNS timer
expires. */
- if(ares->num_pending
+ if(ares->num_pending &&
/* This is only set to non-zero if the timer was started. */
- && (ares->happy_eyeballs_dns_time.tv_sec
- || ares->happy_eyeballs_dns_time.tv_usec)
- && (curlx_timediff_ms(curlx_now(), ares->happy_eyeballs_dns_time)
- >= HAPPY_EYEBALLS_DNS_TIMEOUT)) {
+ (ares->happy_eyeballs_dns_time.tv_sec ||
+ ares->happy_eyeballs_dns_time.tv_usec) &&
+ (curlx_timediff_ms(curlx_now(), ares->happy_eyeballs_dns_time) >=
+ HAPPY_EYEBALLS_DNS_TIMEOUT)) {
/* Remember that the EXPIRE_HAPPY_EYEBALLS_DNS timer is no longer
running. */
memset(&ares->happy_eyeballs_dns_time, 0,
itimeout_ms = (int)timeout_ms;
#endif
- max_timeout.tv_sec = itimeout_ms/1000;
- max_timeout.tv_usec = (itimeout_ms%1000)*1000;
+ max_timeout.tv_sec = itimeout_ms / 1000;
+ max_timeout.tv_usec = (itimeout_ms % 1000) * 1000;
real_timeout = ares_timeout(ares->channel, &max_timeout, &time_buf);
second is left, otherwise just use 1000ms to make sure the progress
callback gets called frequent enough */
if(!real_timeout->tv_sec)
- call_timeout_ms = (timediff_t)(real_timeout->tv_usec/1000);
+ call_timeout_ms = (timediff_t)(real_timeout->tv_usec / 1000);
else
call_timeout_ms = 1000;
if(ARES_SUCCESS == status) {
ares->ares_status = status; /* one success overrules any error */
async_addr_concat(&ares->temp_ai,
- Curl_he2ai(hostent, data->state.async.port));
+ Curl_he2ai(hostent, data->state.async.port));
}
else if(ares->ares_status != ARES_SUCCESS) {
/* no success so far, remember last error */
c-ares retry cycle each request is.
*/
ares->happy_eyeballs_dns_time = curlx_now();
- Curl_expire(data, HAPPY_EYEBALLS_DNS_TIMEOUT,
- EXPIRE_HAPPY_EYEBALLS_DNS);
+ Curl_expire(data, HAPPY_EYEBALLS_DNS_TIMEOUT, EXPIRE_HAPPY_EYEBALLS_DNS);
}
}
**********************************************************************/
#ifdef CURLRES_ASYNCH
-
#ifdef USE_ARES
#if ARES_VERSION < 0x010600
*
* return number of sockets it worked on, or -1 on error
*/
-int Curl_ares_perform(ares_channel channel,
- timediff_t timeout_ms)
+int Curl_ares_perform(ares_channel channel, timediff_t timeout_ms)
{
int nfds;
int bitmask;
pfd[i].revents = 0;
if(ARES_GETSOCK_READABLE(bitmask, i)) {
pfd[i].fd = socks[i];
- pfd[i].events |= POLLRDNORM|POLLIN;
+ pfd[i].events |= POLLRDNORM | POLLIN;
}
if(ARES_GETSOCK_WRITABLE(bitmask, i)) {
pfd[i].fd = socks[i];
- pfd[i].events |= POLLWRNORM|POLLOUT;
+ pfd[i].events |= POLLWRNORM | POLLOUT;
}
if(pfd[i].events)
num++;
#endif
#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
-# include <pthread.h>
+#include <pthread.h>
#endif
#ifdef HAVE_GETADDRINFO
-# define RESOLVER_ENOMEM EAI_MEMORY /* = WSA_NOT_ENOUGH_MEMORY on Windows */
+#define RESOLVER_ENOMEM EAI_MEMORY /* = WSA_NOT_ENOUGH_MEMORY on Windows */
#else
-# define RESOLVER_ENOMEM SOCKENOMEM
+#define RESOLVER_ENOMEM SOCKENOMEM
#endif
#include "urldata.h"
}
}
#endif
-
}
addr_ctx_unlink(&addr_ctx, NULL);
Curl_mutex_acquire(&addr_ctx->mutx);
#ifndef CURL_DISABLE_SOCKETPAIR
- if(!addr_ctx->do_abort)
- Curl_multi_will_close(data, addr_ctx->sock_pair[0]);
+ if(!addr_ctx->do_abort)
+ Curl_multi_will_close(data, addr_ctx->sock_pair[0]);
#endif
addr_ctx->do_abort = TRUE;
done = addr_ctx->thrd_done;
if(!thrd_done) {
#ifndef CURL_DISABLE_SOCKETPAIR
- /* return read fd to client for polling the DNS resolution status */
+ /* return read fd to client for polling the DNS resolution status */
result = Curl_pollset_add_in(data, ps, thrdd->addr->sock_pair[0]);
#else
timediff_t milli;
if(ms < 3)
milli = 0;
else if(ms <= 50)
- milli = ms/3;
+ milli = ms / 3;
else if(ms <= 250)
milli = 50;
else
ares_channel channel,
struct easy_pollset *ps);
-int Curl_ares_perform(ares_channel channel,
- timediff_t timeout_ms);
+int Curl_ares_perform(ares_channel channel, timediff_t timeout_ms);
#endif
#ifdef CURLRES_ARES
/* async resolving implementation using c-ares alone */
struct async_ares_ctx {
ares_channel channel;
- int num_pending; /* number of outstanding c-ares requests */
+ int num_pending; /* number of outstanding c-ares requests */
struct Curl_addrinfo *temp_ai; /* intermediary result while fetching c-ares
parts */
- int ares_status; /* ARES_SUCCESS, ARES_ENOTFOUND, etc. */
- CURLcode result; /* CURLE_OK or error handling response */
+ int ares_status; /* ARES_SUCCESS, ARES_ENOTFOUND, etc. */
+ CURLcode result; /* CURLE_OK or error handling response */
#ifndef HAVE_CARES_GETADDRINFO
struct curltime happy_eyeballs_dns_time; /* when this timer started, or 0 */
#endif
#else /* CURLRES_ASYNCH */
/* convert these functions if an asynch resolver is not used */
-#define Curl_async_get_impl(x,y) (*(y) = NULL, CURLE_OK)
-#define Curl_async_is_resolved(x,y) CURLE_COULDNT_RESOLVE_HOST
-#define Curl_async_await(x,y) CURLE_COULDNT_RESOLVE_HOST
-#define Curl_async_global_init() CURLE_OK
-#define Curl_async_global_cleanup() Curl_nop_stmt
+#define Curl_async_get_impl(x, y) (*(y) = NULL, CURLE_OK)
+#define Curl_async_is_resolved(x,y) CURLE_COULDNT_RESOLVE_HOST
+#define Curl_async_await(x, y) CURLE_COULDNT_RESOLVE_HOST
+#define Curl_async_global_init() CURLE_OK
+#define Curl_async_global_cleanup() Curl_nop_stmt
#endif /* !CURLRES_ASYNCH */
#define Curl_async_destroy(x) Curl_nop_stmt
#endif /* USE_CURL_ASYNC */
-
/********** end of generic resolver interface functions *****************/
#endif /* HEADER_CURL_ASYN_H */
}
}
-
void Curl_bufcp_init(struct bufc_pool *pool,
size_t chunk_size, size_t spare_max)
{
--q->chunk_count;
}
else if((q->chunk_count > q->max_chunks) ||
- (q->opts & BUFQ_OPT_NO_SPARES)) {
+ (q->opts & BUFQ_OPT_NO_SPARES)) {
/* SOFT_LIMIT allowed us more than max. free spares until
* we are at max again. Or free them if we are configured
* to not use spares. */
size_t r_offset; /* first unread bytes */
size_t w_offset; /* one after last written byte */
union {
- uint8_t data[1]; /* the buffer for `dlen` bytes */
+ uint8_t data[1]; /* the buffer for `dlen` bytes */
void *dummy; /* alignment */
} x;
};
DEBUGASSERT(len <= CURL_MAX_INPUT_LENGTH);
Curl_bufref_free(br);
- br->ptr = (const unsigned char *) ptr;
+ br->ptr = (const unsigned char *)ptr;
br->len = len;
br->dtor = dtor;
}
#endif
};
-
void Curl_bufref_init(struct bufref *br);
void Curl_bufref_set(struct bufref *br, const void *ptr, size_t len,
void (*dtor)(void *));
typedef enum {
- H1_TUNNEL_INIT, /* init/default/no tunnel state */
- H1_TUNNEL_CONNECT, /* CONNECT request is being send */
- H1_TUNNEL_RECEIVE, /* CONNECT answer is being received */
- H1_TUNNEL_RESPONSE, /* CONNECT response received completely */
- H1_TUNNEL_ESTABLISHED,
- H1_TUNNEL_FAILED
+ H1_TUNNEL_INIT, /* init/default/no tunnel state */
+ H1_TUNNEL_CONNECT, /* CONNECT request is being send */
+ H1_TUNNEL_RECEIVE, /* CONNECT answer is being received */
+ H1_TUNNEL_RESPONSE, /* CONNECT response received completely */
+ H1_TUNNEL_ESTABLISHED,
+ H1_TUNNEL_FAILED
} h1_tunnel_state;
/* struct for HTTP CONNECT tunneling */
BIT(close_connection);
};
-
static bool tunnel_is_established(struct h1_tunnel_state *ts)
{
return ts && (ts->tunnel_state == H1_TUNNEL_ESTABLISHED);
int http_minor;
CURLcode result;
- /* This only happens if we have looped here due to authentication
- reasons, and we do not really use the newly cloned URL here
- then. Just free it. */
+ /* This only happens if we have looped here due to authentication
+ reasons, and we do not really use the newly cloned URL here
+ then. Just free it. */
Curl_safefree(data->req.newurl);
result = Curl_http_proxy_create_CONNECT(&req, cf, data, 1);
struct SingleRequest *k = &data->req;
(void)cf;
- if((checkprefix("WWW-Authenticate:", header) &&
- (401 == k->httpcode)) ||
- (checkprefix("Proxy-authenticate:", header) &&
- (407 == k->httpcode))) {
+ if((checkprefix("WWW-Authenticate:", header) && (401 == k->httpcode)) ||
+ (checkprefix("Proxy-authenticate:", header) && (407 == k->httpcode))) {
bool proxy = (k->httpcode == 407);
char *auth = Curl_copy_header_value(header);
return result;
}
else if(checkprefix("Content-Length:", header)) {
- if(k->httpcode/100 == 2) {
+ if(k->httpcode / 100 == 2) {
/* A client MUST ignore any Content-Length or Transfer-Encoding
header fields received in a successful response to CONNECT.
"Successful" described as: 2xx (Successful). RFC 7231 4.3.6 */
STRCONST("Connection:"), STRCONST("close")))
ts->close_connection = TRUE;
else if(checkprefix("Transfer-Encoding:", header)) {
- if(k->httpcode/100 == 2) {
+ if(k->httpcode / 100 == 2) {
/* A client MUST ignore any Content-Length or Transfer-Encoding
header fields received in a successful response to CONNECT.
"Successful" described as: 2xx (Successful). RFC 7231 4.3.6 */
ts->keepon = KEEPON_DONE;
}
- DEBUGASSERT(ts->keepon == KEEPON_IGNORE
- || ts->keepon == KEEPON_DONE);
+ DEBUGASSERT(ts->keepon == KEEPON_IGNORE ||
+ ts->keepon == KEEPON_DONE);
continue;
}
if(error)
result = CURLE_RECV_ERROR;
*done = (ts->keepon == KEEPON_DONE);
- if(!result && *done && data->info.httpproxycode/100 != 2) {
+ if(!result && *done && data->info.httpproxycode / 100 != 2) {
/* Deal with the possibly already received authenticate
headers. 'newurl' is set to a new URL if we must loop. */
result = Curl_http_auth_act(data);
} while(data->req.newurl);
DEBUGASSERT(ts->tunnel_state == H1_TUNNEL_RESPONSE);
- if(data->info.httpproxycode/100 != 2) {
+ if(data->info.httpproxycode / 100 != 2) {
/* a non-2xx response and we have no next URL to try. */
Curl_safefree(data->req.newurl);
h1_tunnel_go_state(cf, ts, H1_TUNNEL_FAILED, data);
}
}
-
struct Curl_cftype Curl_cft_h1_proxy = {
"H1-PROXY",
- CF_TYPE_IP_CONNECT|CF_TYPE_PROXY,
+ CF_TYPE_IP_CONNECT | CF_TYPE_PROXY,
0,
cf_h1_proxy_destroy,
cf_h1_proxy_connect,
extern struct Curl_cftype Curl_cft_h1_proxy;
-
#endif /* !CURL_DISABLE_PROXY && !CURL_DISABLE_HTTP */
#endif /* HEADER_CURL_H1_PROXY_H */
#include "curlx/warnless.h"
#include "cf-h2-proxy.h"
-#define PROXY_H2_CHUNK_SIZE (16*1024)
+#define PROXY_H2_CHUNK_SIZE (16 * 1024)
#define PROXY_HTTP2_HUGE_WINDOW_SIZE (100 * 1024 * 1024)
#define H2_TUNNEL_WINDOW_SIZE (10 * 1024 * 1024)
-#define PROXY_H2_NW_RECV_CHUNKS (H2_TUNNEL_WINDOW_SIZE / PROXY_H2_CHUNK_SIZE)
+#define PROXY_H2_NW_RECV_CHUNKS (H2_TUNNEL_WINDOW_SIZE / PROXY_H2_CHUNK_SIZE)
#define PROXY_H2_NW_SEND_CHUNKS 1
#define H2_TUNNEL_RECV_CHUNKS (H2_TUNNEL_WINDOW_SIZE / PROXY_H2_CHUNK_SIZE)
typedef enum {
- H2_TUNNEL_INIT, /* init/default/no tunnel state */
- H2_TUNNEL_CONNECT, /* CONNECT request is being send */
- H2_TUNNEL_RESPONSE, /* CONNECT response received completely */
- H2_TUNNEL_ESTABLISHED,
- H2_TUNNEL_FAILED
+ H2_TUNNEL_INIT, /* init/default/no tunnel state */
+ H2_TUNNEL_CONNECT, /* CONNECT request is being send */
+ H2_TUNNEL_RESPONSE, /* CONNECT response received completely */
+ H2_TUNNEL_ESTABLISHED,
+ H2_TUNNEL_FAILED
} h2_tunnel_state;
struct tunnel_stream {
Curl_http_proxy_get_destination(cf, &hostname, &port, &ipv6_ip);
/* host:port with IPv6 support */
- ts->authority = curl_maprintf("%s%s%s:%d", ipv6_ip ? "[":"", hostname,
+ ts->authority = curl_maprintf("%s%s%s:%d", ipv6_ip ? "[" : "", hostname,
ipv6_ip ? "]" : "", port);
if(!ts->authority)
return CURLE_OUT_OF_MEMORY;
/* How to access `call_data` from a cf_h2 filter */
#undef CF_CTX_CALL_DATA
-#define CF_CTX_CALL_DATA(cf) \
- ((struct cf_h2_proxy_ctx *)(cf)->ctx)->call_data
+#define CF_CTX_CALL_DATA(cf) ((struct cf_h2_proxy_ctx *)(cf)->ctx)->call_data
static void cf_h2_proxy_ctx_clear(struct cf_h2_proxy_ctx *ctx)
{
char *buffer, size_t blen)
{
switch(frame->hd.type) {
- case NGHTTP2_DATA: {
- return curl_msnprintf(buffer, blen,
- "FRAME[DATA, len=%d, eos=%d, padlen=%d]",
- (int)frame->hd.length,
- !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM),
- (int)frame->data.padlen);
+ case NGHTTP2_DATA: {
+ return curl_msnprintf(buffer, blen,
+ "FRAME[DATA, len=%d, eos=%d, padlen=%d]",
+ (int)frame->hd.length,
+ !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM),
+ (int)frame->data.padlen);
+ }
+ case NGHTTP2_HEADERS: {
+ return curl_msnprintf(buffer, blen,
+ "FRAME[HEADERS, len=%d, hend=%d, eos=%d]",
+ (int)frame->hd.length,
+ !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS),
+ !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM));
+ }
+ case NGHTTP2_PRIORITY: {
+ return curl_msnprintf(buffer, blen,
+ "FRAME[PRIORITY, len=%d, flags=%d]",
+ (int)frame->hd.length, frame->hd.flags);
+ }
+ case NGHTTP2_RST_STREAM: {
+ return curl_msnprintf(buffer, blen,
+ "FRAME[RST_STREAM, len=%d, flags=%d, error=%u]",
+ (int)frame->hd.length, frame->hd.flags,
+ frame->rst_stream.error_code);
+ }
+ case NGHTTP2_SETTINGS: {
+ if(frame->hd.flags & NGHTTP2_FLAG_ACK) {
+ return curl_msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]");
}
- case NGHTTP2_HEADERS: {
- return curl_msnprintf(buffer, blen,
- "FRAME[HEADERS, len=%d, hend=%d, eos=%d]",
- (int)frame->hd.length,
- !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS),
- !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM));
- }
- case NGHTTP2_PRIORITY: {
- return curl_msnprintf(buffer, blen,
- "FRAME[PRIORITY, len=%d, flags=%d]",
- (int)frame->hd.length, frame->hd.flags);
- }
- case NGHTTP2_RST_STREAM: {
- return curl_msnprintf(buffer, blen,
- "FRAME[RST_STREAM, len=%d, flags=%d, error=%u]",
- (int)frame->hd.length, frame->hd.flags,
- frame->rst_stream.error_code);
- }
- case NGHTTP2_SETTINGS: {
- if(frame->hd.flags & NGHTTP2_FLAG_ACK) {
- return curl_msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]");
- }
- return curl_msnprintf(buffer, blen,
- "FRAME[SETTINGS, len=%d]", (int)frame->hd.length);
- }
- case NGHTTP2_PUSH_PROMISE:
- return curl_msnprintf(buffer, blen,
- "FRAME[PUSH_PROMISE, len=%d, hend=%d]",
- (int)frame->hd.length,
- !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS));
- case NGHTTP2_PING:
- return curl_msnprintf(buffer, blen,
- "FRAME[PING, len=%d, ack=%d]",
- (int)frame->hd.length,
- frame->hd.flags & NGHTTP2_FLAG_ACK);
- case NGHTTP2_GOAWAY: {
- char scratch[128];
- size_t s_len = CURL_ARRAYSIZE(scratch);
- size_t len = (frame->goaway.opaque_data_len < s_len) ?
- frame->goaway.opaque_data_len : s_len-1;
- if(len)
- memcpy(scratch, frame->goaway.opaque_data, len);
- scratch[len] = '\0';
- return curl_msnprintf(buffer, blen,
- "FRAME[GOAWAY, error=%d, reason='%s', "
- "last_stream=%d]", frame->goaway.error_code,
- scratch, frame->goaway.last_stream_id);
- }
- case NGHTTP2_WINDOW_UPDATE: {
- return curl_msnprintf(buffer, blen,
- "FRAME[WINDOW_UPDATE, incr=%d]",
- frame->window_update.window_size_increment);
- }
- default:
- return curl_msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]",
- frame->hd.type, (int)frame->hd.length,
- frame->hd.flags);
+ return curl_msnprintf(buffer, blen,
+ "FRAME[SETTINGS, len=%d]", (int)frame->hd.length);
+ }
+ case NGHTTP2_PUSH_PROMISE:
+ return curl_msnprintf(buffer, blen,
+ "FRAME[PUSH_PROMISE, len=%d, hend=%d]",
+ (int)frame->hd.length,
+ !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS));
+ case NGHTTP2_PING:
+ return curl_msnprintf(buffer, blen,
+ "FRAME[PING, len=%d, ack=%d]",
+ (int)frame->hd.length,
+ frame->hd.flags & NGHTTP2_FLAG_ACK);
+ case NGHTTP2_GOAWAY: {
+ char scratch[128];
+ size_t s_len = CURL_ARRAYSIZE(scratch);
+ size_t len = (frame->goaway.opaque_data_len < s_len) ?
+ frame->goaway.opaque_data_len : s_len-1;
+ if(len)
+ memcpy(scratch, frame->goaway.opaque_data, len);
+ scratch[len] = '\0';
+ return curl_msnprintf(buffer, blen,
+ "FRAME[GOAWAY, error=%d, reason='%s', "
+ "last_stream=%d]", frame->goaway.error_code,
+ scratch, frame->goaway.last_stream_id);
+ }
+ case NGHTTP2_WINDOW_UPDATE: {
+ return curl_msnprintf(buffer, blen,
+ "FRAME[WINDOW_UPDATE, incr=%d]",
+ frame->window_update.window_size_increment);
+ }
+ default:
+ return curl_msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]",
+ frame->hd.type, (int)frame->hd.length,
+ frame->hd.flags);
}
}
if(data && Curl_trc_cf_is_verbose(cf, data)) {
char buffer[256];
int len;
- len = proxy_h2_fr_print(frame, buffer, sizeof(buffer)-1);
+ len = proxy_h2_fr_print(frame, buffer, sizeof(buffer) - 1);
buffer[len] = 0;
CURL_TRC_CF(data, cf, "[%d] -> %s", frame->hd.stream_id, buffer);
}
if(Curl_trc_cf_is_verbose(cf, data)) {
char buffer[256];
int len;
- len = proxy_h2_fr_print(frame, buffer, sizeof(buffer)-1);
+ len = proxy_h2_fr_print(frame, buffer, sizeof(buffer) - 1);
buffer[len] = 0;
- CURL_TRC_CF(data, cf, "[%d] <- %s",frame->hd.stream_id, buffer);
+ CURL_TRC_CF(data, cf, "[%d] <- %s", frame->hd.stream_id, buffer);
}
#endif /* !CURL_DISABLE_VERBOSE_STRINGS */
(void)cf;
DEBUGASSERT(ts->resp);
- if(ts->resp->status/100 == 2) {
+ if(ts->resp->status / 100 == 2) {
infof(data, "CONNECT tunnel established, response %d", ts->resp->status);
h2_tunnel_go_state(cf, ts, H2_TUNNEL_ESTABLISHED, data);
return CURLE_OK;
c_exhaust = !nghttp2_session_get_remote_window_size(ctx->h2);
s_exhaust = ctx->tunnel.stream_id >= 0 &&
!nghttp2_session_get_stream_remote_window_size(
- ctx->h2, ctx->tunnel.stream_id);
+ ctx->h2, ctx->tunnel.stream_id);
want_recv = (want_recv || c_exhaust || s_exhaust);
want_send = (!s_exhaust && want_send) ||
(!c_exhaust && nghttp2_session_want_write(ctx->h2)) ||
"h2 windows %d-%d (stream-conn), buffers %zu-%zu (stream-conn)",
ctx->tunnel.stream_id, len, result, *pnwritten,
nghttp2_session_get_stream_remote_window_size(
- ctx->h2, ctx->tunnel.stream_id),
+ ctx->h2, ctx->tunnel.stream_id),
nghttp2_session_get_remote_window_size(ctx->h2),
Curl_bufq_len(&ctx->tunnel.sendbuf),
Curl_bufq_len(&ctx->outbufq));
struct Curl_cftype Curl_cft_h2_proxy = {
"H2-PROXY",
- CF_TYPE_IP_CONNECT|CF_TYPE_PROXY,
+ CF_TYPE_IP_CONNECT | CF_TYPE_PROXY,
CURL_LOG_LVL_NONE,
cf_h2_proxy_destroy,
cf_h2_proxy_connect,
typedef enum {
- HAPROXY_INIT, /* init/default/no tunnel state */
- HAPROXY_SEND, /* data_out being sent */
- HAPROXY_DONE /* all work done */
+ HAPROXY_INIT, /* init/default/no tunnel state */
+ HAPROXY_SEND, /* data_out being sent */
+ HAPROXY_DONE /* all work done */
} haproxy_state;
struct cf_haproxy_ctx {
}
}
-static CURLcode cf_haproxy_date_out_set(struct Curl_cfilter*cf,
+static CURLcode cf_haproxy_date_out_set(struct Curl_cfilter *cf,
struct Curl_easy *data)
{
struct cf_haproxy_ctx *ctx = cf->ctx;
}
#endif /* UNITTESTS */
-
struct cf_ai_iter {
const struct Curl_addrinfo *head;
const struct Curl_addrinfo *last;
int ai_family = 0;
#ifdef USE_IPV6
if((bs->last_attempt_ai_family == AF_INET) ||
- !cf_ai_iter_has_more(&bs->addr_iter)) {
- addr = cf_ai_iter_next(&bs->ipv6_iter);
- ai_family = bs->ipv6_iter.ai_family;
+ !cf_ai_iter_has_more(&bs->addr_iter)) {
+ addr = cf_ai_iter_next(&bs->ipv6_iter);
+ ai_family = bs->ipv6_iter.ai_family;
}
#endif
if(!addr) {
struct curltime started;
};
-
static CURLcode is_connected(struct Curl_cfilter *cf,
struct Curl_easy *data,
bool *connected)
*done = FALSE;
switch(ctx->state) {
- case SCFST_INIT:
- DEBUGASSERT(CURL_SOCKET_BAD == Curl_conn_cf_get_socket(cf, data));
- DEBUGASSERT(!cf->connected);
- result = start_connect(cf, data);
- if(result)
- return result;
- ctx->state = SCFST_WAITING;
- FALLTHROUGH();
- case SCFST_WAITING:
- result = is_connected(cf, data, done);
- if(!result && *done) {
- DEBUGASSERT(ctx->ballers.winner);
- DEBUGASSERT(ctx->ballers.winner->cf);
- DEBUGASSERT(ctx->ballers.winner->cf->connected);
- /* we have a winner. Install and activate it.
- * close/free all others. */
- ctx->state = SCFST_DONE;
- cf->connected = TRUE;
- cf->next = ctx->ballers.winner->cf;
- ctx->ballers.winner->cf = NULL;
- cf_ip_happy_ctx_clear(cf, data);
- Curl_expire_done(data, EXPIRE_HAPPY_EYEBALLS);
-
- if(cf->conn->handler->protocol & PROTO_FAMILY_SSH)
- Curl_pgrsTime(data, TIMER_APPCONNECT); /* we are connected already */
+ case SCFST_INIT:
+ DEBUGASSERT(CURL_SOCKET_BAD == Curl_conn_cf_get_socket(cf, data));
+ DEBUGASSERT(!cf->connected);
+ result = start_connect(cf, data);
+ if(result)
+ return result;
+ ctx->state = SCFST_WAITING;
+ FALLTHROUGH();
+ case SCFST_WAITING:
+ result = is_connected(cf, data, done);
+ if(!result && *done) {
+ DEBUGASSERT(ctx->ballers.winner);
+ DEBUGASSERT(ctx->ballers.winner->cf);
+ DEBUGASSERT(ctx->ballers.winner->cf->connected);
+ /* we have a winner. Install and activate it.
+ * close/free all others. */
+ ctx->state = SCFST_DONE;
+ cf->connected = TRUE;
+ cf->next = ctx->ballers.winner->cf;
+ ctx->ballers.winner->cf = NULL;
+ cf_ip_happy_ctx_clear(cf, data);
+ Curl_expire_done(data, EXPIRE_HAPPY_EYEBALLS);
+
+ if(cf->conn->handler->protocol & PROTO_FAMILY_SSH)
+ Curl_pgrsTime(data, TIMER_APPCONNECT); /* we are connected already */
#ifndef CURL_DISABLE_VERBOSE_STRINGS
- if(Curl_trc_cf_is_verbose(cf, data)) {
- struct ip_quadruple ipquad;
- bool is_ipv6;
- if(!Curl_conn_cf_get_ip_info(cf->next, data, &is_ipv6, &ipquad)) {
- const char *host;
- int port;
- Curl_conn_get_current_host(data, cf->sockindex, &host, &port);
- CURL_TRC_CF(data, cf, "Connected to %s (%s) port %u",
- host, ipquad.remote_ip, ipquad.remote_port);
- }
+ if(Curl_trc_cf_is_verbose(cf, data)) {
+ struct ip_quadruple ipquad;
+ bool is_ipv6;
+ if(!Curl_conn_cf_get_ip_info(cf->next, data, &is_ipv6, &ipquad)) {
+ const char *host;
+ int port;
+ Curl_conn_get_current_host(data, cf->sockindex, &host, &port);
+ CURL_TRC_CF(data, cf, "Connected to %s (%s) port %u",
+ host, ipquad.remote_ip, ipquad.remote_port);
}
-#endif
- data->info.numconnects++; /* to track the # of connections made */
}
- break;
- case SCFST_DONE:
- *done = TRUE;
- break;
+#endif
+ data->info.numconnects++; /* to track the # of connections made */
+ }
+ break;
+ case SCFST_DONE:
+ *done = TRUE;
+ break;
}
return result;
}
(void)setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on, sizeof(on));
}
#else
-#define set_ipv6_v6only(x,y)
+#define set_ipv6_v6only(x, y)
#endif
static void tcpnodelay(struct Curl_cfilter *cf,
curl_socket_t sockfd)
{
#if defined(TCP_NODELAY) && defined(CURL_TCP_NODELAY_SUPPORTED)
- curl_socklen_t onoff = (curl_socklen_t) 1;
+ curl_socklen_t onoff = (curl_socklen_t)1;
int level = IPPROTO_TCP;
char buffer[STRERROR_LEN];
}
}
#else
-#define nosigpipe(x,y,z) Curl_nop_stmt
+#define nosigpipe(x, y, z) Curl_nop_stmt
#endif
#if defined(USE_WINSOCK) || \
#define KEEPALIVE_FACTOR(x)
#endif
-static void
-tcpkeepalive(struct Curl_cfilter *cf,
- struct Curl_easy *data,
- curl_socket_t sockfd)
+static void tcpkeepalive(struct Curl_cfilter *cf,
+ struct Curl_easy *data,
+ curl_socket_t sockfd)
{
int optval = data->set.tcp_keepalive ? 1 : 0;
{
/* Offered by mingw-w64 and MS SDK. Latter only when targeting Win7+. */
#ifndef SIO_KEEPALIVE_VALS
-#define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4)
+#define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR, 4)
struct tcp_keepalive {
u_long onoff;
u_long keepalivetime;
DEBUGASSERT(data);
DEBUGASSERT(data->conn);
if(data->set.fopensocket) {
- /*
- * If the opensocket callback is set, all the destination address
- * information is passed to the callback. Depending on this information the
- * callback may opt to abort the connection, this is indicated returning
- * CURL_SOCKET_BAD; otherwise it will return a not-connected socket. When
- * the callback returns a valid socket the destination address information
- * might have been changed and this 'new' address will actually be used
- * here to connect.
- */
+ /*
+ * If the opensocket callback is set, all the destination address
+ * information is passed to the callback. Depending on this information the
+ * callback may opt to abort the connection, this is indicated returning
+ * CURL_SOCKET_BAD; otherwise it will return a not-connected socket. When
+ * the callback returns a valid socket the destination address information
+ * might have been changed and this 'new' address will actually be used
+ * here to connect.
+ */
Curl_set_in_callback(data, TRUE);
*sockfd = data->set.fopensocket(data->set.opensocket_client,
CURLSOCKTYPE_IPCXN,
if(!iface && !host && !port)
/* no local kind of binding was requested */
return CURLE_OK;
- else if(iface && (strlen(iface) >= 255) )
+ else if(iface && (strlen(iface) >= 255))
return CURLE_BAD_FUNCTION_ARGUMENT;
memset(&sa, 0, sizeof(struct Curl_sockaddr_storage));
/* Discover IP from input device, then bind to it */
if2ip_result = Curl_if2ip(af,
#ifdef USE_IPV6
- scope, conn->scope_id,
+ scope, conn->scope_id,
#endif
- iface, myhost, sizeof(myhost));
+ iface, myhost, sizeof(myhost));
}
switch(if2ip_result) {
- case IF2IP_NOT_FOUND:
- if(iface_input && !host_input) {
- /* Do not fall back to treating it as a hostname */
- char buffer[STRERROR_LEN];
- data->state.os_errno = error = SOCKERRNO;
- failf(data, "Could not bind to interface '%s' with errno %d: %s",
- iface, error, curlx_strerror(error, buffer, sizeof(buffer)));
- return CURLE_INTERFACE_FAILED;
- }
- break;
- case IF2IP_AF_NOT_SUPPORTED:
- /* Signal the caller to try another address family if available */
- return CURLE_UNSUPPORTED_PROTOCOL;
- case IF2IP_FOUND:
- /*
- * We now have the numerical IP address in the 'myhost' buffer
- */
- host = myhost;
- infof(data, "Local Interface %s is ip %s using address family %i",
- iface, host, af);
- done = 1;
- break;
+ case IF2IP_NOT_FOUND:
+ if(iface_input && !host_input) {
+ /* Do not fall back to treating it as a hostname */
+ char buffer[STRERROR_LEN];
+ data->state.os_errno = error = SOCKERRNO;
+ failf(data, "Could not bind to interface '%s' with errno %d: %s",
+ iface, error, curlx_strerror(error, buffer, sizeof(buffer)));
+ return CURLE_INTERFACE_FAILED;
+ }
+ break;
+ case IF2IP_AF_NOT_SUPPORTED:
+ /* Signal the caller to try another address family if available */
+ return CURLE_UNSUPPORTED_PROTOCOL;
+ case IF2IP_FOUND:
+ /*
+ * We now have the numerical IP address in the 'myhost' buffer
+ */
+ host = myhost;
+ infof(data, "Local Interface %s is ip %s using address family %i",
+ iface, host, af);
+ done = 1;
+ break;
}
if(!iface_input || host_input) {
/*
present, is known to be numeric */
curl_off_t scope_id;
if(curlx_str_number((const char **)CURL_UNCONST(&scope_ptr),
- &scope_id, UINT_MAX))
+ &scope_id, UINT_MAX))
return CURLE_UNSUPPORTED_PROTOCOL;
si6->sin6_scope_id = (unsigned int)scope_id;
}
int wblock_percent; /* percent of writes doing EAGAIN */
int wpartial_percent; /* percent of bytes written in send */
int rblock_percent; /* percent of reads doing EAGAIN */
- size_t recv_max; /* max enforced read size */
+ size_t recv_max; /* max enforced read size */
#endif
BIT(got_first_byte); /* if first byte was received */
BIT(listening); /* socket is listening */
curl_socklen_t slen = sizeof(struct Curl_sockaddr_storage);
memset(&ssloc, 0, sizeof(ssloc));
- if(getsockname(ctx->sock, (struct sockaddr*) &ssloc, &slen)) {
+ if(getsockname(ctx->sock, (struct sockaddr *)&ssloc, &slen)) {
int error = SOCKERRNO;
infof(data, "getsockname() failed with errno %d: %s",
error, curlx_strerror(error, buffer, sizeof(buffer)));
}
- else if(!Curl_addr2string((struct sockaddr*)&ssloc, slen,
+ else if(!Curl_addr2string((struct sockaddr *)&ssloc, slen,
ctx->ip.local_ip, &ctx->ip.local_port)) {
infof(data, "ssloc inet_ntop() failed with errno %d: %s",
errno, curlx_strerror(errno, buffer, sizeof(buffer)));
infof(data, " Trying %s:%d...", ctx->ip.remote_ip, ctx->ip.remote_port);
#ifdef USE_IPV6
- is_tcp = (ctx->addr.family == AF_INET
- || ctx->addr.family == AF_INET6) &&
+ is_tcp = (ctx->addr.family == AF_INET ||
+ ctx->addr.family == AF_INET6) &&
ctx->addr.socktype == SOCK_STREAM;
#else
is_tcp = (ctx->addr.family == AF_INET) &&
rc = SOCKET_WRITABLE(ctx->sock, 0);
if(rc == 0) { /* no connection yet */
- CURL_TRC_CF(data, cf, "not connected yet on fd=%" FMT_SOCKET_T,
- ctx->sock);
+ CURL_TRC_CF(data, cf, "not connected yet on fd=%" FMT_SOCKET_T, ctx->sock);
return CURLE_OK;
}
else if(rc == CURL_CSELECT_OUT || cf->conn->bits.tcp_fastopen) {
if(curlx_timediff_ms(n, ctx->last_sndbuf_query_at) > 1000) {
if(!WSAIoctl(ctx->sock, SIO_IDEAL_SEND_BACKLOG_QUERY, 0, 0,
- &ideal, sizeof(ideal), &ideallen, 0, 0) &&
+ &ideal, sizeof(ideal), &ideallen, 0, 0) &&
ideal != ctx->sndbuf_size &&
!setsockopt(ctx->sock, SOL_SOCKET, SO_SNDBUF,
(const char *)&ideal, sizeof(ideal))) {
if(ctx->wblock_percent > 0) {
unsigned char c = 0;
Curl_rand_bytes(data, FALSE, &c, 1);
- if(c >= ((100-ctx->wblock_percent)*256/100)) {
+ if(c >= ((100 - ctx->wblock_percent) * 256 / 100)) {
CURL_TRC_CF(data, cf, "send(len=%zu) SIMULATE EWOULDBLOCK", orig_len);
cf->conn->sock[cf->sockindex] = fdsave;
return CURLE_AGAIN;
if(cf->cft != &Curl_cft_udp && ctx->rblock_percent > 0) {
unsigned char c = 0;
Curl_rand(data, &c, 1);
- if(c >= ((100-ctx->rblock_percent)*256/100)) {
+ if(c >= ((100 - ctx->rblock_percent) * 256 / 100)) {
CURL_TRC_CF(data, cf, "recv(len=%zu) SIMULATE EWOULDBLOCK", len);
return CURLE_AGAIN;
}
/* Check with 0 timeout if there are any events pending on the socket */
pfd[0].fd = ctx->sock;
- pfd[0].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI;
+ pfd[0].events = POLLRDNORM | POLLIN | POLLRDBAND | POLLPRI;
pfd[0].revents = 0;
r = Curl_poll(pfd, 1, 0);
CURL_TRC_CF(data, cf, "is_alive: poll timeout, assume alive");
return TRUE;
}
- else if(pfd[0].revents & (POLLERR|POLLHUP|POLLPRI|POLLNVAL)) {
+ else if(pfd[0].revents & (POLLERR | POLLHUP | POLLPRI | POLLNVAL)) {
CURL_TRC_CF(data, cf, "is_alive: err/hup/etc events, assume dead");
return FALSE;
}
#define linux_quic_gro(x)
#endif
-
static CURLcode cf_udp_setup_quic(struct Curl_cfilter *cf,
struct Curl_easy *data)
{
ctx->ip.remote_port = 0;
plen = sizeof(ssrem);
memset(&ssrem, 0, plen);
- if(getpeername(ctx->sock, (struct sockaddr*) &ssrem, &plen)) {
+ if(getpeername(ctx->sock, (struct sockaddr *)&ssrem, &plen)) {
int error = SOCKERRNO;
failf(data, "getpeername() failed with errno %d: %s",
error, curlx_strerror(error, buffer, sizeof(buffer)));
return;
}
- if(!Curl_addr2string((struct sockaddr*)&ssrem, plen,
+ if(!Curl_addr2string((struct sockaddr *)&ssrem, plen,
ctx->ip.remote_ip, &ctx->ip.remote_port)) {
failf(data, "ssrem inet_ntop() failed with errno %d: %s",
errno, curlx_strerror(errno, buffer, sizeof(buffer)));
size = sizeof(add);
#ifdef HAVE_ACCEPT4
- s_accepted = CURL_ACCEPT4(ctx->sock, (struct sockaddr *) &add, &size,
+ s_accepted = CURL_ACCEPT4(ctx->sock, (struct sockaddr *)&add, &size,
SOCK_NONBLOCK | SOCK_CLOEXEC);
#else
- s_accepted = CURL_ACCEPT(ctx->sock, (struct sockaddr *) &add, &size);
+ s_accepted = CURL_ACCEPT(ctx->sock, (struct sockaddr *)&add, &size);
#endif
if(CURL_SOCKET_BAD == s_accepted) {
/*
* Parse interface option, and return the interface name and the host part.
-*/
+ */
CURLcode Curl_parse_interface(const char *input,
char **dev, char **iface, char **host);
goto out;
}
else if(result) {
- CURL_TRC_CF(data, cf, "Curl_conn_connect(), filter returned %d",
- result);
+ CURL_TRC_CF(data, cf, "Curl_conn_connect(), filter returned %d", result);
conn_report_connect_stats(cf, data);
goto out;
}
for(; cf; cf = cf->next) {
if(cf->cft->flags & CF_TYPE_MULTIPLEX)
return TRUE;
- if(cf->cft->flags & (CF_TYPE_IP_CONNECT|CF_TYPE_SSL))
+ if(cf->cft->flags & (CF_TYPE_IP_CONNECT | CF_TYPE_SSL))
return FALSE;
}
return FALSE;
v = (unsigned char)value;
break;
}
- if(cf->cft->flags & (CF_TYPE_IP_CONNECT|CF_TYPE_SSL))
+ if(cf->cft->flags & (CF_TYPE_IP_CONNECT | CF_TYPE_SSL))
break;
}
return (unsigned char)(result ? 0 : v);
cf = CONN_SOCK_IDX_VALID(sockindex) ? data->conn->cfilter[sockindex] : NULL;
/* Find the "lowest" tunneling proxy filter that has not connected yet. */
while(cf && !cf->connected) {
- if((cf->cft->flags & (CF_TYPE_IP_CONNECT|CF_TYPE_PROXY)) ==
- (CF_TYPE_IP_CONNECT|CF_TYPE_PROXY))
- cf_proxy = cf;
+ if((cf->cft->flags & (CF_TYPE_IP_CONNECT | CF_TYPE_PROXY)) ==
+ (CF_TYPE_IP_CONNECT | CF_TYPE_PROXY))
+ cf_proxy = cf;
cf = cf->next;
}
/* cf_proxy (!= NULL) is not connected yet. It is talking
CURLcode Curl_conn_ev_data_setup(struct Curl_easy *data)
{
- return cf_cntrl_all(data->conn, data, FALSE,
- CF_CTRL_DATA_SETUP, 0, NULL);
+ return cf_cntrl_all(data->conn, data, FALSE, CF_CTRL_DATA_SETUP, 0, NULL);
}
CURLcode Curl_conn_flush(struct Curl_easy *data, int sockindex)
return CURLE_BAD_FUNCTION_ARGUMENT;
#ifdef DEBUGBUILD
if(write_len) {
- /* Allow debug builds to override this logic to force short sends
- */
+ /* Allow debug builds to override this logic to force short sends */
const char *p = getenv("CURL_SMALLSENDS");
if(p) {
curl_off_t altsize;
* "ignored" meaning return values are ignored and the event is distributed
* to all filters in the chain. Overall result is always CURLE_OK.
*/
-/* data event arg1 arg2 return */
-#define CF_CTRL_DATA_SETUP 4 /* 0 NULL first fail */
-/* unused now 5 */
-#define CF_CTRL_DATA_PAUSE 6 /* on/off NULL first fail */
-#define CF_CTRL_DATA_DONE 7 /* premature NULL ignored */
-#define CF_CTRL_DATA_DONE_SEND 8 /* 0 NULL ignored */
+/* data event arg1 arg2 return */
+#define CF_CTRL_DATA_SETUP 4 /* 0 NULL first fail */
+/* unused now 5 */
+#define CF_CTRL_DATA_PAUSE 6 /* on/off NULL first fail */
+#define CF_CTRL_DATA_DONE 7 /* premature NULL ignored */
+#define CF_CTRL_DATA_DONE_SEND 8 /* 0 NULL ignored */
/* update conn info at connection and data */
-#define CF_CTRL_CONN_INFO_UPDATE (256+0) /* 0 NULL ignored */
-#define CF_CTRL_FORGET_SOCKET (256+1) /* 0 NULL ignored */
-#define CF_CTRL_FLUSH (256+2) /* 0 NULL first fail */
+#define CF_CTRL_CONN_INFO_UPDATE (256 + 0) /* 0 NULL ignored */
+#define CF_CTRL_FORGET_SOCKET (256 + 1) /* 0 NULL ignored */
+#define CF_CTRL_FLUSH (256 + 2) /* 0 NULL first fail */
/**
* Handle event/control for the filter.
struct Curl_easy *data,
int event, int arg1, void *arg2);
-
/**
* Queries to ask via a `Curl_cft_query *query` method on a cfilter chain.
* - MAX_CONCURRENT: the maximum number of parallel transfers the filter
/* A connection filter type, e.g. specific implementation. */
struct Curl_cftype {
- const char *name; /* name of the filter type */
- int flags; /* flags of filter type */
- int log_level; /* log level for such filters */
- Curl_cft_destroy_this *destroy; /* destroy resources of this cf */
- Curl_cft_connect *do_connect; /* establish connection */
- Curl_cft_close *do_close; /* close conn */
- Curl_cft_shutdown *do_shutdown; /* shutdown conn */
+ const char *name; /* name of the filter type */
+ int flags; /* flags of filter type */
+ int log_level; /* log level for such filters */
+ Curl_cft_destroy_this *destroy; /* destroy resources of this cf */
+ Curl_cft_connect *do_connect; /* establish connection */
+ Curl_cft_close *do_close; /* close conn */
+ Curl_cft_shutdown *do_shutdown; /* shutdown conn */
Curl_cft_adjust_pollset *adjust_pollset; /* adjust transfer poll set */
- Curl_cft_data_pending *has_data_pending;/* conn has data pending */
- Curl_cft_send *do_send; /* send data */
- Curl_cft_recv *do_recv; /* receive data */
- Curl_cft_cntrl *cntrl; /* events/control */
- Curl_cft_conn_is_alive *is_alive; /* FALSE if conn is dead, Jim! */
- Curl_cft_conn_keep_alive *keep_alive; /* try to keep it alive */
- Curl_cft_query *query; /* query filter chain */
+ Curl_cft_data_pending *has_data_pending; /* conn has data pending */
+ Curl_cft_send *do_send; /* send data */
+ Curl_cft_recv *do_recv; /* receive data */
+ Curl_cft_cntrl *cntrl; /* events/control */
+ Curl_cft_conn_is_alive *is_alive; /* FALSE if conn is dead, Jim! */
+ Curl_cft_conn_keep_alive *keep_alive; /* try to keep it alive */
+ Curl_cft_query *query; /* query filter chain */
};
/* A connection filter instance, e.g. registered at a connection */
/**
* Close the filter chain at `sockindex` for connection `data->conn`.
- * Filters remain in place and may be connected again afterwards.
+ * Filters remain in place and may be connected again afterwards.
*/
void Curl_conn_close(struct Curl_easy *data, int sockindex);
const void *buf, size_t blen, bool eos,
size_t *pnwritten);
-
/**
* Types and macros used to keep the current easy handle in filter calls,
* allowing for nested invocations. See #10336.
* a member in the cfilter's `ctx`.
*
* #define CF_CTX_CALL_DATA(cf) -> struct cf_call_data instance
-*/
+ */
#ifdef DEBUGBUILD
#endif /* !DEBUGBUILD */
-#define CF_DATA_CURRENT(cf) \
- ((cf)? (CF_CTX_CALL_DATA(cf).data) : NULL)
+#define CF_DATA_CURRENT(cf) ((cf) ? (CF_CTX_CALL_DATA(cf).data) : NULL)
#endif /* HEADER_CURL_CFILTERS_H */
} \
} while(0)
-#define CPOOL_UNLOCK(c,d) \
+#define CPOOL_UNLOCK(c,d) \
do { \
if((c)) { \
DEBUGASSERT((c)->locked); \
return NULL;
}
-
static struct cpool_bundle *cpool_find_bundle(struct cpool *cpool,
struct connectdata *conn)
{
Curl_hash_delete(&cpool->dest2bundle, bundle->dest, bundle->dest_len);
}
-
static void cpool_remove_conn(struct cpool *cpool,
struct connectdata *conn)
{
}
}
-static struct cpool_bundle *
-cpool_add_bundle(struct cpool *cpool, struct connectdata *conn)
+static struct cpool_bundle *cpool_add_bundle(struct cpool *cpool,
+ struct connectdata *conn)
{
struct cpool_bundle *bundle;
return oldest_idle;
}
-
int Curl_cpool_check_limits(struct Curl_easy *data,
struct connectdata *conn)
{
if(!oldest_idle)
break;
/* disconnect the old conn and continue */
- CURL_TRC_M(data, "Discarding connection #%"
- FMT_OFF_T " from %zu to reach destination "
- "limit of %zu", oldest_idle->connection_id,
- Curl_llist_count(&bundle->conns), dest_limit);
+ CURL_TRC_M(data, "Discarding connection #%" FMT_OFF_T
+ " from %zu to reach destination limit of %zu",
+ oldest_idle->connection_id,
+ Curl_llist_count(&bundle->conns), dest_limit);
Curl_conn_terminate(cpool->idata, oldest_idle, FALSE);
/* in case the bundle was destroyed in disconnect, look it up again */
CPOOL_UNLOCK(cpool, data);
}
-
struct cpool_reaper_ctx {
struct curltime now;
};
bool aborted);
struct cpool {
- /* the pooled connections, bundled per destination */
+ /* the pooled connections, bundled per destination */
struct Curl_hash dest2bundle;
size_t num_conn;
curl_off_t next_connection_id;
/* Close all unused connections, prevent reuse of existing ones. */
void Curl_cpool_nw_changed(struct Curl_easy *data);
-
#endif /* HEADER_CURL_CONNCACHE_H */
#endif
switch(sa->sa_family) {
- case AF_INET:
- si = (struct sockaddr_in *)(void *) sa;
- if(curlx_inet_ntop(sa->sa_family, &si->sin_addr, addr, MAX_IPADR_LEN)) {
- *port = ntohs(si->sin_port);
- return TRUE;
- }
- break;
+ case AF_INET:
+ si = (struct sockaddr_in *)(void *)sa;
+ if(curlx_inet_ntop(sa->sa_family, &si->sin_addr, addr, MAX_IPADR_LEN)) {
+ *port = ntohs(si->sin_port);
+ return TRUE;
+ }
+ break;
#ifdef USE_IPV6
- case AF_INET6:
- si6 = (struct sockaddr_in6 *)(void *) sa;
- if(curlx_inet_ntop(sa->sa_family, &si6->sin6_addr, addr,
- MAX_IPADR_LEN)) {
- *port = ntohs(si6->sin6_port);
- return TRUE;
- }
- break;
+ case AF_INET6:
+ si6 = (struct sockaddr_in6 *)(void *)sa;
+ if(curlx_inet_ntop(sa->sa_family, &si6->sin6_addr, addr, MAX_IPADR_LEN)) {
+ *port = ntohs(si6->sin6_port);
+ return TRUE;
+ }
+ break;
#endif
#if (defined(HAVE_SYS_UN_H) || defined(WIN32_SOCKADDR_UN)) && defined(AF_UNIX)
- case AF_UNIX:
- if(salen > (curl_socklen_t)sizeof(CURL_SA_FAMILY_T)) {
- su = (struct sockaddr_un*)sa;
- curl_msnprintf(addr, MAX_IPADR_LEN, "%s", su->sun_path);
- }
- else
- addr[0] = 0; /* socket with no name */
- *port = 0;
- return TRUE;
+ case AF_UNIX:
+ if(salen > (curl_socklen_t)sizeof(CURL_SA_FAMILY_T)) {
+ su = (struct sockaddr_un *)sa;
+ curl_msnprintf(addr, MAX_IPADR_LEN, "%s", su->sun_path);
+ }
+ else
+ addr[0] = 0; /* socket with no name */
+ *port = 0;
+ return TRUE;
#endif
- default:
- break;
+ default:
+ break;
}
addr[0] = '\0';
#endif
is_multiplex = Curl_conn_is_multiplex(conn, FIRSTSOCKET);
closeit = (ctrl == CONNCTRL_CONNECTION) ||
- ((ctrl == CONNCTRL_STREAM) && !is_multiplex);
+ ((ctrl == CONNCTRL_STREAM) && !is_multiplex);
if((ctrl == CONNCTRL_STREAM) && is_multiplex)
; /* stream signal on multiplex conn never affects close state */
else if((bit)closeit != conn->bits.close) {
if(ctx->state < CF_SETUP_CNNCT_HTTP_PROXY && cf->conn->bits.httpproxy) {
#ifdef USE_SSL
- if(IS_HTTPS_PROXY(cf->conn->http_proxy.proxytype)
- && !Curl_conn_is_ssl(cf->conn, cf->sockindex)) {
+ if(IS_HTTPS_PROXY(cf->conn->http_proxy.proxytype) &&
+ !Curl_conn_is_ssl(cf->conn, cf->sockindex)) {
result = Curl_cf_ssl_proxy_insert_after(cf, data);
if(result)
return result;
if(ctx->state < CF_SETUP_CNNCT_SSL) {
#ifdef USE_SSL
- if((ctx->ssl_mode == CURL_CF_SSL_ENABLE
- || (ctx->ssl_mode != CURL_CF_SSL_DISABLE
- && cf->conn->handler->flags & PROTOPT_SSL)) /* we want SSL */
+ if((ctx->ssl_mode == CURL_CF_SSL_ENABLE ||
+ (ctx->ssl_mode != CURL_CF_SSL_DISABLE &&
+ cf->conn->handler->flags & PROTOPT_SSL)) /* we want SSL */
&& !Curl_conn_is_ssl(cf->conn, cf->sockindex)) { /* it is missing */
result = Curl_cf_ssl_insert_after(cf, data);
if(result)
Curl_safefree(ctx);
}
-
struct Curl_cftype Curl_cft_setup = {
"SETUP",
0,
);
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
-#define streamclose(x,y) Curl_conncontrol(x, CONNCTRL_STREAM, y)
-#define connclose(x,y) Curl_conncontrol(x, CONNCTRL_CONNECTION, y)
-#define connkeep(x,y) Curl_conncontrol(x, CONNCTRL_KEEP, y)
+#define streamclose(x, y) Curl_conncontrol(x, CONNCTRL_STREAM, y)
+#define connclose(x, y) Curl_conncontrol(x, CONNCTRL_CONNECTION, y)
+#define connkeep(x, y) Curl_conncontrol(x, CONNCTRL_KEEP, y)
#else /* if !DEBUGBUILD || CURL_DISABLE_VERBOSE_STRINGS */
-#define streamclose(x,y) Curl_conncontrol(x, CONNCTRL_STREAM)
-#define connclose(x,y) Curl_conncontrol(x, CONNCTRL_CONNECTION)
-#define connkeep(x,y) Curl_conncontrol(x, CONNCTRL_KEEP)
+#define streamclose(x, y) Curl_conncontrol(x, CONNCTRL_STREAM)
+#define connclose(x, y) Curl_conncontrol(x, CONNCTRL_CONNECTION)
+#define connkeep(x, y) Curl_conncontrol(x, CONNCTRL_KEEP)
#endif
CURLcode Curl_cf_setup_insert_after(struct Curl_cfilter *cf_at,
static void strstore(char **str, const char *newstr, size_t len);
/* number of seconds in 400 days */
-#define COOKIES_MAXAGE (400*24*3600)
+#define COOKIES_MAXAGE (400 * 24 * 3600)
/* Make sure cookies never expire further away in time than 400 days into the
future. (from RFC6265bis draft-19)
timediff_t cap = now + COOKIES_MAXAGE;
if(co->expires > cap) {
cap += 30;
- co->expires = (cap/60)*60;
+ co->expires = (cap / 60) * 60;
}
}
}
return FALSE;
if(!curl_strnequal(cookie_domain,
- hostname + hostname_len-cookie_domain_len,
+ hostname + hostname_len - cookie_domain_len,
cookie_domain_len))
return FALSE;
* combination of name + contents. Chrome and Firefox support 4095 or
* 4096 bytes combo
*/
- if(curlx_strlen(&name) >= (MAX_NAME-1) ||
- curlx_strlen(&val) >= (MAX_NAME-1) ||
+ if(curlx_strlen(&name) >= (MAX_NAME - 1) ||
+ curlx_strlen(&val) >= (MAX_NAME - 1) ||
((curlx_strlen(&name) + curlx_strlen(&val)) > MAX_NAME)) {
infof(data, "oversized cookie dropped, name/val %zu + %zu bytes",
curlx_strlen(&name), curlx_strlen(&val));
is_ip = Curl_host_is_ipnum(domain ? domain : curlx_str(&val));
- if(!domain
- || (is_ip && !strncmp(curlx_str(&val), domain,
- curlx_strlen(&val)) &&
- (curlx_strlen(&val) == strlen(domain)))
- || (!is_ip && cookie_tailmatch(curlx_str(&val),
+ if(!domain ||
+ (is_ip &&
+ !strncmp(curlx_str(&val), domain, curlx_strlen(&val)) &&
+ (curlx_strlen(&val) == strlen(domain))) ||
+ (!is_ip && cookie_tailmatch(curlx_str(&val),
curlx_strlen(&val), domain))) {
strstore(&co->domain, curlx_str(&val), curlx_strlen(&val));
if(!co->domain)
co->httponly = TRUE;
}
- if(lineptr[0]=='#')
+ if(lineptr[0] == '#')
/* do not even try the comments */
return CURLE_OK;
next = (ptr[len] == '\t' ? &ptr[len + 1] : NULL);
switch(fields) {
case 0:
- if(ptr[0]=='.') { /* skip preceding dots */
+ if(ptr[0] == '.') { /* skip preceding dots */
ptr++;
len--;
}
return CURLE_OK;
}
-static bool
-is_public_suffix(struct Curl_easy *data,
- struct Cookie *co,
- const char *domain)
+static bool is_public_suffix(struct Curl_easy *data,
+ struct Cookie *co,
+ const char *domain)
{
#ifdef USE_LIBPSL
/*
if(clist->domain && co->domain) {
if(curl_strequal(clist->domain, co->domain) &&
- (clist->tailmatch == co->tailmatch))
+ (clist->tailmatch == co->tailmatch))
/* The domains are identical */
replace_old = TRUE;
}
return result;
}
-
/*
* Curl_cookie_init()
*
return result;
}
-
/*
* cookie_sort
*
/* at first, remove expired cookies */
remove_expired(ci);
- for(n = Curl_llist_head(&ci->cookielist[myhash]);
- n; n = Curl_node_next(n)) {
+ for(n = Curl_llist_head(&ci->cookielist[myhash]); n; n = Curl_node_next(n)) {
struct Cookie *co = Curl_node_elem(n);
/* if the cookie requires we are secure we must only continue if we are! */
if(!co->domain ||
(co->tailmatch && !is_ip &&
cookie_tailmatch(co->domain, strlen(co->domain), host)) ||
- ((!co->tailmatch || is_ip) && curl_strequal(host, co->domain)) ) {
+ ((!co->tailmatch || is_ip) && curl_strequal(host, co->domain))) {
/*
* the right part of the host matches the domain stuff in the
* cookie data
* now check the left part of the path with the cookies path
* requirement
*/
- if(!co->spath || pathmatch(co->spath, path) ) {
+ if(!co->spath || pathmatch(co->spath, path)) {
/*
* This is a match and we add it to the return-linked-list
static char *get_netscape_format(const struct Cookie *co)
{
return curl_maprintf(
- "%s" /* httponly preamble */
- "%s%s\t" /* domain */
- "%s\t" /* tailmatch */
- "%s\t" /* path */
- "%s\t" /* secure */
- "%" FMT_OFF_T "\t" /* expires */
- "%s\t" /* name */
- "%s", /* value */
+ "%s" /* httponly preamble */
+ "%s%s\t" /* domain */
+ "%s\t" /* tailmatch */
+ "%s\t" /* path */
+ "%s\t" /* secure */
+ "%" FMT_OFF_T "\t" /* expires */
+ "%s\t" /* name */
+ "%s", /* value */
co->httponly ? "#HttpOnly_" : "",
/*
* Make sure all domains are prefixed with a dot if they allow
/* only sort the cookies with a domain property */
for(i = 0; i < COOKIE_HASH_SIZE; i++) {
- for(n = Curl_llist_head(&ci->cookielist[i]); n;
- n = Curl_node_next(n)) {
+ for(n = Curl_llist_head(&ci->cookielist[i]); n; n = Curl_node_next(n)) {
struct Cookie *co = Curl_node_elem(n);
if(!co->domain)
continue;
#include "llist.h"
struct Cookie {
- struct Curl_llist_node node; /* for the main cookie list */
+ struct Curl_llist_node node; /* for the main cookie list */
struct Curl_llist_node getnode; /* for getlist */
- char *name; /* <this> = value */
- char *value; /* name = <this> */
- char *path; /* path = <this> which is in Set-Cookie: */
- char *spath; /* sanitized cookie path */
- char *domain; /* domain = <this> */
- curl_off_t expires; /* expires = <this> */
- unsigned int creationtime; /* time when the cookie was written */
- BIT(tailmatch); /* tail-match the domain name */
- BIT(secure); /* the 'secure' keyword was used */
- BIT(livecookie); /* updated from a server, not a stored file */
- BIT(httponly); /* the httponly directive is present */
- BIT(prefix_secure); /* secure prefix is set */
- BIT(prefix_host); /* host prefix is set */
+ char *name; /* <this> = value */
+ char *value; /* name = <this> */
+ char *path; /* path = <this> which is in Set-Cookie: */
+ char *spath; /* sanitized cookie path */
+ char *domain; /* domain = <this> */
+ curl_off_t expires; /* expires = <this> */
+ unsigned int creationtime; /* time when the cookie was written */
+ BIT(tailmatch); /* tail-match the domain name */
+ BIT(secure); /* the 'secure' keyword was used */
+ BIT(livecookie); /* updated from server, not a stored file */
+ BIT(httponly); /* the httponly directive is present */
+ BIT(prefix_secure); /* secure prefix is set */
+ BIT(prefix_host); /* host prefix is set */
};
/*
* Available cookie prefixes, as defined in
* draft-ietf-httpbis-rfc6265bis-02
*/
-#define COOKIE_PREFIX__SECURE (1<<0)
-#define COOKIE_PREFIX__HOST (1<<1)
+#define COOKIE_PREFIX__SECURE (1 << 0)
+#define COOKIE_PREFIX__HOST (1 << 1)
#define COOKIE_HASH_SIZE 63
/* linked lists of cookies we know of */
struct Curl_llist cookielist[COOKIE_HASH_SIZE];
curl_off_t next_expiration; /* the next time at which expiration happens */
- unsigned int numcookies; /* number of cookies in the "jar" */
- unsigned int lastct; /* last creation-time used in the jar */
- BIT(running); /* state info, for cookie adding information */
+ unsigned int numcookies; /* number of cookies in the "jar" */
+ unsigned int lastct; /* last creation-time used in the jar */
+ BIT(running); /* state info, for cookie adding information */
BIT(newsession); /* new session, discard session cookies on load */
};
#define Curl_cookie_init() NULL
#define Curl_cookie_run(x) Curl_nop_stmt
#define Curl_cookie_cleanup(x) Curl_nop_stmt
-#define Curl_flush_cookies(x,y) Curl_nop_stmt
+#define Curl_flush_cookies(x, y) Curl_nop_stmt
#else
void Curl_flush_cookies(struct Curl_easy *data, bool cleanup);
void Curl_cookie_cleanup(struct CookieInfo *c);
Curl_detach_connection(data);
}
-
void Curl_cshutdn_terminate(struct Curl_easy *data,
struct connectdata *conn,
bool do_shutdown)
return result;
}
-
static void cshutdn_perform(struct cshutdn *cshutdn,
struct Curl_easy *data)
{
Curl_expire_ex(data, nowp, next_expire_ms, EXPIRE_SHUTDOWN);
}
-
static void cshutdn_terminate_all(struct cshutdn *cshutdn,
struct Curl_easy *data,
int timeout_ms)
spent_ms = curlx_timediff_ms(curlx_now(), started);
if(spent_ms >= (timediff_t)timeout_ms) {
CURL_TRC_M(data, "[SHUTDOWN] shutdown finished, %s",
- (timeout_ms > 0) ? "timeout" : "best effort done");
+ (timeout_ms > 0) ? "timeout" : "best effort done");
break;
}
sigpipe_restore(&pipe_st);
}
-
int Curl_cshutdn_init(struct cshutdn *cshutdn,
struct Curl_multi *multi)
{
return 0; /* good */
}
-
void Curl_cshutdn_destroy(struct cshutdn *cshutdn,
struct Curl_easy *data)
{
return 0;
}
-
static CURLMcode cshutdn_update_ev(struct cshutdn *cshutdn,
struct Curl_easy *data,
struct connectdata *conn)
return mresult;
}
-
void Curl_cshutdn_add(struct cshutdn *cshutdn,
struct connectdata *conn,
size_t conns_in_pool)
conn->connection_id, Curl_llist_count(&cshutdn->list));
}
-
static void cshutdn_multi_socket(struct cshutdn *cshutdn,
struct Curl_easy *data,
curl_socket_t s)
}
}
-
void Curl_cshutdn_perform(struct cshutdn *cshutdn,
struct Curl_easy *data,
curl_socket_t s)
struct easy_pollset ps;
Curl_pollset_init(&ps);
- for(e = Curl_llist_head(&cshutdn->list); e;
- e = Curl_node_next(e)) {
+ for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
unsigned int i;
struct connectdata *conn = Curl_node_elem(e);
CURLcode result;
CURLcode result;
Curl_pollset_init(&ps);
- for(e = Curl_llist_head(&cshutdn->list); e;
- e = Curl_node_next(e)) {
+ for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
conn = Curl_node_elem(e);
Curl_pollset_reset(&ps);
Curl_attach_connection(data, conn);
struct connectdata *conn;
Curl_pollset_init(&ps);
- for(e = Curl_llist_head(&cshutdn->list); e;
- e = Curl_node_next(e)) {
+ for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
conn = Curl_node_elem(e);
Curl_pollset_reset(&ps);
Curl_attach_connection(data, conn);