diff options
author | FxQnLr <[email protected]> | 2024-04-11 09:20:04 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2024-04-11 09:20:04 +0200 |
commit | 6b05d1a437a49db98056de7b029923e8aedf1a5a (patch) | |
tree | bc70f14cae1760e91369705273904c0de1bfbf75 /src/wol.rs | |
parent | 907e5cb5bc48899b444f7fedd85af7b5974d9a2e (diff) | |
parent | 2476e182f61d209768635e8eca6e75b4acfbd007 (diff) | |
download | webol-6b05d1a437a49db98056de7b029923e8aedf1a5a.tar webol-6b05d1a437a49db98056de7b029923e8aedf1a5a.tar.gz webol-6b05d1a437a49db98056de7b029923e8aedf1a5a.zip |
Merge pull request #32 from FxQnLr/0.4.0
0.4.0
Diffstat (limited to 'src/wol.rs')
-rw-r--r-- | src/wol.rs | 20 |
1 files changed, 0 insertions, 20 deletions
@@ -2,26 +2,6 @@ use std::net::{ToSocketAddrs, UdpSocket}; | |||
2 | 2 | ||
3 | use crate::error::Error; | 3 | use crate::error::Error; |
4 | 4 | ||
5 | /// Creates the magic packet from a mac address | ||
6 | /// | ||
7 | /// # Panics | ||
8 | /// | ||
9 | /// Panics if `mac_addr` is an invalid mac | ||
10 | pub fn create_buffer(mac_addr: &str) -> Result<Vec<u8>, Error> { | ||
11 | let mut mac = Vec::new(); | ||
12 | let sp = mac_addr.split(':'); | ||
13 | for f in sp { | ||
14 | mac.push(u8::from_str_radix(f, 16)?); | ||
15 | } | ||
16 | let mut buf = vec![255; 6]; | ||
17 | for _ in 0..16 { | ||
18 | for i in &mac { | ||
19 | buf.push(*i); | ||
20 | } | ||
21 | } | ||
22 | Ok(buf) | ||
23 | } | ||
24 | |||
25 | /// Sends a buffer on UDP broadcast | 5 | /// Sends a buffer on UDP broadcast |
26 | pub fn send_packet<A: ToSocketAddrs>( | 6 | pub fn send_packet<A: ToSocketAddrs>( |
27 | bind_addr: A, | 7 | bind_addr: A, |