Skip to content

Commit

Permalink
Change port from uint16_t to uint32_t, to support VSOCK (#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
graebm authored Dec 30, 2023
1 parent 2f18149 commit 8ec54ac
Show file tree
Hide file tree
Showing 30 changed files with 62 additions and 62 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ instance of this class for each reservation.
tlsCtxOptions.OverrideDefaultTrustStore(nullptr, caFile.c_str());
}
uint16_t port = 8883;
uint32_t port = 8883;
if (Io::TlsContextOptions::IsAlpnSupported())
{
/*
Expand Down
2 changes: 1 addition & 1 deletion bin/elasticurl_cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ int main(int argc, char **argv)
apiHandle.InitializeLogging(appCtx.LogLevel, stderr);
}
bool useTls = true;
uint16_t port = 443;
uint32_t port = 443;
if (!appCtx.uri.GetScheme().len && (appCtx.uri.GetPort() == 80 || appCtx.uri.GetPort() == 8080))
{
useTls = false;
Expand Down
2 changes: 1 addition & 1 deletion bin/mqtt5_app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct app_ctx
{
struct aws_allocator *allocator;
Io::Uri uri;
uint16_t port;
uint32_t port;
const char *cacert;
const char *cert;
const char *key;
Expand Down
2 changes: 1 addition & 1 deletion bin/mqtt5_canary/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct AppCtx
Allocator *allocator;
struct aws_mutex lock;
Io::Uri uri;
uint16_t port;
uint32_t port;
const char *cacert;
const char *cert;
const char *key;
Expand Down
2 changes: 1 addition & 1 deletion crt/aws-c-common
2 changes: 1 addition & 1 deletion crt/aws-lc
2 changes: 1 addition & 1 deletion crt/s2n
Submodule s2n updated from 95753f to a9a07a
4 changes: 2 additions & 2 deletions include/aws/crt/http/HttpConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ namespace Aws
* The port of the proxy server to connect to.
* Required.
*/
uint16_t Port;
uint32_t Port;

/**
* Sets the TLS options for the connection to the proxy.
Expand Down Expand Up @@ -391,7 +391,7 @@ namespace Aws
* The port of the http server to connect to.
* Required.
*/
uint16_t Port;
uint32_t Port;

/**
* The socket options of the connection.
Expand Down
2 changes: 1 addition & 1 deletion include/aws/crt/io/Uri.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ namespace Aws
* be set to 0. In that case, it is your responsibility to determine the correct port
* based on the protocol you're using.
*/
uint16_t GetPort() const noexcept;
uint32_t GetPort() const noexcept;

/** @return the Path and Query portion of the URI. In the case of Http, this likely the value for the
* URI parameter.
Expand Down
4 changes: 2 additions & 2 deletions include/aws/crt/mqtt/Mqtt5Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ namespace Aws
*
* @return this option object
*/
Mqtt5ClientOptions &WithPort(uint16_t port) noexcept;
Mqtt5ClientOptions &WithPort(uint32_t port) noexcept;

/**
* Set booststrap for mqtt5 client
Expand Down Expand Up @@ -754,7 +754,7 @@ namespace Aws
/**
* Network port of the MQTT server to connect to.
*/
uint16_t m_port;
uint32_t m_port;

/**
* Client bootstrap to use. In almost all cases, this can be left undefined.
Expand Down
4 changes: 2 additions & 2 deletions include/aws/crt/mqtt/MqttClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace Aws
*/
std::shared_ptr<MqttConnection> NewConnection(
const char *hostName,
uint16_t port,
uint32_t port,
const Io::SocketOptions &socketOptions,
const Crt::Io::TlsContext &tlsContext,
bool useWebsocket = false) noexcept;
Expand All @@ -109,7 +109,7 @@ namespace Aws
*/
std::shared_ptr<MqttConnection> NewConnection(
const char *hostName,
uint16_t port,
uint32_t port,
const Io::SocketOptions &socketOptions,
bool useWebsocket = false) noexcept;

Expand Down
2 changes: 1 addition & 1 deletion include/aws/crt/mqtt/MqttTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Aws
struct MqttConnectionOptions
{
const char *hostName = nullptr;
uint16_t port = 0;
uint32_t port = 0;
Io::SocketOptions socketOptions;
Crt::Io::TlsContext tlsContext;
Crt::Io::TlsConnectionOptions tlsConnectionOptions;
Expand Down
2 changes: 1 addition & 1 deletion include/aws/crt/mqtt/private/MqttConnectionCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ namespace Aws

aws_mqtt_client_connection *m_underlyingConnection;
String m_hostName;
uint16_t m_port;
uint32_t m_port;
Crt::Io::TlsContext m_tlsContext;
Io::TlsConnectionOptions m_tlsOptions;
Io::SocketOptions m_socketOptions;
Expand Down
4 changes: 2 additions & 2 deletions include/aws/iot/Mqtt5Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ namespace Aws
*
* @return this option object
*/
Mqtt5ClientBuilder &WithPort(uint16_t port) noexcept;
Mqtt5ClientBuilder &WithPort(uint32_t port) noexcept;

/**
* Set booststrap for mqtt5 client
Expand Down Expand Up @@ -542,7 +542,7 @@ namespace Aws
/**
* Network port of the MQTT server to connect to.
*/
uint16_t m_port;
uint32_t m_port;

/**
* TLS context for secure socket connections.
Expand Down
12 changes: 6 additions & 6 deletions include/aws/iot/MqttClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Aws
*/
MqttClientConnectionConfig(
const Crt::String &endpoint,
uint16_t port,
uint32_t port,
const Crt::Io::SocketOptions &socketOptions,
Crt::Io::TlsContext &&tlsContext);

Expand All @@ -60,7 +60,7 @@ namespace Aws
*/
MqttClientConnectionConfig(
const Crt::String &endpoint,
uint16_t port,
uint32_t port,
const Crt::Io::SocketOptions &socketOptions,
Crt::Io::TlsContext &&tlsContext,
Crt::Mqtt::OnWebSocketHandshakeIntercept &&interceptor,
Expand All @@ -81,13 +81,13 @@ namespace Aws

MqttClientConnectionConfig(
const Crt::String &endpoint,
uint16_t port,
uint32_t port,
const Crt::Io::SocketOptions &socketOptions,
Crt::Io::TlsContext &&tlsContext,
const Crt::Optional<Crt::Http::HttpClientConnectionProxyOptions> &proxyOptions);

Crt::String m_endpoint;
uint16_t m_port;
uint32_t m_port;
Crt::Io::TlsContext m_context;
Crt::Io::SocketOptions m_socketOptions;
Crt::Mqtt::OnWebSocketHandshakeIntercept m_webSocketInterceptor;
Expand Down Expand Up @@ -219,7 +219,7 @@ namespace Aws
*
* @return this builder object
*/
MqttClientConnectionConfigBuilder &WithPortOverride(uint16_t port) noexcept;
MqttClientConnectionConfigBuilder &WithPortOverride(uint32_t port) noexcept;

/**
* Sets the certificate authority for the endpoint you're connecting to. This is a path to a file on disk
Expand Down Expand Up @@ -437,7 +437,7 @@ namespace Aws

Crt::Allocator *m_allocator;
Crt::String m_endpoint;
uint16_t m_portOverride;
uint32_t m_portOverride;
Crt::Io::SocketOptions m_socketOptions;
Crt::Io::TlsContextOptions m_contextOptions;
Crt::Optional<WebsocketConfig> m_websocketConfig;
Expand Down
2 changes: 1 addition & 1 deletion source/io/Uri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace Aws

ByteCursor Uri::GetHostName() const noexcept { return m_uri.host_name; }

uint16_t Uri::GetPort() const noexcept { return m_uri.port; }
uint32_t Uri::GetPort() const noexcept { return m_uri.port; }

ByteCursor Uri::GetPathAndQuery() const noexcept { return m_uri.path_and_query; }

Expand Down
4 changes: 2 additions & 2 deletions source/iot/Mqtt5Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ namespace Aws
return *this;
}

Mqtt5ClientBuilder &Mqtt5ClientBuilder::WithPort(uint16_t port) noexcept
Mqtt5ClientBuilder &Mqtt5ClientBuilder::WithPort(uint32_t port) noexcept
{
m_port = port;
return *this;
Expand Down Expand Up @@ -479,7 +479,7 @@ namespace Aws
return nullptr;
}

uint16_t port = m_port;
uint32_t port = m_port;

if (!port) // port is default to 0
{
Expand Down
10 changes: 5 additions & 5 deletions source/iot/MqttClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Aws

MqttClientConnectionConfig::MqttClientConnectionConfig(
const Crt::String &endpoint,
uint16_t port,
uint32_t port,
const Crt::Io::SocketOptions &socketOptions,
Crt::Io::TlsContext &&tlsContext)
: m_endpoint(endpoint), m_port(port), m_context(std::move(tlsContext)), m_socketOptions(socketOptions),
Expand All @@ -39,7 +39,7 @@ namespace Aws

MqttClientConnectionConfig::MqttClientConnectionConfig(
const Crt::String &endpoint,
uint16_t port,
uint32_t port,
const Crt::Io::SocketOptions &socketOptions,
Crt::Io::TlsContext &&tlsContext,
Crt::Mqtt::OnWebSocketHandshakeIntercept &&interceptor,
Expand All @@ -51,7 +51,7 @@ namespace Aws

MqttClientConnectionConfig::MqttClientConnectionConfig(
const Crt::String &endpoint,
uint16_t port,
uint32_t port,
const Crt::Io::SocketOptions &socketOptions,
Crt::Io::TlsContext &&tlsContext,
const Crt::Optional<Crt::Http::HttpClientConnectionProxyOptions> &proxyOptions)
Expand Down Expand Up @@ -218,7 +218,7 @@ namespace Aws
return *this;
}

MqttClientConnectionConfigBuilder &MqttClientConnectionConfigBuilder::WithPortOverride(uint16_t port) noexcept
MqttClientConnectionConfigBuilder &MqttClientConnectionConfigBuilder::WithPortOverride(uint32_t port) noexcept
{
m_portOverride = port;
return *this;
Expand Down Expand Up @@ -443,7 +443,7 @@ namespace Aws
return MqttClientConnectionConfig::CreateInvalid(m_lastError);
}

uint16_t port = m_portOverride;
uint32_t port = m_portOverride;

if (!m_portOverride)
{
Expand Down
2 changes: 1 addition & 1 deletion source/mqtt/Mqtt5Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ namespace Aws
return *this;
}

Mqtt5ClientOptions &Mqtt5ClientOptions::WithPort(uint16_t port) noexcept
Mqtt5ClientOptions &Mqtt5ClientOptions::WithPort(uint32_t port) noexcept
{
m_port = port;
return *this;
Expand Down
4 changes: 2 additions & 2 deletions source/mqtt/MqttClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace Aws

std::shared_ptr<MqttConnection> MqttClient::NewConnection(
const char *hostName,
uint16_t port,
uint32_t port,
const Io::SocketOptions &socketOptions,
const Crt::Io::TlsContext &tlsContext,
bool useWebsocket) noexcept
Expand Down Expand Up @@ -91,7 +91,7 @@ namespace Aws

std::shared_ptr<MqttConnection> MqttClient::NewConnection(
const char *hostName,
uint16_t port,
uint32_t port,
const Io::SocketOptions &socketOptions,
bool useWebsocket) noexcept

Expand Down
2 changes: 1 addition & 1 deletion tests/CredentialsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ static int s_InitializeProxyOptions(
ASSERT_SUCCESS(aws_get_environment_value(allocator, s_httpProxyPortEnvVariable, &proxy_port));

proxyOptions.HostName = Aws::Crt::String(aws_string_c_str(proxy_host_name));
proxyOptions.Port = static_cast<uint16_t>(atoi(aws_string_c_str(proxy_port)));
proxyOptions.Port = static_cast<uint32_t>(atoi(aws_string_c_str(proxy_port)));

aws_string_destroy(proxy_host_name);
aws_string_destroy(proxy_port);
Expand Down
Loading

0 comments on commit 8ec54ac

Please sign in to comment.