mirror of
https://github.com/curl/curl.git
synced 2026-08-25 23:23:31 +03:00
ip_quadruple/proxy: make port uint16_t
Make `port` member in these struct of type `uint16_t`. add `uint8_t transport` to `struct ip_quadruple Define TRNSPRT_NONE as 0. By assigning a valid transport only on a successful connection, it is clear when the ip_quadruple members are valid. Also, for transports not involving ports, the getinfos for `CURLINFO_PRIMARY_PORT` and `CURLINFO_LOCAL_PORT` will now always return -1. Make all `transport` members and parameters of type `uint8_t`. Document the return value of `CURLINFO_LOCAL_PORT` and `CURLINFO_PRIMARY_PORT` in this regard. Add tests that writeout stats report ports correctly. Closes #19708
This commit is contained in:
parent
feea968512
commit
c4f29cc508
20 changed files with 104 additions and 80 deletions
|
|
@ -238,7 +238,7 @@ bool Curl_shutdown_started(struct Curl_easy *data, int sockindex)
|
|||
/* retrieves ip address and port from a sockaddr structure. note it calls
|
||||
curlx_inet_ntop which sets errno on fail, not SOCKERRNO. */
|
||||
bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
|
||||
char *addr, int *port)
|
||||
char *addr, uint16_t *port)
|
||||
{
|
||||
struct sockaddr_in *si = NULL;
|
||||
#ifdef USE_IPV6
|
||||
|
|
@ -254,8 +254,7 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
|
|||
case AF_INET:
|
||||
si = (struct sockaddr_in *)(void *) sa;
|
||||
if(curlx_inet_ntop(sa->sa_family, &si->sin_addr, addr, MAX_IPADR_LEN)) {
|
||||
unsigned short us_port = ntohs(si->sin_port);
|
||||
*port = us_port;
|
||||
*port = ntohs(si->sin_port);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
|
@ -264,8 +263,7 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
|
|||
si6 = (struct sockaddr_in6 *)(void *) sa;
|
||||
if(curlx_inet_ntop(sa->sa_family, &si6->sin6_addr, addr,
|
||||
MAX_IPADR_LEN)) {
|
||||
unsigned short us_port = ntohs(si6->sin6_port);
|
||||
*port = us_port;
|
||||
*port = ntohs(si6->sin6_port);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
|
@ -366,7 +364,7 @@ typedef enum {
|
|||
struct cf_setup_ctx {
|
||||
cf_setup_state state;
|
||||
int ssl_mode;
|
||||
int transport;
|
||||
uint8_t transport;
|
||||
};
|
||||
|
||||
static CURLcode cf_setup_connect(struct Curl_cfilter *cf,
|
||||
|
|
@ -521,7 +519,7 @@ struct Curl_cftype Curl_cft_setup = {
|
|||
|
||||
static CURLcode cf_setup_create(struct Curl_cfilter **pcf,
|
||||
struct Curl_easy *data,
|
||||
int transport,
|
||||
uint8_t transport,
|
||||
int ssl_mode)
|
||||
{
|
||||
struct Curl_cfilter *cf = NULL;
|
||||
|
|
@ -554,7 +552,7 @@ out:
|
|||
static CURLcode cf_setup_add(struct Curl_easy *data,
|
||||
struct connectdata *conn,
|
||||
int sockindex,
|
||||
int transport,
|
||||
uint8_t transport,
|
||||
int ssl_mode)
|
||||
{
|
||||
struct Curl_cfilter *cf;
|
||||
|
|
@ -571,7 +569,7 @@ out:
|
|||
|
||||
CURLcode Curl_cf_setup_insert_after(struct Curl_cfilter *cf_at,
|
||||
struct Curl_easy *data,
|
||||
int transport,
|
||||
uint8_t transport,
|
||||
int ssl_mode)
|
||||
{
|
||||
struct Curl_cfilter *cf;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue