fn pnet_send_packet(ifname: String) {
        let payload = DATA_STRING.as_bytes();

        // eth hdr + ip hdr + udp hdr + payload len
        let buf_size = 14 + 20 + 8 + payload.len();

        let (mac, mut tx, _) = pnet_get_mac_tx_rx(ifname);

        let res = tx.build_and_send(1, buf_size, &mut |buf| {
            pnet_build_packet(buf, mac, payload);
        });
        // Make sure build_and_send() -> Option<io::Result<()>> succeeds.
        res.unwrap().unwrap();
    }
// Sends a test packet on the interface named "ifname".
Sends a test packet on the interface named "ifname".
Sends a test packet on the interface named " ifname " .
fn pnet_send_packet(ifname: String) {
        let payload = DATA_STRING.as_bytes();
        // eth hdr + ip hdr + udp hdr + payload len
        let buf_size = 14 + 20 + 8 + payload.len();
        let (mac, mut tx, _) = pnet_get_mac_tx_rx(ifname);
        let res = tx.build_and_send(1, buf_size, &mut |buf| {
            pnet_build_packet(buf, mac, payload);
        });
        // Make sure build_and_send() -> Option<io::Result<()>> succeeds.
        res.unwrap().unwrap();
    }
fn pnet_send_packet ( ifname : String ) { let payload = DATA_STRING . as_bytes ( ) ; // eth hdr + ip hdr + udp hdr + payload len let buf_size = 14 + 20 + 8 + payload . len ( ) ; let ( mac , mut tx , _ ) = pnet_get_mac_tx_rx ( ifname ) ; let res = tx . build_and_send ( 1 , buf_size , & mut | buf | { pnet_build_packet ( buf , mac , payload ) ; } ) ; // Make sure build_and_send() -> Option<io::Result<()>> succeeds. res . unwrap ( ) . unwrap ( ) ; }
Sends a test packet on the interface named "ifname".
Sends a test packet on the interface named " ifname " .
ifname
String
ifname
String