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:
Stefan Eissing 2025-11-26 14:05:46 +01:00 committed by Daniel Stenberg
parent feea968512
commit c4f29cc508
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
20 changed files with 104 additions and 80 deletions

View file

@ -55,7 +55,7 @@ struct cf_hc_baller {
CURLcode result;
struct curltime started;
int reply_ms;
unsigned char transport;
uint8_t transport;
enum alpnid alpn_id;
BIT(shutdown);
};
@ -124,7 +124,7 @@ struct cf_hc_ctx {
static void cf_hc_baller_assign(struct cf_hc_baller *b,
enum alpnid alpn_id,
unsigned char def_transport)
uint8_t def_transport)
{
b->alpn_id = alpn_id;
b->transport = def_transport;
@ -148,7 +148,7 @@ static void cf_hc_baller_assign(struct cf_hc_baller *b,
static void cf_hc_baller_init(struct cf_hc_baller *b,
struct Curl_cfilter *cf,
struct Curl_easy *data,
int transport)
uint8_t transport)
{
struct Curl_cfilter *save = cf->next;
@ -581,7 +581,7 @@ struct Curl_cftype Curl_cft_http_connect = {
static CURLcode cf_hc_create(struct Curl_cfilter **pcf,
struct Curl_easy *data,
enum alpnid *alpnids, size_t alpn_count,
unsigned char def_transport)
uint8_t def_transport)
{
struct Curl_cfilter *cf = NULL;
struct cf_hc_ctx *ctx;
@ -626,7 +626,7 @@ static CURLcode cf_http_connect_add(struct Curl_easy *data,
struct connectdata *conn,
int sockindex,
enum alpnid *alpn_ids, size_t alpn_count,
unsigned char def_transport)
uint8_t def_transport)
{
struct Curl_cfilter *cf;
CURLcode result = CURLE_OK;