Skip to content

Commit

Permalink
Adding suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Lukas <[email protected]>
  • Loading branch information
SebaLukas committed Dec 9, 2024
1 parent e7973df commit 882b571
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/iso15118/detail/io/socket_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace iso15118::io {

bool check_and_udapte_interface(std::string& interface_name);
bool check_and_update_interface(std::string& interface_name);

bool get_first_sockaddr_in6_for_interface(const std::string& interface_name, sockaddr_in6& address);

Expand Down
2 changes: 1 addition & 1 deletion include/iso15118/io/sdp_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct PeerRequestContext {

class SdpServer {
public:
explicit SdpServer(std::string interface_name);
explicit SdpServer(const std::string& interface_name);
~SdpServer();
PeerRequestContext get_peer_request();
void send_response(const PeerRequestContext&, const Ipv6EndPoint&);
Expand Down
8 changes: 4 additions & 4 deletions src/iso15118/io/connection_mbedtls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ ConnectionSSL::ConnectionSSL(PollManager& poll_manager_, const std::string& inte
log_and_throw(msg.c_str());
}

end_point.port = 50000;
memcpy(&end_point.address, &address.sin6_addr, sizeof(address.sin6_addr));

const auto address_name = sockaddr_in6_to_name(address);

if (not address_name) {
Expand All @@ -157,10 +160,7 @@ ConnectionSSL::ConnectionSSL(PollManager& poll_manager_, const std::string& inte
log_and_throw(msg.c_str());
}

logf_info("Incoming connection from [%s]:%" PRIu16, address_name.get(), ntohs(address.sin6_port));

end_point.port = 50000;
memcpy(&end_point.address, &address.sin6_addr, sizeof(address.sin6_addr));
logf_info("Start TLS server [%s]:%" PRIu16, address_name.get(), end_point.port);

//
// mbedtls specifica
Expand Down
10 changes: 5 additions & 5 deletions src/iso15118/io/connection_openssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ ConnectionSSL::ConnectionSSL(PollManager& poll_manager_, const std::string& inte
log_and_throw(msg.c_str());
}

// Todo(sl): Define constexpr -> 50000 is fixed?
end_point.port = 50000;
memcpy(&end_point.address, &address.sin6_addr, sizeof(address.sin6_addr));

const auto address_name = sockaddr_in6_to_name(address);

if (not address_name) {
Expand All @@ -143,11 +147,7 @@ ConnectionSSL::ConnectionSSL(PollManager& poll_manager_, const std::string& inte
log_and_throw(msg.c_str());
}

logf_info("Incoming connection from [%s]:%" PRIu16, address_name.get(), ntohs(address.sin6_port));

// Todo(sl): Define constexpr -> 50000 is fixed?
end_point.port = 50000;
memcpy(&end_point.address, &address.sin6_addr, sizeof(address.sin6_addr));
logf_info("Start TLS server [%s]:%" PRIu16, address_name.get(), end_point.port);

ssl->fd = socket(AF_INET6, SOCK_STREAM, 0);
if (ssl->fd == -1) {
Expand Down
2 changes: 1 addition & 1 deletion src/iso15118/io/sdp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static void log_peer_hostname(const struct sockaddr_in6& address) {

namespace io {

SdpServer::SdpServer(std::string interface_name) {
SdpServer::SdpServer(const std::string& interface_name) {
fd = socket(AF_INET6, SOCK_DGRAM, 0);

if (fd == -1) {
Expand Down
4 changes: 2 additions & 2 deletions src/iso15118/io/socket_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace iso15118::io {
namespace {

auto choose_first_ipv6_interface() {
std::string interface_name{""};
std::string interface_name{};
struct ifaddrs* if_list_head;
const auto get_if_addrs_result = getifaddrs(&if_list_head);

Expand Down Expand Up @@ -46,7 +46,7 @@ auto choose_first_ipv6_interface() {

} // namespace

bool check_and_udapte_interface(std::string& interface_name) {
bool check_and_update_interface(std::string& interface_name) {

if (interface_name == "auto") {
logf_info("Search for the first available ipv6 interface");
Expand Down
2 changes: 1 addition & 1 deletion src/iso15118/tbd_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TbdController::TbdController(TbdConfig config_, session::feedback::Callbacks cal
evse_setup(std::move(setup_)),
interface_name(config.interface_name) {

const auto result_interface_check = io::check_and_udapte_interface(interface_name);
const auto result_interface_check = io::check_and_update_interface(interface_name);
if (result_interface_check) {
logf_info("Using ethernet interface: %s", interface_name.c_str());
} else {
Expand Down

0 comments on commit 882b571

Please sign in to comment.