Skip to content

Commit

Permalink
Change port from uint16_t to uint32_t, to support VSOCK (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
graebm authored Dec 30, 2023
1 parent 2f07551 commit 6a1c157
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion bin/elasticurl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ int main(int argc, char **argv) {
}

bool use_tls = true;
uint16_t port = 443;
uint32_t port = 443;

if (!app_ctx.uri.scheme.len && (app_ctx.uri.port == 80 || app_ctx.uri.port == 8080)) {
use_tls = false;
Expand Down
2 changes: 1 addition & 1 deletion include/aws/http/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ struct aws_http_client_connection_options {
/**
* Required.
*/
uint16_t port;
uint32_t port;

/**
* Required.
Expand Down
2 changes: 1 addition & 1 deletion include/aws/http/connection_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct aws_http_connection_manager_options {

const struct aws_http_connection_monitoring_options *monitoring_options;
struct aws_byte_cursor host;
uint16_t port;
uint32_t port;

/**
* Optional.
Expand Down
2 changes: 1 addition & 1 deletion include/aws/http/http2_stream_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct aws_http2_stream_manager_options {
bool http2_prior_knowledge;

struct aws_byte_cursor host;
uint16_t port;
uint32_t port;

/**
* Optional.
Expand Down
4 changes: 2 additions & 2 deletions include/aws/http/private/proxy_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct aws_http_proxy_config {

struct aws_byte_buf host;

uint16_t port;
uint32_t port;

struct aws_tls_connection_options *tls_options;

Expand Down Expand Up @@ -97,7 +97,7 @@ struct aws_http_proxy_user_data {
* Cached original connect options
*/
struct aws_string *original_host;
uint16_t original_port;
uint32_t original_port;
void *original_user_data;
struct aws_tls_connection_options *original_tls_options;
struct aws_client_bootstrap *original_bootstrap;
Expand Down
2 changes: 1 addition & 1 deletion include/aws/http/proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct aws_http_proxy_options {
/**
* Port to make the proxy connection to
*/
uint16_t port;
uint32_t port;

/**
* Optional.
Expand Down
2 changes: 1 addition & 1 deletion include/aws/http/websocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ struct aws_websocket_client_connection_options {
* Optional.
* Defaults to 443 if tls_options is present, 80 if it is not.
*/
uint16_t port;
uint32_t port;

/**
* Required.
Expand Down
12 changes: 6 additions & 6 deletions source/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ static void s_server_bootstrap_on_accept_channel_setup(
if (put_err) {
AWS_LOGF_ERROR(
AWS_LS_HTTP_SERVER,
"%p: %s:%d: Failed to store connection object, error %d (%s).",
"%p: %s:%u: Failed to store connection object, error %d (%s).",
(void *)server,
server->socket->local_endpoint.address,
server->socket->local_endpoint.port,
Expand All @@ -519,7 +519,7 @@ static void s_server_bootstrap_on_accept_channel_setup(
/* Tell user of successful connection. */
AWS_LOGF_INFO(
AWS_LS_HTTP_CONNECTION,
"id=%p: " PRInSTR " server connection established at %p %s:%d.",
"id=%p: " PRInSTR " server connection established at %p %s:%u.",
(void *)connection,
AWS_BYTE_CURSOR_PRI(aws_http_version_to_str(connection->http_version)),
(void *)server,
Expand Down Expand Up @@ -701,7 +701,7 @@ struct aws_http_server *aws_http_server_new(const struct aws_http_server_options

AWS_LOGF_INFO(
AWS_LS_HTTP_SERVER,
"%p %s:%d: Server setup complete, listening for incoming connections.",
"%p %s:%u: Server setup complete, listening for incoming connections.",
(void *)server,
server->socket->local_endpoint.address,
server->socket->local_endpoint.port);
Expand Down Expand Up @@ -751,7 +751,7 @@ void aws_http_server_release(struct aws_http_server *server) {
* s_server_bootstrap_on_server_listener_destroy will be invoked, clean up of the server will be there */
AWS_LOGF_INFO(
AWS_LS_HTTP_SERVER,
"%p %s:%d: Shutting down the server.",
"%p %s:%u: Shutting down the server.",
(void *)server,
server->socket->local_endpoint.address,
server->socket->local_endpoint.port);
Expand Down Expand Up @@ -1099,9 +1099,9 @@ int aws_http_client_connect_internal(

AWS_LOGF_TRACE(
AWS_LS_HTTP_CONNECTION,
"static: attempting to initialize a new client channel to %s:%d",
"static: attempting to initialize a new client channel to %s:%u",
aws_string_c_str(host_name),
(int)options.port);
options.port);

struct aws_socket_channel_bootstrap_options channel_options = {
.bootstrap = options.bootstrap,
Expand Down
2 changes: 1 addition & 1 deletion source/connection_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ struct aws_http_connection_manager {
struct aws_string *host;
struct proxy_env_var_settings proxy_ev_settings;
struct aws_tls_connection_options *proxy_ev_tls_options;
uint16_t port;
uint32_t port;
/*
* HTTP/2 specific.
*/
Expand Down
2 changes: 1 addition & 1 deletion source/proxy_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ static struct aws_http_message *s_build_h1_proxy_connect_request(struct aws_http
}

char port_str[20] = "\0";
snprintf(port_str, sizeof(port_str), "%d", (int)user_data->original_port);
snprintf(port_str, sizeof(port_str), "%u", user_data->original_port);
struct aws_byte_cursor port_cursor = aws_byte_cursor_from_c_str(port_str);
if (aws_byte_buf_append(&path_buffer, &port_cursor)) {
goto on_error;
Expand Down
2 changes: 1 addition & 1 deletion source/websocket_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ int aws_websocket_client_connect(const struct aws_websocket_client_connection_op
/* Success! (so far) */
AWS_LOGF_TRACE(
AWS_LS_HTTP_WEBSOCKET_SETUP,
"id=%p: Websocket setup begun, connecting to " PRInSTR ":%" PRIu16 PRInSTR,
"id=%p: Websocket setup begun, connecting to " PRInSTR ":%" PRIu32 PRInSTR,
(void *)ws_bootstrap,
AWS_BYTE_CURSOR_PRI(options->host),
options->port,
Expand Down
6 changes: 3 additions & 3 deletions tests/proxy_test_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,9 @@ int proxy_tester_verify_connect_request(struct proxy_tester *tester) {
snprintf(
connect_request_buffer,
AWS_ARRAY_SIZE(connect_request_buffer),
"CONNECT " PRInSTR ":%d HTTP/1.1",
"CONNECT " PRInSTR ":%u HTTP/1.1",
AWS_BYTE_CURSOR_PRI(tester->host),
(int)tester->port);
tester->port);

struct aws_byte_cursor expected_connect_message_first_line_cursor =
aws_byte_cursor_from_c_str(connect_request_buffer);
Expand Down Expand Up @@ -474,7 +474,7 @@ int proxy_tester_send_connect_response(struct proxy_tester *tester) {
int proxy_tester_verify_connection_attempt_was_to_proxy(
struct proxy_tester *tester,
struct aws_byte_cursor expected_host,
uint16_t expected_port) {
uint32_t expected_port) {
ASSERT_BIN_ARRAYS_EQUALS(
tester->connection_host_name.buffer,
tester->connection_host_name.len,
Expand Down
8 changes: 4 additions & 4 deletions tests/proxy_test_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct proxy_tester_options {
struct aws_allocator *alloc;
struct aws_http_proxy_options *proxy_options;
struct aws_byte_cursor host;
uint16_t port;
uint32_t port;
enum proxy_tester_test_mode test_mode;
enum proxy_tester_failure_type failure_type;

Expand All @@ -59,7 +59,7 @@ struct proxy_tester {

struct aws_http_proxy_options proxy_options;
struct aws_byte_cursor host;
uint16_t port;
uint32_t port;

enum proxy_tester_test_mode test_mode;
enum proxy_tester_failure_type failure_type;
Expand All @@ -81,7 +81,7 @@ struct proxy_tester {
bool tls_successful;

struct aws_byte_buf connection_host_name;
uint16_t connection_port;
uint32_t connection_port;

struct aws_array_list connect_requests;

Expand Down Expand Up @@ -120,7 +120,7 @@ int proxy_tester_send_connect_response(struct proxy_tester *tester);
int proxy_tester_verify_connection_attempt_was_to_proxy(
struct proxy_tester *tester,
struct aws_byte_cursor expected_host,
uint16_t expected_port);
uint32_t expected_port);

struct testing_channel *proxy_tester_get_current_channel(struct proxy_tester *tester);

Expand Down
4 changes: 2 additions & 2 deletions tests/test_connection_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ static struct aws_byte_cursor s_get_proxy_host_for_test(
return aws_byte_cursor_from_string(host_string);
}

static uint16_t s_get_proxy_port_for_test(
static uint32_t s_get_proxy_port_for_test(
struct proxy_integration_configurations *configs,
enum proxy_test_type proxy_test_type,
enum aws_http_proxy_authentication_type auth_type,
Expand All @@ -1447,7 +1447,7 @@ static uint16_t s_get_proxy_port_for_test(
} else {
port_string = configs->http_proxy_port;
}
return (uint16_t)atoi(aws_string_c_str(port_string));
return (uint32_t)atoi(aws_string_c_str(port_string));
}
static struct aws_string *s_get_proxy_url_for_test(
struct proxy_integration_configurations *configs,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
static struct proxy_tester tester;

static char *s_host_name = "aws.amazon.com";
static uint16_t s_port = 80;
static uint32_t s_port = 80;
static char *s_proxy_host_name = "www.myproxy.hmm";
static uint16_t s_proxy_port = 777;
static uint32_t s_proxy_port = 777;

AWS_STATIC_STRING_FROM_LITERAL(s_mock_request_method, "GET");
AWS_STATIC_STRING_FROM_LITERAL(s_mock_request_path, "/");
Expand Down
2 changes: 1 addition & 1 deletion tests/test_stream_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static int s_tester_init(struct sm_tester_options *options) {
}

bool use_tls = true;
uint16_t port = 443;
uint32_t port = 443;
if (!s_tester.endpoint.scheme.len && (s_tester.endpoint.port == 80 || s_tester.endpoint.port == 3280)) {
use_tls = false;
} else {
Expand Down

0 comments on commit 6a1c157

Please sign in to comment.