From 9370ed86046648eb2c28d54c3cc491418920a16a Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Tue, 18 Dec 2018 19:21:20 -0500 Subject: [PATCH] rawnet - add functions to get mac and mtu, if known. --- src/rawnet/rawnetarch.h | 4 ++++ src/rawnet/rawnetarch_darwin.c | 13 +++++++++++++ src/rawnet/rawnetarch_unix.c | 8 ++++++++ src/rawnet/rawnetarch_win32.c | 9 +++++++++ 4 files changed, 34 insertions(+) diff --git a/src/rawnet/rawnetarch.h b/src/rawnet/rawnetarch.h index 262dd29..f5749f3 100644 --- a/src/rawnet/rawnetarch.h +++ b/src/rawnet/rawnetarch.h @@ -65,4 +65,8 @@ extern int rawnet_arch_enumadapter_close(void); extern char *rawnet_arch_get_standard_interface(void); + +extern int rawnet_arch_get_mtu(void); +extern int rawnet_arch_get_mac(uint8_t mac[6]); + #endif diff --git a/src/rawnet/rawnetarch_darwin.c b/src/rawnet/rawnetarch_darwin.c index 69af2aa..8855d46 100644 --- a/src/rawnet/rawnetarch_darwin.c +++ b/src/rawnet/rawnetarch_darwin.c @@ -268,3 +268,16 @@ int rawnet_arch_enumadapter_close(void) { char *rawnet_arch_get_standard_interface(void) { return lib_stralloc("vmnet"); } + +int rawnet_arch_get_mtu(void) { + return interface ? interface_mtu : -1; +} + +int rawnet_arch_get_mac(uint8_t mac[6]) { + if (interface) { + memcpy(mac, interface_mac, 6); + return 1; + } + return -1; +} + diff --git a/src/rawnet/rawnetarch_unix.c b/src/rawnet/rawnetarch_unix.c index 7bf8916..4b737d9 100644 --- a/src/rawnet/rawnetarch_unix.c +++ b/src/rawnet/rawnetarch_unix.c @@ -535,4 +535,12 @@ char *rawnet_arch_get_standard_interface(void) return dev; } +extern int rawnet_arch_get_mtu(void) { + return -1; +} + +extern int rawnet_arch_get_mac(uint8_t mac[6]) { + return -1; +} + #endif /* #ifdef HAVE_RAWNET */ diff --git a/src/rawnet/rawnetarch_win32.c b/src/rawnet/rawnetarch_win32.c index 9f2ed1e..3a2655c 100644 --- a/src/rawnet/rawnetarch_win32.c +++ b/src/rawnet/rawnetarch_win32.c @@ -539,4 +539,13 @@ char *rawnet_arch_get_standard_interface(void) return dev; } + +extern int rawnet_arch_get_mtu(void) { + return -1; +} + +extern int rawnet_arch_get_mac(uint8_t mac[6]) { + return -1; +} + #endif /* #ifdef HAVE_RAWNET */