summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ifdata.c7
-rw-r--r--ifdata.docbook5
2 files changed, 11 insertions, 1 deletions
diff --git a/ifdata.c b/ifdata.c
index 99f30e9..6e0bd0b 100644
--- a/ifdata.c
+++ b/ifdata.c
@@ -195,6 +195,13 @@ void if_hwaddr(const char *iface) {
return;
hwaddr = (unsigned char *)r.ifr_hwaddr.sa_data;
+
+ if (!hwaddr[0] && !hwaddr[1] && !hwaddr[2] &&
+ !hwaddr[3] && !hwaddr[4] && !hwaddr[5]) {
+ fprintf(stderr, "Error: %s: no hardware address\n", iface);
+ exit(1);
+ }
+
printf("%02X:%02X:%02X:%02X:%02X:%02X",
hwaddr[0], hwaddr[1], hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]);
}
diff --git a/ifdata.docbook b/ifdata.docbook
index 4aa24db..a8c27d9 100644
--- a/ifdata.docbook
+++ b/ifdata.docbook
@@ -155,7 +155,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<term><option>-ph</option></term>
<listitem>
<para>Prints the hardware address of the
- interface.</para>
+ interface. Exit with a failure exit code
+ if there is not hardware address for the
+ given network interface.
+ </para>
</listitem>
</varlistentry>