MCPcopy Index your code
hub / github.com/cloud-hypervisor/cloud-hypervisor / pnet_send_packet

Function pnet_send_packet

net_util/src/tap.rs:676–689  ·  view source on GitHub ↗

Sends a test packet on the interface named "ifname".

(ifname: &str)

Source from the content-addressed store, hash-verified

674
675 // Sends a test packet on the interface named "ifname".
676 fn pnet_send_packet(ifname: &str) {
677 let payload = DATA_STRING.as_bytes();
678
679 // eth hdr + ip hdr + udp hdr + payload len
680 let buf_size = 14 + 20 + 8 + payload.len();
681
682 let (mac, mut tx, _) = pnet_get_mac_tx_rx(ifname);
683
684 let res = tx.build_and_send(1, buf_size, &mut |buf| {
685 pnet_build_packet(buf, mac, payload);
686 });
687 // Make sure build_and_send() -> Option<io::Result<()>> succeeds.
688 res.unwrap().unwrap();
689 }
690
691 // For a given interface name, this returns a tuple that contains the MAC address of the
692 // interface, an object that can be used to send Ethernet frames, and a receiver of

Callers 1

test_readFunction · 0.85

Calls 4

pnet_get_mac_tx_rxFunction · 0.85
pnet_build_packetFunction · 0.85
as_bytesMethod · 0.80
lenMethod · 0.45

Tested by 1

test_readFunction · 0.68