Subject: | _get_routes not working on NetBSD |
Date: | Tue, 24 May 2016 12:01:08 +0200 |
To: | bug-Net-Libdnet6 [...] rt.cpan.org |
From: | Edgar Fuß <ef [...] math.uni-bonn.de> |
The _get_routes_bsd function doesn't work on NetBSD (and probably OpenBSD) because the netstat -r output has three additional columns (Refs, Use, Mtu) between Flags and Interface. The columns are present on NetBSD 3, which is >10 years old.
The attached patch seems to work on NetBSD (I can't test OpenBSD).
I don't get why you don't filter out the header in the netstat output, but I left it as-is in the _get_routes_bsd I renamed to _get_routes_freebsd.
The code can probably be simplified by either passing the relevant column indices ([0,1,2,3] or [0,1,2,6]) to a common function or by parsing the header for the column titles (on NetBSD, thesese are qw/Destination Gateway Flags Refs Use Mtu Interface/, on Darwin and thus probably on FreeBSD too, they are qw/Destination Gateway Flags Netif Expire/).