summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-12-01 11:49:59 +0000
committerng0 <ng0@n0.is>2019-12-01 11:49:59 +0000
commit79ff68acae7e4774881d6bc53fc5c639da4a2e7b (patch)
treed4de2dfe836accb82ba0f838803035589469b7ea
parent435596a7cb2e5b9adbb8de90f3f917a61d089a1b (diff)
transport: initial commit for bluetooth and wlan in netbsd.
-rw-r--r--src/transport/Makefile.am25
-rw-r--r--src/transport/gnunet-helper-transport-bluetooth.c20
-rw-r--r--src/transport/gnunet-helper-transport-wlan.c48
3 files changed, 85 insertions, 8 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index e77220d50..bbf51058e 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -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
diff --git a/src/transport/gnunet-helper-transport-bluetooth.c b/src/transport/gnunet-helper-transport-bluetooth.c
index 4923e6428..d16cec981 100644
--- a/src/transport/gnunet-helper-transport-bluetooth.c
+++ b/src/transport/gnunet-helper-transport-bluetooth.c
@@ -21,18 +21,31 @@
*/
#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],
diff --git a/src/transport/gnunet-helper-transport-wlan.c b/src/transport/gnunet-helper-transport-wlan.c
index 83ade115b..b77f09851 100644
--- a/src/transport/gnunet-helper-transport-wlan.c
+++ b/src/transport/gnunet-helper-transport-wlan.c
@@ -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
@@ -110,6 +110,7 @@
* 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>
@@ -117,12 +118,26 @@
#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>
@@ -130,7 +145,6 @@
#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,