Struct wake_on_lan::MagicPacket
source · pub struct MagicPacket { /* private fields */ }
Expand description
A Wake-on-LAN magic packet.
Implementations§
source§impl MagicPacket
impl MagicPacket
sourcepub fn new(mac_address: &[u8; 6]) -> MagicPacket
pub fn new(mac_address: &[u8; 6]) -> MagicPacket
Creates a new MagicPacket
intended for mac_address
(but doesn’t send it yet).
sourcepub fn send(&self) -> Result<()>
pub fn send(&self) -> Result<()>
Sends the magic packet via UDP to the broadcast address 255.255.255.255:9
.
Lets the operating system choose the source port and network interface.
sourcepub fn send_to<A: ToSocketAddrs>(&self, to_addr: A, from_addr: A) -> Result<()>
pub fn send_to<A: ToSocketAddrs>(&self, to_addr: A, from_addr: A) -> Result<()>
Sends the magic packet via UDP to/from an IP address and port number of your choosing.
sourcepub fn magic_bytes(&self) -> &[u8; 102]
pub fn magic_bytes(&self) -> &[u8; 102]
Returns the magic packet’s payload (6 repetitions of 0xFF
and 16 repetitions of the
target device’s MAC address). Send these bytes yourself over the network if you want to do
something more advanced (like reuse a single UDP socket when sending a large number of
magic packets).