diff options
author | ng0 <ng0@n0.is> | 2019-12-01 11:49:59 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-12-01 11:49:59 +0000 |
commit | 79ff68acae7e4774881d6bc53fc5c639da4a2e7b (patch) | |
tree | d4de2dfe836accb82ba0f838803035589469b7ea /src/transport/gnunet-helper-transport-wlan.c | |
parent | 435596a7cb2e5b9adbb8de90f3f917a61d089a1b (diff) | |
download | gnunet-79ff68acae7e4774881d6bc53fc5c639da4a2e7b.tar.gz gnunet-79ff68acae7e4774881d6bc53fc5c639da4a2e7b.zip |
transport: initial commit for bluetooth and wlan in netbsd.
Diffstat (limited to 'src/transport/gnunet-helper-transport-wlan.c')
-rw-r--r-- | src/transport/gnunet-helper-transport-wlan.c | 48 |
1 files changed, 43 insertions, 5 deletions
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010, 2011, 2012 GNUnet e.V. | 3 | Copyright (C) 2010, 2011, 2012 GNUnet e.V. |
4 | Copyright (c) 2007, 2008, Andy Green <andy@warmcat.com> | 4 | Copyright (C) 2007, 2008, Andy Green <andy@warmcat.com> |
5 | Copyright Copyright (C) 2009 Thomas d'Otreppe | 5 | Copyright (C) 2009 Thomas d'Otreppe |
6 | 6 | ||
7 | GNUnet is free software: you can redistribute it and/or modify it | 7 | GNUnet is free software: you can redistribute it and/or modify it |
8 | under the terms of the GNU Affero General Public License as published | 8 | under the terms of the GNU Affero General Public License as published |
@@ -110,6 +110,7 @@ | |||
110 | * parts taken from aircrack-ng, parts changend. | 110 | * parts taken from aircrack-ng, parts changend. |
111 | */ | 111 | */ |
112 | #include "gnunet_config.h" | 112 | #include "gnunet_config.h" |
113 | #include <sys/param.h> | ||
113 | #include <sys/socket.h> | 114 | #include <sys/socket.h> |
114 | #include <sys/ioctl.h> | 115 | #include <sys/ioctl.h> |
115 | #include <sys/types.h> | 116 | #include <sys/types.h> |
@@ -117,12 +118,26 @@ | |||
117 | #include <sys/wait.h> | 118 | #include <sys/wait.h> |
118 | #include <sys/time.h> | 119 | #include <sys/time.h> |
119 | #include <sys/stat.h> | 120 | #include <sys/stat.h> |
121 | #ifdef AF_LINK | ||
122 | #include <net/if_dl.h> | ||
123 | #endif | ||
124 | #ifdef AF_PACKET | ||
120 | #include <netpacket/packet.h> | 125 | #include <netpacket/packet.h> |
126 | #endif | ||
127 | #if defined(__linux__) | ||
121 | #include <linux/if_ether.h> | 128 | #include <linux/if_ether.h> |
122 | #include <linux/if.h> | 129 | #include <linux/if.h> |
123 | #include <linux/wireless.h> | 130 | #include <linux/wireless.h> |
131 | #endif | ||
132 | #if defined(BSD) | ||
133 | #include <net/if.h> | ||
134 | #include <net/if_ether.h> | ||
135 | #include <net80211/ieee80211_node.h> | ||
136 | #endif | ||
124 | #include <netinet/in.h> | 137 | #include <netinet/in.h> |
125 | #include <linux/if_tun.h> | 138 | #ifdef IF_TUN_HDR |
139 | #include IF_TUN_HDR | ||
140 | #endif | ||
126 | #include <stdio.h> | 141 | #include <stdio.h> |
127 | #include <stdlib.h> | 142 | #include <stdlib.h> |
128 | #include <string.h> | 143 | #include <string.h> |
@@ -130,7 +145,6 @@ | |||
130 | #include <fcntl.h> | 145 | #include <fcntl.h> |
131 | #include <errno.h> | 146 | #include <errno.h> |
132 | #include <dirent.h> | 147 | #include <dirent.h> |
133 | #include <sys/param.h> | ||
134 | #include <unistd.h> | 148 | #include <unistd.h> |
135 | #include <stdint.h> | 149 | #include <stdint.h> |
136 | 150 | ||
@@ -1661,7 +1675,12 @@ open_device_raw (struct HardwareInfos *dev) | |||
1661 | struct ifreq ifr; | 1675 | struct ifreq ifr; |
1662 | struct iwreq wrq; | 1676 | struct iwreq wrq; |
1663 | struct packet_mreq mr; | 1677 | struct packet_mreq mr; |
1678 | #ifdef AF_PACKET | ||
1664 | struct sockaddr_ll sll; | 1679 | struct sockaddr_ll sll; |
1680 | #endif | ||
1681 | #ifdef AF_LINK | ||
1682 | struct sockaddr_dl sll; | ||
1683 | #endif | ||
1665 | 1684 | ||
1666 | /* find the interface index */ | 1685 | /* find the interface index */ |
1667 | memset (&ifr, 0, sizeof(ifr)); | 1686 | memset (&ifr, 0, sizeof(ifr)); |
@@ -1675,9 +1694,16 @@ open_device_raw (struct HardwareInfos *dev) | |||
1675 | 1694 | ||
1676 | /* lookup the hardware type */ | 1695 | /* lookup the hardware type */ |
1677 | memset (&sll, 0, sizeof(sll)); | 1696 | memset (&sll, 0, sizeof(sll)); |
1697 | #if defined(AF_PACKET) | ||
1678 | sll.sll_family = AF_PACKET; | 1698 | sll.sll_family = AF_PACKET; |
1679 | sll.sll_ifindex = ifr.ifr_ifindex; | 1699 | sll.sll_ifindex = ifr.ifr_ifindex; |
1680 | sll.sll_protocol = htons (ETH_P_ALL); | 1700 | sll.sll_protocol = htons (ETH_P_ALL); |
1701 | #endif | ||
1702 | #if defined(AF_LINK) | ||
1703 | sll.sdl_family = AF_LINK; | ||
1704 | sll.sdl_index = ifr.ifr_ifindex; | ||
1705 | sll.sdl_protocol = htons (ETH_P_ALL); | ||
1706 | #endif | ||
1681 | if (-1 == ioctl (dev->fd_raw, SIOCGIFHWADDR, &ifr)) | 1707 | if (-1 == ioctl (dev->fd_raw, SIOCGIFHWADDR, &ifr)) |
1682 | { | 1708 | { |
1683 | fprintf (stderr, "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n", | 1709 | fprintf (stderr, "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n", |
@@ -1760,10 +1786,22 @@ open_device_raw (struct HardwareInfos *dev) | |||
1760 | 1786 | ||
1761 | /* enable promiscuous mode */ | 1787 | /* enable promiscuous mode */ |
1762 | memset (&mr, 0, sizeof(mr)); | 1788 | memset (&mr, 0, sizeof(mr)); |
1789 | #ifdef AF_PACKET | ||
1763 | mr.mr_ifindex = sll.sll_ifindex; | 1790 | mr.mr_ifindex = sll.sll_ifindex; |
1791 | #endif | ||
1792 | #ifdef AF_LINK | ||
1793 | mr.mr_ifindex = sll.sdl_index; | ||
1794 | #endif | ||
1764 | mr.mr_type = PACKET_MR_PROMISC; | 1795 | mr.mr_type = PACKET_MR_PROMISC; |
1765 | if (0 != | 1796 | if (0 != |
1766 | setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr, | 1797 | setsockopt (dev->fd_raw, SOL_PACKET, |
1798 | #ifdef AF_PACKET | ||
1799 | PACKET_ADD_MEMBERSHIP, | ||
1800 | #endif | ||
1801 | #ifdef AF_LINK | ||
1802 | SIOCADDMULTI, | ||
1803 | #endif | ||
1804 | &mr, | ||
1767 | sizeof(mr))) | 1805 | sizeof(mr))) |
1768 | { | 1806 | { |
1769 | fprintf (stderr, | 1807 | fprintf (stderr, |