2025-09-29 01:43:17 +08:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2025 RTAkland
|
|
|
|
|
* Author: RTAkland
|
|
|
|
|
* Date: 9/29/25
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package cn.rtast.nmdns
|
|
|
|
|
|
2025-09-30 10:50:08 +08:00
|
|
|
import kotlin.experimental.ExperimentalNativeApi
|
|
|
|
|
import kotlin.native.CName
|
|
|
|
|
import kotlin.random.Random
|
2025-09-29 01:43:17 +08:00
|
|
|
|
2025-09-29 06:30:39 +08:00
|
|
|
/**
|
2025-09-30 10:50:08 +08:00
|
|
|
* generate random mac address
|
2025-09-29 06:30:39 +08:00
|
|
|
*/
|
2025-09-30 10:50:08 +08:00
|
|
|
@OptIn(ExperimentalNativeApi::class)
|
|
|
|
|
@CName("random_mac_address")
|
|
|
|
|
public fun randomMacAddress(): String {
|
|
|
|
|
val bytes = ByteArray(6) { Random.nextInt(0, 256).toByte() }
|
|
|
|
|
return bytes.joinToString(":") { it.toHexString() }
|
|
|
|
|
}
|