From 59ebc4b87e340537d40940b2ddd9c9df8cefcaab Mon Sep 17 00:00:00 2001 From: Guillaume Meunier Date: Fri, 24 Nov 2023 12:00:16 +0100 Subject: [PATCH] Publish server and protocol version on avahi --- common/version.cpp.in | 7 ++++--- common/version.h | 12 +++++++++++- server/main.cpp | 9 +++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/common/version.cpp.in b/common/version.cpp.in index e9db04a2..94b2a003 100644 --- a/common/version.cpp.in +++ b/common/version.cpp.in @@ -17,6 +17,7 @@ * along with this program. If not, see . */ -#include "version.h" - -const char git_version[] = "@GIT_DESC@"; +namespace xrt::drivers::wivrn +{ + const char git_version[] = "@GIT_DESC@"; +} diff --git a/common/version.h b/common/version.h index 2c80a970..df005a6c 100644 --- a/common/version.h +++ b/common/version.h @@ -1,3 +1,13 @@ #pragma once -extern const char git_version[]; +#include "wivrn_serialization.h" +#include "wivrn_packets.h" + + +namespace xrt::drivers::wivrn +{ + using protocol = std::pair; + + extern const char git_version[]; + static inline const constinit auto protocol_version = serialization_type_hash(); +} diff --git a/server/main.cpp b/server/main.cpp index ea44839d..db80140d 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -165,7 +165,7 @@ void waitpid_verbose(pid_t pid, const std::string & name) int inner_main(int argc, char * argv[]) { - std::cerr << "WiVRn " << git_version << " starting" << std::endl; + std::cerr << "WiVRn " << xrt::drivers::wivrn::git_version << " starting" << std::endl; create_listen_socket(); u_trace_marker_init(); @@ -188,12 +188,17 @@ int inner_main(int argc, char * argv[]) fcntl(pipe_fds[0], F_SETFD, FD_CLOEXEC); fcntl(pipe_fds[1], F_SETFD, FD_CLOEXEC); + std::vector TXT; + TXT.push_back(std::format("protocol={:16x}", xrt::drivers::wivrn::protocol_version)); + TXT.push_back(std::format("version={}", (const char*)xrt::drivers::wivrn::git_version)); + + bool quit = false; while (!quit) { try { - avahi_publisher publisher(hostname().c_str(), "_wivrn._tcp", default_port); + avahi_publisher publisher(hostname().c_str(), "_wivrn._tcp", default_port, TXT); TCPListener listener(default_port); bool client_connected = false;