From 79ff68acae7e4774881d6bc53fc5c639da4a2e7b Mon Sep 17 00:00:00 2001 From: ng0 Date: Sun, 1 Dec 2019 11:49:59 +0000 Subject: transport: initial commit for bluetooth and wlan in netbsd. --- src/transport/Makefile.am | 25 ++++++++++++ src/transport/gnunet-helper-transport-bluetooth.c | 20 ++++++++-- src/transport/gnunet-helper-transport-wlan.c | 48 ++++++++++++++++++++--- 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 +#if defined(__linux__) #include #include #include #include #include #include +#endif +#if defined(BSD) && defined(__NetBSD__) +#include +#include +#include +#include +#endif #include +#if defined(__linux__) #include +#endif +#if defined(BSD) +#include +#endif #include #include #include -#include #include #include #include @@ -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 - Copyright Copyright (C) 2009 Thomas d'Otreppe + Copyright (C) 2007, 2008, Andy Green + 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 #include #include #include @@ -117,12 +118,26 @@ #include #include #include +#ifdef AF_LINK +#include +#endif +#ifdef AF_PACKET #include +#endif +#if defined(__linux__) #include #include #include +#endif +#if defined(BSD) +#include +#include +#include +#endif #include -#include +#ifdef IF_TUN_HDR +#include IF_TUN_HDR +#endif #include #include #include @@ -130,7 +145,6 @@ #include #include #include -#include #include #include @@ -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, -- cgit v1.2.3