aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-helper-transport-wlan.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-11-16 17:32:14 +0000
committerChristian Grothoff <christian@grothoff.org>2012-11-16 17:32:14 +0000
commit2fe4c0eb178885680f687ff915eba8ba3fb76435 (patch)
tree0f3bedda0f806e4b4598d3615bf760cedac20847 /src/transport/gnunet-helper-transport-wlan.c
parenta427cf1b7a5129119063ea5a3977e88cfda82fb2 (diff)
downloadgnunet-2fe4c0eb178885680f687ff915eba8ba3fb76435.tar.gz
gnunet-2fe4c0eb178885680f687ff915eba8ba3fb76435.zip
-fix
Diffstat (limited to 'src/transport/gnunet-helper-transport-wlan.c')
-rw-r--r--src/transport/gnunet-helper-transport-wlan.c52
1 files changed, 35 insertions, 17 deletions
diff --git a/src/transport/gnunet-helper-transport-wlan.c b/src/transport/gnunet-helper-transport-wlan.c
index 3c42e7523..1b599d1ce 100644
--- a/src/transport/gnunet-helper-transport-wlan.c
+++ b/src/transport/gnunet-helper-transport-wlan.c
@@ -1599,8 +1599,6 @@ linux_read (struct HardwareInfos *dev,
1599 break; 1599 break;
1600 case ARPHRD_ETHER: 1600 case ARPHRD_ETHER:
1601 { 1601 {
1602 ;
1603
1604 if (sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) > caplen) 1602 if (sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) > caplen)
1605 return 0; /* invalid */ 1603 return 0; /* invalid */
1606 memcpy (&buf[sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame)], 1604 memcpy (&buf[sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame)],
@@ -1841,6 +1839,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr)
1841 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *wlanheader; 1839 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *wlanheader;
1842 size_t sendsize; 1840 size_t sendsize;
1843 struct RadiotapTransmissionHeader rtheader; 1841 struct RadiotapTransmissionHeader rtheader;
1842 struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame etheader;
1844 1843
1845 sendsize = ntohs (hdr->size); 1844 sendsize = ntohs (hdr->size);
1846 if ( (sendsize < 1845 if ( (sendsize <
@@ -1857,21 +1856,40 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr)
1857 exit (1); 1856 exit (1);
1858 } 1857 }
1859 header = (const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) hdr; 1858 header = (const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) hdr;
1860 rtheader.header.it_version = 0; 1859 switch (dev->arptype_in)
1861 rtheader.header.it_pad = 0; 1860 {
1862 rtheader.header.it_len = GNUNET_htole16 (sizeof (rtheader)); 1861 case ARPHRD_IEEE80211_PRISM:
1863 rtheader.header.it_present = GNUNET_htole16 (IEEE80211_RADIOTAP_OUR_TRANSMISSION_HEADER_MASK); 1862 case ARPHRD_IEEE80211_FULL:
1864 rtheader.rate = header->rate; 1863 case ARPHRD_IEEE80211:
1865 rtheader.pad1 = 0; 1864 rtheader.header.it_version = 0;
1866 rtheader.txflags = GNUNET_htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ); 1865 rtheader.header.it_pad = 0;
1867 memcpy (write_pout.buf, &rtheader, sizeof (rtheader)); 1866 rtheader.header.it_len = GNUNET_htole16 (sizeof (rtheader));
1868 memcpy (&write_pout.buf[sizeof (rtheader)], &header->frame, sendsize); 1867 rtheader.header.it_present = GNUNET_htole16 (IEEE80211_RADIOTAP_OUR_TRANSMISSION_HEADER_MASK);
1869 wlanheader = (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) &write_pout.buf[sizeof (rtheader)]; 1868 rtheader.rate = header->rate;
1870 1869 rtheader.pad1 = 0;
1871 /* payload contains MAC address, but we don't trust it, so we'll 1870 rtheader.txflags = GNUNET_htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ);
1872 * overwrite it with OUR MAC address to prevent mischief */ 1871 memcpy (write_pout.buf, &rtheader, sizeof (rtheader));
1873 mac_set (wlanheader, dev); 1872 memcpy (&write_pout.buf[sizeof (rtheader)], &header->frame, sendsize);
1874 write_pout.size = sendsize + sizeof (rtheader); 1873 wlanheader = (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) &write_pout.buf[sizeof (rtheader)];
1874
1875 /* payload contains MAC address, but we don't trust it, so we'll
1876 * overwrite it with OUR MAC address to prevent mischief */
1877 mac_set (wlanheader, dev);
1878 write_pout.size = sendsize + sizeof (rtheader);
1879 break;
1880 case ARPHRD_ETHER:
1881 etheader.dst = header->frame.addr1;
1882 etheader.src = header->frame.addr2;
1883 etheader.type = htons (ETH_P_IP);
1884 memcpy (write_pout.buf, &etheader, sizeof (etheader));
1885 memcpy (&write_pout.buf[sizeof (etheader)], &header[1], sendsize - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame));
1886 write_pout.size = sendsize - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame) + sizeof (etheader);
1887 break;
1888 default:
1889 fprintf (stderr,
1890 "Unsupported ARPTYPE!\n");
1891 break;
1892 }
1875} 1893}
1876 1894
1877 1895