diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-12-11 15:31:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-12-11 15:31:47 +0000 |
commit | 2a80e31499ae4b7d2dcdbdcac7a3604c42b357f7 (patch) | |
tree | 4712323ff418b56ab05b714d6752322c9d7a9b36 /src/transport/plugin_transport_wlan.c | |
parent | f8ae79bdfd193320a1db1ff3ead82c5e19d5d4e6 (diff) | |
download | gnunet-2a80e31499ae4b7d2dcdbdcac7a3604c42b357f7.tar.gz gnunet-2a80e31499ae4b7d2dcdbdcac7a3604c42b357f7.zip |
-more minor cleanup
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 75 |
1 files changed, 3 insertions, 72 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index e2af0da36..d7b061d70 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -121,41 +121,6 @@ | |||
121 | #define IEEE80211_FC0_TYPE_DATA 0x08 | 121 | #define IEEE80211_FC0_TYPE_DATA 0x08 |
122 | 122 | ||
123 | /* | 123 | /* |
124 | * Structure of an internet header, naked of options. | ||
125 | */ | ||
126 | struct iph | ||
127 | { | ||
128 | #if __BYTE_ORDER == __LITTLE_ENDIAN | ||
129 | unsigned int ip_hl:4; /* header length */ | ||
130 | unsigned int ip_v:4; /* version */ | ||
131 | #endif | ||
132 | #if __BYTE_ORDER == __BIG_ENDIAN | ||
133 | unsigned int ip_v:4; /* version */ | ||
134 | unsigned int ip_hl:4; /* header length */ | ||
135 | #endif | ||
136 | u_int8_t ip_tos; /* type of service */ | ||
137 | u_short ip_len; /* total length */ | ||
138 | u_short ip_id; /* identification */ | ||
139 | u_short ip_off; /* fragment offset field */ | ||
140 | #define IP_RF 0x8000 /* reserved fragment flag */ | ||
141 | #define IP_DF 0x4000 /* dont fragment flag */ | ||
142 | #define IP_MF 0x2000 /* more fragments flag */ | ||
143 | #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ | ||
144 | u_int8_t ip_ttl; /* time to live */ | ||
145 | u_int8_t ip_p; /* protocol */ | ||
146 | u_short ip_sum; /* checksum */ | ||
147 | struct in_addr ip_src, ip_dst; /* source and dest address */ | ||
148 | }; | ||
149 | |||
150 | struct udphdr | ||
151 | { | ||
152 | u_int16_t source; | ||
153 | u_int16_t dest; | ||
154 | u_int16_t len; | ||
155 | u_int16_t check; | ||
156 | }; | ||
157 | |||
158 | /* | ||
159 | * generic definitions for IEEE 802.11 frames | 124 | * generic definitions for IEEE 802.11 frames |
160 | */ | 125 | */ |
161 | struct ieee80211_frame | 126 | struct ieee80211_frame |
@@ -167,10 +132,6 @@ struct ieee80211_frame | |||
167 | u_int8_t i_addr3[IEEE80211_ADDR_LEN]; | 132 | u_int8_t i_addr3[IEEE80211_ADDR_LEN]; |
168 | u_int8_t i_seq[2]; | 133 | u_int8_t i_seq[2]; |
169 | u_int8_t llc[4]; | 134 | u_int8_t llc[4]; |
170 | #if DEBUG_wlan_ip_udp_packets_on_air > 1 | ||
171 | struct iph ip; | ||
172 | struct udphdr udp; | ||
173 | #endif | ||
174 | } GNUNET_PACKED; | 135 | } GNUNET_PACKED; |
175 | 136 | ||
176 | /** | 137 | /** |
@@ -1344,7 +1305,7 @@ getWlanHeader (struct ieee80211_frame *Header, | |||
1344 | 1305 | ||
1345 | Header->i_fc[0] = IEEE80211_FC0_TYPE_DATA; | 1306 | Header->i_fc[0] = IEEE80211_FC0_TYPE_DATA; |
1346 | Header->i_fc[1] = 0x00; | 1307 | Header->i_fc[1] = 0x00; |
1347 | memcpy (&Header->i_addr3, &mac_bssid, sizeof (mac_bssid)); | 1308 | memcpy (&Header->i_addr3, &mac_bssid_gnunet, sizeof (mac_bssid_gnunet)); |
1348 | memcpy (&Header->i_addr2, plugin->mac_address.mac, | 1309 | memcpy (&Header->i_addr2, plugin->mac_address.mac, |
1349 | sizeof (plugin->mac_address)); | 1310 | sizeof (plugin->mac_address)); |
1350 | memcpy (&Header->i_addr1, to_mac_addr, sizeof (struct MacAddress)); | 1311 | memcpy (&Header->i_addr1, to_mac_addr, sizeof (struct MacAddress)); |
@@ -1354,36 +1315,6 @@ getWlanHeader (struct ieee80211_frame *Header, | |||
1354 | Header->llc[0] = WLAN_LLC_DSAP_FIELD; | 1315 | Header->llc[0] = WLAN_LLC_DSAP_FIELD; |
1355 | Header->llc[1] = WLAN_LLC_SSAP_FIELD; | 1316 | Header->llc[1] = WLAN_LLC_SSAP_FIELD; |
1356 | 1317 | ||
1357 | #if DEBUG_wlan_ip_udp_packets_on_air > 1 | ||
1358 | uint crc = 0; | ||
1359 | uint16_t *x; | ||
1360 | int count; | ||
1361 | |||
1362 | Header->ip.ip_dst.s_addr = *((uint32_t *) & to_mac_addr->mac[2]); | ||
1363 | Header->ip.ip_src.s_addr = *((uint32_t *) & plugin->mac_address.mac[2]); | ||
1364 | Header->ip.ip_v = 4; | ||
1365 | Header->ip.ip_hl = 5; | ||
1366 | Header->ip.ip_p = 17; | ||
1367 | Header->ip.ip_ttl = 1; | ||
1368 | Header->ip.ip_len = htons (size + 8); | ||
1369 | Header->ip.ip_sum = 0; | ||
1370 | x = (uint16_t *) & Header->ip; | ||
1371 | count = sizeof (struct iph); | ||
1372 | while (count > 1) | ||
1373 | { | ||
1374 | /* This is the inner loop */ | ||
1375 | crc += (unsigned short) *x++; | ||
1376 | count -= 2; | ||
1377 | } | ||
1378 | /* Add left-over byte, if any */ | ||
1379 | if (count > 0) | ||
1380 | crc += *(unsigned char *) x; | ||
1381 | crc = (crc & 0xffff) + (crc >> 16); | ||
1382 | Header->ip.ip_sum = htons (~(unsigned short) crc); | ||
1383 | Header->udp.len = htons (size - sizeof (struct ieee80211_frame)); | ||
1384 | |||
1385 | #endif | ||
1386 | |||
1387 | return GNUNET_YES; | 1318 | return GNUNET_YES; |
1388 | } | 1319 | } |
1389 | 1320 | ||
@@ -3124,7 +3055,7 @@ wlan_process_helper (void *cls, void *client, | |||
3124 | 3055 | ||
3125 | //check for bssid | 3056 | //check for bssid |
3126 | if (memcmp | 3057 | if (memcmp |
3127 | (&(wlanIeeeHeader->i_addr3), &mac_bssid, | 3058 | (&(wlanIeeeHeader->i_addr3), &mac_bssid_gnunet, |
3128 | sizeof (struct MacAddress)) == 0) | 3059 | sizeof (struct MacAddress)) == 0) |
3129 | { | 3060 | { |
3130 | //check for broadcast or mac | 3061 | //check for broadcast or mac |
@@ -3204,7 +3135,7 @@ wlan_process_helper (void *cls, void *client, | |||
3204 | break; | 3135 | break; |
3205 | case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL: | 3136 | case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL: |
3206 | //TODO more control messages | 3137 | //TODO more control messages |
3207 | if (ntohs (hdr->size) != sizeof (struct Wlan_Helper_Control_Message)) | 3138 | if (ntohs (hdr->size) != sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage)) |
3208 | { | 3139 | { |
3209 | GNUNET_break (0); | 3140 | GNUNET_break (0); |
3210 | /* FIXME: restart SUID process */ | 3141 | /* FIXME: restart SUID process */ |