Expand description
Wake on LAN magic packets.
§Send magic packets
send_magic_packet provides a convenience function to send a single packet:
use std::str::FromStr;
use std::net::Ipv4Addr;
let mac_address = wol::MacAddr6::from_str("12-13-14-15-16-17").unwrap();
wol::send_magic_packet(mac_address, None, (Ipv4Addr::BROADCAST, 9).into()).unwrap();For more control, create the std::net::UdpSocket yourself:
use std::str::FromStr;
use std::net::{Ipv4Addr, UdpSocket};
use wol::SendMagicPacket;
let socket = UdpSocket::bind((Ipv4Addr::UNSPECIFIED, 0)).unwrap();
let mac_address = wol::MacAddr6::from_str("12-13-14-15-16-17").unwrap();
socket.send_magic_packet(mac_address, None, (Ipv4Addr::BROADCAST, 9)).unwrap();§Assemble magic packets
To send magic packets over other socket APIs, use fill_magic_packet or write_magic_packet
to assmble magic packets.
§SecureON
This crate supports SecureON magic packets. If a SecureON sequence is set in the firmware of the target device, the device will only wake up if the magic packet additionally includes the given SecureON sequence. This offers a marginal amount of protection against unauthorized wake-ups in case the MAC address of the target device is known. Note however that this SecureON byte sequence is included in the magic packet as plain text, so it should not be assumed a secret.
Re-exports§
pub use macaddr;
Structs§
- MacAddr6
- MAC address in EUI-48 format.
Traits§
- Send
Magic Packet - A socket which supports sending a magic packet.
Functions§
- fill_
magic_ packet - Fill the given
bufferwith the magic packet for the givenmac_address. - fill_
magic_ packet_ secure_ on - Fill the given
bufferwith the magic packet for the givenmac_addressandsecure_onsequence. - send_
magic_ packet - Send a magic packet for
mac_addresstoaddr. - write_
magic_ packet - Write a magic packet for the given
mac_addresstosink.