summaryrefslogtreecommitdiff
path: root/security/openvas/files/patch-misc_pcap.c
diff options
context:
space:
mode:
authorJose Alonso Cardenas Marquez <acm@FreeBSD.org>2022-05-22 00:39:40 -0500
committerJose Alonso Cardenas Marquez <acm@FreeBSD.org>2022-05-22 00:43:00 -0500
commit5212323270f6dbd887a9c4a427a1e2c838557c6f (patch)
treef9516ab7cf9476bd7de9daf00de91d74df326f3a /security/openvas/files/patch-misc_pcap.c
parentsecuryt/py-python-gvm: update to 21.11.0 (diff)
security/openvas: update to 21.4.4
ChangeLog at: https://github.com/greenbone/openvas-scanner/releases/tag/v21.4.4
Diffstat (limited to 'security/openvas/files/patch-misc_pcap.c')
-rw-r--r--security/openvas/files/patch-misc_pcap.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/security/openvas/files/patch-misc_pcap.c b/security/openvas/files/patch-misc_pcap.c
new file mode 100644
index 000000000000..13deb1337376
--- /dev/null
+++ b/security/openvas/files/patch-misc_pcap.c
@@ -0,0 +1,101 @@
+--- misc/pcap.c 2022-02-22 05:32:53.000000000 -0500
++++ misc/pcap.c 2022-05-21 23:28:28.467854000 -0500
+@@ -38,6 +38,13 @@
+ #include <sys/ioctl.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
++#if defined __FreeBSD__
++#include <sys/socket.h>
++#include <net/if.h>
++#include <net/if_dl.h>
++#include <net/if_types.h>
++#include <errno.h>
++#endif
+ #include <unistd.h>
+
+ #define MAXROUTES 1024
+@@ -1196,8 +1203,84 @@
+ }
+ else
+ {
++#if defined(__FreeBSD__)
++ void * addr_ptr;
++ struct sockaddr * sockaddr_ptr;
++ struct ifaddrs * ifaddrs_ptr;
++ int status;
++ char address[INET6_ADDRSTRLEN];
++ unsigned long tmp;
++
++ status = getifaddrs (& ifaddrs_ptr);
++ if(status == -1) {
++ g_debug("Error in 'getifaddrs': %d (%s)\n",
++ errno, strerror (errno));
++ exit (1);
++ }
++
++ while (ifaddrs_ptr)
++ {
++ if (ifaddrs_ptr->ifa_addr->sa_family == AF_INET)
++ {
++ strncpy (iface, ifaddrs_ptr->ifa_name, sizeof (iface));
++ iface[MAX_IFACE_NAME_LEN - 1] = '\0';
++
++ sockaddr_ptr = ifaddrs_ptr->ifa_dstaddr;
++ addr_ptr = &((struct sockaddr_in *) sockaddr_ptr)->sin_addr;
++
++ inet_ntop (ifaddrs_ptr->ifa_addr->sa_family,
++ addr_ptr,
++ address, sizeof (address));
++
++ endptr = NULL;
++ tmp = strtoul (address, &endptr, 16);
++ myroutes[numroutes].dest = tmp;
++
++ endptr = NULL;
++ tmp = strtol ("0", &endptr, 10);
++ myroutes[numroutes].metric = tmp;
++
++ sockaddr_ptr = ifaddrs_ptr->ifa_netmask;
++ addr_ptr = &((struct sockaddr_in *) sockaddr_ptr)->sin_addr;
++
++ inet_ntop (ifaddrs_ptr->ifa_addr->sa_family,
++ addr_ptr,
++ address, sizeof (address));
++
++ endptr = NULL;
++ tmp = strtoul (address, &endptr, 16);
++ myroutes[numroutes].mask = tmp;
++
++ g_debug("#%d: for dev %s, The dest is %lX and the mask is %lX",
++ numroutes, iface, myroutes[numroutes].dest,
++ myroutes[numroutes].mask);
++
++ for (i = 0; i < numinterfaces; i++)
++ if (!strcmp (iface, mydevs[i].name))
++ {
++ myroutes[numroutes].dev = &mydevs[i];
++ break;
++ }
++
++ if (i == numinterfaces)
++ g_message (
++ "Failed to find interface %s",
++ iface);
++
++ numroutes++;
++
++ if (numroutes >= MAXROUTES)
++ {
++ g_message ("You seem to have WAY to many routes!");
++ break;
++ }
++ }
++ ifaddrs_ptr = ifaddrs_ptr->ifa_next;
++ }
++#else
+ g_message ("Could not read from /proc/net/route");
+ return NULL;
++#endif
+ }
+ }
+ else