transport: initial commit for bluetooth and wlan in netbsd.
authorng0 <ng0@n0.is>
Sun, 1 Dec 2019 11:49:59 +0000 (11:49 +0000)
committerng0 <ng0@n0.is>
Sun, 1 Dec 2019 11:49:59 +0000 (11:49 +0000)
src/transport/Makefile.am
src/transport/gnunet-helper-transport-bluetooth.c
src/transport/gnunet-helper-transport-wlan.c

index e77220d50ab06fd3f8f7a311b0faac26b7dab8e3..bbf51058edc0a8a0a5469210199779e2d75ed2cb 100644 (file)
@@ -92,6 +92,19 @@ if LINUX
  WLAN_QUOTA_TEST = test_quota_compliance_wlan \
                test_quota_compliance_wlan_asymmetric
 endif
+if XBSD
+ WLAN_BIN = gnunet-helper-transport-wlan
+ WLAN_BIN_DUMMY = gnunet-helper-transport-wlan-dummy
+ WLAN_BIN_SENDER = gnunet-transport-wlan-sender
+ WLAN_BIN_RECEIVER = gnunet-transport-wlan-receiver
+ WLAN_PLUGIN_LA = libgnunet_plugin_transport_wlan.la
+ WLAN_PLUGIN_TEST = test_plugin_wlan
+ WLAN_API_TEST = test_transport_api_wlan
+ WLAN_TIMEOUT_TEST = test_transport_api_timeout_wlan
+ WLAN_REL_TEST = test_transport_api_reliability_wlan
+ WLAN_QUOTA_TEST = test_quota_compliance_wlan \
+               test_quota_compliance_wlan_asymmetric
+endif
 
 if LINUX
 if HAVE_LIBBLUETOOTH
@@ -105,6 +118,18 @@ if HAVE_LIBBLUETOOTH
     test_quota_compliance_bluetooth_asymmetric
 endif
 endif
+if XBSD
+if HAVE_LIBBLUETOOTH
+ BT_BIN = gnunet-helper-transport-bluetooth
+ BT_PLUGIN_LA = libgnunet_plugin_transport_bluetooth.la
+ BT_PLUGIN_TEST = test_plugin_bluetooth
+ BT_API_TEST = test_transport_api_bluetooth
+ BT_TIMEOUT_TEST = test_transport_api_timeout_bluetooth
+ BT_REL_TEST = test_transport_api_reliability_bluetooth
+ BT_QUOTA_TEST = test_quota_compliance_bluetooth \
+    test_quota_compliance_bluetooth_asymmetric
+endif
+endif
 
 # end of HAVE_EXPERIMENTAL
 endif
index 4923e64286c456fc6c2239874bb2590cbf89aee0..d16cec981f32a1319b751fcb57cfc131d077eb1e 100644 (file)
  */
 #include "gnunet_config.h"
 
+#include <sys/param.h>
+#if defined(__linux__)
 #include <bluetooth/bluetooth.h>
 #include <bluetooth/hci.h>
 #include <bluetooth/hci_lib.h>
 #include <bluetooth/rfcomm.h>
 #include <bluetooth/sdp.h>
 #include <bluetooth/sdp_lib.h>
+#endif
+#if defined(BSD) && defined(__NetBSD__)
+#include <netbt/bluetooth.h>
+#include <netbt/hci.h>
+#include <netbt/l2cap.h>
+#include <netbt/rfcomm.h>
+#endif
 #include <errno.h>
+#if defined(__linux__)
 #include <linux/if.h>
+#endif
+#if defined(BSD)
+#include <net/if.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/ioctl.h>
-#include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -166,7 +179,7 @@ static struct SendBuffer write_pout;
 static struct SendBuffer write_std;
 
 
-/* ****** this are the same functions as the ones used in gnunet-helper-transport-wlan.c ****** */
+/* ****** these are the same functions as the ones used in gnunet-helper-transport-wlan.c ****** */
 
 /**
  * To what multiple do we align messages?  8 byte should suffice for everyone
@@ -615,7 +628,8 @@ register_service (struct HardwareInfos *dev, int rc_channel)
    * 5. set the name, provider and description
    * 6. register the service record to the local SDP server
    * 7. cleanup
-   */uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+   */
+  uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                              dev->pl_mac.mac[5], dev->pl_mac.mac[4],
                              dev->pl_mac.mac[3],
                              dev->pl_mac.mac[2], dev->pl_mac.mac[1],
index 83ade115ba0599c83b671c30c497f2e10549909e..b77f09851ca91f5c2d67746797dfcc8a8307ddef 100644 (file)
@@ -1,8 +1,8 @@
 /*
    This file is part of GNUnet.
    Copyright (C) 2010, 2011, 2012 GNUnet e.V.
-   Copyright (c) 2007, 2008, Andy Green <andy@warmcat.com>
-   Copyright Copyright (C) 2009 Thomas d'Otreppe
+   Copyright (C) 2007, 2008, Andy Green <andy@warmcat.com>
+   Copyright (C) 2009 Thomas d'Otreppe
 
    GNUnet is free software: you can redistribute it and/or modify it
    under the terms of the GNU Affero General Public License as published
  * parts taken from aircrack-ng, parts changend.
  */
 #include "gnunet_config.h"
+#include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/time.h>
 #include <sys/stat.h>
+#ifdef AF_LINK
+#include <net/if_dl.h>
+#endif
+#ifdef AF_PACKET
 #include <netpacket/packet.h>
+#endif
+#if defined(__linux__)
 #include <linux/if_ether.h>
 #include <linux/if.h>
 #include <linux/wireless.h>
+#endif
+#if defined(BSD)
+#include <net/if.h>
+#include <net/if_ether.h>
+#include <net80211/ieee80211_node.h>
+#endif
 #include <netinet/in.h>
-#include <linux/if_tun.h>
+#ifdef IF_TUN_HDR
+#include IF_TUN_HDR
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <dirent.h>
-#include <sys/param.h>
 #include <unistd.h>
 #include <stdint.h>
 
@@ -1661,7 +1675,12 @@ open_device_raw (struct HardwareInfos *dev)
   struct ifreq ifr;
   struct iwreq wrq;
   struct packet_mreq mr;
+#ifdef AF_PACKET
   struct sockaddr_ll sll;
+#endif
+#ifdef AF_LINK
+  struct sockaddr_dl sll;
+#endif
 
   /* find the interface index */
   memset (&ifr, 0, sizeof(ifr));
@@ -1675,9 +1694,16 @@ open_device_raw (struct HardwareInfos *dev)
 
   /* lookup the hardware type */
   memset (&sll, 0, sizeof(sll));
+#if defined(AF_PACKET)
   sll.sll_family = AF_PACKET;
   sll.sll_ifindex = ifr.ifr_ifindex;
   sll.sll_protocol = htons (ETH_P_ALL);
+#endif
+#if defined(AF_LINK)
+  sll.sdl_family = AF_LINK;
+  sll.sdl_index = ifr.ifr_ifindex;
+  sll.sdl_protocol = htons (ETH_P_ALL);
+#endif
   if (-1 == ioctl (dev->fd_raw, SIOCGIFHWADDR, &ifr))
   {
     fprintf (stderr, "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n",
@@ -1760,10 +1786,22 @@ open_device_raw (struct HardwareInfos *dev)
 
   /* enable promiscuous mode */
   memset (&mr, 0, sizeof(mr));
+#ifdef AF_PACKET
   mr.mr_ifindex = sll.sll_ifindex;
+#endif
+#ifdef AF_LINK
+  mr.mr_ifindex = sll.sdl_index;
+#endif
   mr.mr_type = PACKET_MR_PROMISC;
   if (0 !=
-      setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr,
+      setsockopt (dev->fd_raw, SOL_PACKET,
+#ifdef AF_PACKET
+                  PACKET_ADD_MEMBERSHIP,
+#endif
+#ifdef AF_LINK
+                  SIOCADDMULTI,
+#endif
+                  &mr,
                   sizeof(mr)))
   {
     fprintf (stderr,