if(data->set.str[STRING_HAPROXY_CLIENT_IP])
client_ip = data->set.str[STRING_HAPROXY_CLIENT_IP];
else
- client_ip = data->info.conn_local_ip;
+ client_ip = data->info.primary.local_ip;
result = Curl_dyn_addf(&ctx->data_out, "PROXY %s %s %s %i %i\r\n",
tcp_version,
client_ip,
- data->info.conn_primary_ip,
- data->info.conn_local_port,
- data->info.conn_primary_port);
+ data->info.primary.remote_ip,
+ data->info.primary.local_port,
+ data->info.primary.remote_port);
#ifdef USE_UNIX_SOCKETS
}
struct Curl_sockaddr_ex addr; /* address to connect to */
curl_socket_t sock; /* current attempt socket */
struct bufq recvbuf; /* used when `buffer_recv` is set */
- char r_ip[MAX_IPADR_LEN]; /* remote IP as string */
- int r_port; /* remote port number */
- char l_ip[MAX_IPADR_LEN]; /* local IP as string */
- int l_port; /* local port number */
+ struct ip_quadruple ip; /* The IP quadruple 2x(addr+port) */
struct curltime started_at; /* when socket was created */
struct curltime connected_at; /* when socket connected/got first byte */
struct curltime first_byte_at; /* when first byte was recvd */
return CURLE_FAILED_INIT;
}
if(!Curl_addr2string((struct sockaddr*)&ssloc, slen,
- ctx->l_ip, &ctx->l_port)) {
+ ctx->ip.local_ip, &ctx->ip.local_port)) {
failf(data, "ssloc inet_ntop() failed with errno %d: %s",
errno, Curl_strerror(errno, buffer, sizeof(buffer)));
return CURLE_FAILED_INIT;
/* store remote address and port used in this connection attempt */
if(!Curl_addr2string(&ctx->addr.sa_addr, ctx->addr.addrlen,
- ctx->r_ip, &ctx->r_port)) {
+ ctx->ip.remote_ip, &ctx->ip.remote_port)) {
char buffer[STRERROR_LEN];
ctx->error = errno;
#ifdef ENABLE_IPV6
if(ctx->addr.family == AF_INET6) {
set_ipv6_v6only(ctx->sock, 0);
- infof(data, " Trying [%s]:%d...", ctx->r_ip, ctx->r_port);
+ infof(data, " Trying [%s]:%d...", ctx->ip.remote_ip, ctx->ip.remote_port);
}
else
#endif
- infof(data, " Trying %s:%d...", ctx->r_ip, ctx->r_port);
+ infof(data, " Trying %s:%d...", ctx->ip.remote_ip, ctx->ip.remote_port);
#ifdef ENABLE_IPV6
is_tcp = (ctx->addr.family == AF_INET
error = SOCKERRNO;
set_local_ip(cf, data);
CURL_TRC_CF(data, cf, "local address %s port %d...",
- ctx->l_ip, ctx->l_port);
+ ctx->ip.local_ip, ctx->ip.local_port);
if(-1 == rc) {
- result = socket_connect_result(data, ctx->r_ip, error);
+ result = socket_connect_result(data, ctx->ip.remote_ip, error);
goto out;
}
}
{
char buffer[STRERROR_LEN];
infof(data, "connect to %s port %u from %s port %d failed: %s",
- ctx->r_ip, ctx->r_port, ctx->l_ip, ctx->l_port,
+ ctx->ip.remote_ip, ctx->ip.remote_port,
+ ctx->ip.local_ip, ctx->ip.local_port,
Curl_strerror(ctx->error, buffer, sizeof(buffer)));
}
#endif
const char **pdisplay_host,
int *pport)
{
+ struct cf_socket_ctx *ctx = cf->ctx;
(void)data;
*phost = cf->conn->host.name;
*pdisplay_host = cf->conn->host.dispname;
- *pport = cf->conn->port;
+ *pport = ctx->ip.remote_port;
}
static void cf_socket_adjust_pollset(struct Curl_cfilter *cf,
return nread;
}
-static void conn_set_primary_ip(struct Curl_cfilter *cf,
- struct Curl_easy *data)
-{
- struct cf_socket_ctx *ctx = cf->ctx;
-
- (void)data;
- DEBUGASSERT(sizeof(ctx->r_ip) == sizeof(cf->conn->primary_ip));
- memcpy(cf->conn->primary_ip, ctx->r_ip, sizeof(cf->conn->primary_ip));
-}
-
static void cf_socket_active(struct Curl_cfilter *cf, struct Curl_easy *data)
{
struct cf_socket_ctx *ctx = cf->ctx;
/* use this socket from now on */
cf->conn->sock[cf->sockindex] = ctx->sock;
- /* the first socket info gets set at conn and data */
+ set_local_ip(cf, data);
+ if(cf->sockindex == SECONDARYSOCKET)
+ cf->conn->secondary = ctx->ip;
+ else
+ cf->conn->primary = ctx->ip;
+ /* the first socket info gets some specials */
if(cf->sockindex == FIRSTSOCKET) {
cf->conn->remote_addr = &ctx->addr;
#ifdef ENABLE_IPV6
cf->conn->bits.ipv6 = (ctx->addr.family == AF_INET6)? TRUE : FALSE;
#endif
- conn_set_primary_ip(cf, data);
- set_local_ip(cf, data);
- Curl_persistconninfo(data, cf->conn, ctx->l_ip, ctx->l_port);
+ Curl_persistconninfo(data, cf->conn, &ctx->ip);
/* buffering is currently disabled by default because we have stalls
* in parallel transfers where not all buffered data is consumed and no
* socket events happen.
cf_socket_active(cf, data);
break;
case CF_CTRL_DATA_SETUP:
- Curl_persistconninfo(data, cf->conn, ctx->l_ip, ctx->l_port);
+ Curl_persistconninfo(data, cf->conn, &ctx->ip);
break;
case CF_CTRL_FORGET_SOCKET:
ctx->sock = CURL_SOCKET_BAD;
#else
rc = connect(ctx->sock, &ctx->addr.sa_addr, ctx->addr.addrlen);
if(-1 == rc) {
- return socket_connect_result(data, ctx->r_ip, SOCKERRNO);
+ return socket_connect_result(data, ctx->ip.remote_ip, SOCKERRNO);
}
ctx->sock_connected = TRUE;
#endif
CURL_TRC_CF(data, cf, "%s socket %" CURL_FORMAT_SOCKET_T
" connected: [%s:%d] -> [%s:%d]",
(ctx->transport == TRNSPRT_QUIC)? "QUIC" : "UDP",
- ctx->sock, ctx->l_ip, ctx->l_port, ctx->r_ip, ctx->r_port);
+ ctx->sock, ctx->ip.local_ip, ctx->ip.local_port,
+ ctx->ip.remote_ip, ctx->ip.remote_port);
(void)curlx_nonblock(ctx->sock, TRUE);
switch(ctx->addr.family) {
goto out;
CURL_TRC_CF(data, cf, "cf_udp_connect(), opened socket=%"
CURL_FORMAT_SOCKET_T " (%s:%d)",
- ctx->sock, ctx->l_ip, ctx->l_port);
+ ctx->sock, ctx->ip.local_ip, ctx->ip.local_port);
}
else {
CURL_TRC_CF(data, cf, "cf_udp_connect(), opened socket=%"
struct Curl_sockaddr_storage ssrem;
curl_socklen_t plen;
- ctx->r_ip[0] = 0;
- ctx->r_port = 0;
+ ctx->ip.remote_ip[0] = 0;
+ ctx->ip.remote_port = 0;
plen = sizeof(ssrem);
memset(&ssrem, 0, plen);
if(getpeername(ctx->sock, (struct sockaddr*) &ssrem, &plen)) {
return;
}
if(!Curl_addr2string((struct sockaddr*)&ssrem, plen,
- ctx->r_ip, &ctx->r_port)) {
+ ctx->ip.remote_ip, &ctx->ip.remote_port)) {
failf(data, "ssrem inet_ntop() failed with errno %d: %s",
errno, Curl_strerror(errno, buffer, sizeof(buffer)));
return;
}
#else
- ctx->r_ip[0] = 0;
- ctx->r_port = 0;
+ ctx->ip.remote_ip[0] = 0;
+ ctx->ip.remote_port = 0;
(void)data;
#endif
}
cf->connected = TRUE;
CURL_TRC_CF(data, cf, "accepted_set(sock=%" CURL_FORMAT_SOCKET_T
", remote=%s port=%d)",
- ctx->sock, ctx->r_ip, ctx->r_port);
+ ctx->sock, ctx->ip.remote_ip, ctx->ip.remote_port);
return CURLE_OK;
}
struct Curl_easy *data,
curl_socket_t *psock,
const struct Curl_sockaddr_ex **paddr,
- const char **pr_ip_str, int *pr_port,
- const char **pl_ip_str, int *pl_port)
+ struct ip_quadruple *pip)
{
+ (void)data;
if(cf_is_socket(cf) && cf->ctx) {
struct cf_socket_ctx *ctx = cf->ctx;
*psock = ctx->sock;
if(paddr)
*paddr = &ctx->addr;
- if(pr_ip_str)
- *pr_ip_str = ctx->r_ip;
- if(pr_port)
- *pr_port = ctx->r_port;
- if(pl_port ||pl_ip_str) {
- set_local_ip(cf, data);
- if(pl_ip_str)
- *pl_ip_str = ctx->l_ip;
- if(pl_port)
- *pl_port = ctx->l_port;
- }
+ if(pip)
+ *pip = ctx->ip;
return CURLE_OK;
}
return CURLE_FAILED_INIT;
struct Curl_easy;
struct connectdata;
struct Curl_sockaddr_ex;
+struct ip_quadruple;
/*
* The Curl_sockaddr_ex structure is basically libcurl's external API
* The filter owns all returned values.
* @param psock pointer to hold socket descriptor or NULL
* @param paddr pointer to hold addr reference or NULL
- * @param pr_ip_str pointer to hold remote addr as string or NULL
- * @param pr_port pointer to hold remote port number or NULL
- * @param pl_ip_str pointer to hold local addr as string or NULL
- * @param pl_port pointer to hold local port number or NULL
+ * @param pip pointer to get IP quadruple or NULL
* Returns error if the filter is of invalid type.
*/
CURLcode Curl_cf_socket_peek(struct Curl_cfilter *cf,
struct Curl_easy *data,
curl_socket_t *psock,
const struct Curl_sockaddr_ex **paddr,
- const char **pr_ip_str, int *pr_port,
- const char **pl_ip_str, int *pl_port);
+ struct ip_quadruple *pip);
extern struct Curl_cftype Curl_cft_tcp;
extern struct Curl_cftype Curl_cft_udp;
else {
*phost = cf->conn->host.name;
*pdisplay_host = cf->conn->host.dispname;
- *pport = cf->conn->port;
+ *pport = cf->conn->primary.remote_port;
}
}
#ifndef CURL_DISABLE_PROXY
if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
hostname = conn->http_proxy.host.name;
- port = conn->port;
+ port = conn->primary.remote_port;
}
else
#endif
/* Copies connection info into the transfer handle to make it available when
the transfer handle is no longer associated with the connection. */
void Curl_persistconninfo(struct Curl_easy *data, struct connectdata *conn,
- char *local_ip, int local_port)
+ struct ip_quadruple *ip)
{
- memcpy(data->info.conn_primary_ip, conn->primary_ip, MAX_IPADR_LEN);
- if(local_ip && local_ip[0])
- memcpy(data->info.conn_local_ip, local_ip, MAX_IPADR_LEN);
- else
- data->info.conn_local_ip[0] = 0;
+ if(ip)
+ data->info.primary = *ip;
+ else {
+ memset(&data->info.primary, 0, sizeof(data->info.primary));
+ data->info.primary.remote_port = -1;
+ data->info.primary.local_port = -1;
+ }
data->info.conn_scheme = conn->handler->scheme;
/* conn_protocol can only provide "old" protocols */
data->info.conn_protocol = (conn->handler->protocol) & CURLPROTO_MASK;
- data->info.conn_primary_port = conn->port;
data->info.conn_remote_port = conn->remote_port;
- data->info.conn_local_port = local_port;
data->info.used_proxy =
#ifdef CURL_DISABLE_PROXY
0
failf(data, "Failed to connect to %s port %u after "
"%" CURL_FORMAT_TIMEDIFF_T " ms: %s",
- hostname, conn->port,
+ hostname, conn->primary.remote_port,
Curl_timediff(now, data->progress.t_startsingle),
curl_easy_strerror(result));
if(cf->conn->handler->protocol & PROTO_FAMILY_SSH)
Curl_pgrsTime(data, TIMER_APPCONNECT); /* we're connected already */
- Curl_verboseconnect(data, cf->conn);
+ Curl_verboseconnect(data, cf->conn, cf->sockindex);
data->info.numconnects++; /* to track the # of connections made */
}
break;
#include "timeval.h"
struct Curl_dns_entry;
+struct ip_quadruple;
/* generic function that returns how much time there's left to run, according
to the timeouts set */
char *addr, int *port);
void Curl_persistconninfo(struct Curl_easy *data, struct connectdata *conn,
- char *local_ip, int local_port);
+ struct ip_quadruple *ip);
/*
* Curl_conncontrol() marks the end of a connection/stream. The 'closeit'
if(conn->bits.tunnel_proxy || conn->bits.socksproxy)
return conn->host.name;
#endif
- return conn->primary_ip;
+ return conn->primary.remote_ip;
}
static bool match_pasv_6nums(const char *p,
*/
const char * const host_name = conn->bits.socksproxy ?
conn->socks_proxy.host.name : conn->http_proxy.host.name;
- rc = Curl_resolv(data, host_name, conn->port, FALSE, &addr);
+ rc = Curl_resolv(data, host_name, conn->primary.remote_port, FALSE, &addr);
if(rc == CURLRESOLV_PENDING)
/* BLOCKING, ignores the return code but 'addr' will be NULL in
case of failure */
(void)Curl_resolver_wait_resolv(data, &addr);
- connectport =
- (unsigned short)conn->port; /* we connect to the proxy's port */
+ /* we connect to the proxy's port */
+ connectport = (unsigned short)conn->primary.remote_port;
if(!addr) {
failf(data, "Can't resolve proxy host %s:%hu", host_name, connectport);
free(info->wouldredirect);
info->wouldredirect = NULL;
- info->conn_primary_ip[0] = '\0';
- info->conn_local_ip[0] = '\0';
- info->conn_primary_port = 0;
- info->conn_local_port = 0;
+ info->primary.remote_ip[0] = '\0';
+ info->primary.local_ip[0] = '\0';
+ info->primary.remote_port = 0;
+ info->primary.local_port = 0;
info->retry_after = 0;
info->conn_scheme = 0;
break;
case CURLINFO_PRIMARY_IP:
/* Return the ip address of the most recent (primary) connection */
- *param_charp = data->info.conn_primary_ip;
+ *param_charp = data->info.primary.remote_ip;
break;
case CURLINFO_LOCAL_IP:
/* Return the source/local ip address of the most recent (primary)
connection */
- *param_charp = data->info.conn_local_ip;
+ *param_charp = data->info.primary.local_ip;
break;
case CURLINFO_RTSP_SESSION_ID:
*param_charp = data->set.str[STRING_RTSP_SESSION_ID];
break;
case CURLINFO_PRIMARY_PORT:
/* Return the (remote) port of the most recent (primary) connection */
- *param_longp = data->info.conn_primary_port;
+ *param_longp = data->info.primary.remote_port;
break;
case CURLINFO_LOCAL_PORT:
/* Return the local port of the most recent (primary) connection */
- *param_longp = data->info.conn_local_port;
+ *param_longp = data->info.primary.local_port;
break;
case CURLINFO_PROXY_ERROR:
*param_longp = (long)data->info.pxcode;
#ifdef HAVE_LDAP_SSL
#ifdef USE_WIN32_LDAP
/* Win32 LDAP SDK doesn't support insecure mode without CA! */
- server = ldap_sslinit(host, conn->port, 1);
+ server = ldap_sslinit(host, conn->primary.remote_port, 1);
ldap_set_option(server, LDAP_OPT_SSL, LDAP_OPT_ON);
#else
int ldap_option;
result = CURLE_SSL_CERTPROBLEM;
goto quit;
}
- server = ldapssl_init(host, conn->port, 1);
+ server = ldapssl_init(host, conn->primary.remote_port, 1);
if(!server) {
failf(data, "LDAP local: Cannot connect to %s:%u",
- conn->host.dispname, conn->port);
+ conn->host.dispname, conn->primary.remote_port);
result = CURLE_COULDNT_CONNECT;
goto quit;
}
result = CURLE_SSL_CERTPROBLEM;
goto quit;
}
- server = ldap_init(host, conn->port);
+ server = ldap_init(host, conn->primary.remote_port);
if(!server) {
failf(data, "LDAP local: Cannot connect to %s:%u",
- conn->host.dispname, conn->port);
+ conn->host.dispname, conn->primary.remote_port);
result = CURLE_COULDNT_CONNECT;
goto quit;
}
goto quit;
}
else {
- server = ldap_init(host, conn->port);
+ server = ldap_init(host, conn->primary.remote_port);
if(!server) {
failf(data, "LDAP local: Cannot connect to %s:%u",
- conn->host.dispname, conn->port);
+ conn->host.dispname, conn->primary.remote_port);
result = CURLE_COULDNT_CONNECT;
goto quit;
}
hostname = conn->host.name;
/* check if we have the name resolved by now */
- dns = Curl_fetch_addr(data, hostname, (int)conn->port);
+ dns = Curl_fetch_addr(data, hostname, conn->primary.remote_port);
if(dns) {
#ifdef CURLRES_ASYNCH
/* call the prerequest callback function */
Curl_set_in_callback(data, true);
prereq_rc = data->set.fprereq(data->set.prereq_userp,
- data->info.conn_primary_ip,
- data->info.conn_local_ip,
- data->info.conn_primary_port,
- data->info.conn_local_port);
+ data->info.primary.remote_ip,
+ data->info.primary.local_ip,
+ data->info.primary.remote_port,
+ data->info.primary.local_port);
Curl_set_in_callback(data, false);
if(prereq_rc != CURL_PREREQFUNC_OK) {
failf(data, "operation aborted by pre-request callback");
case CONNECT_RESOLVING:
/* check if we have the name resolved by now */
- dns = Curl_fetch_addr(data, sx->hostname, (int)conn->port);
+ dns = Curl_fetch_addr(data, sx->hostname, conn->primary.remote_port);
if(dns) {
#ifdef CURLRES_ASYNCH
result = connect_SOCKS(cf, sx, data);
if(!result && sx->state == CONNECT_DONE) {
cf->connected = TRUE;
- Curl_verboseconnect(data, conn);
+ Curl_verboseconnect(data, conn, cf->sockindex);
socks_proxy_cf_free(cf);
}
if(!canmultiplex) {
if(Curl_resolver_asynch() &&
- /* primary_ip[0] is NUL only if the resolving of the name hasn't
+ /* remote_ip[0] is NUL only if the resolving of the name hasn't
completed yet and until then we don't reuse this connection */
- !check->primary_ip[0])
+ !check->primary.remote_ip[0])
continue;
}
*/
#ifndef CURL_DISABLE_VERBOSE_STRINGS
void Curl_verboseconnect(struct Curl_easy *data,
- struct connectdata *conn)
+ struct connectdata *conn, int sockindex)
{
- if(data->set.verbose)
+ if(data->set.verbose && sockindex == SECONDARYSOCKET)
+ infof(data, "Connected 2nd connection to %s port %u",
+ conn->secondary.remote_ip, conn->secondary.remote_port);
+ else
infof(data, "Connected to %s (%s) port %u",
- CURL_CONN_HOST_DISPNAME(conn), conn->primary_ip, conn->port);
+ CURL_CONN_HOST_DISPNAME(conn), conn->primary.remote_ip,
+ conn->primary.remote_port);
}
#endif
conn->sockfd = CURL_SOCKET_BAD;
conn->writesockfd = CURL_SOCKET_BAD;
conn->connection_id = -1; /* no ID */
- conn->port = -1; /* unknown at this point */
+ conn->primary.remote_port = -1; /* unknown at this point */
conn->remote_port = -1; /* unknown at this point */
/* Default protocol-independent behavior doesn't support persistent
}
else {
unsigned long port = strtoul(data->state.up.port, NULL, 10);
- conn->port = conn->remote_port =
+ conn->primary.remote_port = conn->remote_port =
(data->set.use_port && data->state.allow_port) ?
data->set.use_port : curlx_ultous(port);
}
p = conn->handler; /* May have changed. */
}
- if(conn->port < 0)
+ if(conn->primary.remote_port < 0)
/* we check for -1 here since if proxy was detected already, this
was very likely already set to the proxy port */
- conn->port = p->defport;
+ conn->primary.remote_port = p->defport;
return CURLE_OK;
}
}
if(port >= 0) {
proxyinfo->port = port;
- if(conn->port < 0 || sockstype || !conn->socks_proxy.host.rawalloc)
- conn->port = port;
+ if(conn->primary.remote_port < 0 || sockstype ||
+ !conn->socks_proxy.host.rawalloc)
+ conn->primary.remote_port = port;
}
/* now, clone the proxy host name */
if(!conn->hostname_resolve)
return CURLE_OUT_OF_MEMORY;
- rc = Curl_resolv_timeout(data, conn->hostname_resolve, (int)conn->port,
- &hostaddr, timeout_ms);
+ rc = Curl_resolv_timeout(data, conn->hostname_resolve,
+ conn->primary.remote_port, &hostaddr, timeout_ms);
conn->dns_entry = hostaddr;
if(rc == CURLRESOLV_PENDING)
*async = TRUE;
/* If not connecting via a proxy, extract the port from the URL, if it is
* there, thus overriding any defaults that might have been set above. */
- conn->port = conn->bits.conn_to_port ? conn->conn_to_port :
+ conn->primary.remote_port = conn->bits.conn_to_port ? conn->conn_to_port :
conn->remote_port;
/* Resolve target host right on */
if(!conn->hostname_resolve)
return CURLE_OUT_OF_MEMORY;
- rc = Curl_resolv_timeout(data, conn->hostname_resolve, (int)conn->port,
- &hostaddr, timeout_ms);
+ rc = Curl_resolv_timeout(data, conn->hostname_resolve,
+ conn->primary.remote_port, &hostaddr, timeout_ms);
conn->dns_entry = hostaddr;
if(rc == CURLRESOLV_PENDING)
*async = TRUE;
/* this is supposed to be the connect function so we better at least check
that the file is present here! */
DEBUGASSERT(conn->handler->connect_it);
- Curl_persistconninfo(data, conn, NULL, -1);
+ Curl_persistconninfo(data, conn, NULL);
result = conn->handler->connect_it(data, &done);
/* Setup a "faked" transfer that'll do nothing */
specified */
#ifdef CURL_DISABLE_VERBOSE_STRINGS
-#define Curl_verboseconnect(x,y) Curl_nop_stmt
+#define Curl_verboseconnect(x,y,z) Curl_nop_stmt
#else
-void Curl_verboseconnect(struct Curl_easy *data, struct connectdata *conn);
+void Curl_verboseconnect(struct Curl_easy *data, struct connectdata *conn,
+ int sockindex);
#endif
#if defined(USE_HTTP2) || defined(USE_HTTP3)
#define CONNRESULT_NONE 0 /* No extra information. */
#define CONNRESULT_DEAD (1<<0) /* The connection is dead. */
+struct ip_quadruple {
+ char remote_ip[MAX_IPADR_LEN];
+ char local_ip[MAX_IPADR_LEN];
+ int remote_port;
+ int local_port;
+};
+
struct proxy_info {
struct hostname host;
int port;
struct proxy_info socks_proxy;
struct proxy_info http_proxy;
#endif
- /* 'primary_ip' and 'primary_port' get filled with peer's numerical
- ip address and port number whenever an outgoing connection is
- *attempted* from the primary socket to a remote address. When more
- than one address is tried for a connection these will hold data
+ /* 'primary' and 'secondary' get filled with IP quadruple
+ (local/remote numerical ip address and port) whenever a is *attempted*.
+ When more than one address is tried for a connection these will hold data
for the last attempt. When the connection is actually established
these are updated with data which comes directly from the socket. */
-
- char primary_ip[MAX_IPADR_LEN];
+ struct ip_quadruple primary;
+ struct ip_quadruple secondary;
char *user; /* user name string, allocated */
char *passwd; /* password string, allocated */
char *options; /* options string, allocated */
int socks5_gssapi_enctype;
#endif
/* The field below gets set in connect.c:connecthost() */
- int port; /* which port to use locally - to connect to */
int remote_port; /* the remote port, not the proxy port! */
int conn_to_port; /* the remote port to connect to. valid only if
bits.conn_to_port is set */
curl_off_t retry_after; /* info from Retry-After: header */
unsigned int header_size; /* size of read header(s) in bytes */
- /* PureInfo members 'conn_primary_ip', 'conn_primary_port', 'conn_local_ip'
- and, 'conn_local_port' are copied over from the connectdata struct in
- order to allow curl_easy_getinfo() to return this information even when
- the session handle is no longer associated with a connection, and also
- allow curl_easy_reset() to clear this information from the session handle
- without disturbing information which is still alive, and that might be
- reused, in the connection cache. */
-
- char conn_primary_ip[MAX_IPADR_LEN];
- int conn_primary_port; /* this is the destination port to the connection,
- which might have been a proxy */
+ /* PureInfo primary ip_quadruple is copied over from the connectdata
+ struct in order to allow curl_easy_getinfo() to return this information
+ even when the session handle is no longer associated with a connection,
+ and also allow curl_easy_reset() to clear this information from the
+ session handle without disturbing information which is still alive, and
+ that might be reused, in the connection cache. */
+ struct ip_quadruple primary;
int conn_remote_port; /* this is the "remote port", which is the port
number of the used URL, independent of proxy or
not */
- char conn_local_ip[MAX_IPADR_LEN];
- int conn_local_port;
const char *conn_scheme;
unsigned int conn_protocol;
struct curl_certinfo certs; /* info about the certs. Asked for with
return pending;
}
-static void cf_msh3_active(struct Curl_cfilter *cf, struct Curl_easy *data)
-{
- struct cf_msh3_ctx *ctx = cf->ctx;
-
- /* use this socket from now on */
- cf->conn->sock[cf->sockindex] = ctx->sock[SP_LOCAL];
- /* the first socket info gets set at conn and data */
- if(cf->sockindex == FIRSTSOCKET) {
- cf->conn->remote_addr = &ctx->addr;
- #ifdef ENABLE_IPV6
- cf->conn->bits.ipv6 = (ctx->addr.family == AF_INET6)? TRUE : FALSE;
- #endif
- Curl_persistconninfo(data, cf->conn, ctx->l_ip, ctx->l_port);
- }
- ctx->active = TRUE;
-}
-
static CURLcode h3_data_pause(struct Curl_cfilter *cf,
struct Curl_easy *data,
bool pause)
}
}
break;
- case CF_CTRL_CONN_INFO_UPDATE:
- CURL_TRC_CF(data, cf, "req: update info");
- cf_msh3_active(cf, data);
- break;
default:
break;
}
if(result)
return result;
- Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd,
- &sockaddr, NULL, NULL, NULL, NULL);
+ Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd, &sockaddr, NULL);
if(!sockaddr)
return CURLE_QUIC_CONNECT_ERROR;
ctx->q.local_addrlen = sizeof(ctx->q.local_addr);
#ifndef CURL_DISABLE_VERBOSE_STRINGS
if(result) {
- const char *r_ip = NULL;
- int r_port = 0;
+ struct ip_quadruple ip;
- Curl_cf_socket_peek(cf->next, data, NULL, NULL,
- &r_ip, &r_port, NULL, NULL);
+ Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
infof(data, "QUIC connect to %s port %u failed: %s",
- r_ip, r_port, curl_easy_strerror(result));
+ ip.remote_ip, ip.remote_port, curl_easy_strerror(result));
}
#endif
if(!result && ctx->qconn) {
if(CURLE_SSL_CONNECT_ERROR == result && errdetail == 0) {
char extramsg[80]="";
int sockerr = SOCKERRNO;
- const char *r_ip = NULL;
- int r_port = 0;
+ struct ip_quadruple ip;
- Curl_cf_socket_peek(cf->next, data, NULL, NULL,
- &r_ip, &r_port, NULL, NULL);
+ Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
if(sockerr && detail == SSL_ERROR_SYSCALL)
Curl_strerror(sockerr, extramsg, sizeof(extramsg));
failf(data, "QUIC connect: %s in connection to %s:%d (%s)",
extramsg[0] ? extramsg : osslq_SSL_ERROR_to_str(detail),
- ctx->peer.dispname, r_port, r_ip);
+ ctx->peer.dispname, ip.remote_port, ip.remote_ip);
}
else {
/* Could be a CERT problem */
CURLcode result;
int rv;
const struct Curl_sockaddr_ex *peer_addr = NULL;
- int peer_port;
BIO *bio = NULL;
BIO_ADDR *baddr = NULL;
goto out;
result = CURLE_QUIC_CONNECT_ERROR;
- Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd,
- &peer_addr, NULL, &peer_port, NULL, NULL);
+ Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd, &peer_addr, NULL);
if(!peer_addr)
goto out;
#ifndef CURL_DISABLE_VERBOSE_STRINGS
if(result) {
- const char *r_ip = NULL;
- int r_port = 0;
+ struct ip_quadruple ip;
- Curl_cf_socket_peek(cf->next, data, NULL, NULL,
- &r_ip, &r_port, NULL, NULL);
+ Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
infof(data, "QUIC connect to %s port %u failed: %s",
- r_ip, r_port, curl_easy_strerror(result));
+ ip.remote_ip, ip.remote_port, curl_easy_strerror(result));
}
#endif
if(!result)
if(result)
return result;
- Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd,
- &sockaddr, NULL, NULL, NULL, NULL);
+ Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd, &sockaddr, NULL);
ctx->q.local_addrlen = sizeof(ctx->q.local_addr);
rv = getsockname(ctx->q.sockfd, (struct sockaddr *)&ctx->q.local_addr,
&ctx->q.local_addrlen);
out:
#ifndef CURL_DISABLE_VERBOSE_STRINGS
if(result && result != CURLE_AGAIN) {
- const char *r_ip;
- int r_port;
+ struct ip_quadruple ip;
- Curl_cf_socket_peek(cf->next, data, NULL, NULL,
- &r_ip, &r_port, NULL, NULL);
+ Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
infof(data, "connect to %s port %u failed: %s",
- r_ip, r_port, curl_easy_strerror(result));
+ ip.remote_ip, ip.remote_port, curl_easy_strerror(result));
}
#endif
return result;
goto out;
}
if(!cf->connected && SOCKERRNO == ECONNREFUSED) {
- const char *r_ip = NULL;
- int r_port = 0;
- Curl_cf_socket_peek(cf->next, data, NULL, NULL,
- &r_ip, &r_port, NULL, NULL);
+ struct ip_quadruple ip;
+ Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
failf(data, "QUIC: connection to %s port %u refused",
- r_ip, r_port);
+ ip.remote_ip, ip.remote_port);
result = CURLE_COULDNT_CONNECT;
goto out;
}
goto out;
}
if(!cf->connected && SOCKERRNO == ECONNREFUSED) {
- const char *r_ip = NULL;
- int r_port = 0;
- Curl_cf_socket_peek(cf->next, data, NULL, NULL,
- &r_ip, &r_port, NULL, NULL);
+ struct ip_quadruple ip;
+ Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
failf(data, "QUIC: connection to %s port %u refused",
- r_ip, r_port);
+ ip.remote_ip, ip.remote_port);
result = CURLE_COULDNT_CONNECT;
goto out;
}
goto out;
}
if(!cf->connected && SOCKERRNO == ECONNREFUSED) {
- const char *r_ip = NULL;
- int r_port = 0;
- Curl_cf_socket_peek(cf->next, data, NULL, NULL,
- &r_ip, &r_port, NULL, NULL);
+ struct ip_quadruple ip;
+ Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
failf(data, "QUIC: connection to %s port %u refused",
- r_ip, r_port);
+ ip.remote_ip, ip.remote_port);
result = CURLE_COULDNT_CONNECT;
goto out;
}