Crates.io | manuf |
lib.rs | manuf |
version | 0.2.0 |
source | src |
created_at | 2018-08-09 11:55:37.966504 |
updated_at | 2020-05-20 11:05:07.809474 |
description | Ethernet vendor codes, and well-known MAC addresses |
homepage | |
repository | https://github.com/flier/rust-manuf |
max_upload_size | |
id | 78492 |
size | 1,720,098 |
rust-manuf
is a Rust library provides the Ethernet vendor codes, and well-known MAC addresses
To use rust-manuf
, add this to your Cargo.toml
:
[dependencies]
manuf = "0.2"
Use vendor
function to find name and description base on an ethernet (MAC) address.
assert_eq!(
manuf::vendor([0x8c, 0x85, 0x90, 0x0b, 0xcb, 0x9e]),
Some(("Apple", "Apple, Inc."))
);
Use prefix
function to find vendor's prefix and mask for the ethernet (MAC) address.
assert!(
manuf::prefix("Apple")
.any(|prefix| prefix == ([0x8c, 0x85, 0x90, 0x00, 0x00, 0x00], 24))
);
use parse
function to extract verdor's ((prefix, prefix_length), (name, description))
from a manuf
file.
let f = File::open("manuf").unwrap();
let r = BufReader::new(f);
for ((prefix, prefix_len), (name, desc)) in manuf::parse(r) {
println!("{:?}/{}\t{}\t{}", prefix, prefix_len, name, desc)
}
Note: The manuf file was generated by the Wireshark project.
If you want to use the latest version of manuf
file, please add the latest
feature.
[dependencies]
manuf = { version = "0.2", features = ["latest"] }
Released under the terms of the MIT license.