Skip to content
/ eui48 Public
forked from abaumhauer/eui48

Rust implementation of IEEE EUI-48 datatype, also known as MAC-48 for network Media Access Control addressing

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

kamek-pf/eui48

 
 

Repository files navigation

Crates.io docs.rs Build Status Build Status Build Status Coverage Status

eui48

A Rust library to represent and parse IEEE EUI-48 also known as MAC-48 media access control addresses. The IEEE claims trademarks on the names EUI-48 and EUI-64, in which EUI is an abbreviation for Extended Unique Identifier.

Usage

Add this to your Cargo.toml:

[dependencies]

eui48 = "0.4.6"

and this to your crate root:

extern crate eui48;

Examples

To create a new MAC address and print it out in canonical form:

extern crate eui48;
use eui48::{MacAddress, Eui48};

fn main() {
	let eui: Eui48 = [ 0x12, 0x34, 0x56, 0xAB, 0xCD, 0xEF ];
	let mac = MacAddress::new( eui );

	println!("{}", mac.to_canonical());
	println!("{}", mac.to_hex_string());
	println!("{}", mac.to_dot_string());
	println!("{}", mac.to_hexadecimal());
	println!("{}", mac.to_interfaceid());
	println!("{}", mac.to_link_local());

	let mac = MacAddress::parse_str( "01-02-03-0A-0b-0f" ).expect("Parse error {}");
	let mac = MacAddress::parse_str( "01:02:03:0A:0b:0f" ).expect("Parse error {}");
	let mac = MacAddress::parse_str( "0102.030A.0b0f" ).expect("Parse error {}");
	let mac = MacAddress::parse_str( "0x1234567890ab" ).expect("Parse error {}");
}

References

Wikipedia: MAC address

Authors

  • 0.1 Andrew Baumhauer - Initial design
  • 0.2 rlcomstock3 - Added support for btree keys
  • 0.3 Michal 'vorner' Vaner [email protected] - Serde 1.0 support
  • 0.3.1 Michal 'vorner' Vaner [email protected] - Derive useful traits
  • 0.4.0 Rainer Stademann - Define ABI as repr(C)
  • 0.4.1 Andrew Baumhauer - Add IPv6 Interface ID and Link Local conversions
  • 0.4.2 Andrew Baumhauer / Eric Clone - Bug fix in is_local() and is_unicast() functions
  • 0.4.3 Andrew Baumhauer - Update travis-ci, appveyor, codecov
  • 0.4.4 Andrew Baumhauer - Update documentation
  • 0.4.5 Andrew Baumhauer - Improve code coverage and tests
  • 0.4.6 Jiwoong Lee - Add to_array() for compatibility, add feature disp_hexstring

About

Rust implementation of IEEE EUI-48 datatype, also known as MAC-48 for network Media Access Control addressing

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%