Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Adding initial iso mux support #28

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/iso15118/tbd_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
config::SSLConfig ssl{config::CertificateBackend::EVEREST_LAYOUT, ""};
std::string interface_name;
config::TlsNegotiationStrategy tls_negotiation_strategy{config::TlsNegotiationStrategy::ACCEPT_CLIENT_OFFER};
bool enable_sdp_server{true};

Check notice on line 23 in include/iso15118/tbd_controller.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

include/iso15118/tbd_controller.hpp#L23

struct member 'TbdConfig::enable_sdp_server' is never used.
};

class TbdController {
Expand All @@ -36,7 +37,7 @@

private:
io::PollManager poll_manager;
io::SdpServer sdp_server;
std::unique_ptr<io::SdpServer> sdp_server;

d20::SessionConfig session_config;

Expand Down
4 changes: 3 additions & 1 deletion src/iso15118/io/socket_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ bool get_first_sockaddr_in6_for_interface(const std::string& interface_name, soc

// NOTE (aw): because we did the check for AF_INET6, we can assume that ifa_addr is indeed an sockaddr_in6
const auto current_addr = reinterpret_cast<const sockaddr_in6*>(current_if->ifa_addr);
if (not IN6_IS_ADDR_LINKLOCAL(&(current_addr->sin6_addr))) {

// NOTE (sl): If using loopback device, accept any address. Loopback usually does not have a link local address
if (interface_name.compare("lo") != 0 and not IN6_IS_ADDR_LINKLOCAL(&(current_addr->sin6_addr))) {
continue;
}

Expand Down
14 changes: 11 additions & 3 deletions src/iso15118/tbd_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@

TbdController::TbdController(TbdConfig config_, session::feedback::Callbacks callbacks_) :
config(std::move(config_)), callbacks(std::move(callbacks_)) {
poll_manager.register_fd(sdp_server.get_fd(), [this]() { handle_sdp_server_input(); });
if (config.enable_sdp_server) {
sdp_server = std::make_unique<io::SdpServer>();
poll_manager.register_fd(sdp_server->get_fd(), [this]() { handle_sdp_server_input(); });
}
session_config = d20::SessionConfig();
}

void TbdController::loop() {
static constexpr auto POLL_MANAGER_TIMEOUT_MS = 50;

if (not config.enable_sdp_server) {
auto connection = std::make_unique<io::ConnectionPlain>(poll_manager, config.interface_name);
const auto& new_session = sessions.emplace_back(std::move(connection), session_config, callbacks);

Check notice on line 37 in src/iso15118/tbd_controller.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/iso15118/tbd_controller.cpp#L37

Variable 'new_session' is assigned a value that is never used.
}

auto next_event = get_current_time_point();

while (true) {
Expand Down Expand Up @@ -73,7 +81,7 @@
}

void TbdController::handle_sdp_server_input() {
auto request = sdp_server.get_peer_request();
auto request = sdp_server->get_peer_request();

if (not request) {
return;
Expand Down Expand Up @@ -104,7 +112,7 @@
// Todo(sl): Check if session_config is empty
const auto& new_session = sessions.emplace_back(std::move(connection), session_config, callbacks);

sdp_server.send_response(request, ipv6_endpoint);
sdp_server->send_response(request, ipv6_endpoint);
}

} // namespace iso15118
Loading