MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / mac_from_sandbox_id

Function mac_from_sandbox_id

crates/openshell-driver-vm/src/gpu.rs:240–250  ·  view source on GitHub ↗

Generate a locally-administered MAC from sandbox ID using FNV-1a.

(sandbox_id: &str)

Source from the content-addressed store, hash-verified

238
239/// Generate a locally-administered MAC from sandbox ID using FNV-1a.
240pub fn mac_from_sandbox_id(sandbox_id: &str) -> [u8; 6] {
241 let mut hash: u64 = 0xcbf2_9ce4_8422_2325;
242 for byte in sandbox_id.as_bytes() {
243 hash ^= u64::from(*byte);
244 hash = hash.wrapping_mul(0x0000_0100_0000_01b3);
245 }
246 let bytes = hash.to_le_bytes();
247 let mut mac = [bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5]];
248 mac[0] = (mac[0] & 0xFE) | 0x02;
249 mac
250}
251
252/// TAP device name from sandbox ID (fits `IFNAMSIZ=16`).
253pub fn tap_device_name(sandbox_id: &str) -> String {

Calls

no outgoing calls