| @@ -1,31 +1,42 @@ | | | @@ -1,31 +1,42 @@ |
1 | $NetBSD: patch-aa,v 1.4 2015/12/29 04:04:29 dholland Exp $ | | 1 | $NetBSD: patch-aa,v 1.5 2016/04/18 11:41:50 jperkin Exp $ |
2 | | | 2 | |
3 | --- src/netstatus-iface.c.orig 2007-02-13 10:39:19.000000000 +0100 | | 3 | Don't use SIOCGIFHWADDR on SunOS. |
| | | 4 | |
| | | 5 | --- src/netstatus-iface.c.orig 2009-03-08 05:25:52.000000000 +0000 |
4 | +++ src/netstatus-iface.c | | 6 | +++ src/netstatus-iface.c |
| | | 7 | @@ -1024,7 +1024,7 @@ netstatus_iface_get_hw_details (Netstatu |
| | | 8 | char **hw_addr) |
| | | 9 | |
| | | 10 | { |
| | | 11 | -#ifdef SIOCGIFHWADDR |
| | | 12 | +#if defined(SIOCGIFHWADDR) && !defined(__sun) |
| | | 13 | static struct HwType *hw_type = NULL; |
| | | 14 | struct ifreq if_req; |
| | | 15 | int fd; |
5 | @@ -1121,12 +1121,6 @@ netstatus_iface_get_device_details (Nets | | 16 | @@ -1121,12 +1121,6 @@ netstatus_iface_get_device_details (Nets |
6 | return TRUE; | | 17 | return TRUE; |
7 | } | | 18 | } |
8 | | | 19 | |
9 | -#if !defined(HAVE_SOCKADDR_SA_LEN) | | 20 | -#if !defined(HAVE_SOCKADDR_SA_LEN) |
10 | -#define NETSTATUS_SA_LEN(saddr) (sizeof (struct sockaddr)) | | 21 | -#define NETSTATUS_SA_LEN(saddr) (sizeof (struct sockaddr)) |
11 | -#else | | 22 | -#else |
12 | -#define NETSTATUS_SA_LEN(saddr) (MAX ((saddr)->sa_len, sizeof (struct sockaddr))) | | 23 | -#define NETSTATUS_SA_LEN(saddr) (MAX ((saddr)->sa_len, sizeof (struct sockaddr))) |
13 | -#endif /* HAVE_SOCKADDR_SA_LEN */ | | 24 | -#endif /* HAVE_SOCKADDR_SA_LEN */ |
14 | - | | 25 | - |
15 | /* Taken From R. Stevens Unix Network Programming Vol. 1. | | 26 | /* Taken From R. Stevens Unix Network Programming Vol. 1. |
16 | * | | 27 | * |
17 | * SIOCGIFCONF does not return an error on all systems if | | 28 | * SIOCGIFCONF does not return an error on all systems if |
18 | @@ -1220,7 +1214,12 @@ netstatus_list_interface_names (GError * | | 29 | @@ -1220,7 +1214,12 @@ netstatus_list_interface_names (GError * |
19 | struct ifreq *if_req = (struct ifreq *) p; | | 30 | struct ifreq *if_req = (struct ifreq *) p; |
20 | gboolean loopback = FALSE; | | 31 | gboolean loopback = FALSE; |
21 | | | 32 | |
22 | - p += sizeof (if_req->ifr_name) + NETSTATUS_SA_LEN (&if_req->ifr_addr); | | 33 | - p += sizeof (if_req->ifr_name) + NETSTATUS_SA_LEN (&if_req->ifr_addr); |
23 | +#ifdef HAVE_SOCKADDR_SA_LEN | | 34 | +#ifdef HAVE_SOCKADDR_SA_LEN |
24 | + if (if_req->ifr_addr.sa_len > sizeof(if_req->ifr_ifru)) | | 35 | + if (if_req->ifr_addr.sa_len > sizeof(if_req->ifr_ifru)) |
25 | + p += offsetof(struct ifreq, ifr_ifru) + if_req->ifr_addr.sa_len; | | 36 | + p += offsetof(struct ifreq, ifr_ifru) + if_req->ifr_addr.sa_len; |
26 | + else | | 37 | + else |
27 | +#endif /* HAVE_SOCKADDR_SA_LEN */ | | 38 | +#endif /* HAVE_SOCKADDR_SA_LEN */ |
28 | + p += sizeof (*if_req); | | 39 | + p += sizeof (*if_req); |
29 | | | 40 | |
30 | if (ioctl (fd, SIOCGIFFLAGS, if_req) < 0) | | 41 | if (ioctl (fd, SIOCGIFFLAGS, if_req) < 0) |
31 | { | | 42 | { |