Paweł Anikiel | 813c800 | 2022-06-17 12:47:19 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright 2022 Google LLC |
| 4 | */ |
| 5 | #include <net.h> |
| 6 | #include <errno.h> |
| 7 | #include "mercury_aa1.h" |
| 8 | |
| 9 | int misc_init_r(void) |
| 10 | { |
| 11 | u8 mac[ARP_HLEN]; |
| 12 | int res; |
| 13 | |
| 14 | if (env_get("ethaddr")) |
| 15 | return 0; |
| 16 | |
| 17 | res = mercury_aa1_read_mac(mac); |
| 18 | if (res) { |
| 19 | printf("couldn't read mac address: %s\n", errno_str(res)); |
| 20 | return 0; |
| 21 | } |
| 22 | |
| 23 | if (is_valid_ethaddr(mac)) |
| 24 | eth_env_set_enetaddr("ethaddr", mac); |
| 25 | |
| 26 | return 0; |
| 27 | } |