diff options
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 428 |
1 files changed, 171 insertions, 257 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 084fc611c..1dc2713ed 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -98,7 +98,8 @@ | |||
98 | #define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC 1 | 98 | #define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC 1 |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * LLC fields for better compatibility | 101 | * Link layer control fields for better compatibility |
102 | * (i.e. GNUnet over WLAN is not IP-over-WLAN). | ||
102 | */ | 103 | */ |
103 | #define WLAN_LLC_DSAP_FIELD 0x1f | 104 | #define WLAN_LLC_DSAP_FIELD 0x1f |
104 | #define WLAN_LLC_SSAP_FIELD 0x1f | 105 | #define WLAN_LLC_SSAP_FIELD 0x1f |
@@ -115,22 +116,6 @@ | |||
115 | #define IEEE80211_FC0_TYPE_CTL 0x04 | 116 | #define IEEE80211_FC0_TYPE_CTL 0x04 |
116 | #define IEEE80211_FC0_TYPE_DATA 0x08 | 117 | #define IEEE80211_FC0_TYPE_DATA 0x08 |
117 | 118 | ||
118 | GNUNET_NETWORK_STRUCT_BEGIN | ||
119 | |||
120 | /* | ||
121 | * generic definitions for IEEE 802.11 frames | ||
122 | */ | ||
123 | struct ieee80211_frame | ||
124 | { | ||
125 | u_int8_t i_fc[2]; | ||
126 | u_int8_t i_dur[2]; | ||
127 | u_int8_t i_addr1[IEEE80211_ADDR_LEN]; | ||
128 | u_int8_t i_addr2[IEEE80211_ADDR_LEN]; | ||
129 | u_int8_t i_addr3[IEEE80211_ADDR_LEN]; | ||
130 | u_int8_t i_seq[2]; | ||
131 | u_int8_t llc[4]; | ||
132 | } GNUNET_PACKED; | ||
133 | GNUNET_NETWORK_STRUCT_END | ||
134 | 119 | ||
135 | /** | 120 | /** |
136 | * Encapsulation of all of the state of the plugin. | 121 | * Encapsulation of all of the state of the plugin. |
@@ -248,10 +233,12 @@ struct Plugin | |||
248 | * messages ready for send, head | 233 | * messages ready for send, head |
249 | */ | 234 | */ |
250 | struct FragmentMessage_queue *sending_messages_head; | 235 | struct FragmentMessage_queue *sending_messages_head; |
236 | |||
251 | /** | 237 | /** |
252 | * messages ready for send, tail | 238 | * messages ready for send, tail |
253 | */ | 239 | */ |
254 | struct FragmentMessage_queue *sending_messages_tail; | 240 | struct FragmentMessage_queue *sending_messages_tail; |
241 | |||
255 | /** | 242 | /** |
256 | * time of the next "hello-beacon" | 243 | * time of the next "hello-beacon" |
257 | */ | 244 | */ |
@@ -291,7 +278,7 @@ struct Finish_send | |||
291 | /** | 278 | /** |
292 | * head of the next part to send to the helper | 279 | * head of the next part to send to the helper |
293 | */ | 280 | */ |
294 | char *head_of_next_write; | 281 | const char *head_of_next_write; |
295 | 282 | ||
296 | /** | 283 | /** |
297 | * Start of the message to send, needed for free | 284 | * Start of the message to send, needed for free |
@@ -400,6 +387,7 @@ struct PendingMessage | |||
400 | * dll next | 387 | * dll next |
401 | */ | 388 | */ |
402 | struct PendingMessage *next; | 389 | struct PendingMessage *next; |
390 | |||
403 | /** | 391 | /** |
404 | * dll prev | 392 | * dll prev |
405 | */ | 393 | */ |
@@ -434,6 +422,7 @@ struct PendingMessage | |||
434 | 422 | ||
435 | }; | 423 | }; |
436 | 424 | ||
425 | |||
437 | /** | 426 | /** |
438 | * Queue for acks to send for fragments recived | 427 | * Queue for acks to send for fragments recived |
439 | */ | 428 | */ |
@@ -444,33 +433,29 @@ struct AckSendQueue | |||
444 | * next ack in the ack send queue | 433 | * next ack in the ack send queue |
445 | */ | 434 | */ |
446 | struct AckSendQueue *next; | 435 | struct AckSendQueue *next; |
436 | |||
447 | /** | 437 | /** |
448 | * previous ack in the ack send queue | 438 | * previous ack in the ack send queue |
449 | */ | 439 | */ |
450 | struct AckSendQueue *prev; | 440 | struct AckSendQueue *prev; |
441 | |||
451 | /** | 442 | /** |
452 | * pointer to the session this ack belongs to | 443 | * pointer to the session this ack belongs to |
453 | */ | 444 | */ |
454 | struct MacEndpoint *endpoint; | 445 | struct MacEndpoint *endpoint; |
446 | |||
455 | /** | 447 | /** |
456 | * ID of message, to distinguish between the messages, picked randomly. | 448 | * ID of message, to distinguish between the messages, picked randomly. |
457 | */ | 449 | */ |
458 | uint32_t message_id; | 450 | uint32_t message_id; |
459 | 451 | ||
460 | /** | 452 | /** |
461 | * msg to send | 453 | * pointer to the radiotap header with the ACK Message. |
462 | */ | ||
463 | struct GNUNET_MessageHeader *hdr; | ||
464 | /** | ||
465 | * pointer to the ieee wlan header | ||
466 | */ | 454 | */ |
467 | struct ieee80211_frame *ieeewlanheader; | 455 | const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader; |
468 | /** | ||
469 | * pointer to the radiotap header | ||
470 | */ | ||
471 | struct Radiotap_Send *radioHeader; | ||
472 | }; | 456 | }; |
473 | 457 | ||
458 | |||
474 | /** | 459 | /** |
475 | * Session infos gathered from a messages | 460 | * Session infos gathered from a messages |
476 | */ | 461 | */ |
@@ -559,14 +544,17 @@ struct MacEndpoint | |||
559 | * Pointer to the global plugin struct. | 544 | * Pointer to the global plugin struct. |
560 | */ | 545 | */ |
561 | struct Plugin *plugin; | 546 | struct Plugin *plugin; |
547 | |||
562 | /** | 548 | /** |
563 | * Struct to hold the session reachable over this mac; head | 549 | * Struct to hold the session reachable over this mac; head |
564 | */ | 550 | */ |
565 | struct Sessionqueue *sessions_head; | 551 | struct Sessionqueue *sessions_head; |
552 | |||
566 | /** | 553 | /** |
567 | * Struct to hold the session reachable over this mac; tail | 554 | * Struct to hold the session reachable over this mac; tail |
568 | */ | 555 | */ |
569 | struct Sessionqueue *sessions_tail; | 556 | struct Sessionqueue *sessions_tail; |
557 | |||
570 | /** | 558 | /** |
571 | * Messages currently sending | 559 | * Messages currently sending |
572 | * to a peer, if any. | 560 | * to a peer, if any. |
@@ -578,10 +566,12 @@ struct MacEndpoint | |||
578 | * to a peer (tail), if any. | 566 | * to a peer (tail), if any. |
579 | */ | 567 | */ |
580 | struct FragmentMessage *sending_messages_tail; | 568 | struct FragmentMessage *sending_messages_tail; |
569 | |||
581 | /** | 570 | /** |
582 | * dll next | 571 | * dll next |
583 | */ | 572 | */ |
584 | struct MacEndpoint *next; | 573 | struct MacEndpoint *next; |
574 | |||
585 | /** | 575 | /** |
586 | * dll prev | 576 | * dll prev |
587 | */ | 577 | */ |
@@ -600,7 +590,6 @@ struct MacEndpoint | |||
600 | /** | 590 | /** |
601 | * count of messages in the fragment out queue for this mac endpoint | 591 | * count of messages in the fragment out queue for this mac endpoint |
602 | */ | 592 | */ |
603 | |||
604 | int fragment_messages_out_count; | 593 | int fragment_messages_out_count; |
605 | 594 | ||
606 | //TODO DOXIGEN | 595 | //TODO DOXIGEN |
@@ -672,38 +661,29 @@ struct FragmentMessage | |||
672 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | 661 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; |
673 | 662 | ||
674 | /** | 663 | /** |
675 | * Fragment to send | ||
676 | */ | ||
677 | char *frag; | ||
678 | |||
679 | /** | ||
680 | * size of message | ||
681 | */ | ||
682 | size_t size; | ||
683 | |||
684 | /** | ||
685 | * pointer to the ieee wlan header | ||
686 | */ | ||
687 | struct ieee80211_frame *ieeewlanheader; | ||
688 | /** | ||
689 | * pointer to the radiotap header | 664 | * pointer to the radiotap header |
690 | */ | 665 | */ |
691 | struct Radiotap_Send *radioHeader; | 666 | struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader; |
692 | }; | 667 | }; |
693 | 668 | ||
669 | |||
694 | static void | 670 | static void |
695 | do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 671 | do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
696 | 672 | ||
673 | |||
697 | static void | 674 | static void |
698 | free_session (struct Plugin *plugin, struct Sessionqueue *queue, | 675 | free_session (struct Plugin *plugin, struct Sessionqueue *queue, |
699 | int do_free_macendpoint); | 676 | int do_free_macendpoint); |
700 | 677 | ||
678 | |||
701 | static struct MacEndpoint * | 679 | static struct MacEndpoint * |
702 | create_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr); | 680 | create_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr); |
703 | 681 | ||
682 | |||
704 | static void | 683 | static void |
705 | finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 684 | finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
706 | 685 | ||
686 | |||
707 | /** | 687 | /** |
708 | * Generates a nice hexdump of a memory area. | 688 | * Generates a nice hexdump of a memory area. |
709 | * | 689 | * |
@@ -758,6 +738,7 @@ hexdump (const void *mem, unsigned length) | |||
758 | } | 738 | } |
759 | } | 739 | } |
760 | 740 | ||
741 | |||
761 | /** | 742 | /** |
762 | * Function to find a MacEndpoint with a specific mac addr | 743 | * Function to find a MacEndpoint with a specific mac addr |
763 | * @param plugin pointer to the plugin struct | 744 | * @param plugin pointer to the plugin struct |
@@ -787,9 +768,9 @@ get_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAd | |||
787 | { | 768 | { |
788 | return NULL; | 769 | return NULL; |
789 | } | 770 | } |
790 | |||
791 | } | 771 | } |
792 | 772 | ||
773 | |||
793 | /** | 774 | /** |
794 | * search for a session with the macendpoint and peer id | 775 | * search for a session with the macendpoint and peer id |
795 | * | 776 | * |
@@ -1227,7 +1208,7 @@ free_fragment_message (struct Plugin *plugin, struct FragmentMessage *fm) | |||
1227 | fmq = fmq_next; | 1208 | fmq = fmq_next; |
1228 | } | 1209 | } |
1229 | 1210 | ||
1230 | (session->mac->fragment_messages_out_count)--; | 1211 | session->mac->fragment_messages_out_count--; |
1231 | session->fragment_messages_out_count--; | 1212 | session->fragment_messages_out_count--; |
1232 | plugin->pending_Fragment_Messages--; | 1213 | plugin->pending_Fragment_Messages--; |
1233 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending fragments"), | 1214 | GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending fragments"), |
@@ -1240,27 +1221,30 @@ free_fragment_message (struct Plugin *plugin, struct FragmentMessage *fm) | |||
1240 | GNUNET_SCHEDULER_cancel (fm->timeout_task); | 1221 | GNUNET_SCHEDULER_cancel (fm->timeout_task); |
1241 | fm->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1222 | fm->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
1242 | } | 1223 | } |
1243 | |||
1244 | GNUNET_free (fm); | 1224 | GNUNET_free (fm); |
1245 | |||
1246 | queue_session (plugin, session); | 1225 | queue_session (plugin, session); |
1247 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1226 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1248 | "Free pending fragment messages %p, session %p\n", fm, | 1227 | "Free pending fragment messages %p, session %p\n", fm, |
1249 | session); | 1228 | session); |
1250 | } | 1229 | } |
1251 | 1230 | ||
1231 | |||
1252 | /** | 1232 | /** |
1253 | * function to fill the radiotap header | 1233 | * function to fill the radiotap header |
1234 | * | ||
1254 | * @param plugin pointer to the plugin struct | 1235 | * @param plugin pointer to the plugin struct |
1255 | * @param endpoint pointer to the endpoint | 1236 | * @param endpoint pointer to the endpoint |
1256 | * @param header pointer to the radiotap header | 1237 | * @param header pointer to the radiotap header |
1238 | * @param size total message size | ||
1257 | * @return GNUNET_YES at success | 1239 | * @return GNUNET_YES at success |
1258 | */ | 1240 | */ |
1259 | static int | 1241 | static int |
1260 | getRadiotapHeader (struct Plugin *plugin, struct MacEndpoint *endpoint, | 1242 | getRadiotapHeader (struct Plugin *plugin, struct MacEndpoint *endpoint, |
1261 | struct Radiotap_Send *header) | 1243 | struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header, |
1244 | uint16_t size) | ||
1262 | { | 1245 | { |
1263 | 1246 | header->header.type = ntohs (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA); | |
1247 | header->header.size = ntohs (size); | ||
1264 | if (endpoint != NULL) | 1248 | if (endpoint != NULL) |
1265 | { | 1249 | { |
1266 | header->rate = endpoint->rate; | 1250 | header->rate = endpoint->rate; |
@@ -1277,34 +1261,33 @@ getRadiotapHeader (struct Plugin *plugin, struct MacEndpoint *endpoint, | |||
1277 | return GNUNET_YES; | 1261 | return GNUNET_YES; |
1278 | } | 1262 | } |
1279 | 1263 | ||
1264 | |||
1280 | /** | 1265 | /** |
1281 | * function to generate the wlan hardware header for one packet | 1266 | * function to generate the wlan hardware header for one packet |
1282 | * @param Header address to write the header to | 1267 | * @param Header address to write the header to |
1283 | * @param to_mac_addr address of the recipient | 1268 | * @param to_mac_addr address of the recipient |
1284 | * @param plugin pointer to the plugin struct | 1269 | * @param plugin pointer to the plugin struct |
1285 | * @param size size of the whole packet, needed to calculate the time to send the packet | 1270 | * @param size size of the whole packet, needed to calculate the time to send the packet |
1271 | * FIXME: 'size' is initialized inconsistently throughout the code (sometimes payload, sometimes everything) | ||
1286 | * @return GNUNET_YES if there was no error | 1272 | * @return GNUNET_YES if there was no error |
1287 | */ | 1273 | */ |
1288 | static int | 1274 | static int |
1289 | getWlanHeader (struct ieee80211_frame *Header, | 1275 | getWlanHeader (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *Header, |
1290 | const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, struct Plugin *plugin, | 1276 | const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, struct Plugin *plugin, |
1291 | unsigned int size) | 1277 | unsigned int size) |
1292 | { | 1278 | { |
1293 | uint16_t *tmp16; | ||
1294 | const int rate = 11000000; | 1279 | const int rate = 11000000; |
1295 | 1280 | ||
1296 | Header->i_fc[0] = IEEE80211_FC0_TYPE_DATA; | 1281 | Header->frame_control = htons (IEEE80211_FC0_TYPE_DATA); // FIXME: check: might need to shift by 8? |
1297 | Header->i_fc[1] = 0x00; | 1282 | Header->addr1 = *to_mac_addr; |
1298 | memcpy (&Header->i_addr3, &mac_bssid_gnunet, sizeof (mac_bssid_gnunet)); | 1283 | Header->addr2 = plugin->mac_address; |
1299 | memcpy (&Header->i_addr2, plugin->mac_address.mac, | 1284 | Header->addr3 = mac_bssid_gnunet; |
1300 | sizeof (plugin->mac_address)); | 1285 | Header->duration = GNUNET_htole16 ((size * 1000000) / rate + 290); |
1301 | memcpy (&Header->i_addr1, to_mac_addr, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); | 1286 | Header->sequence_control = 0; // FIXME? |
1302 | |||
1303 | tmp16 = (uint16_t *) Header->i_dur; | ||
1304 | *tmp16 = (uint16_t) GNUNET_htole16 ((size * 1000000) / rate + 290); | ||
1305 | Header->llc[0] = WLAN_LLC_DSAP_FIELD; | 1287 | Header->llc[0] = WLAN_LLC_DSAP_FIELD; |
1306 | Header->llc[1] = WLAN_LLC_SSAP_FIELD; | 1288 | Header->llc[1] = WLAN_LLC_SSAP_FIELD; |
1307 | 1289 | Header->llc[2] = 0; // FIXME? | |
1290 | Header->llc[3] = 0; // FIXME? | ||
1308 | return GNUNET_YES; | 1291 | return GNUNET_YES; |
1309 | } | 1292 | } |
1310 | 1293 | ||
@@ -1317,39 +1300,28 @@ getWlanHeader (struct ieee80211_frame *Header, | |||
1317 | static void | 1300 | static void |
1318 | add_message_for_send (void *cls, const struct GNUNET_MessageHeader *hdr) | 1301 | add_message_for_send (void *cls, const struct GNUNET_MessageHeader *hdr) |
1319 | { | 1302 | { |
1320 | |||
1321 | struct FragmentMessage *fm = cls; | 1303 | struct FragmentMessage *fm = cls; |
1322 | struct FragmentMessage_queue *fmqueue; | 1304 | struct FragmentMessage_queue *fmqueue; |
1305 | struct MacEndpoint *endpoint; | ||
1306 | struct Plugin *plugin; | ||
1307 | uint16_t size; | ||
1323 | 1308 | ||
1324 | GNUNET_assert (cls != NULL); | 1309 | GNUNET_assert (cls != NULL); |
1325 | GNUNET_assert (fm->frag == NULL); | 1310 | endpoint = fm->session->mac; |
1326 | struct MacEndpoint *endpoint = fm->session->mac; | 1311 | plugin = endpoint->plugin; |
1327 | struct Plugin *plugin = endpoint->plugin; | ||
1328 | struct GNUNET_MessageHeader *msgheader; | ||
1329 | struct GNUNET_MessageHeader *msgheader2; | ||
1330 | uint16_t size; | ||
1331 | 1312 | ||
1332 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1313 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1333 | "Adding fragment of message %p to send, session %p, endpoint %p, type %u\n", | 1314 | "Adding fragment of message %p to send, session %p, endpoint %p, type %u\n", |
1334 | fm, fm->session, endpoint, hdr->type); | 1315 | fm, fm->session, endpoint, hdr->type); |
1335 | size = | 1316 | size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + ntohs (hdr->size); |
1336 | sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + | 1317 | fm->radioHeader = GNUNET_malloc (size); |
1337 | sizeof (struct ieee80211_frame) + ntohs (hdr->size); | 1318 | getRadiotapHeader (plugin, fm->session->mac, fm->radioHeader, size); |
1338 | fm->frag = GNUNET_malloc (size); | 1319 | getWlanHeader (&fm->radioHeader->frame, &(fm->session->mac->addr), plugin, |
1339 | fm->size = size; | 1320 | size); |
1340 | 1321 | memcpy (&fm->radioHeader[1], hdr, ntohs (hdr->size)); | |
1341 | msgheader = (struct GNUNET_MessageHeader *) fm->frag; | 1322 | // FIXME: yucky allocation structure! |
1342 | msgheader->size = htons (size); | ||
1343 | msgheader->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA); | ||
1344 | |||
1345 | fm->radioHeader = (struct Radiotap_Send *) &msgheader[1]; | ||
1346 | fm->ieeewlanheader = (struct ieee80211_frame *) &fm->radioHeader[1]; | ||
1347 | msgheader2 = (struct GNUNET_MessageHeader *) &fm->ieeewlanheader[1]; | ||
1348 | memcpy (msgheader2, hdr, ntohs (hdr->size)); | ||
1349 | |||
1350 | fmqueue = GNUNET_malloc (sizeof (struct FragmentMessage_queue)); | 1323 | fmqueue = GNUNET_malloc (sizeof (struct FragmentMessage_queue)); |
1351 | fmqueue->content = fm; | 1324 | fmqueue->content = fm; |
1352 | |||
1353 | GNUNET_CONTAINER_DLL_insert_tail (plugin->sending_messages_head, | 1325 | GNUNET_CONTAINER_DLL_insert_tail (plugin->sending_messages_head, |
1354 | plugin->sending_messages_tail, fmqueue); | 1326 | plugin->sending_messages_tail, fmqueue); |
1355 | set_next_send (plugin); | 1327 | set_next_send (plugin); |
@@ -1707,6 +1679,7 @@ finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1707 | } | 1679 | } |
1708 | } | 1680 | } |
1709 | 1681 | ||
1682 | |||
1710 | /** | 1683 | /** |
1711 | * function to send a hello beacon | 1684 | * function to send a hello beacon |
1712 | * @param plugin pointer to the plugin struct | 1685 | * @param plugin pointer to the plugin struct |
@@ -1717,47 +1690,26 @@ send_hello_beacon (struct Plugin *plugin) | |||
1717 | uint16_t size; | 1690 | uint16_t size; |
1718 | ssize_t bytes; | 1691 | ssize_t bytes; |
1719 | uint16_t hello_size; | 1692 | uint16_t hello_size; |
1720 | struct GNUNET_MessageHeader *msgheader; | 1693 | struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader; |
1721 | struct ieee80211_frame *ieeewlanheader; | ||
1722 | struct Radiotap_Send *radioHeader; | ||
1723 | struct GNUNET_MessageHeader *msgheader2; | ||
1724 | const struct GNUNET_MessageHeader *hello; | 1694 | const struct GNUNET_MessageHeader *hello; |
1725 | struct Finish_send *finish; | 1695 | struct Finish_send *finish; |
1726 | 1696 | ||
1697 | GNUNET_assert (plugin != NULL); | ||
1727 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1698 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1728 | "Sending hello beacon\n"); | 1699 | "Sending hello beacon\n"); |
1729 | |||
1730 | GNUNET_assert (plugin != NULL); | ||
1731 | |||
1732 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello beacons send"), | 1700 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello beacons send"), |
1733 | 1, GNUNET_NO); | 1701 | 1, GNUNET_NO); |
1734 | |||
1735 | hello = plugin->env->get_our_hello (); | 1702 | hello = plugin->env->get_our_hello (); |
1736 | hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); | 1703 | hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); |
1737 | GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU); | 1704 | GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU); |
1738 | size = | ||
1739 | sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + | ||
1740 | sizeof (struct ieee80211_frame) + hello_size; | ||
1741 | |||
1742 | msgheader = GNUNET_malloc (size); | ||
1743 | msgheader->size = htons (size); | ||
1744 | msgheader->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA); | ||
1745 | |||
1746 | radioHeader = (struct Radiotap_Send *) &msgheader[1]; | ||
1747 | getRadiotapHeader (plugin, NULL, radioHeader); | ||
1748 | ieeewlanheader = (struct ieee80211_frame *) &radioHeader[1]; | ||
1749 | getWlanHeader (ieeewlanheader, &bc_all_mac, plugin, size); | ||
1750 | |||
1751 | msgheader2 = (struct GNUNET_MessageHeader *) &ieeewlanheader[1]; | ||
1752 | /*msgheader2->size = | ||
1753 | * htons (GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello) + | ||
1754 | * sizeof (struct GNUNET_MessageHeader)); | ||
1755 | * | ||
1756 | * msgheader2->type = htons (GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT); */ | ||
1757 | memcpy (msgheader2, hello, hello_size); | ||
1758 | |||
1759 | bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, msgheader, size); | ||
1760 | 1705 | ||
1706 | size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size; | ||
1707 | radioHeader = GNUNET_malloc (size); | ||
1708 | getRadiotapHeader (plugin, NULL, radioHeader, size); | ||
1709 | getWlanHeader (&radioHeader->frame, &bc_all_mac, plugin, size); | ||
1710 | memcpy (&radioHeader[1], hello, hello_size); | ||
1711 | bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, radioHeader, size); | ||
1712 | GNUNET_free (radioHeader); | ||
1761 | if (bytes == GNUNET_SYSERR) | 1713 | if (bytes == GNUNET_SYSERR) |
1762 | { | 1714 | { |
1763 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, | 1715 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, |
@@ -1770,9 +1722,7 @@ send_hello_beacon (struct Plugin *plugin) | |||
1770 | finish->size = 0; | 1722 | finish->size = 0; |
1771 | finish->msgstart = NULL; | 1723 | finish->msgstart = NULL; |
1772 | restart_helper (plugin, finish); | 1724 | restart_helper (plugin, finish); |
1773 | |||
1774 | set_next_beacon_time (plugin); | 1725 | set_next_beacon_time (plugin); |
1775 | |||
1776 | } | 1726 | } |
1777 | else | 1727 | else |
1778 | { | 1728 | { |
@@ -1780,64 +1730,51 @@ send_hello_beacon (struct Plugin *plugin) | |||
1780 | set_next_beacon_time (plugin); | 1730 | set_next_beacon_time (plugin); |
1781 | set_next_send (plugin); | 1731 | set_next_send (plugin); |
1782 | } | 1732 | } |
1783 | GNUNET_free (msgheader); | ||
1784 | |||
1785 | |||
1786 | } | 1733 | } |
1787 | 1734 | ||
1735 | |||
1788 | /** | 1736 | /** |
1789 | * function to add an ack to send it for a received fragment | 1737 | * function to add an ack to send it for a received fragment |
1738 | * | ||
1790 | * @param cls MacEndpoint this ack belongs to | 1739 | * @param cls MacEndpoint this ack belongs to |
1791 | * @param msg_id id of the message | 1740 | * @param msg_id id of the message |
1792 | * @param hdr pointer to the hdr where the ack is stored | 1741 | * @param hdr pointer to the hdr where the ack is stored |
1793 | * | ||
1794 | */ | 1742 | */ |
1795 | static void | 1743 | static void |
1796 | add_ack_for_send (void *cls, uint32_t msg_id, | 1744 | add_ack_for_send (void *cls, uint32_t msg_id, |
1797 | const struct GNUNET_MessageHeader *hdr) | 1745 | const struct GNUNET_MessageHeader *hdr) |
1798 | { | 1746 | { |
1799 | |||
1800 | struct AckSendQueue *ack; | ||
1801 | |||
1802 | GNUNET_assert (cls != NULL); | ||
1803 | struct MacEndpoint *endpoint = cls; | 1747 | struct MacEndpoint *endpoint = cls; |
1804 | struct Plugin *plugin = endpoint->plugin; | 1748 | struct Plugin *plugin = endpoint->plugin; |
1749 | struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage* radioHeader; | ||
1750 | struct AckSendQueue *ack; | ||
1805 | struct GNUNET_MessageHeader *msgheader; | 1751 | struct GNUNET_MessageHeader *msgheader; |
1806 | struct GNUNET_MessageHeader *msgheader2; | ||
1807 | uint16_t size; | 1752 | uint16_t size; |
1808 | 1753 | ||
1809 | size = | 1754 | GNUNET_assert (endpoint != NULL); |
1810 | sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + | 1755 | size = sizeof (struct AckSendQueue) + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + ntohs (hdr->size); |
1811 | sizeof (struct ieee80211_frame) + ntohs (hdr->size) + | ||
1812 | sizeof (struct AckSendQueue); | ||
1813 | |||
1814 | ack = GNUNET_malloc (size); | 1756 | ack = GNUNET_malloc (size); |
1815 | ack->message_id = msg_id; | 1757 | ack->message_id = msg_id; |
1816 | ack->endpoint = endpoint; | 1758 | ack->endpoint = endpoint; |
1817 | 1759 | radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) &ack[1]; | |
1818 | size = | 1760 | ack->radioHeader = radioHeader; |
1819 | sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + | 1761 | getRadiotapHeader (plugin, ack->endpoint, radioHeader, size - sizeof (struct AckSendQueue)); |
1820 | sizeof (struct ieee80211_frame) + ntohs (hdr->size); | 1762 | size = ntohs (hdr->size); |
1821 | 1763 | getWlanHeader (&radioHeader->frame, | |
1822 | msgheader = (struct GNUNET_MessageHeader *) &ack[1]; | 1764 | &ack->endpoint->addr, |
1823 | ack->hdr = (struct GNUNET_MessageHeader *) &ack[1]; | 1765 | plugin, |
1824 | msgheader->size = htons (size); | 1766 | size); |
1825 | msgheader->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA); | 1767 | msgheader = (struct GNUNET_MessageHeader *) &radioHeader[1]; |
1826 | 1768 | memcpy (msgheader, hdr, size); | |
1827 | ack->radioHeader = (struct Radiotap_Send *) &msgheader[1]; | ||
1828 | ack->ieeewlanheader = (struct ieee80211_frame *) &(ack->radioHeader)[1]; | ||
1829 | msgheader2 = (struct GNUNET_MessageHeader *) &(ack->ieeewlanheader)[1]; | ||
1830 | memcpy (msgheader2, hdr, ntohs (hdr->size)); | ||
1831 | |||
1832 | GNUNET_CONTAINER_DLL_insert_tail (plugin->ack_send_queue_head, | 1769 | GNUNET_CONTAINER_DLL_insert_tail (plugin->ack_send_queue_head, |
1833 | plugin->ack_send_queue_tail, ack); | 1770 | plugin->ack_send_queue_tail, ack); |
1834 | |||
1835 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1771 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1836 | "Adding ack with message id %u to send, AckSendQueue %p, endpoint %p\n", | 1772 | "Adding ack with message id %u to send, AckSendQueue %p, endpoint %p\n", |
1837 | msg_id, ack, endpoint); | 1773 | msg_id, ack, endpoint); |
1838 | set_next_send (plugin); | 1774 | set_next_send (plugin); |
1839 | } | 1775 | } |
1840 | 1776 | ||
1777 | |||
1841 | /** | 1778 | /** |
1842 | * Function for the scheduler if a FragmentMessage times out | 1779 | * Function for the scheduler if a FragmentMessage times out |
1843 | * @param cls pointer to the FragmentMessage | 1780 | * @param cls pointer to the FragmentMessage |
@@ -1891,7 +1828,6 @@ check_fragment_queue (struct Plugin *plugin) | |||
1891 | fm = GNUNET_malloc (sizeof (struct FragmentMessage)); | 1828 | fm = GNUNET_malloc (sizeof (struct FragmentMessage)); |
1892 | fm->session = session; | 1829 | fm->session = session; |
1893 | fm->timeout.abs_value = pm->timeout.abs_value; | 1830 | fm->timeout.abs_value = pm->timeout.abs_value; |
1894 | fm->frag = NULL; | ||
1895 | fm->fragcontext = | 1831 | fm->fragcontext = |
1896 | GNUNET_FRAGMENT_context_create (plugin->env->stats, WLAN_MTU, | 1832 | GNUNET_FRAGMENT_context_create (plugin->env->stats, WLAN_MTU, |
1897 | &plugin->tracker, | 1833 | &plugin->tracker, |
@@ -1933,6 +1869,7 @@ check_fragment_queue (struct Plugin *plugin) | |||
1933 | set_next_send (plugin); | 1869 | set_next_send (plugin); |
1934 | } | 1870 | } |
1935 | 1871 | ||
1872 | |||
1936 | /** | 1873 | /** |
1937 | * Function to send an ack, does not free the ack | 1874 | * Function to send an ack, does not free the ack |
1938 | * @param plugin pointer to the plugin | 1875 | * @param plugin pointer to the plugin |
@@ -1940,27 +1877,21 @@ check_fragment_queue (struct Plugin *plugin) | |||
1940 | static void | 1877 | static void |
1941 | send_ack (struct Plugin *plugin) | 1878 | send_ack (struct Plugin *plugin) |
1942 | { | 1879 | { |
1943 | |||
1944 | ssize_t bytes; | 1880 | ssize_t bytes; |
1945 | struct AckSendQueue *ack; | 1881 | struct AckSendQueue *ack; |
1946 | struct Finish_send *finish; | 1882 | struct Finish_send *finish; |
1947 | 1883 | ||
1884 | GNUNET_assert (plugin != NULL); | ||
1948 | ack = plugin->ack_send_queue_head; | 1885 | ack = plugin->ack_send_queue_head; |
1949 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1886 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1950 | "Sending ack for message_id %u for mac endpoint %p, size %u\n", | 1887 | "Sending ack for message_id %u for mac endpoint %p, size %u\n", |
1951 | ack->message_id, ack->endpoint, | 1888 | ack->message_id, ack->endpoint, |
1952 | ntohs (ack->hdr->size) - sizeof (struct Radiotap_Send)); | 1889 | ntohs (ack->radioHeader->header.size)); |
1953 | GNUNET_assert (plugin != NULL); | ||
1954 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks send"), 1, | 1890 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks send"), 1, |
1955 | GNUNET_NO); | 1891 | GNUNET_NO); |
1956 | |||
1957 | getRadiotapHeader (plugin, ack->endpoint, ack->radioHeader); | ||
1958 | getWlanHeader (ack->ieeewlanheader, &ack->endpoint->addr, plugin, | ||
1959 | ntohs (ack->hdr->size)); | ||
1960 | |||
1961 | bytes = | 1892 | bytes = |
1962 | GNUNET_DISK_file_write (plugin->server_stdin_handle, ack->hdr, | 1893 | GNUNET_DISK_file_write (plugin->server_stdin_handle, ack->radioHeader, |
1963 | ntohs (ack->hdr->size)); | 1894 | ntohs (ack->radioHeader->header.size)); |
1964 | if (bytes == GNUNET_SYSERR) | 1895 | if (bytes == GNUNET_SYSERR) |
1965 | { | 1896 | { |
1966 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, | 1897 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, |
@@ -1973,17 +1904,16 @@ send_ack (struct Plugin *plugin) | |||
1973 | finish->size = 0; | 1904 | finish->size = 0; |
1974 | finish->msgstart = NULL; | 1905 | finish->msgstart = NULL; |
1975 | restart_helper (plugin, finish); | 1906 | restart_helper (plugin, finish); |
1907 | return; | ||
1976 | } | 1908 | } |
1977 | else | 1909 | GNUNET_assert (bytes == ntohs (ack->radioHeader->header.size)); |
1978 | { | 1910 | GNUNET_CONTAINER_DLL_remove (plugin->ack_send_queue_head, |
1979 | GNUNET_assert (bytes == ntohs (ack->hdr->size)); | 1911 | plugin->ack_send_queue_tail, ack); |
1980 | GNUNET_CONTAINER_DLL_remove (plugin->ack_send_queue_head, | 1912 | GNUNET_free (ack); |
1981 | plugin->ack_send_queue_tail, ack); | 1913 | set_next_send (plugin); |
1982 | GNUNET_free (ack); | ||
1983 | set_next_send (plugin); | ||
1984 | } | ||
1985 | } | 1914 | } |
1986 | 1915 | ||
1916 | |||
1987 | /** | 1917 | /** |
1988 | * Function called when wlan helper is ready to get some data | 1918 | * Function called when wlan helper is ready to get some data |
1989 | * | 1919 | * |
@@ -1994,104 +1924,89 @@ static void | |||
1994 | do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1924 | do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
1995 | { | 1925 | { |
1996 | struct Plugin *plugin = cls; | 1926 | struct Plugin *plugin = cls; |
1997 | |||
1998 | GNUNET_assert (plugin != NULL); | ||
1999 | |||
2000 | plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK; | ||
2001 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
2002 | return; | ||
2003 | |||
2004 | struct Session *session; | 1927 | struct Session *session; |
2005 | struct FragmentMessage *fm; | 1928 | struct FragmentMessage *fm; |
2006 | struct Finish_send *finish; | 1929 | struct Finish_send *finish; |
2007 | struct FragmentMessage_queue *fmq; | 1930 | struct FragmentMessage_queue *fmq; |
2008 | ssize_t bytes; | 1931 | ssize_t bytes; |
2009 | 1932 | ||
1933 | |||
1934 | GNUNET_assert (plugin != NULL); | ||
1935 | plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK; | ||
1936 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1937 | return; | ||
2010 | if (plugin->ack_send_queue_head != NULL) | 1938 | if (plugin->ack_send_queue_head != NULL) |
2011 | { | 1939 | { |
2012 | send_ack (plugin); | 1940 | send_ack (plugin); |
2013 | return; | 1941 | return; |
2014 | } | 1942 | } |
2015 | |||
2016 | //test if a "hello-beacon" has to be send | 1943 | //test if a "hello-beacon" has to be send |
2017 | if (GNUNET_TIME_absolute_get_remaining (plugin->beacon_time).rel_value == 0) | 1944 | if (GNUNET_TIME_absolute_get_remaining (plugin->beacon_time).rel_value == 0) |
2018 | { | 1945 | { |
2019 | send_hello_beacon (plugin); | 1946 | send_hello_beacon (plugin); |
2020 | return; | 1947 | return; |
2021 | } | 1948 | } |
2022 | 1949 | if (NULL == plugin->sending_messages_head) | |
2023 | if (plugin->sending_messages_head != NULL) | ||
2024 | { | 1950 | { |
2025 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan fragments send"), 1, | 1951 | /* do_transmit did nothing, should not happen */ |
2026 | GNUNET_NO); | 1952 | GNUNET_break (0); |
2027 | 1953 | set_next_send (plugin); | |
2028 | fmq = plugin->sending_messages_head; | 1954 | return; |
2029 | fm = fmq->content; | 1955 | } |
2030 | GNUNET_CONTAINER_DLL_remove (plugin->sending_messages_head, | 1956 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan fragments send"), 1, |
2031 | plugin->sending_messages_tail, fmq); | 1957 | GNUNET_NO); |
2032 | GNUNET_free (fmq); | 1958 | |
2033 | 1959 | fmq = plugin->sending_messages_head; | |
2034 | session = fm->session; | 1960 | fm = fmq->content; |
2035 | GNUNET_assert (session != NULL); | 1961 | GNUNET_CONTAINER_DLL_remove (plugin->sending_messages_head, |
2036 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 1962 | plugin->sending_messages_tail, fmq); |
2037 | "Sending GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT for fragment message %p, size: %u\n", | 1963 | GNUNET_free (fmq); |
2038 | fm, fm->size); | 1964 | |
2039 | getRadiotapHeader (plugin, session->mac, fm->radioHeader); | 1965 | session = fm->session; |
2040 | getWlanHeader (fm->ieeewlanheader, &(fm->session->mac->addr), plugin, | 1966 | GNUNET_assert (session != NULL); |
2041 | fm->size); | 1967 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2042 | 1968 | "Sending GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT for fragment message %p, size: %u\n", | |
2043 | bytes = | 1969 | fm, ntohs (fm->radioHeader->header.size)); |
2044 | GNUNET_DISK_file_write (plugin->server_stdin_handle, fm->frag, | 1970 | bytes = |
2045 | fm->size); | 1971 | GNUNET_DISK_file_write (plugin->server_stdin_handle, |
2046 | 1972 | fm->radioHeader, | |
2047 | 1973 | ntohs (fm->radioHeader->header.size)); | |
2048 | if (bytes != fm->size) | 1974 | if (bytes != ntohs (fm->radioHeader->header.size)) |
1975 | { | ||
1976 | finish = GNUNET_malloc (sizeof (struct Finish_send)); | ||
1977 | finish->plugin = plugin; | ||
1978 | finish->msgstart = &fm->radioHeader->header; | ||
1979 | GNUNET_assert (plugin->server_write_task == GNUNET_SCHEDULER_NO_TASK); | ||
1980 | if (bytes == GNUNET_SYSERR) | ||
2049 | { | 1981 | { |
2050 | finish = GNUNET_malloc (sizeof (struct Finish_send)); | 1982 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, |
2051 | finish->plugin = plugin; | 1983 | _ |
2052 | finish->msgstart = (struct GNUNET_MessageHeader *) fm->frag; | 1984 | ("Error writing to wlan helper. errno == %d, ERROR: %s\n"), |
2053 | GNUNET_assert (plugin->server_write_task == GNUNET_SCHEDULER_NO_TASK); | 1985 | errno, strerror (errno)); |
2054 | 1986 | finish->head_of_next_write = (char*) fm->radioHeader; | |
2055 | if (bytes == GNUNET_SYSERR) | 1987 | finish->size = ntohs (fm->radioHeader->header.size); |
2056 | { | 1988 | restart_helper (plugin, finish); |
2057 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, | ||
2058 | _ | ||
2059 | ("Error writing to wlan helper. errno == %d, ERROR: %s\n"), | ||
2060 | errno, strerror (errno)); | ||
2061 | |||
2062 | finish->head_of_next_write = fm->frag; | ||
2063 | finish->size = fm->size; | ||
2064 | restart_helper (plugin, finish); | ||
2065 | } | ||
2066 | else | ||
2067 | { | ||
2068 | finish->head_of_next_write = fm->frag + bytes; | ||
2069 | finish->size = fm->size - bytes; | ||
2070 | plugin->server_write_task = | ||
2071 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, | ||
2072 | plugin->server_stdin_handle, | ||
2073 | &finish_sending, finish); | ||
2074 | } | ||
2075 | |||
2076 | fm->frag = NULL; | ||
2077 | } | 1989 | } |
2078 | else | 1990 | else |
2079 | { | 1991 | { |
2080 | GNUNET_free (fm->frag); | 1992 | finish->head_of_next_write = ((char*) fm->radioHeader) + bytes; |
2081 | fm->frag = NULL; | 1993 | finish->size = ntohs (fm->radioHeader->header.size) - bytes; |
2082 | set_next_send (plugin); | 1994 | plugin->server_write_task = |
2083 | } | 1995 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, |
2084 | GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext); | 1996 | plugin->server_stdin_handle, |
2085 | return; | 1997 | &finish_sending, finish); |
1998 | } | ||
2086 | } | 1999 | } |
2087 | 2000 | else | |
2088 | #if 1 | 2001 | { |
2089 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2002 | GNUNET_free (fm->radioHeader); |
2090 | "do_transmit did nothing, should not happen!\n"); | 2003 | fm->radioHeader = NULL; |
2091 | #endif | 2004 | set_next_send (plugin); |
2092 | set_next_send (plugin); | 2005 | } |
2006 | GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext); | ||
2093 | } | 2007 | } |
2094 | 2008 | ||
2009 | |||
2095 | /** | 2010 | /** |
2096 | * Another peer has suggested an address for this | 2011 | * Another peer has suggested an address for this |
2097 | * peer and transport plugin. Check that this could be a valid | 2012 | * peer and transport plugin. Check that this could be a valid |
@@ -2846,12 +2761,12 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2846 | * @return string to a static buffer with the human-readable mac, will be overwritten during the next call to this function | 2761 | * @return string to a static buffer with the human-readable mac, will be overwritten during the next call to this function |
2847 | */ | 2762 | */ |
2848 | static const char * | 2763 | static const char * |
2849 | macprinter (const u_int8_t * mac) | 2764 | macprinter (const struct GNUNET_TRANSPORT_WLAN_MacAddress * mac) |
2850 | { | 2765 | { |
2851 | static char macstr[20]; | 2766 | static char macstr[20]; |
2852 | 2767 | ||
2853 | GNUNET_snprintf (macstr, sizeof (macstr), "%X:%X:%X:%X:%X:%X", mac[0], mac[1], | 2768 | GNUNET_snprintf (macstr, sizeof (macstr), "%2X:%2X:%2X:%2X:%2X:%2X", mac->mac[0], mac->mac[1], |
2854 | mac[2], mac[3], mac[4], mac[5]); | 2769 | mac->mac[2], mac->mac[3], mac->mac[4], mac->mac[5]); |
2855 | return macstr; | 2770 | return macstr; |
2856 | } | 2771 | } |
2857 | 2772 | ||
@@ -2938,9 +2853,9 @@ wlan_process_helper (void *cls, void *client, | |||
2938 | const struct GNUNET_MessageHeader *hdr) | 2853 | const struct GNUNET_MessageHeader *hdr) |
2939 | { | 2854 | { |
2940 | struct Plugin *plugin = cls; | 2855 | struct Plugin *plugin = cls; |
2941 | struct ieee80211_frame *wlanIeeeHeader = NULL; | 2856 | const struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *wlanIeeeHeader; |
2942 | struct Session_light *session_light = NULL; | 2857 | struct Session_light *session_light = NULL; |
2943 | struct Radiotap_rx *rxinfo; | 2858 | const struct Radiotap_rx *rxinfo; |
2944 | const struct GNUNET_MessageHeader *temp_hdr = NULL; | 2859 | const struct GNUNET_MessageHeader *temp_hdr = NULL; |
2945 | 2860 | ||
2946 | int datasize = 0; | 2861 | int datasize = 0; |
@@ -2958,40 +2873,40 @@ wlan_process_helper (void *cls, void *client, | |||
2958 | GNUNET_NO); | 2873 | GNUNET_NO); |
2959 | //call wlan_process_helper with the message inside, later with wlan: analyze signal | 2874 | //call wlan_process_helper with the message inside, later with wlan: analyze signal |
2960 | if (ntohs (hdr->size) < | 2875 | if (ntohs (hdr->size) < |
2961 | sizeof (struct ieee80211_frame) + | 2876 | sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame) + |
2962 | 2 * sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx)) | 2877 | 2 * sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx)) |
2963 | { | 2878 | { |
2964 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2879 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2965 | "Size of packet is too small; size: %u min size: %u\n", | 2880 | "Size of packet is too small; size: %u min size: %u\n", |
2966 | ntohs (hdr->size), | 2881 | ntohs (hdr->size), |
2967 | sizeof (struct ieee80211_frame) + | 2882 | sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame) + |
2968 | sizeof (struct GNUNET_MessageHeader)); | 2883 | sizeof (struct GNUNET_MessageHeader)); |
2969 | //GNUNET_break (0); | 2884 | //GNUNET_break (0); |
2970 | /* FIXME: restart SUID process */ | 2885 | /* FIXME: restart SUID process */ |
2971 | return; | 2886 | return; |
2972 | } | 2887 | } |
2973 | 2888 | ||
2974 | rxinfo = (struct Radiotap_rx *) &hdr[1]; | 2889 | rxinfo = (const struct Radiotap_rx *) &hdr[1]; |
2975 | wlanIeeeHeader = (struct ieee80211_frame *) &rxinfo[1]; | 2890 | wlanIeeeHeader = (const struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) &rxinfo[1]; |
2976 | 2891 | ||
2977 | //process only if it is an broadcast or for this computer both with the gnunet bssid | 2892 | //process only if it is an broadcast or for this computer both with the gnunet bssid |
2978 | 2893 | ||
2979 | //check for bssid | 2894 | //check for bssid |
2980 | if (memcmp | 2895 | if (memcmp |
2981 | (&(wlanIeeeHeader->i_addr3), &mac_bssid_gnunet, | 2896 | (&wlanIeeeHeader->addr3, &mac_bssid_gnunet, |
2982 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) | 2897 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) |
2983 | { | 2898 | { |
2984 | //check for broadcast or mac | 2899 | //check for broadcast or mac |
2985 | if ((memcmp | 2900 | if ((memcmp |
2986 | (&(wlanIeeeHeader->i_addr1), &bc_all_mac, | 2901 | (&wlanIeeeHeader->addr1, &bc_all_mac, |
2987 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) || | 2902 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) || |
2988 | (memcmp | 2903 | (memcmp |
2989 | (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address), | 2904 | (&wlanIeeeHeader->addr1, &(plugin->mac_address), |
2990 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)) | 2905 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)) |
2991 | { | 2906 | { |
2992 | //if packet is from us return | 2907 | //if packet is from us return |
2993 | if ((memcmp | 2908 | if ((memcmp |
2994 | (&(wlanIeeeHeader->i_addr2), &(plugin->mac_address), | 2909 | (&wlanIeeeHeader->addr2, &(plugin->mac_address), |
2995 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)) | 2910 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)) |
2996 | { | 2911 | { |
2997 | return; | 2912 | return; |
@@ -3000,12 +2915,11 @@ wlan_process_helper (void *cls, void *client, | |||
3000 | 2915 | ||
3001 | 2916 | ||
3002 | datasize = | 2917 | datasize = |
3003 | ntohs (hdr->size) - sizeof (struct ieee80211_frame) - | 2918 | ntohs (hdr->size) - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame) - |
3004 | sizeof (struct GNUNET_MessageHeader) - sizeof (struct Radiotap_rx); | 2919 | sizeof (struct GNUNET_MessageHeader) - sizeof (struct Radiotap_rx); |
3005 | 2920 | ||
3006 | session_light = GNUNET_malloc (sizeof (struct Session_light)); | 2921 | session_light = GNUNET_malloc (sizeof (struct Session_light)); |
3007 | memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2), | 2922 | session_light->addr = wlanIeeeHeader->addr2; |
3008 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); | ||
3009 | //session_light->session = search_session(plugin,session_light->addr); | 2923 | //session_light->session = search_session(plugin,session_light->addr); |
3010 | GNUNET_STATISTICS_update (plugin->env->stats, | 2924 | GNUNET_STATISTICS_update (plugin->env->stats, |
3011 | _("# wlan messages for this client received"), | 2925 | _("# wlan messages for this client received"), |
@@ -3040,14 +2954,14 @@ wlan_process_helper (void *cls, void *client, | |||
3040 | { | 2954 | { |
3041 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2955 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
3042 | "Func wlan_process_helper got wrong MAC: %s\n", | 2956 | "Func wlan_process_helper got wrong MAC: %s\n", |
3043 | macprinter (wlanIeeeHeader->i_addr1)); | 2957 | macprinter (&wlanIeeeHeader->addr1)); |
3044 | } | 2958 | } |
3045 | } | 2959 | } |
3046 | else | 2960 | else |
3047 | { | 2961 | { |
3048 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | 2962 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
3049 | "Func wlan_process_helper got wrong BSSID: %s\n", | 2963 | "Func wlan_process_helper got wrong BSSID: %s\n", |
3050 | macprinter (wlanIeeeHeader->i_addr2)); | 2964 | macprinter (&wlanIeeeHeader->addr2)); |
3051 | } | 2965 | } |
3052 | break; | 2966 | break; |
3053 | case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL: | 2967 | case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL: |