diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-01-23 02:15:56 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-01-23 02:15:56 +0000 |
commit | 3aeee94d77c864be17f65b0fa0315308213babce (patch) | |
tree | fcceec43d7cc9f6624ac707d636b23277d5ff73f | |
parent | a6ed50e171e39d7d145dce75866f51d63b4aa41d (diff) | |
parent | d90e7686765bfda892de6f50500d0d737a8b6125 (diff) | |
download | netsim-3aeee94d77c864be17f65b0fa0315308213babce.tar.gz |
Snap for 11342487 from d90e7686765bfda892de6f50500d0d737a8b6125 to emu-34-release
Change-Id: I4e6893eac7a255f5193f6d47b32f98c7e29fa888
-rw-r--r-- | Android.bp | 25 | ||||
-rw-r--r-- | cmake/netsim_dependencies.cmake | 2 | ||||
-rw-r--r-- | rust/daemon/src/echip/mod.rs | 4 | ||||
-rw-r--r-- | rust/daemon/src/echip/packet.rs | 14 | ||||
-rw-r--r-- | rust/daemon/src/echip/wifi.rs | 23 | ||||
-rw-r--r-- | rust/daemon/src/wifi/hwsim_attr_set.rs | 22 | ||||
-rw-r--r-- | rust/daemon/src/wifi/medium.rs | 211 | ||||
-rw-r--r-- | rust/frontend/Cargo.toml | 23 | ||||
-rw-r--r-- | rust/frontend/src/netsim_test_client.rs | 30 | ||||
-rw-r--r-- | rust/frontend/src/netsim_test_server.rs | 117 | ||||
-rw-r--r-- | rust/proto/src/frontend.rs | 219 | ||||
-rw-r--r-- | rust/proto/src/frontend_grpc.rs | 558 | ||||
-rw-r--r-- | rust/proto/src/lib.rs | 5 | ||||
-rwxr-xr-x | scripts/build_tools.py | 7 | ||||
-rwxr-xr-x | scripts/proto_update.sh | 7 | ||||
-rw-r--r-- | scripts/utils.py | 8 |
16 files changed, 79 insertions, 1196 deletions
@@ -302,12 +302,10 @@ cc_test_host { rust_library_host { name: "libnetsim_proto", - features: ["cuttlefish"], crate_name: "netsim_proto", srcs: ["rust/proto/src/lib.rs"], rustlibs: [ "libprotobuf", - "libgrpcio", ], } @@ -406,26 +404,3 @@ rust_binary_host { "libnetsim_cli", ], } - -rust_binary_host { - name: "netsim_test_client", - srcs: ["rust/frontend/src/netsim_test_client.rs"], - rustlibs: [ - "libgrpcio", - "libnetsim_proto", - "libprotobuf", - "libnetsim_common", - ], -} - -rust_binary_host { - name: "netsim_test_server", - srcs: ["rust/frontend/src/netsim_test_server.rs"], - rustlibs: [ - "libgrpcio", - "libnetsim_proto", - "libprotobuf", - "libnetsim_common", - "libfutures", - ], -} diff --git a/cmake/netsim_dependencies.cmake b/cmake/netsim_dependencies.cmake index 8f063f7..ae83310 100644 --- a/cmake/netsim_dependencies.cmake +++ b/cmake/netsim_dependencies.cmake @@ -1,5 +1,5 @@ set(BLUETOOTH_EMULATION True) -get_filename_component(AOSP "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE) +set(AOSP ${CMAKE_CURRENT_LIST_DIR}/../../..) set(EXTERNAL ${AOSP}/external) set(EXTERNAL_QEMU ${EXTERNAL}/qemu) set(ANDROID_QEMU2_TOP_DIR ${EXTERNAL_QEMU}) diff --git a/rust/daemon/src/echip/mod.rs b/rust/daemon/src/echip/mod.rs index 5e8712e..010c9e4 100644 --- a/rust/daemon/src/echip/mod.rs +++ b/rust/daemon/src/echip/mod.rs @@ -23,6 +23,4 @@ pub use crate::echip::emulated_chip::CreateParam; pub use crate::echip::emulated_chip::EmulatedChip; pub use crate::echip::emulated_chip::SharedEmulatedChip; pub use crate::echip::emulated_chip::{get, new, remove}; -pub use crate::echip::packet::{ - handle_request, handle_request_cxx, handle_response, hwsim_cmd_response, -}; +pub use crate::echip::packet::{handle_request, handle_request_cxx, handle_response}; diff --git a/rust/daemon/src/echip/packet.rs b/rust/daemon/src/echip/packet.rs index d92888a..8140594 100644 --- a/rust/daemon/src/echip/packet.rs +++ b/rust/daemon/src/echip/packet.rs @@ -116,20 +116,6 @@ pub fn handle_response(chip_id: ChipIdentifier, packet: &cxx::CxxVector<u8>, pac }; } -// Send HwsimCmd packets to guest OS. -pub fn hwsim_cmd_response(client_id: u32, packet: &[u8]) { - let mut senders = SENDERS.lock(); - if let Some(responder) = senders.get(&client_id) { - let packet_type = PacketType::HCI_PACKET_UNSPECIFIED.value() as u8; - if responder.send(ResponsePacket { packet: packet.to_owned(), packet_type }).is_err() { - warn!("send failed for client: {client_id}"); - senders.remove(&client_id); // Remove from the map using the value itself - } - } else { - warn!("unknown client: {client_id}"); - } -} - /// Handle requests from transports. pub fn handle_request(chip_id: ChipIdentifier, packet: &mut Vec<u8>, packet_type: u8) { captures_handler::handle_packet_request(chip_id, packet, packet_type.into()); diff --git a/rust/daemon/src/echip/wifi.rs b/rust/daemon/src/echip/wifi.rs index 101f259..c2cc1f6 100644 --- a/rust/daemon/src/echip/wifi.rs +++ b/rust/daemon/src/echip/wifi.rs @@ -13,11 +13,10 @@ // limitations under the License. use crate::devices::chip::ChipIdentifier; -use crate::echip::{packet::hwsim_cmd_response, EmulatedChip, SharedEmulatedChip}; +use crate::echip::{EmulatedChip, SharedEmulatedChip}; use crate::ffi::ffi_wifi; -use crate::wifi::medium::Medium; -use lazy_static::lazy_static; -use log::info; +use crate::wifi::medium; +use log::{info, warn}; use netsim_proto::common::ChipKind as ProtoChipKind; use netsim_proto::config::WiFi as WiFiConfig; use netsim_proto::model::chip::Radio; @@ -35,16 +34,15 @@ pub struct Wifi { chip_id: ChipIdentifier, } -// Allocator for chip identifiers. -lazy_static! { - static ref MEDIUM: Mutex<Medium> = Mutex::new(Medium::new(hwsim_cmd_response)); -} - impl EmulatedChip for Wifi { fn handle_request(&self, packet: &[u8]) { - if !MEDIUM.lock().expect("Lock failed").process(self.chip_id, packet) { - ffi_wifi::handle_wifi_request(self.chip_id, &packet.to_vec()); + if let Err(e) = medium::process(self.chip_id, packet) { + warn!("Error medium::process {}", e); } + if crate::config::get_dev() { + let _ = medium::parse_hwsim_cmd(packet); + } + ffi_wifi::handle_wifi_request(self.chip_id, &packet.to_vec()); } fn reset(&mut self) { @@ -95,6 +93,9 @@ pub fn new(_params: &CreateParams, chip_id: ChipIdentifier) -> SharedEmulatedChi /// Starts the WiFi service. pub fn wifi_start(config: &MessageField<WiFiConfig>) { + if crate::config::get_dev() { + medium::test_parse_hwsim_cmd(); + } let proto_bytes = config.as_ref().unwrap_or_default().write_to_bytes().unwrap(); ffi_wifi::wifi_start(&proto_bytes); } diff --git a/rust/daemon/src/wifi/hwsim_attr_set.rs b/rust/daemon/src/wifi/hwsim_attr_set.rs index e5bff25..2f97481 100644 --- a/rust/daemon/src/wifi/hwsim_attr_set.rs +++ b/rust/daemon/src/wifi/hwsim_attr_set.rs @@ -100,7 +100,7 @@ impl HwsimAttrSetBuilder { self.attributes.extend(vec); } - pub fn transmitter(&mut self, transmitter: &[u8; 6]) -> &mut Self { + fn transmitter(&mut self, transmitter: &[u8; 6]) -> &mut Self { self.extend_attributes( mac80211_hwsim::HwsimAttrAddrTransmitterBuilder { address: *transmitter, @@ -113,7 +113,7 @@ impl HwsimAttrSetBuilder { self } - pub fn receiver(&mut self, receiver: &[u8; 6]) -> &mut Self { + fn receiver(&mut self, receiver: &[u8; 6]) -> &mut Self { self.extend_attributes( mac80211_hwsim::HwsimAttrAddrReceiverBuilder { address: *receiver, nla_m: 0, nla_o: 0 } .build(), @@ -122,7 +122,7 @@ impl HwsimAttrSetBuilder { self } - pub fn frame(&mut self, frame: &[u8]) -> &mut Self { + fn frame(&mut self, frame: &[u8]) -> &mut Self { self.extend_attributes( mac80211_hwsim::HwsimAttrFrameBuilder { data: (*frame).to_vec(), nla_m: 0, nla_o: 0 } .build(), @@ -131,7 +131,7 @@ impl HwsimAttrSetBuilder { self } - pub fn flags(&mut self, flags: u32) -> &mut Self { + fn flags(&mut self, flags: u32) -> &mut Self { self.extend_attributes( mac80211_hwsim::HwsimAttrFlagsBuilder { flags, nla_m: 0, nla_o: 0 }.build(), ); @@ -139,7 +139,7 @@ impl HwsimAttrSetBuilder { self } - pub fn rx_rate(&mut self, rx_rate_idx: u32) -> &mut Self { + fn rx_rate(&mut self, rx_rate_idx: u32) -> &mut Self { self.extend_attributes( mac80211_hwsim::HwsimAttrRxRateBuilder { rx_rate_idx, nla_m: 0, nla_o: 0 }.build(), ); @@ -147,7 +147,7 @@ impl HwsimAttrSetBuilder { self } - pub fn signal(&mut self, signal: u32) -> &mut Self { + fn signal(&mut self, signal: u32) -> &mut Self { self.extend_attributes( mac80211_hwsim::HwsimAttrSignalBuilder { signal, nla_m: 0, nla_o: 0 }.build(), ); @@ -155,7 +155,7 @@ impl HwsimAttrSetBuilder { self } - pub fn cookie(&mut self, cookie: u64) -> &mut Self { + fn cookie(&mut self, cookie: u64) -> &mut Self { self.extend_attributes( mac80211_hwsim::HwsimAttrCookieBuilder { cookie, nla_m: 0, nla_o: 0 }.build(), ); @@ -163,7 +163,7 @@ impl HwsimAttrSetBuilder { self } - pub fn freq(&mut self, freq: u32) -> &mut Self { + fn freq(&mut self, freq: u32) -> &mut Self { self.extend_attributes( mac80211_hwsim::HwsimAttrFreqBuilder { freq, nla_m: 0, nla_o: 0 }.build(), ); @@ -171,7 +171,7 @@ impl HwsimAttrSetBuilder { self } - pub fn tx_info(&mut self, tx_info: &[TxRate]) -> &mut Self { + fn tx_info(&mut self, tx_info: &[TxRate]) -> &mut Self { self.extend_attributes( mac80211_hwsim::HwsimAttrTxInfoBuilder { tx_rates: (*tx_info).to_vec(), @@ -184,7 +184,7 @@ impl HwsimAttrSetBuilder { self } - pub fn tx_info_flags(&mut self, tx_rate_flags: &[TxRateFlag]) -> &mut Self { + fn tx_info_flags(&mut self, tx_rate_flags: &[TxRateFlag]) -> &mut Self { self.extend_attributes( mac80211_hwsim::HwsimAttrTxInfoFlagsBuilder { tx_rate_flags: (*tx_rate_flags).to_vec(), @@ -197,7 +197,7 @@ impl HwsimAttrSetBuilder { self } - pub fn build(mut self) -> anyhow::Result<HwsimAttrSet> { + fn build(mut self) -> anyhow::Result<HwsimAttrSet> { Ok(HwsimAttrSet { transmitter: self.transmitter, receiver: self.receiver, diff --git a/rust/daemon/src/wifi/medium.rs b/rust/daemon/src/wifi/medium.rs index c5c4739..cbd88ca 100644 --- a/rust/daemon/src/wifi/medium.rs +++ b/rust/daemon/src/wifi/medium.rs @@ -12,17 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -use super::ieee80211::MacAddress; -use super::packets::mac80211_hwsim::{HwsimAttr, HwsimCmd, HwsimMsg, HwsimMsgHdr, NlMsgHdr}; -use super::packets::netlink::NlAttrHdr; +use super::packets::mac80211_hwsim::{HwsimAttr, HwsimCmd, HwsimMsg, HwsimMsgHdr}; +use super::packets::netlink::{NlAttrHdr, NlMsgHdr}; use crate::devices::chip::ChipIdentifier; use crate::wifi::frame::Frame; use crate::wifi::hwsim_attr_set::HwsimAttrSet; -use crate::wifi::packets::mac80211_hwsim::HwsimMsgBuilder; use anyhow::{anyhow, Context}; use log::{debug, info, warn}; -use pdl_runtime::Packet; -use std::collections::{HashMap, HashSet}; #[derive(Debug)] pub enum HwsimCmdEnum { @@ -37,33 +33,6 @@ pub enum HwsimCmdEnum { DelMacAddr, } -struct Station { - client_id: u32, - addr: MacAddress, // virtual interface mac address -} - -pub struct Medium { - callback: HwsimCmdCallback, - stations: HashMap<MacAddress, Station>, -} - -type HwsimCmdCallback = fn(u32, &[u8]); - -impl Medium { - pub fn new(callback: HwsimCmdCallback) -> Medium { - Self { callback, stations: HashMap::new() } - } - fn get_station_by_addr(&self, addr: MacAddress) -> Option<&Station> { - self.stations.get(&addr) - } -} - -impl Station { - fn new(client_id: u32, addr: MacAddress) -> Self { - Self { client_id, addr } - } -} - /// Process commands from the kernel's mac80211_hwsim subsystem. /// /// This is the processing that will be implemented: @@ -72,117 +41,43 @@ impl Station { /// unique MacAddress because resumed Emulator AVDs appear with the /// same address. /// -/// * 802.11 frames sent between stations -/// /// * 802.11 multicast frames are re-broadcast to connected stations. /// - -impl Medium { - pub fn process(&mut self, client_id: u32, packet: &[u8]) -> bool { - match self.process_internal(client_id, packet) { - Ok(b) => b, - Err(e) => { - warn!("error processing wifi {e}"); - // continue processing hwsim cmd on error - false - } +pub fn process(chip_id: ChipIdentifier, packet: &[u8]) -> anyhow::Result<()> { + let hwsim_msg = HwsimMsg::parse(packet)?; + match (hwsim_msg.get_hwsim_hdr().hwsim_cmd) { + HwsimCmd::Frame => { + let frame = Frame::parse(&hwsim_msg)?; + info!( + "Frame chip {}, addr {}, flags {}, cookie {:?}, ieee80211 {}", + chip_id, frame.transmitter, frame.flags, frame.cookie, frame.ieee80211 + ); } - } - - fn process_internal(&mut self, client_id: u32, packet: &[u8]) -> anyhow::Result<bool> { - let hwsim_msg = HwsimMsg::parse(packet)?; - match (hwsim_msg.get_hwsim_hdr().hwsim_cmd) { - HwsimCmd::Frame => { - let frame = Frame::parse(&hwsim_msg)?; - info!( - "Frame chip {}, addr {}, flags {}, cookie {:?}, ieee80211 {}", - client_id, frame.transmitter, frame.flags, frame.cookie, frame.ieee80211 - ); - let addr = frame.transmitter; - // Creates Stations on the fly when there is no config file - let _ = self.stations.entry(addr).or_insert_with(|| Station::new(client_id, addr)); - let sender = self.stations.get(&addr).unwrap(); - self.queue_frame(sender, frame) - } - HwsimCmd::AddMacAddr => { - let attr_set = HwsimAttrSet::parse(hwsim_msg.get_attributes())?; - if let (Some(addr), Some(hwaddr)) = (attr_set.transmitter, attr_set.receiver) { - info!("ADD_MAC_ADDR transmitter {:?} receiver {:?}", hwaddr, addr); - } else { - warn!("ADD_MAC_ADDR missing transmitter or receiver"); - } - Ok(false) + HwsimCmd::AddMacAddr => { + let attr_set = HwsimAttrSet::parse(hwsim_msg.get_attributes())?; + if let (Some(addr), Some(hwaddr)) = (attr_set.transmitter, attr_set.receiver) { + info!("ADD_MAC_ADDR transmitter {:?} receiver {:?}", hwaddr, addr); + } else { + warn!("ADD_MAC_ADDR missing transmitter or receiver"); } - HwsimCmd::DelMacAddr => { - let attr_set = HwsimAttrSet::parse(hwsim_msg.get_attributes())?; - if let (Some(addr), Some(hwaddr)) = (attr_set.transmitter, attr_set.receiver) { - info!("DEL_MAC_ADDR transmitter {:?} receiver {:?}", hwaddr, addr); - } else { - warn!("DEL_MAC_ADDR missing transmitter or receiver"); - } - Ok(false) - } - _ => { - info!("Another command found {:?}", hwsim_msg); - Ok(false) + } + HwsimCmd::DelMacAddr => { + let attr_set = HwsimAttrSet::parse(hwsim_msg.get_attributes())?; + if let (Some(addr), Some(hwaddr)) = (attr_set.transmitter, attr_set.receiver) { + info!("DEL_MAC_ADDR transmitter {:?} receiver {:?}", hwaddr, addr); + } else { + warn!("DEL_MAC_ADDR missing transmitter or receiver"); } } - } - - fn queue_frame(&self, station: &Station, frame: Frame) -> anyhow::Result<bool> { - let destination = frame.ieee80211.get_destination(); - if let Some(station) = self.stations.get(&destination) { - info!("Frame deliver from {} to {}", station.addr, destination); - // rewrite packet to destination client: ToAP -> FromAP - Ok(true) - } else if destination.is_multicast() { - info!("Frame multicast {}", frame.ieee80211); - Ok(true) - } else { - // pass to libslirp - Ok(false) + _ => { + info!("Another command found {:?}", hwsim_msg); } } + Ok(()) } -fn build_tx_info(hwsim_msg: &HwsimMsg) -> anyhow::Result<HwsimMsg> { - let attrs = HwsimAttrSet::parse(hwsim_msg.get_attributes()).context("HwsimAttrSet").unwrap(); - - let hwsim_hdr = hwsim_msg.get_hwsim_hdr(); - let nl_hdr = hwsim_msg.get_nl_hdr(); - let mut new_attr_builder = HwsimAttrSet::builder(); - const SIGNAL: u32 = 4294967246; +// TODO: move code below here into test module usable from CMake - new_attr_builder - .transmitter(&attrs.transmitter.context("transmitter")?.into()) - .flags(attrs.flags.context("flags")?) - .cookie(attrs.cookie.context("cookie")?) - .signal(attrs.signal.unwrap_or(SIGNAL)) - .tx_info(attrs.tx_info.context("tx_info")?.as_slice()); - - let new_attr = new_attr_builder.build().unwrap(); - let nlmsg_len = - nl_hdr.nlmsg_len + new_attr.attributes.len() as u32 - attrs.attributes.len() as u32; - let new_hwsim_msg = HwsimMsgBuilder { - attributes: new_attr.attributes, - hwsim_hdr: HwsimMsgHdr { - hwsim_cmd: HwsimCmd::TxInfoFrame, - hwsim_version: hwsim_hdr.hwsim_version, - reserved: hwsim_hdr.reserved, - }, - nl_hdr: NlMsgHdr { - nlmsg_len, - nlmsg_type: nl_hdr.nlmsg_type, - nlmsg_flags: nl_hdr.nlmsg_flags, - nlmsg_seq: 0, - nlmsg_pid: 0, - }, - } - .build(); - Ok(new_hwsim_msg) -} - -// It's usd by radiotap.rs for packet capture. pub fn parse_hwsim_cmd(packet: &[u8]) -> anyhow::Result<HwsimCmdEnum> { let hwsim_msg = HwsimMsg::parse(packet)?; match (hwsim_msg.get_hwsim_hdr().hwsim_cmd) { @@ -194,26 +89,30 @@ pub fn parse_hwsim_cmd(packet: &[u8]) -> anyhow::Result<HwsimCmdEnum> { } } +pub fn test_parse_hwsim_cmd() { + let packet: Vec<u8> = include!("test_packets/hwsim_cmd_frame.csv"); + assert!(parse_hwsim_cmd(&packet).is_ok()); + + // missing transmitter attribute + let packet2: Vec<u8> = include!("test_packets/hwsim_cmd_frame2.csv"); + assert!(parse_hwsim_cmd(&packet2).is_err()); + + // missing cookie attribute + let packet3: Vec<u8> = include!("test_packets/hwsim_cmd_frame_no_cookie.csv"); + assert!(parse_hwsim_cmd(&packet3).is_err()); + + // HwsimkMsg cmd=TxInfoFrame packet + let packet3: Vec<u8> = include!("test_packets/hwsim_cmd_tx_info.csv"); + assert!(parse_hwsim_cmd(&packet3).is_err()); +} + #[cfg(test)] mod tests { use super::*; #[test] fn test_netlink_attr() { - let packet: Vec<u8> = include!("test_packets/hwsim_cmd_frame.csv"); - assert!(parse_hwsim_cmd(&packet).is_ok()); - - // missing transmitter attribute - let packet2: Vec<u8> = include!("test_packets/hwsim_cmd_frame2.csv"); - assert!(parse_hwsim_cmd(&packet2).is_err()); - - // missing cookie attribute - let packet3: Vec<u8> = include!("test_packets/hwsim_cmd_frame_no_cookie.csv"); - assert!(parse_hwsim_cmd(&packet3).is_err()); - - // HwsimkMsg cmd=TxInfoFrame packet - let packet3: Vec<u8> = include!("test_packets/hwsim_cmd_tx_info.csv"); - assert!(parse_hwsim_cmd(&packet3).is_err()); + test_parse_hwsim_cmd(); } #[test] @@ -228,22 +127,4 @@ mod tests { let non_mdns_frame = Frame::parse(&hwsim_msg).unwrap(); assert!(!non_mdns_frame.ieee80211.get_destination().is_multicast()); } - - #[test] - fn test_build_tx_info_reconstruct() { - let packet: Vec<u8> = include!("test_packets/hwsim_cmd_tx_info.csv"); - let hwsim_msg = HwsimMsg::parse(&packet).unwrap(); - assert_eq!(hwsim_msg.get_hwsim_hdr().hwsim_cmd, HwsimCmd::TxInfoFrame); - - let new_hwsim_msg = build_tx_info(&hwsim_msg).unwrap(); - assert_eq!(hwsim_msg, new_hwsim_msg); - } - - #[test] - fn test_build_tx_info() { - let packet: Vec<u8> = include!("test_packets/hwsim_cmd_frame.csv"); - let hwsim_msg = HwsimMsg::parse(&packet).unwrap(); - let hwsim_msg_tx_info = build_tx_info(&hwsim_msg).unwrap(); - assert_eq!(hwsim_msg_tx_info.get_hwsim_hdr().hwsim_cmd, HwsimCmd::TxInfoFrame); - } } diff --git a/rust/frontend/Cargo.toml b/rust/frontend/Cargo.toml deleted file mode 100644 index 9d5f308..0000000 --- a/rust/frontend/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "frontend" -version = "0.1.0" -edition = "2021" - -[dependencies] -protobuf = "3.2.0" -protoc-grpcio = "3.0.0" -protoc-rust = "2.27" -grpcio = "0.13.0" -grpcio-sys = "0.12.1" -futures = "0.3.26" - -##[build-dependencies] -##protoc-grpcio = "3.0.0" - -##[[bin]] -##name = "server" -##path = "src/server.rs" - -##[[bin]] -##name = "netsim-grpc" -##path = "src/client.rs"
\ No newline at end of file diff --git a/rust/frontend/src/netsim_test_client.rs b/rust/frontend/src/netsim_test_client.rs deleted file mode 100644 index b65d256..0000000 --- a/rust/frontend/src/netsim_test_client.rs +++ /dev/null @@ -1,30 +0,0 @@ -//! netsim Rust grpc test client - -use std::env; -use std::sync::Arc; - -use grpcio::{ChannelBuilder, EnvBuilder}; -use netsim_common::util::os_utils::get_server_address; -use netsim_proto::frontend_grpc::FrontendServiceClient; - -fn main() { - let args: Vec<String> = env::args().collect(); - let server_addr: String = if args.len() > 1 { - args[1].to_owned() - } else { - match get_server_address(1) { - Some(addr) => addr, - None => { - println!("Unable to get server address."); - return; - } - } - }; - let env = Arc::new(EnvBuilder::new().build()); - - let ch = ChannelBuilder::new(env).connect(&server_addr); - let client = FrontendServiceClient::new(ch); - - let reply = client.get_version(&::protobuf::well_known_types::empty::Empty::new()).unwrap(); - println!("Version: {}", reply.version); -} diff --git a/rust/frontend/src/netsim_test_server.rs b/rust/frontend/src/netsim_test_server.rs deleted file mode 100644 index 6cbf4f9..0000000 --- a/rust/frontend/src/netsim_test_server.rs +++ /dev/null @@ -1,117 +0,0 @@ -//! netsim Rust grpc test server -use std::io::Read; -use std::sync::Arc; -use std::{io, thread}; - -use futures::channel::oneshot; -use futures::executor::block_on; -use futures::prelude::*; -use grpcio::{ - ChannelBuilder, Environment, ResourceQuota, RpcContext, ServerBuilder, ServerCredentials, - UnarySink, -}; - -use netsim_proto::frontend::VersionResponse; -use netsim_proto::frontend_grpc::{create_frontend_service, FrontendService}; - -#[derive(Clone)] -struct FrontendClient; - -impl FrontendService for FrontendClient { - fn get_version( - &mut self, - ctx: RpcContext<'_>, - req: protobuf::well_known_types::empty::Empty, - sink: UnarySink<VersionResponse>, - ) { - let response = VersionResponse { - version: "netsim test server version 0.0.1".to_string(), - ..Default::default() - }; - let f = sink - .success(response) - .map_err(move |e| eprintln!("failed to reply {:?}: {:?}", req, e)) - .map(|_| ()); - ctx.spawn(f) - } - - fn list_device( - &mut self, - _ctx: grpcio::RpcContext, - _req: protobuf::well_known_types::empty::Empty, - _sink: grpcio::UnarySink<netsim_proto::frontend::ListDeviceResponse>, - ) { - todo!() - } - - fn patch_device( - &mut self, - _ctx: grpcio::RpcContext, - _req: netsim_proto::frontend::PatchDeviceRequest, - _sink: grpcio::UnarySink<protobuf::well_known_types::empty::Empty>, - ) { - todo!() - } - - fn reset( - &mut self, - _ctx: grpcio::RpcContext, - _req: protobuf::well_known_types::empty::Empty, - _sink: grpcio::UnarySink<protobuf::well_known_types::empty::Empty>, - ) { - todo!() - } - - fn patch_capture( - &mut self, - _ctx: grpcio::RpcContext, - _req: netsim_proto::frontend::PatchCaptureRequest, - _sink: grpcio::UnarySink<protobuf::well_known_types::empty::Empty>, - ) { - todo!() - } - - fn list_capture( - &mut self, - _ctx: grpcio::RpcContext, - _req: protobuf::well_known_types::empty::Empty, - _sink: grpcio::UnarySink<netsim_proto::frontend::ListCaptureResponse>, - ) { - todo!() - } - - fn get_capture( - &mut self, - _ctx: grpcio::RpcContext, - _req: netsim_proto::frontend::GetCaptureRequest, - _sink: grpcio::ServerStreamingSink<netsim_proto::frontend::GetCaptureResponse>, - ) { - todo!() - } -} - -fn main() { - let env = Arc::new(Environment::new(1)); - let service = create_frontend_service(FrontendClient); - - let quota = ResourceQuota::new(Some("HelloServerQuota")).resize_memory(1024 * 1024); - let ch_builder = ChannelBuilder::new(env.clone()).set_resource_quota(quota); - - let mut server = ServerBuilder::new(env) - .register_service(service) - .channel_args(ch_builder.build_args()) - .build() - .unwrap(); - let port = server.add_listening_port("127.0.0.1:50051", ServerCredentials::insecure()).unwrap(); - server.start(); - println!("listening on port {}", port); - - let (tx, rx) = oneshot::channel(); - thread::spawn(move || { - println!("Press ENTER to exit..."); - let _ = io::stdin().read(&mut [0]).unwrap(); - tx.send(()) - }); - let _ = block_on(rx); - let _ = block_on(server.shutdown()); -} diff --git a/rust/proto/src/frontend.rs b/rust/proto/src/frontend.rs index a0227b3..053533b 100644 --- a/rust/proto/src/frontend.rs +++ b/rust/proto/src/frontend.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 3.2.0. Do not edit -// .proto file is parsed by protoc --rust-out=... +// .proto file is parsed by protoc 3.21.12 // @generated // https://github.com/rust-lang/rust-clippy/issues/702 @@ -25,14 +25,10 @@ /// of protobuf runtime. const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_2_0; -/// Response of GetVersion. -/// -/// Returns the version of the netsim service #[derive(PartialEq,Clone,Default,Debug)] // @@protoc_insertion_point(message:netsim.frontend.VersionResponse) pub struct VersionResponse { // message fields - /// Version of netsim service // @@protoc_insertion_point(field:netsim.frontend.VersionResponse.version) pub version: ::std::string::String, // special fields @@ -151,15 +147,10 @@ impl ::protobuf::reflect::ProtobufValue for VersionResponse { type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>; } -/// Request of CreateDevice. -/// -/// CreateDevice is only used for built-in devices. #[derive(PartialEq,Clone,Default,Debug)] // @@protoc_insertion_point(message:netsim.frontend.CreateDeviceRequest) pub struct CreateDeviceRequest { // message fields - /// DeviceCreate proto for creation. Check DeviceCreate in model.proto for more - /// detail. // @@protoc_insertion_point(field:netsim.frontend.CreateDeviceRequest.device) pub device: ::protobuf::MessageField<super::model::DeviceCreate>, // special fields @@ -279,14 +270,10 @@ impl ::protobuf::reflect::ProtobufValue for CreateDeviceRequest { type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>; } -/// Response of CreateDevice. -/// -/// Returns the device created in netsim #[derive(PartialEq,Clone,Default,Debug)] // @@protoc_insertion_point(message:netsim.frontend.CreateDeviceResponse) pub struct CreateDeviceResponse { // message fields - /// Device proto // @@protoc_insertion_point(field:netsim.frontend.CreateDeviceResponse.device) pub device: ::protobuf::MessageField<super::model::Device>, // special fields @@ -406,14 +393,10 @@ impl ::protobuf::reflect::ProtobufValue for CreateDeviceResponse { type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>; } -/// Request of DeleteDevice. -/// -/// DeleteDevice is only used for built-in device. #[derive(PartialEq,Clone,Default,Debug)] // @@protoc_insertion_point(message:netsim.frontend.DeleteChipRequest) pub struct DeleteChipRequest { // message fields - /// Device Identifier // @@protoc_insertion_point(field:netsim.frontend.DeleteChipRequest.id) pub id: u32, // special fields @@ -532,16 +515,10 @@ impl ::protobuf::reflect::ProtobufValue for DeleteChipRequest { type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>; } -/// Request of PatchDevice. -/// -/// You may patch the device position, orientation, and the radio states. -/// For built-in devices, you may patch the specific configurations. #[derive(PartialEq,Clone,Default,Debug)] // @@protoc_insertion_point(message:netsim.frontend.PatchDeviceRequest) pub struct PatchDeviceRequest { // message fields - /// Device proto. You must include either the id or name field to have - /// a successful patch. // @@protoc_insertion_point(field:netsim.frontend.PatchDeviceRequest.device) pub device: ::protobuf::MessageField<super::model::Device>, // special fields @@ -661,20 +638,12 @@ impl ::protobuf::reflect::ProtobufValue for PatchDeviceRequest { type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>; } -/// Response for ListDevice request. -/// -/// Returns the emulators and accessory devices that are connected to -/// the network simulator. #[derive(PartialEq,Clone,Default,Debug)] // @@protoc_insertion_point(message:netsim.frontend.ListDeviceResponse) pub struct ListDeviceResponse { // message fields - /// List of Device protos // @@protoc_insertion_point(field:netsim.frontend.ListDeviceResponse.devices) pub devices: ::std::vec::Vec<super::model::Device>, - /// Last modified timestamp for device resource. - /// The timestamp will be updated if devices state has changed (except for - /// packet counts) // @@protoc_insertion_point(field:netsim.frontend.ListDeviceResponse.last_modified) pub last_modified: ::protobuf::MessageField<::protobuf::well_known_types::timestamp::Timestamp>, // special fields @@ -811,14 +780,10 @@ impl ::protobuf::reflect::ProtobufValue for ListDeviceResponse { type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>; } -/// Request for SubscribeDevice. #[derive(PartialEq,Clone,Default,Debug)] // @@protoc_insertion_point(message:netsim.frontend.SubscribeDeviceRequest) pub struct SubscribeDeviceRequest { // message fields - /// The SubscribeDevice will immediately return if the - /// provided last_modified timestamp is prior to the current last_modified - /// timestamp in device resource. // @@protoc_insertion_point(field:netsim.frontend.SubscribeDeviceRequest.last_modified) pub last_modified: ::protobuf::MessageField<::protobuf::well_known_types::timestamp::Timestamp>, // special fields @@ -938,7 +903,6 @@ impl ::protobuf::reflect::ProtobufValue for SubscribeDeviceRequest { type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>; } -/// Response for SubscribeDevice request. #[derive(PartialEq,Clone,Default,Debug)] // @@protoc_insertion_point(message:netsim.frontend.SubscribeDeviceResponse) pub struct SubscribeDeviceResponse { @@ -1218,15 +1182,12 @@ pub mod subscribe_device_response { } } -/// Request of PatchCapture. #[derive(PartialEq,Clone,Default,Debug)] // @@protoc_insertion_point(message:netsim.frontend.PatchCaptureRequest) pub struct PatchCaptureRequest { // message fields - /// Capture Identifier // @@protoc_insertion_point(field:netsim.frontend.PatchCaptureRequest.id) pub id: u32, - /// PatchCapture proto // @@protoc_insertion_point(field:netsim.frontend.PatchCaptureRequest.patch) pub patch: ::protobuf::MessageField<patch_capture_request::PatchCapture>, // special fields @@ -1364,13 +1325,10 @@ impl ::protobuf::reflect::ProtobufValue for PatchCaptureRequest { /// Nested message and enums of message `PatchCaptureRequest` pub mod patch_capture_request { - /// Body of PatchCapture that will be channeled into - /// body for HandleCaptureCxx #[derive(PartialEq,Clone,Default,Debug)] // @@protoc_insertion_point(message:netsim.frontend.PatchCaptureRequest.PatchCapture) pub struct PatchCapture { // message fields - /// Capture state // @@protoc_insertion_point(field:netsim.frontend.PatchCaptureRequest.PatchCapture.state) pub state: ::protobuf::EnumOrUnknown<super::super::model::State>, // special fields @@ -1490,14 +1448,10 @@ pub mod patch_capture_request { } } -/// Response of ListCapture -/// -/// Returns all capture information of devices connected to netsim. #[derive(PartialEq,Clone,Default,Debug)] // @@protoc_insertion_point(message:netsim.frontend.ListCaptureResponse) pub struct ListCaptureResponse { // message fields - /// List of Capture protos // @@protoc_insertion_point(field:netsim.frontend.ListCaptureResponse.captures) pub captures: ::std::vec::Vec<super::model::Capture>, // special fields @@ -1617,12 +1571,10 @@ impl ::protobuf::reflect::ProtobufValue for ListCaptureResponse { type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>; } -/// Request of GetCapture #[derive(PartialEq,Clone,Default,Debug)] // @@protoc_insertion_point(message:netsim.frontend.GetCaptureRequest) pub struct GetCaptureRequest { // message fields - /// Capture Identifier // @@protoc_insertion_point(field:netsim.frontend.GetCaptureRequest.id) pub id: u32, // special fields @@ -1741,15 +1693,10 @@ impl ::protobuf::reflect::ProtobufValue for GetCaptureRequest { type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>; } -/// Response of GetCapture -/// -/// Returns a max of 1024 bytes of capture file. -/// GetCapture will be returning a stream of GetCaptureResponse #[derive(PartialEq,Clone,Default,Debug)] // @@protoc_insertion_point(message:netsim.frontend.GetCaptureResponse) pub struct GetCaptureResponse { // message fields - /// Max of 1024 bytes of capture file // @@protoc_insertion_point(field:netsim.frontend.GetCaptureResponse.capture_stream) pub capture_stream: ::std::vec::Vec<u8>, // special fields @@ -1907,169 +1854,7 @@ static file_descriptor_proto_data: &'static [u8] = b"\ reRequest\x1a\x16.google.protobuf.Empty\x12K\n\x0bListCapture\x12\x16.go\ ogle.protobuf.Empty\x1a$.netsim.frontend.ListCaptureResponse\x12W\n\nGet\ Capture\x12\".netsim.frontend.GetCaptureRequest\x1a#.netsim.frontend.Get\ - CaptureResponse0\x01J\xdc)\n\x07\x12\x05\x0e\0\xb3\x01\x01\n\xd2\x04\n\ - \x01\x0c\x12\x03\x0e\0\x122\xc7\x04\x20Copyright\x202022\x20The\x20Andro\ - id\x20Open\x20Source\x20Project\n\n\x20Licensed\x20under\x20the\x20Apach\ - e\x20License,\x20Version\x202.0\x20(the\x20\"License\");\n\x20you\x20may\ - \x20not\x20use\x20this\x20file\x20except\x20in\x20compliance\x20with\x20\ - the\x20License.\n\x20You\x20may\x20obtain\x20a\x20copy\x20of\x20the\x20L\ - icense\x20at\n\n\x20\x20\x20\x20\x20\x20http://www.apache.org/licenses/L\ - ICENSE-2.0\n\n\x20Unless\x20required\x20by\x20applicable\x20law\x20or\ - \x20agreed\x20to\x20in\x20writing,\x20software\n\x20distributed\x20under\ - \x20the\x20License\x20is\x20distributed\x20on\x20an\x20\"AS\x20IS\"\x20B\ - ASIS,\n\x20WITHOUT\x20WARRANTIES\x20OR\x20CONDITIONS\x20OF\x20ANY\x20KIN\ - D,\x20either\x20express\x20or\x20implied.\n\x20See\x20the\x20License\x20\ - for\x20the\x20specific\x20language\x20governing\x20permissions\x20and\n\ - \x20limitations\x20under\x20the\x20License.\n\n\x08\n\x01\x02\x12\x03\ - \x10\0\x18\n\t\n\x02\x03\0\x12\x03\x12\0%\n\t\n\x02\x03\x01\x12\x03\x13\ - \0)\n\t\n\x02\x03\x02\x12\x03\x14\0\x1c\n\xe2\x02\n\x02\x06\0\x12\x04!\0\ - B\x01\x1a\xd5\x02*\n\x20The\x20frontend\x20service\x20for\x20the\x20netw\ - ork\x20simulator.\n\n\x20The\x20network\x20simulator\x20interconnects\ - \x20virtual\x20radio\x20controllers\x20on\x20emulated\n\x20android\x20an\ - d\x20accessory\x20devices\x20to\x20allows\x20control\x20of\x20the\x20top\ - ology,\x20device\n\x20positions,\x20and\x20RF\x20characteristics.\n\n\ - \x20Clients\x20of\x20the\x20frontend\x20service\x20include\x20a\x20Comma\ - nd\x20Line\x20Interface\x20(cli),\x20Mobly\n\x20scripts,\x20and\x20a\x20\ - web\x20UI.\n\n\n\n\n\x03\x06\0\x01\x12\x03!\x08\x17\n5\n\x04\x06\0\x02\0\ - \x12\x03#\x02B\x1a(\x20Get\x20the\x20version\x20of\x20the\x20netsim\x20s\ - ervice.\n\n\x0c\n\x05\x06\0\x02\0\x01\x12\x03#\x06\x10\n\x0c\n\x05\x06\0\ - \x02\0\x02\x12\x03#\x11&\n\x0c\n\x05\x06\0\x02\0\x03\x12\x03#1@\n&\n\x04\ - \x06\0\x02\x01\x12\x03&\x02G\x1a\x19\x20Create\x20a\x20builtin\x20device\ - \n\n\x0c\n\x05\x06\0\x02\x01\x01\x12\x03&\x06\x12\n\x0c\n\x05\x06\0\x02\ - \x01\x02\x12\x03&\x13&\n\x0c\n\x05\x06\0\x02\x01\x03\x12\x03&1E\nX\n\x04\ - \x06\0\x02\x02\x12\x03)\x02D\x1aK\x20Delete\x20a\x20builtin\x20chip.\x20\ - Implicitly\x20deletes\x20devices\x20which\x20contain\x20no\x20chips.\n\n\ - \x0c\n\x05\x06\0\x02\x02\x01\x12\x03)\x06\x10\n\x0c\n\x05\x06\0\x02\x02\ - \x02\x12\x03)\x11\"\n\x0c\n\x05\x06\0\x02\x02\x03\x12\x03)-B\n\x1d\n\x04\ - \x06\0\x02\x03\x12\x03,\x02F\x1a\x10\x20Patch\x20a\x20device\n\n\x0c\n\ - \x05\x06\0\x02\x03\x01\x12\x03,\x06\x11\n\x0c\n\x05\x06\0\x02\x03\x02\ - \x12\x03,\x12$\n\x0c\n\x05\x06\0\x02\x03\x03\x12\x03,/D\n!\n\x04\x06\0\ - \x02\x04\x12\x03/\x02C\x1a\x14\x20Reset\x20all\x20devices.\n\n\x0c\n\x05\ - \x06\0\x02\x04\x01\x12\x03/\x06\x0b\n\x0c\n\x05\x06\0\x02\x04\x02\x12\ - \x03/\x0c!\n\x0c\n\x05\x06\0\x02\x04\x03\x12\x03/,A\n$\n\x04\x06\0\x02\ - \x05\x12\x032\x02E\x1a\x17\x20Get\x20a\x20list\x20of\x20devices\n\n\x0c\ - \n\x05\x06\0\x02\x05\x01\x12\x032\x06\x10\n\x0c\n\x05\x06\0\x02\x05\x02\ - \x12\x032\x11&\n\x0c\n\x05\x06\0\x02\x05\x03\x12\x0321C\n\xa4\x01\n\x04\ - \x06\0\x02\x06\x12\x037\x02P\x1a\x96\x01\x20Get\x20a\x20list\x20of\x20de\ - vices\x20when\x20a\x20device\x20event\x20is\x20published.\n\x20Waits\x20\ - for\x20device\x20event\x20up\x20to\x2015\x20seconds\x20and\x20returns\ - \x20Error\x20response\x20if\x20no\n\x20event\x20is\x20received\n\n\x0c\n\ - \x05\x06\0\x02\x06\x01\x12\x037\x06\x15\n\x0c\n\x05\x06\0\x02\x06\x02\ - \x12\x037\x16,\n\x0c\n\x05\x06\0\x02\x06\x03\x12\x0377N\nt\n\x04\x06\0\ - \x02\x07\x12\x03;\x02H\x1ag\x20Patch\x20a\x20Capture\x20source\x20to\x20\ - turn\x20capture\x20on/off.\n\x20When\x20turned\x20on\x20the\x20old\x20ca\ - pture\x20contents\x20are\x20replaced.\n\n\x0c\n\x05\x06\0\x02\x07\x01\ - \x12\x03;\x06\x12\n\x0c\n\x05\x06\0\x02\x07\x02\x12\x03;\x13&\n\x0c\n\ - \x05\x06\0\x02\x07\x03\x12\x03;1F\n?\n\x04\x06\0\x02\x08\x12\x03>\x02G\ - \x1a2\x20List\x20all\x20Captures\x20currently\x20connected\x20on\x20nets\ - im.\n\n\x0c\n\x05\x06\0\x02\x08\x01\x12\x03>\x06\x11\n\x0c\n\x05\x06\0\ - \x02\x08\x02\x12\x03>\x12'\n\x0c\n\x05\x06\0\x02\x08\x03\x12\x03>2E\nM\n\ - \x04\x06\0\x02\t\x12\x03A\x02H\x1a@\x20Retrieve\x20the\x20contents\x20of\ - \x20the\x20packet\x20capture\x20as\x20streaming\x20bytes\n\n\x0c\n\x05\ - \x06\0\x02\t\x01\x12\x03A\x06\x10\n\x0c\n\x05\x06\0\x02\t\x02\x12\x03A\ - \x11\"\n\x0c\n\x05\x06\0\x02\t\x06\x12\x03A-3\n\x0c\n\x05\x06\0\x02\t\ - \x03\x12\x03A4F\nQ\n\x02\x04\0\x12\x04G\0J\x01\x1aE\x20Response\x20of\ - \x20GetVersion.\n\n\x20Returns\x20the\x20version\x20of\x20the\x20netsim\ - \x20service\n\n\n\n\x03\x04\0\x01\x12\x03G\x08\x17\n(\n\x04\x04\0\x02\0\ - \x12\x03I\x02\x15\x1a\x1b\x20Version\x20of\x20netsim\x20service\n\n\x0c\ - \n\x05\x04\0\x02\0\x05\x12\x03I\x02\x08\n\x0c\n\x05\x04\0\x02\0\x01\x12\ - \x03I\t\x10\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03I\x13\x14\nX\n\x02\x04\ - \x01\x12\x04O\0S\x01\x1aL\x20Request\x20of\x20CreateDevice.\n\n\x20Creat\ - eDevice\x20is\x20only\x20used\x20for\x20built-in\x20devices.\n\n\n\n\x03\ - \x04\x01\x01\x12\x03O\x08\x1b\nc\n\x04\x04\x01\x02\0\x12\x03R\x02'\x1aV\ - \x20DeviceCreate\x20proto\x20for\x20creation.\x20Check\x20DeviceCreate\ - \x20in\x20model.proto\x20for\x20more\n\x20detail.\n\n\x0c\n\x05\x04\x01\ - \x02\0\x06\x12\x03R\x02\x1b\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03R\x1c\"\ - \n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03R%&\nN\n\x02\x04\x02\x12\x04X\0[\ - \x01\x1aB\x20Response\x20of\x20CreateDevice.\n\n\x20Returns\x20the\x20de\ - vice\x20created\x20in\x20netsim\n\n\n\n\x03\x04\x02\x01\x12\x03X\x08\x1c\ - \n\x1b\n\x04\x04\x02\x02\0\x12\x03Z\x02!\x1a\x0e\x20Device\x20proto\n\n\ - \x0c\n\x05\x04\x02\x02\0\x06\x12\x03Z\x02\x15\n\x0c\n\x05\x04\x02\x02\0\ - \x01\x12\x03Z\x16\x1c\n\x0c\n\x05\x04\x02\x02\0\x03\x12\x03Z\x1f\x20\nW\ - \n\x02\x04\x03\x12\x04`\0c\x01\x1aK\x20Request\x20of\x20DeleteDevice.\n\ - \n\x20DeleteDevice\x20is\x20only\x20used\x20for\x20built-in\x20device.\n\ - \n\n\n\x03\x04\x03\x01\x12\x03`\x08\x19\n\x20\n\x04\x04\x03\x02\0\x12\ - \x03b\x02\x10\x1a\x13\x20Device\x20Identifier\n\n\x0c\n\x05\x04\x03\x02\ - \0\x05\x12\x03b\x02\x08\n\x0c\n\x05\x04\x03\x02\0\x01\x12\x03b\t\x0b\n\ - \x0c\n\x05\x04\x03\x02\0\x03\x12\x03b\x0e\x0f\n\xb0\x01\n\x02\x04\x04\ - \x12\x04i\0m\x01\x1a\xa3\x01\x20Request\x20of\x20PatchDevice.\n\n\x20You\ - \x20may\x20patch\x20the\x20device\x20position,\x20orientation,\x20and\ - \x20the\x20radio\x20states.\n\x20For\x20built-in\x20devices,\x20you\x20m\ - ay\x20patch\x20the\x20specific\x20configurations.\n\n\n\n\x03\x04\x04\ - \x01\x12\x03i\x08\x1a\nf\n\x04\x04\x04\x02\0\x12\x03l\x02!\x1aY\x20Devic\ - e\x20proto.\x20You\x20must\x20include\x20either\x20the\x20id\x20or\x20na\ - me\x20field\x20to\x20have\n\x20a\x20successful\x20patch.\n\n\x0c\n\x05\ - \x04\x04\x02\0\x06\x12\x03l\x02\x15\n\x0c\n\x05\x04\x04\x02\0\x01\x12\ - \x03l\x16\x1c\n\x0c\n\x05\x04\x04\x02\0\x03\x12\x03l\x1f\x20\n\x8a\x01\n\ - \x02\x04\x05\x12\x04s\0z\x01\x1a~\x20Response\x20for\x20ListDevice\x20re\ - quest.\n\n\x20Returns\x20the\x20emulators\x20and\x20accessory\x20devices\ - \x20that\x20are\x20connected\x20to\n\x20the\x20network\x20simulator.\n\n\ - \n\n\x03\x04\x05\x01\x12\x03s\x08\x1a\n$\n\x04\x04\x05\x02\0\x12\x03u\ - \x02+\x1a\x17\x20List\x20of\x20Device\x20protos\n\n\x0c\n\x05\x04\x05\ - \x02\0\x04\x12\x03u\x02\n\n\x0c\n\x05\x04\x05\x02\0\x06\x12\x03u\x0b\x1e\ - \n\x0c\n\x05\x04\x05\x02\0\x01\x12\x03u\x1f&\n\x0c\n\x05\x04\x05\x02\0\ - \x03\x12\x03u)*\n\x94\x01\n\x04\x04\x05\x02\x01\x12\x03y\x02.\x1a\x86\ - \x01\x20Last\x20modified\x20timestamp\x20for\x20device\x20resource.\n\ - \x20The\x20timestamp\x20will\x20be\x20updated\x20if\x20devices\x20state\ - \x20has\x20changed\x20(except\x20for\n\x20packet\x20counts)\n\n\x0c\n\ - \x05\x04\x05\x02\x01\x06\x12\x03y\x02\x1b\n\x0c\n\x05\x04\x05\x02\x01\ - \x01\x12\x03y\x1c)\n\x0c\n\x05\x04\x05\x02\x01\x03\x12\x03y,-\n+\n\x02\ - \x04\x06\x12\x05}\0\x82\x01\x01\x1a\x1e\x20Request\x20for\x20SubscribeDe\ - vice.\n\n\n\n\x03\x04\x06\x01\x12\x03}\x08\x1e\n\xaa\x01\n\x04\x04\x06\ - \x02\0\x12\x04\x81\x01\x027\x1a\x9b\x01\x20The\x20SubscribeDevice\x20wil\ - l\x20immediately\x20return\x20if\x20the\n\x20provided\x20last_modified\ - \x20timestamp\x20is\x20prior\x20to\x20the\x20current\x20last_modified\n\ - \x20timestamp\x20in\x20device\x20resource.\n\n\r\n\x05\x04\x06\x02\0\x04\ - \x12\x04\x81\x01\x02\n\n\r\n\x05\x04\x06\x02\0\x06\x12\x04\x81\x01\x0b$\ - \n\r\n\x05\x04\x06\x02\0\x01\x12\x04\x81\x01%2\n\r\n\x05\x04\x06\x02\0\ - \x03\x12\x04\x81\x0156\n5\n\x02\x04\x07\x12\x06\x85\x01\0\x8d\x01\x01\ - \x1a'\x20Response\x20for\x20SubscribeDevice\x20request.\n\n\x0b\n\x03\ - \x04\x07\x01\x12\x04\x85\x01\x08\x1f\nD\n\x04\x04\x07\x08\0\x12\x06\x87\ - \x01\x02\x8c\x01\x03\x1a4\x20Will\x20return\x20ListDeviceResponse\x20or\ - \x20an\x20EmptyResponse\n\n\r\n\x05\x04\x07\x08\0\x01\x12\x04\x87\x01\ - \x08\x10\n'\n\x04\x04\x07\x02\0\x12\x04\x89\x01\x040\x1a\x19\x20Response\ - \x20for\x20ListDevice\n\n\r\n\x05\x04\x07\x02\0\x06\x12\x04\x89\x01\x04\ - \x16\n\r\n\x05\x04\x07\x02\0\x01\x12\x04\x89\x01\x17+\n\r\n\x05\x04\x07\ - \x02\0\x03\x12\x04\x89\x01./\n\x1e\n\x04\x04\x07\x02\x01\x12\x04\x8b\x01\ - \x04-\x1a\x10\x20Empty\x20Response\n\n\r\n\x05\x04\x07\x02\x01\x06\x12\ - \x04\x8b\x01\x04\x19\n\r\n\x05\x04\x07\x02\x01\x01\x12\x04\x8b\x01\x1a(\ - \n\r\n\x05\x04\x07\x02\x01\x03\x12\x04\x8b\x01+,\n(\n\x02\x04\x08\x12\ - \x06\x90\x01\0\x9c\x01\x01\x1a\x1a\x20Request\x20of\x20PatchCapture.\n\n\ - \x0b\n\x03\x04\x08\x01\x12\x04\x90\x01\x08\x1b\n\"\n\x04\x04\x08\x02\0\ - \x12\x04\x92\x01\x02\x10\x1a\x14\x20Capture\x20Identifier\n\n\r\n\x05\ - \x04\x08\x02\0\x05\x12\x04\x92\x01\x02\x08\n\r\n\x05\x04\x08\x02\0\x01\ - \x12\x04\x92\x01\t\x0b\n\r\n\x05\x04\x08\x02\0\x03\x12\x04\x92\x01\x0e\ - \x0f\n]\n\x04\x04\x08\x03\0\x12\x06\x96\x01\x02\x99\x01\x03\x1aM\x20Body\ - \x20of\x20PatchCapture\x20that\x20will\x20be\x20channeled\x20into\n\x20b\ - ody\x20for\x20HandleCaptureCxx\n\n\r\n\x05\x04\x08\x03\0\x01\x12\x04\x96\ - \x01\n\x16\n\x1f\n\x06\x04\x08\x03\0\x02\0\x12\x04\x98\x01\x04!\x1a\x0f\ - \x20Capture\x20state\n\n\x0f\n\x07\x04\x08\x03\0\x02\0\x06\x12\x04\x98\ - \x01\x04\x16\n\x0f\n\x07\x04\x08\x03\0\x02\0\x01\x12\x04\x98\x01\x17\x1c\ - \n\x0f\n\x07\x04\x08\x03\0\x02\0\x03\x12\x04\x98\x01\x1f\x20\n\"\n\x04\ - \x04\x08\x02\x01\x12\x04\x9b\x01\x02\x19\x1a\x14\x20PatchCapture\x20prot\ - o\n\n\r\n\x05\x04\x08\x02\x01\x06\x12\x04\x9b\x01\x02\x0e\n\r\n\x05\x04\ - \x08\x02\x01\x01\x12\x04\x9b\x01\x0f\x14\n\r\n\x05\x04\x08\x02\x01\x03\ - \x12\x04\x9b\x01\x17\x18\ni\n\x02\x04\t\x12\x06\xa1\x01\0\xa4\x01\x01\ - \x1a[\x20Response\x20of\x20ListCapture\n\n\x20Returns\x20all\x20capture\ - \x20information\x20of\x20devices\x20connected\x20to\x20netsim.\n\n\x0b\n\ - \x03\x04\t\x01\x12\x04\xa1\x01\x08\x1b\n&\n\x04\x04\t\x02\0\x12\x04\xa3\ - \x01\x02-\x1a\x18\x20List\x20of\x20Capture\x20protos\n\n\r\n\x05\x04\t\ - \x02\0\x04\x12\x04\xa3\x01\x02\n\n\r\n\x05\x04\t\x02\0\x06\x12\x04\xa3\ - \x01\x0b\x1f\n\r\n\x05\x04\t\x02\0\x01\x12\x04\xa3\x01\x20(\n\r\n\x05\ - \x04\t\x02\0\x03\x12\x04\xa3\x01+,\n%\n\x02\x04\n\x12\x06\xa7\x01\0\xaa\ - \x01\x01\x1a\x17\x20Request\x20of\x20GetCapture\n\n\x0b\n\x03\x04\n\x01\ - \x12\x04\xa7\x01\x08\x19\n\"\n\x04\x04\n\x02\0\x12\x04\xa9\x01\x02\x10\ - \x1a\x14\x20Capture\x20Identifier\n\n\r\n\x05\x04\n\x02\0\x05\x12\x04\ - \xa9\x01\x02\x08\n\r\n\x05\x04\n\x02\0\x01\x12\x04\xa9\x01\t\x0b\n\r\n\ - \x05\x04\n\x02\0\x03\x12\x04\xa9\x01\x0e\x0f\n\x93\x01\n\x02\x04\x0b\x12\ - \x06\xb0\x01\0\xb3\x01\x01\x1a\x84\x01\x20Response\x20of\x20GetCapture\n\ - \n\x20Returns\x20a\x20max\x20of\x201024\x20bytes\x20of\x20capture\x20fil\ - e.\n\x20GetCapture\x20will\x20be\x20returning\x20a\x20stream\x20of\x20Ge\ - tCaptureResponse\n\n\x0b\n\x03\x04\x0b\x01\x12\x04\xb0\x01\x08\x1a\n1\n\ - \x04\x04\x0b\x02\0\x12\x04\xb2\x01\x02\x1b\x1a#\x20Max\x20of\x201024\x20\ - bytes\x20of\x20capture\x20file\n\n\r\n\x05\x04\x0b\x02\0\x05\x12\x04\xb2\ - \x01\x02\x07\n\r\n\x05\x04\x0b\x02\0\x01\x12\x04\xb2\x01\x08\x16\n\r\n\ - \x05\x04\x0b\x02\0\x03\x12\x04\xb2\x01\x19\x1ab\x06proto3\ + CaptureResponse0\x01b\x06proto3\ "; /// `FileDescriptorProto` object which was a source for this generated file diff --git a/rust/proto/src/frontend_grpc.rs b/rust/proto/src/frontend_grpc.rs deleted file mode 100644 index f1e60ed..0000000 --- a/rust/proto/src/frontend_grpc.rs +++ /dev/null @@ -1,558 +0,0 @@ -// This file is generated. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy::all)] -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] - -const METHOD_FRONTEND_SERVICE_GET_VERSION: ::grpcio::Method< - super::empty::Empty, - super::frontend::VersionResponse, -> = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/netsim.frontend.FrontendService/GetVersion", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_FRONTEND_SERVICE_CREATE_DEVICE: ::grpcio::Method< - super::frontend::CreateDeviceRequest, - super::frontend::CreateDeviceResponse, -> = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/netsim.frontend.FrontendService/CreateDevice", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_FRONTEND_SERVICE_DELETE_CHIP: ::grpcio::Method< - super::frontend::DeleteChipRequest, - super::empty::Empty, -> = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/netsim.frontend.FrontendService/DeleteChip", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_FRONTEND_SERVICE_PATCH_DEVICE: ::grpcio::Method< - super::frontend::PatchDeviceRequest, - super::empty::Empty, -> = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/netsim.frontend.FrontendService/PatchDevice", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_FRONTEND_SERVICE_RESET: ::grpcio::Method<super::empty::Empty, super::empty::Empty> = - ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/netsim.frontend.FrontendService/Reset", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - }; - -const METHOD_FRONTEND_SERVICE_LIST_DEVICE: ::grpcio::Method< - super::empty::Empty, - super::frontend::ListDeviceResponse, -> = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/netsim.frontend.FrontendService/ListDevice", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_FRONTEND_SERVICE_SUBSCRIBE_DEVICE: ::grpcio::Method< - super::frontend::SubscribeDeviceRequest, - super::frontend::SubscribeDeviceResponse, -> = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/netsim.frontend.FrontendService/SubscribeDevice", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_FRONTEND_SERVICE_PATCH_CAPTURE: ::grpcio::Method< - super::frontend::PatchCaptureRequest, - super::empty::Empty, -> = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/netsim.frontend.FrontendService/PatchCapture", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_FRONTEND_SERVICE_LIST_CAPTURE: ::grpcio::Method< - super::empty::Empty, - super::frontend::ListCaptureResponse, -> = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/netsim.frontend.FrontendService/ListCapture", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -const METHOD_FRONTEND_SERVICE_GET_CAPTURE: ::grpcio::Method< - super::frontend::GetCaptureRequest, - super::frontend::GetCaptureResponse, -> = ::grpcio::Method { - ty: ::grpcio::MethodType::ServerStreaming, - name: "/netsim.frontend.FrontendService/GetCapture", - req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, - resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, -}; - -#[derive(Clone)] -pub struct FrontendServiceClient { - pub client: ::grpcio::Client, -} - -impl FrontendServiceClient { - pub fn new(channel: ::grpcio::Channel) -> Self { - FrontendServiceClient { client: ::grpcio::Client::new(channel) } - } - - pub fn get_version_opt( - &self, - req: &super::empty::Empty, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<super::frontend::VersionResponse> { - self.client.unary_call(&METHOD_FRONTEND_SERVICE_GET_VERSION, req, opt) - } - - pub fn get_version( - &self, - req: &super::empty::Empty, - ) -> ::grpcio::Result<super::frontend::VersionResponse> { - self.get_version_opt(req, ::grpcio::CallOption::default()) - } - - pub fn get_version_async_opt( - &self, - req: &super::empty::Empty, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::frontend::VersionResponse>> { - self.client.unary_call_async(&METHOD_FRONTEND_SERVICE_GET_VERSION, req, opt) - } - - pub fn get_version_async( - &self, - req: &super::empty::Empty, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::frontend::VersionResponse>> { - self.get_version_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn create_device_opt( - &self, - req: &super::frontend::CreateDeviceRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<super::frontend::CreateDeviceResponse> { - self.client.unary_call(&METHOD_FRONTEND_SERVICE_CREATE_DEVICE, req, opt) - } - - pub fn create_device( - &self, - req: &super::frontend::CreateDeviceRequest, - ) -> ::grpcio::Result<super::frontend::CreateDeviceResponse> { - self.create_device_opt(req, ::grpcio::CallOption::default()) - } - - pub fn create_device_async_opt( - &self, - req: &super::frontend::CreateDeviceRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::frontend::CreateDeviceResponse>> - { - self.client.unary_call_async(&METHOD_FRONTEND_SERVICE_CREATE_DEVICE, req, opt) - } - - pub fn create_device_async( - &self, - req: &super::frontend::CreateDeviceRequest, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::frontend::CreateDeviceResponse>> - { - self.create_device_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn delete_chip_opt( - &self, - req: &super::frontend::DeleteChipRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<super::empty::Empty> { - self.client.unary_call(&METHOD_FRONTEND_SERVICE_DELETE_CHIP, req, opt) - } - - pub fn delete_chip( - &self, - req: &super::frontend::DeleteChipRequest, - ) -> ::grpcio::Result<super::empty::Empty> { - self.delete_chip_opt(req, ::grpcio::CallOption::default()) - } - - pub fn delete_chip_async_opt( - &self, - req: &super::frontend::DeleteChipRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::empty::Empty>> { - self.client.unary_call_async(&METHOD_FRONTEND_SERVICE_DELETE_CHIP, req, opt) - } - - pub fn delete_chip_async( - &self, - req: &super::frontend::DeleteChipRequest, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::empty::Empty>> { - self.delete_chip_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn patch_device_opt( - &self, - req: &super::frontend::PatchDeviceRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<super::empty::Empty> { - self.client.unary_call(&METHOD_FRONTEND_SERVICE_PATCH_DEVICE, req, opt) - } - - pub fn patch_device( - &self, - req: &super::frontend::PatchDeviceRequest, - ) -> ::grpcio::Result<super::empty::Empty> { - self.patch_device_opt(req, ::grpcio::CallOption::default()) - } - - pub fn patch_device_async_opt( - &self, - req: &super::frontend::PatchDeviceRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::empty::Empty>> { - self.client.unary_call_async(&METHOD_FRONTEND_SERVICE_PATCH_DEVICE, req, opt) - } - - pub fn patch_device_async( - &self, - req: &super::frontend::PatchDeviceRequest, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::empty::Empty>> { - self.patch_device_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn reset_opt( - &self, - req: &super::empty::Empty, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<super::empty::Empty> { - self.client.unary_call(&METHOD_FRONTEND_SERVICE_RESET, req, opt) - } - - pub fn reset(&self, req: &super::empty::Empty) -> ::grpcio::Result<super::empty::Empty> { - self.reset_opt(req, ::grpcio::CallOption::default()) - } - - pub fn reset_async_opt( - &self, - req: &super::empty::Empty, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::empty::Empty>> { - self.client.unary_call_async(&METHOD_FRONTEND_SERVICE_RESET, req, opt) - } - - pub fn reset_async( - &self, - req: &super::empty::Empty, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::empty::Empty>> { - self.reset_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn list_device_opt( - &self, - req: &super::empty::Empty, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<super::frontend::ListDeviceResponse> { - self.client.unary_call(&METHOD_FRONTEND_SERVICE_LIST_DEVICE, req, opt) - } - - pub fn list_device( - &self, - req: &super::empty::Empty, - ) -> ::grpcio::Result<super::frontend::ListDeviceResponse> { - self.list_device_opt(req, ::grpcio::CallOption::default()) - } - - pub fn list_device_async_opt( - &self, - req: &super::empty::Empty, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::frontend::ListDeviceResponse>> { - self.client.unary_call_async(&METHOD_FRONTEND_SERVICE_LIST_DEVICE, req, opt) - } - - pub fn list_device_async( - &self, - req: &super::empty::Empty, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::frontend::ListDeviceResponse>> { - self.list_device_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn subscribe_device_opt( - &self, - req: &super::frontend::SubscribeDeviceRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<super::frontend::SubscribeDeviceResponse> { - self.client.unary_call(&METHOD_FRONTEND_SERVICE_SUBSCRIBE_DEVICE, req, opt) - } - - pub fn subscribe_device( - &self, - req: &super::frontend::SubscribeDeviceRequest, - ) -> ::grpcio::Result<super::frontend::SubscribeDeviceResponse> { - self.subscribe_device_opt(req, ::grpcio::CallOption::default()) - } - - pub fn subscribe_device_async_opt( - &self, - req: &super::frontend::SubscribeDeviceRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::frontend::SubscribeDeviceResponse>> - { - self.client.unary_call_async(&METHOD_FRONTEND_SERVICE_SUBSCRIBE_DEVICE, req, opt) - } - - pub fn subscribe_device_async( - &self, - req: &super::frontend::SubscribeDeviceRequest, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::frontend::SubscribeDeviceResponse>> - { - self.subscribe_device_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn patch_capture_opt( - &self, - req: &super::frontend::PatchCaptureRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<super::empty::Empty> { - self.client.unary_call(&METHOD_FRONTEND_SERVICE_PATCH_CAPTURE, req, opt) - } - - pub fn patch_capture( - &self, - req: &super::frontend::PatchCaptureRequest, - ) -> ::grpcio::Result<super::empty::Empty> { - self.patch_capture_opt(req, ::grpcio::CallOption::default()) - } - - pub fn patch_capture_async_opt( - &self, - req: &super::frontend::PatchCaptureRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::empty::Empty>> { - self.client.unary_call_async(&METHOD_FRONTEND_SERVICE_PATCH_CAPTURE, req, opt) - } - - pub fn patch_capture_async( - &self, - req: &super::frontend::PatchCaptureRequest, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::empty::Empty>> { - self.patch_capture_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn list_capture_opt( - &self, - req: &super::empty::Empty, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<super::frontend::ListCaptureResponse> { - self.client.unary_call(&METHOD_FRONTEND_SERVICE_LIST_CAPTURE, req, opt) - } - - pub fn list_capture( - &self, - req: &super::empty::Empty, - ) -> ::grpcio::Result<super::frontend::ListCaptureResponse> { - self.list_capture_opt(req, ::grpcio::CallOption::default()) - } - - pub fn list_capture_async_opt( - &self, - req: &super::empty::Empty, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::frontend::ListCaptureResponse>> { - self.client.unary_call_async(&METHOD_FRONTEND_SERVICE_LIST_CAPTURE, req, opt) - } - - pub fn list_capture_async( - &self, - req: &super::empty::Empty, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::frontend::ListCaptureResponse>> { - self.list_capture_async_opt(req, ::grpcio::CallOption::default()) - } - - pub fn get_capture_opt( - &self, - req: &super::frontend::GetCaptureRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<::grpcio::ClientSStreamReceiver<super::frontend::GetCaptureResponse>> - { - self.client.server_streaming(&METHOD_FRONTEND_SERVICE_GET_CAPTURE, req, opt) - } - - pub fn get_capture( - &self, - req: &super::frontend::GetCaptureRequest, - ) -> ::grpcio::Result<::grpcio::ClientSStreamReceiver<super::frontend::GetCaptureResponse>> - { - self.get_capture_opt(req, ::grpcio::CallOption::default()) - } - pub fn spawn<F>(&self, f: F) - where - F: ::std::future::Future<Output = ()> + Send + 'static, - { - self.client.spawn(f) - } -} - -pub trait FrontendService { - fn get_version( - &mut self, - ctx: ::grpcio::RpcContext, - _req: super::empty::Empty, - sink: ::grpcio::UnarySink<super::frontend::VersionResponse>, - ) { - grpcio::unimplemented_call!(ctx, sink) - } - fn create_device( - &mut self, - ctx: ::grpcio::RpcContext, - _req: super::frontend::CreateDeviceRequest, - sink: ::grpcio::UnarySink<super::frontend::CreateDeviceResponse>, - ) { - grpcio::unimplemented_call!(ctx, sink) - } - fn delete_chip( - &mut self, - ctx: ::grpcio::RpcContext, - _req: super::frontend::DeleteChipRequest, - sink: ::grpcio::UnarySink<super::empty::Empty>, - ) { - grpcio::unimplemented_call!(ctx, sink) - } - fn patch_device( - &mut self, - ctx: ::grpcio::RpcContext, - _req: super::frontend::PatchDeviceRequest, - sink: ::grpcio::UnarySink<super::empty::Empty>, - ) { - grpcio::unimplemented_call!(ctx, sink) - } - fn reset( - &mut self, - ctx: ::grpcio::RpcContext, - _req: super::empty::Empty, - sink: ::grpcio::UnarySink<super::empty::Empty>, - ) { - grpcio::unimplemented_call!(ctx, sink) - } - fn list_device( - &mut self, - ctx: ::grpcio::RpcContext, - _req: super::empty::Empty, - sink: ::grpcio::UnarySink<super::frontend::ListDeviceResponse>, - ) { - grpcio::unimplemented_call!(ctx, sink) - } - fn subscribe_device( - &mut self, - ctx: ::grpcio::RpcContext, - _req: super::frontend::SubscribeDeviceRequest, - sink: ::grpcio::UnarySink<super::frontend::SubscribeDeviceResponse>, - ) { - grpcio::unimplemented_call!(ctx, sink) - } - fn patch_capture( - &mut self, - ctx: ::grpcio::RpcContext, - _req: super::frontend::PatchCaptureRequest, - sink: ::grpcio::UnarySink<super::empty::Empty>, - ) { - grpcio::unimplemented_call!(ctx, sink) - } - fn list_capture( - &mut self, - ctx: ::grpcio::RpcContext, - _req: super::empty::Empty, - sink: ::grpcio::UnarySink<super::frontend::ListCaptureResponse>, - ) { - grpcio::unimplemented_call!(ctx, sink) - } - fn get_capture( - &mut self, - ctx: ::grpcio::RpcContext, - _req: super::frontend::GetCaptureRequest, - sink: ::grpcio::ServerStreamingSink<super::frontend::GetCaptureResponse>, - ) { - grpcio::unimplemented_call!(ctx, sink) - } -} - -pub fn create_frontend_service<S: FrontendService + Send + Clone + 'static>( - s: S, -) -> ::grpcio::Service { - let mut builder = ::grpcio::ServiceBuilder::new(); - let mut instance = s.clone(); - builder = builder - .add_unary_handler(&METHOD_FRONTEND_SERVICE_GET_VERSION, move |ctx, req, resp| { - instance.get_version(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder - .add_unary_handler(&METHOD_FRONTEND_SERVICE_CREATE_DEVICE, move |ctx, req, resp| { - instance.create_device(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder - .add_unary_handler(&METHOD_FRONTEND_SERVICE_DELETE_CHIP, move |ctx, req, resp| { - instance.delete_chip(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder - .add_unary_handler(&METHOD_FRONTEND_SERVICE_PATCH_DEVICE, move |ctx, req, resp| { - instance.patch_device(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder.add_unary_handler(&METHOD_FRONTEND_SERVICE_RESET, move |ctx, req, resp| { - instance.reset(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder - .add_unary_handler(&METHOD_FRONTEND_SERVICE_LIST_DEVICE, move |ctx, req, resp| { - instance.list_device(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder - .add_unary_handler(&METHOD_FRONTEND_SERVICE_SUBSCRIBE_DEVICE, move |ctx, req, resp| { - instance.subscribe_device(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder - .add_unary_handler(&METHOD_FRONTEND_SERVICE_PATCH_CAPTURE, move |ctx, req, resp| { - instance.patch_capture(ctx, req, resp) - }); - let mut instance = s.clone(); - builder = builder - .add_unary_handler(&METHOD_FRONTEND_SERVICE_LIST_CAPTURE, move |ctx, req, resp| { - instance.list_capture(ctx, req, resp) - }); - let mut instance = s; - builder = builder.add_server_streaming_handler( - &METHOD_FRONTEND_SERVICE_GET_CAPTURE, - move |ctx, req, resp| instance.get_capture(ctx, req, resp), - ); - builder.build() -} diff --git a/rust/proto/src/lib.rs b/rust/proto/src/lib.rs index 8397ff6..c9eb9ec 100644 --- a/rust/proto/src/lib.rs +++ b/rust/proto/src/lib.rs @@ -14,16 +14,11 @@ // limitations under the License. //! protobuf library for netsim -#[cfg(feature = "cuttlefish")] -use protobuf::well_known_types::empty; pub mod common; pub mod config; pub mod configuration; pub mod frontend; -// TODO: Remove feature check once crate dependency is resolved -#[cfg(feature = "cuttlefish")] -pub mod frontend_grpc; pub mod hci_packet; pub mod model; pub mod packet_streamer; diff --git a/scripts/build_tools.py b/scripts/build_tools.py index acb00a4..e8f5db0 100755 --- a/scripts/build_tools.py +++ b/scripts/build_tools.py @@ -85,8 +85,7 @@ def main(): args.out_dir = os.path.join(AOSP_ROOT, args.out_dir) out = Path(args.out_dir) - if out.exists(): - shutil.rmtree(out) + shutil.rmtree(out) out.mkdir(exist_ok=True, parents=True) @@ -120,8 +119,8 @@ def main(): with ServerConfig(presubmit, args) as cfg: # Turn on sccache? - #if cfg.sccache: - # launcher.append(f"-DOPTION_CCACHE=${cfg.sccache}") + if cfg.sccache: + launcher.append(f"-DOPTION_CCACHE=${cfg.sccache}") # Configure run(launcher, cfg.get_env(), "bld") diff --git a/scripts/proto_update.sh b/scripts/proto_update.sh index 6353465..1062b91 100755 --- a/scripts/proto_update.sh +++ b/scripts/proto_update.sh @@ -40,13 +40,6 @@ export CARGO_HOME=$REPO/objs/rust/.cargo cd $REPO cargo build --manifest-path $CARGO -# run protoc command to generate grpc proto rust files -# Possibly need to install compilers: -# $ cargo install protobuf-codegen -# $ cargo install grpcio-compiler -# TODO: Need to add required crate mappings to work in emu-master-dev -# protoc --rust_out=./rust/proto/src --grpc_out=./rust/proto/src --plugin=protoc-gen-grpc=`which grpc_rust_plugin` -I./proto -I../../external/protobuf/src -I../../packages/modules/Bluetooth/tools/rootcanal/proto ./proto/netsim/frontend.proto - # Undo changed to Cargo.toml git checkout $CARGO diff --git a/scripts/utils.py b/scripts/utils.py index 8809fc7..4bf6124 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -40,11 +40,9 @@ TARGET_MAP = { "windows_x64": "windows_msvc-x86_64", "linux": "linux-x86_64", "linux_x64": "linux-x86_64", - "linux_x86_64": "linux-x86_64", - "linux_aarch64": "linux-aarch64", "darwin": "darwin-x86_64", "darwin_x64": "darwin-x86_64", - "darwin_x86_64" : "darwin-x86_64", + "linux_aarch64": "linux-aarch64", "darwin_aarch64": "darwin-aarch64", } @@ -59,7 +57,7 @@ AVAILABLE = { def platform_to_cmake_target(target): """Translates platform to cmake target""" - return TARGET_MAP[target.replace("-","_")] + return TARGET_MAP[target] def cmake_toolchain(target) -> str: @@ -71,7 +69,7 @@ def cmake_toolchain(target) -> str: / "android" / "build" / "cmake" - / AVAILABLE[TARGET_MAP[target.replace("-", "_")]] + / AVAILABLE[TARGET_MAP[target]] ) |