From 8debfc71c227dbc3ffd2d6fa172ee25e525ea2df Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 16 Nov 2012 16:59:44 +0000 Subject: -trying to add 802.3-encoding support --- src/transport/gnunet-helper-transport-wlan.c | 21 +++++++++++++++++++++ src/transport/plugin_transport_wlan.h | 23 +++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/transport/gnunet-helper-transport-wlan.c b/src/transport/gnunet-helper-transport-wlan.c index 515da4334..4b4d5426e 100644 --- a/src/transport/gnunet-helper-transport-wlan.c +++ b/src/transport/gnunet-helper-transport-wlan.c @@ -137,6 +137,14 @@ #include "gnunet_protocols.h" #include "plugin_transport_wlan.h" +/** + * Packet format type for the messages we receive from + * the kernel. This is for Ethernet 10Mbps format (no + * performance information included). + */ +#define ARPHRD_ETHER 1 + + /** * Packet format type for the messages we receive from * the kernel. This is for plain messages (with no @@ -144,6 +152,7 @@ */ #define ARPHRD_IEEE80211 801 + /** * Packet format type for the messages we receive from * the kernel. This is for the PRISM format. @@ -1588,6 +1597,17 @@ linux_read (struct HardwareInfos *dev, case ARPHRD_IEEE80211: n = 0; /* no header */ break; + case ARPHRD_ETHER: + { + ; + + if (sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) > caplen) + return 0; /* invalid */ + memcpy (&buf[sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame)], + tmpbuf + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame), + caplen - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) - 4 /* 4 byte FCS */); + return caplen - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) - 4; + } default: errno = ENOTSUP; /* unsupported format */ return -1; @@ -1652,6 +1672,7 @@ open_device_raw (struct HardwareInfos *dev) return 1; } if (((ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211) && + (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) && (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM) && (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL)) ) { diff --git a/src/transport/plugin_transport_wlan.h b/src/transport/plugin_transport_wlan.h index 2b70fc0f5..b7f22de71 100644 --- a/src/transport/plugin_transport_wlan.h +++ b/src/transport/plugin_transport_wlan.h @@ -80,6 +80,29 @@ struct GNUNET_TRANSPORT_WLAN_HelperControlMessage struct GNUNET_TRANSPORT_WLAN_MacAddress mac; }; +/** + * generic definitions for IEEE 802.3 frames + */ +struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame +{ + + /** + * Address 1: destination address in ad-hoc mode or AP, BSSID if station, + */ + struct GNUNET_TRANSPORT_WLAN_MacAddress dst; + + /** + * Address 2: source address if in ad-hoc-mode or station, BSSID if AP + */ + struct GNUNET_TRANSPORT_WLAN_MacAddress src; + + /** + * Packet type ID. + */ + uint16_t type; + +}; + /** * generic definitions for IEEE 802.11 frames -- cgit v1.2.3