diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-24 23:32:49 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-24 23:32:49 -0400 |
commit | 912fe9fd05732d4e7da17f7110fe5e895ac88672 (patch) | |
tree | 905cbb758e99941c621e4e0738cd288b1ed99fe3 /src/include | |
parent | 570dc38023cac588a66118e8beb8dba66a3ec459 (diff) |
link: Get MAC address from specified interface
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/if_ether.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/include/if_ether.h b/src/include/if_ether.h index a71bd21..0cdf2fa 100644 --- a/src/include/if_ether.h +++ b/src/include/if_ether.h @@ -44,6 +44,20 @@ struct ether_hdr { uint16_t proto; } __attribute__((packed)); +static inline mac_addr_t +mac_swap(uint8_t mac[HW_ADDR_LEN]) +{ + mac_addr_t swapped = 0; + + swapped |= (uint64_t)mac[0] << 40; + swapped |= (uint64_t)mac[1] << 32; + swapped |= (uint64_t)mac[2] << 24; + swapped |= (uint64_t)mac[3] << 16; + swapped |= (uint64_t)mac[4] << 8; + swapped |= (uint64_t)mac[5]; + return swapped; +} + /* * Load the source and dest routes into an ethernet * frame. |