diff --git a/Cargo.lock b/Cargo.lock index 106ba77..7299457 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -462,6 +462,7 @@ dependencies = [ "anyhow", "clap", "lanparty-client-core", + "lanparty-client-tap", "lanparty-ctrl", "lanparty-proto", "tokio", diff --git a/README.md b/README.md index b0c9f24..7c84464 100644 --- a/README.md +++ b/README.md @@ -122,5 +122,6 @@ The Windows client binary currently connects to the relay as `role = client` with a generated locally administered virtual MAC persisted in `lanparty-client-identity.json`, completes the control-stream hello/welcome handshake, and then waits for shutdown. `--virtual-mac` can still override the -stored identity for manual testing. TAP adapter binding and route pinning are -not wired yet. +stored identity for manual testing. On Windows it opens the first TAP-Windows6 +adapter, marks media connected, and reports the driver MAC/MTU before waiting +for shutdown. TAP frame pumping and route pinning are not wired yet. diff --git a/crates/lanparty-client-win/Cargo.toml b/crates/lanparty-client-win/Cargo.toml index 96bba40..3060cc8 100644 --- a/crates/lanparty-client-win/Cargo.toml +++ b/crates/lanparty-client-win/Cargo.toml @@ -10,3 +10,6 @@ lanparty-client-core = { path = "../lanparty-client-core" } lanparty-ctrl = { path = "../lanparty-ctrl" } lanparty-proto = { path = "../lanparty-proto" } tokio.workspace = true + +[target.'cfg(windows)'.dependencies] +lanparty-client-tap = { path = "../lanparty-client-tap" } diff --git a/crates/lanparty-client-win/src/main.rs b/crates/lanparty-client-win/src/main.rs index 0bcf649..923138e 100644 --- a/crates/lanparty-client-win/src/main.rs +++ b/crates/lanparty-client-win/src/main.rs @@ -3,7 +3,7 @@ use std::{fs, net::SocketAddr, path::PathBuf}; use anyhow::{Context, Result}; use clap::Parser; use lanparty_client_core::{ - ClientIdentity, ClientIdentityStore, ClientSessionConfig, connect_client, + ClientIdentity, ClientIdentityStore, ClientSession, ClientSessionConfig, connect_client, }; use lanparty_ctrl::RoomCode; use lanparty_proto::MacAddr; @@ -89,7 +89,11 @@ async fn main() -> Result<()> { session.welcome().room_id(), session.welcome().effective_tap_mtu() ); - println!("Windows TAP binding and route pinning are not wired yet; press Ctrl-C to stop"); + #[cfg(windows)] + let _tap = open_tap_adapter(&session)?; + #[cfg(not(windows))] + open_tap_adapter(&session); + println!("TAP frame pump and route pinning are not wired yet; press Ctrl-C to stop"); tokio::signal::ctrl_c() .await @@ -98,3 +102,43 @@ async fn main() -> Result<()> { Ok(()) } + +#[cfg(windows)] +fn open_tap_adapter(session: &ClientSession) -> Result { + let tap = lanparty_client_tap::open_first_adapter()?; + tap.set_media_connected(true)?; + let driver_mac = tap.driver_mac()?; + let driver_mtu = tap.driver_mtu()?; + + println!( + "lanparty-client-win opened TAP adapter {}", + tap.info().device_path() + ); + println!( + "TAP driver reports MAC {} and MTU {}; relay selected TAP MTU {}", + driver_mac, + driver_mtu, + session.welcome().effective_tap_mtu() + ); + if driver_mac != session.config().virtual_mac() { + eprintln!( + "TAP driver MAC {} does not match tunnel identity {}; MAC configuration is not wired yet", + driver_mac, + session.config().virtual_mac() + ); + } + if driver_mtu != u32::from(session.welcome().effective_tap_mtu()) { + eprintln!( + "TAP driver MTU {} does not match relay-selected MTU {}; MTU configuration is not wired yet", + driver_mtu, + session.welcome().effective_tap_mtu() + ); + } + + Ok(tap) +} + +#[cfg(not(windows))] +fn open_tap_adapter(_session: &ClientSession) { + println!("Windows TAP adapter opening is compiled only on Windows"); +}