summaryrefslogtreecommitdiff
path: root/security/gvm-libs/files/patch-boreas_util.c
blob: 1de3346db51bf82750735cb95568354d46a6b5d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
--- boreas/util.c	2020-12-30 23:52:07.849996000 -0500
+++ boreas/util.c	2020-12-31 01:36:37.600382000 -0500
@@ -21,12 +21,20 @@
 
 #include "../base/networking.h" /* for range_t */
 
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
 #include <errno.h>
 #include <glib.h>
 #include <ifaddrs.h> /* for getifaddrs() */
 #include <net/ethernet.h>
 #include <net/if.h>           /* for if_nametoindex() */
-#include <netpacket/packet.h> /* for sockaddr_ll */
+#ifdef AF_LINK
+#   include <net/if_dl.h>
+#endif
+#ifdef AF_PACKET
+#   include <netpacket/packet.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 #include <sys/socket.h>
@@ -109,22 +117,22 @@
     {
       for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
         {
-          if ((ifa->ifa_addr) && (ifa->ifa_addr->sa_family == AF_PACKET)
+          if ((ifa->ifa_addr) && (ifa->ifa_addr->sa_family == AF_LINK)
               && !(ifa->ifa_flags & (IFF_LOOPBACK)))
             {
               if (interface_provided)
                 {
                   if (g_strcmp0 (interface, ifa->ifa_name) == 0)
                     {
-                      struct sockaddr_ll *s =
-                        (struct sockaddr_ll *) ifa->ifa_addr;
-                      memcpy (mac, s->sll_addr, 6 * sizeof (uint8_t));
+                      struct sockaddr_dl *s =
+                        (struct sockaddr_dl *) ifa->ifa_addr;
+                      memcpy (mac, s->sdl_data, 6 * sizeof (uint8_t));
                     }
                 }
               else
                 {
-                  struct sockaddr_ll *s = (struct sockaddr_ll *) ifa->ifa_addr;
-                  memcpy (mac, s->sll_addr, 6 * sizeof (uint8_t));
+                  struct sockaddr_dl *s = (struct sockaddr_dl *) ifa->ifa_addr;
+                  memcpy (mac, s->sdl_data, 6 * sizeof (uint8_t));
                 }
             }
         }
@@ -508,7 +516,7 @@
       break;
     case ARPV4:
       {
-        soc = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL));
+        soc = socket (PF_LINK, SOCK_RAW, 0);
         if (soc < 0)
           {
             g_warning ("%s: failed to open ARPV4 socket: %s", __func__,