MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / get_ifreq

Method get_ifreq

net_util/src/tap.rs:492–509  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

490 }
491
492 fn get_ifreq(&self) -> libc::ifreq {
493 let mut ifreq: libc::ifreq = libc::ifreq {
494 ifr_name: [0; libc::IFNAMSIZ],
495 ifr_ifru: __c_anonymous_ifr_ifru { ifru_flags: 0 },
496 };
497
498 // Convert and copy bytes to `ifr_name` buffer.
499 // `self.if_name` will fit into `ifr_name` since we enforce the length when setting it.
500 ifreq
501 .ifr_name
502 .iter_mut()
503 .zip(self.if_name.as_bytes_with_nul())
504 .for_each(|(ifr_name_char, terminated_if_name_byte)| {
505 *ifr_name_char = *terminated_if_name_byte as c_char;
506 });
507
508 ifreq
509 }
510
511 /// Returns the interface name as a string, truncated at the first NUL byte
512 /// if present.

Callers 6

set_ip_addrMethod · 0.80
set_mac_addrMethod · 0.80
get_mac_addrMethod · 0.80
mtuMethod · 0.80
set_mtuMethod · 0.80
enableMethod · 0.80

Calls 1

iter_mutMethod · 0.80

Tested by

no test coverage detected