Description
The current implementation uses hardcoded MAC addresses (02:12:34:56:78:ca/cb) which can cause conflicts when multiple devices are on the same network.
Current Problem
# Current static MACs in usb-gadget.sh
echo "02:12:34:56:78:ca" > "$G/functions/$FUNC_NCM/dev_addr"
echo "02:12:34:56:78:cb" > "$G/functions/$FUNC_NCM/host_addr"
Proposed Solution
Generate locally-administered MAC addresses based on device serial number using SHA256 hashing, ensuring uniqueness while maintaining deterministic generation.
Implementation Details
- Extract device serial from
/proc/cpuinfo or device-tree
- Generate hash-based MAC with locally-administered bit set
- Create different MACs for host and device interfaces
- Use the generate_mac() function from edgeos-flavor
Example Implementation
generate_mac() {
local input="$1"
local hash=$(echo -n "$input" | sha256sum | awk '{print $1}')
local mac_base=${hash:0:12}
local first_byte=${mac_base:0:2}
local second_char=$(printf '%x' $((0x$first_byte & 0xfe | 0x02)))
printf "%02x:%02x:%02x:%02x:%02x:%02x" \
0x$second_char \
0x${mac_base:2:2} \
0x${mac_base:4:2} \
0x${mac_base:6:2} \
0x${mac_base:8:2} \
0x${mac_base:10:2}
}
Acceptance Criteria
Description
The current implementation uses hardcoded MAC addresses (02:12:34:56:78:ca/cb) which can cause conflicts when multiple devices are on the same network.
Current Problem
Proposed Solution
Generate locally-administered MAC addresses based on device serial number using SHA256 hashing, ensuring uniqueness while maintaining deterministic generation.
Implementation Details
/proc/cpuinfoor device-treeExample Implementation
Acceptance Criteria