(&self)
| 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. |
no test coverage detected