aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_wlan.c
diff options
context:
space:
mode:
authorDavid Brodski <david@brodski.eu>2011-09-14 15:17:22 +0000
committerDavid Brodski <david@brodski.eu>2011-09-14 15:17:22 +0000
commitc9e58a448ef96bf6eecae21cafc82b64ef551662 (patch)
treeb535522241380a618e76da5b6029cdf437fe1de3 /src/transport/plugin_transport_wlan.c
parent5f6bac4a191655d892ad2f04785647a96337da6b (diff)
downloadgnunet-c9e58a448ef96bf6eecae21cafc82b64ef551662.tar.gz
gnunet-c9e58a448ef96bf6eecae21cafc82b64ef551662.zip
Fixed wlan beacon, added llc protocol for better compatibility.
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r--src/transport/plugin_transport_wlan.c55
1 files changed, 36 insertions, 19 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 6d06b1af1..63ca85fe0 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -49,7 +49,7 @@
49/** 49/**
50 * Max size of packet 50 * Max size of packet
51 */ 51 */
52#define WLAN_MTU 1450 52#define WLAN_MTU 1430
53 53
54/** 54/**
55 * time out of a session 55 * time out of a session
@@ -89,6 +89,12 @@
89 */ 89 */
90#define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC 1 90#define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC 1
91 91
92/**
93 * LLC fields for better compatibility
94 */
95#define WLAN_LLC_DSAP_FIELD 0xf
96#define WLAN_LLC_SSAP_FIELD 0xf
97
92 98
93/** 99/**
94 * DEBUG switch 100 * DEBUG switch
@@ -156,8 +162,8 @@ struct ieee80211_frame
156 u_int8_t i_addr2[IEEE80211_ADDR_LEN]; 162 u_int8_t i_addr2[IEEE80211_ADDR_LEN];
157 u_int8_t i_addr3[IEEE80211_ADDR_LEN]; 163 u_int8_t i_addr3[IEEE80211_ADDR_LEN];
158 u_int8_t i_seq[2]; 164 u_int8_t i_seq[2];
159#if DEBUG_wlan_ip_udp_packets_on_air
160 u_int8_t llc[4]; 165 u_int8_t llc[4];
166#if DEBUG_wlan_ip_udp_packets_on_air
161 struct iph ip; 167 struct iph ip;
162 struct udphdr udp; 168 struct udphdr udp;
163#endif 169#endif
@@ -1086,16 +1092,24 @@ get_next_queue_session (struct Plugin *plugin)
1086 GNUNET_assert (session != NULL); 1092 GNUNET_assert (session != NULL);
1087 pm = session->pending_message_head; 1093 pm = session->pending_message_head;
1088 1094
1089#if DEBUG_wlan
1090 if (pm == NULL) 1095 if (pm == NULL)
1091 { 1096 {
1092 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, 1097#if DEBUG_wlan
1093 "pending message is empty, should not happen. session %p\n", 1098 GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
1094 session); 1099 "pending message is empty, should not happen. session %p\n",
1095 } 1100 session);
1096#endif 1101#endif
1102 sessionqueue_alt = sessionqueue;
1103 sessionqueue = sessionqueue->next;
1104 plugin->pendingsessions--;
1105 GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head,
1106 plugin->pending_Sessions_tail,
1107 sessionqueue_alt);
1108
1109 GNUNET_free (sessionqueue_alt);
1110 continue;
1097 1111
1098 GNUNET_assert (pm != NULL); 1112 }
1099 1113
1100 //check for message timeout 1114 //check for message timeout
1101 if (GNUNET_TIME_absolute_get_remaining (pm->timeout).rel_value > 0) 1115 if (GNUNET_TIME_absolute_get_remaining (pm->timeout).rel_value > 0)
@@ -1248,6 +1262,8 @@ getWlanHeader (struct ieee80211_frame *Header,
1248 1262
1249 tmp16 = (uint16_t *) Header->i_dur; 1263 tmp16 = (uint16_t *) Header->i_dur;
1250 *tmp16 = (uint16_t) htole16 ((size * 1000000) / rate + 290); 1264 *tmp16 = (uint16_t) htole16 ((size * 1000000) / rate + 290);
1265 Header->llc[0] = WLAN_LLC_DSAP_FIELD;
1266 Header->llc[1] = WLAN_LLC_SSAP_FIELD;
1251 1267
1252#if DEBUG_wlan_ip_udp_packets_on_air 1268#if DEBUG_wlan_ip_udp_packets_on_air
1253 uint crc = 0; 1269 uint crc = 0;
@@ -1275,8 +1291,6 @@ getWlanHeader (struct ieee80211_frame *Header,
1275 crc += *(unsigned char *) x; 1291 crc += *(unsigned char *) x;
1276 crc = (crc & 0xffff) + (crc >> 16); 1292 crc = (crc & 0xffff) + (crc >> 16);
1277 Header->ip.ip_sum = htons (~(unsigned short) crc); 1293 Header->ip.ip_sum = htons (~(unsigned short) crc);
1278 Header->llc[0] = 6;
1279 Header->llc[1] = 6;
1280 Header->udp.len = htons (size - sizeof (struct ieee80211_frame)); 1294 Header->udp.len = htons (size - sizeof (struct ieee80211_frame));
1281 1295
1282#endif 1296#endif
@@ -2592,13 +2606,17 @@ wlan_process_helper (void *cls, void *client,
2592 sizeof (struct MacAddress)) == 0) 2606 sizeof (struct MacAddress)) == 0)
2593 { 2607 {
2594 //check for broadcast or mac 2608 //check for broadcast or mac
2595 if (memcmp 2609 if ((memcmp
2596 (&(wlanIeeeHeader->i_addr1), &bc_all_mac, 2610 (&(wlanIeeeHeader->i_addr1), &bc_all_mac,
2597 sizeof (struct MacAddress) == 0) || 2611 sizeof (struct MacAddress)) == 0) ||
2598 memcmp (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address), 2612 (memcmp (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address),
2599 sizeof (struct MacAddress)) == 0) 2613 sizeof (struct MacAddress)) == 0))
2600 { 2614 {
2601 2615 //if packet is from us return
2616 if ((memcmp (&(wlanIeeeHeader->i_addr2), &(plugin->mac_address),
2617 sizeof (struct MacAddress)) == 0)){
2618 return;
2619 }
2602 // process the inner data 2620 // process the inner data
2603 2621
2604 2622
@@ -2983,10 +3001,9 @@ libgnunet_plugin_transport_wlan_init (void *cls)
2983 } 3001 }
2984 3002
2985 //start the plugin 3003 //start the plugin
2986 set_next_beacon_time (plugin);
2987
2988 wlan_transport_start_wlan_helper (plugin, testmode); 3004 wlan_transport_start_wlan_helper (plugin, testmode);
2989 3005 set_next_beacon_time (plugin);
3006 set_next_send(plugin);
2990#if DEBUG_wlan 3007#if DEBUG_wlan
2991 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 3008 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2992 "wlan init finished\n"); 3009 "wlan init finished\n");