From 57e980b04f511c7d5baa82914061a465e9f64b9a Mon Sep 17 00:00:00 2001 From: Wiktor Mazur Date: Thu, 1 Aug 2019 12:00:56 +0200 Subject: [PATCH] +payload --- lib/packet-sniffer/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/packet-sniffer/src/lib.rs b/lib/packet-sniffer/src/lib.rs index dfd11b5..cd6514e 100644 --- a/lib/packet-sniffer/src/lib.rs +++ b/lib/packet-sniffer/src/lib.rs @@ -21,6 +21,7 @@ pub struct UdpPacket { pub destination_address: IpAddr, pub destination_port: u16, pub length: u16, + pub payload: Vec } pub fn receive(tx: Sender) { @@ -39,7 +40,7 @@ pub fn receive(tx: Sender) { Err(e) => panic!("packetdump: unable to create channel: {}", e), }; - let child = thread::spawn(move || { + thread::spawn(move || { loop { let mut buf: [u8; 1600] = [0u8; 1600]; let mut fake_ethernet_frame = MutableEthernetPacket::new(&mut buf[..]).unwrap(); @@ -140,7 +141,8 @@ fn handle_udp_packet(interface_name: &str, source: IpAddr, destination: IpAddr, source_port: udp.get_source(), destination_address: destination, destination_port: udp.get_destination(), - length: udp.get_length() + length: udp.get_length(), + payload: Vec::from(udp.payload()) }).unwrap(); } }