diff options
Diffstat (limited to 'src/transport/plugin_transport_bluetooth.c')
-rw-r--r-- | src/transport/plugin_transport_bluetooth.c | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/src/transport/plugin_transport_bluetooth.c b/src/transport/plugin_transport_bluetooth.c index a6b73c494..5ea439310 100644 --- a/src/transport/plugin_transport_bluetooth.c +++ b/src/transport/plugin_transport_bluetooth.c | |||
@@ -81,7 +81,7 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
81 | /** | 81 | /** |
82 | * Header for messages which need fragmentation. This is the format of | 82 | * Header for messages which need fragmentation. This is the format of |
83 | * a message we obtain AFTER defragmentation. We then need to check | 83 | * a message we obtain AFTER defragmentation. We then need to check |
84 | * the CRC and then tokenize the payload and pass it to the | 84 | * the CRC and then tokenize the payload and pass it to the |
85 | * 'receive' callback. | 85 | * 'receive' callback. |
86 | */ | 86 | */ |
87 | struct WlanHeader | 87 | struct WlanHeader |
@@ -397,7 +397,7 @@ struct Plugin | |||
397 | 397 | ||
398 | /** | 398 | /** |
399 | * Handle to helper process for priviledged operations. | 399 | * Handle to helper process for priviledged operations. |
400 | */ | 400 | */ |
401 | struct GNUNET_HELPER_Handle *suid_helper; | 401 | struct GNUNET_HELPER_Handle *suid_helper; |
402 | 402 | ||
403 | /** | 403 | /** |
@@ -559,7 +559,7 @@ get_radiotap_header (struct MacEndpoint *endpoint, | |||
559 | static void | 559 | static void |
560 | get_wlan_header (struct Plugin *plugin, | 560 | get_wlan_header (struct Plugin *plugin, |
561 | struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *header, | 561 | struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *header, |
562 | const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, | 562 | const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, |
563 | unsigned int size) | 563 | unsigned int size) |
564 | { | 564 | { |
565 | const int rate = 11000000; | 565 | const int rate = 11000000; |
@@ -599,12 +599,12 @@ send_ack (void *cls, uint32_t msg_id, | |||
599 | GNUNET_break (0); | 599 | GNUNET_break (0); |
600 | return; | 600 | return; |
601 | } | 601 | } |
602 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 602 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
603 | "Sending ACK to helper\n"); | 603 | "Sending ACK to helper\n"); |
604 | radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf; | 604 | radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf; |
605 | get_radiotap_header (endpoint, radio_header, size); | 605 | get_radiotap_header (endpoint, radio_header, size); |
606 | get_wlan_header (endpoint->plugin, | 606 | get_wlan_header (endpoint->plugin, |
607 | &radio_header->frame, | 607 | &radio_header->frame, |
608 | &endpoint->addr.mac, | 608 | &endpoint->addr.mac, |
609 | size); | 609 | size); |
610 | memcpy (&radio_header[1], hdr, msize); | 610 | memcpy (&radio_header[1], hdr, msize); |
@@ -612,7 +612,7 @@ send_ack (void *cls, uint32_t msg_id, | |||
612 | GNUNET_HELPER_send (endpoint->plugin->suid_helper, | 612 | GNUNET_HELPER_send (endpoint->plugin->suid_helper, |
613 | &radio_header->header, | 613 | &radio_header->header, |
614 | GNUNET_NO /* dropping ACKs is bad */, | 614 | GNUNET_NO /* dropping ACKs is bad */, |
615 | NULL, NULL)) | 615 | NULL, NULL)) |
616 | GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# Bluetooth ACKs sent"), | 616 | GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# Bluetooth ACKs sent"), |
617 | 1, GNUNET_NO); | 617 | 1, GNUNET_NO); |
618 | } | 618 | } |
@@ -636,7 +636,7 @@ bluetooth_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hd | |||
636 | GNUNET_NO); | 636 | GNUNET_NO); |
637 | mas.session = NULL; | 637 | mas.session = NULL; |
638 | mas.endpoint = endpoint; | 638 | mas.endpoint = endpoint; |
639 | (void) GNUNET_SERVER_mst_receive (plugin->fragment_data_tokenizer, | 639 | (void) GNUNET_SERVER_mst_receive (plugin->fragment_data_tokenizer, |
640 | &mas, | 640 | &mas, |
641 | (const char *) hdr, | 641 | (const char *) hdr, |
642 | ntohs (hdr->size), | 642 | ntohs (hdr->size), |
@@ -654,7 +654,7 @@ free_session (struct Session *session) | |||
654 | { | 654 | { |
655 | struct MacEndpoint *endpoint = session->mac; | 655 | struct MacEndpoint *endpoint = session->mac; |
656 | struct PendingMessage *pm; | 656 | struct PendingMessage *pm; |
657 | 657 | ||
658 | endpoint->plugin->env->session_end (endpoint->plugin->env->cls, | 658 | endpoint->plugin->env->session_end (endpoint->plugin->env->cls, |
659 | &session->target, | 659 | &session->target, |
660 | session); | 660 | session); |
@@ -670,7 +670,7 @@ free_session (struct Session *session) | |||
670 | GNUNET_free (pm->msg); | 670 | GNUNET_free (pm->msg); |
671 | GNUNET_free (pm); | 671 | GNUNET_free (pm); |
672 | } | 672 | } |
673 | GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, | 673 | GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, |
674 | endpoint->sessions_tail, | 674 | endpoint->sessions_tail, |
675 | session); | 675 | session); |
676 | if (session->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 676 | if (session->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -698,7 +698,7 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
698 | 698 | ||
699 | session->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 699 | session->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
700 | timeout = GNUNET_TIME_absolute_get_remaining (session->timeout); | 700 | timeout = GNUNET_TIME_absolute_get_remaining (session->timeout); |
701 | if (0 == timeout.rel_value_us) | 701 | if (0 == timeout.rel_value_us) |
702 | { | 702 | { |
703 | free_session (session); | 703 | free_session (session); |
704 | return; | 704 | return; |
@@ -739,7 +739,7 @@ create_session (struct MacEndpoint *endpoint, | |||
739 | session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 739 | session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
740 | session->timeout_task = | 740 | session->timeout_task = |
741 | GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, session); | 741 | GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, session); |
742 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 742 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
743 | "Created new session for peer `%s' with endpoint %s\n", | 743 | "Created new session for peer `%s' with endpoint %s\n", |
744 | GNUNET_i2s (peer), | 744 | GNUNET_i2s (peer), |
745 | mac_to_string (&endpoint->addr.mac)); | 745 | mac_to_string (&endpoint->addr.mac)); |
@@ -752,7 +752,7 @@ create_session (struct MacEndpoint *endpoint, | |||
752 | * message to the SUID helper process and we are thus ready for | 752 | * message to the SUID helper process and we are thus ready for |
753 | * the next fragment. | 753 | * the next fragment. |
754 | * | 754 | * |
755 | * @param cls the 'struct FragmentMessage' | 755 | * @param cls the 'struct FragmentMessage' |
756 | * @param result result of the operation (GNUNET_OK on success, GNUNET_NO if the helper died, GNUNET_SYSERR | 756 | * @param result result of the operation (GNUNET_OK on success, GNUNET_NO if the helper died, GNUNET_SYSERR |
757 | * if the helper was stopped) | 757 | * if the helper was stopped) |
758 | */ | 758 | */ |
@@ -772,7 +772,7 @@ fragment_transmission_done (void *cls, | |||
772 | * Transmit a fragment of a message. | 772 | * Transmit a fragment of a message. |
773 | * | 773 | * |
774 | * @param cls 'struct FragmentMessage' this fragment message belongs to | 774 | * @param cls 'struct FragmentMessage' this fragment message belongs to |
775 | * @param hdr pointer to the start of the fragment message | 775 | * @param hdr pointer to the start of the fragment message |
776 | */ | 776 | */ |
777 | static void | 777 | static void |
778 | transmit_fragment (void *cls, | 778 | transmit_fragment (void *cls, |
@@ -792,7 +792,7 @@ transmit_fragment (void *cls, | |||
792 | radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf; | 792 | radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf; |
793 | get_radiotap_header (endpoint, radio_header, size); | 793 | get_radiotap_header (endpoint, radio_header, size); |
794 | get_wlan_header (endpoint->plugin, | 794 | get_wlan_header (endpoint->plugin, |
795 | &radio_header->frame, | 795 | &radio_header->frame, |
796 | &endpoint->addr.mac, | 796 | &endpoint->addr.mac, |
797 | size); | 797 | size); |
798 | memcpy (&radio_header[1], hdr, msize); | 798 | memcpy (&radio_header[1], hdr, msize); |
@@ -827,7 +827,7 @@ free_fragment_message (struct FragmentMessage *fm) | |||
827 | { | 827 | { |
828 | struct MacEndpoint *endpoint = fm->macendpoint; | 828 | struct MacEndpoint *endpoint = fm->macendpoint; |
829 | 829 | ||
830 | GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# Bluetooth messages pending (with fragmentation)"), | 830 | GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# Bluetooth messages pending (with fragmentation)"), |
831 | -1, GNUNET_NO); | 831 | -1, GNUNET_NO); |
832 | GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head, | 832 | GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head, |
833 | endpoint->sending_messages_tail, fm); | 833 | endpoint->sending_messages_tail, fm); |
@@ -887,7 +887,7 @@ fragmentmessage_timeout (void *cls, | |||
887 | static void | 887 | static void |
888 | send_with_fragmentation (struct MacEndpoint *endpoint, | 888 | send_with_fragmentation (struct MacEndpoint *endpoint, |
889 | struct GNUNET_TIME_Relative timeout, | 889 | struct GNUNET_TIME_Relative timeout, |
890 | const struct GNUNET_PeerIdentity *target, | 890 | const struct GNUNET_PeerIdentity *target, |
891 | const struct GNUNET_MessageHeader *msg, | 891 | const struct GNUNET_MessageHeader *msg, |
892 | size_t payload_size, | 892 | size_t payload_size, |
893 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | 893 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
@@ -914,7 +914,7 @@ send_with_fragmentation (struct MacEndpoint *endpoint, | |||
914 | msg, | 914 | msg, |
915 | &transmit_fragment, fm); | 915 | &transmit_fragment, fm); |
916 | fm->timeout_task = | 916 | fm->timeout_task = |
917 | GNUNET_SCHEDULER_add_delayed (timeout, | 917 | GNUNET_SCHEDULER_add_delayed (timeout, |
918 | &fragmentmessage_timeout, fm); | 918 | &fragmentmessage_timeout, fm); |
919 | GNUNET_CONTAINER_DLL_insert_tail (endpoint->sending_messages_head, | 919 | GNUNET_CONTAINER_DLL_insert_tail (endpoint->sending_messages_head, |
920 | endpoint->sending_messages_tail, | 920 | endpoint->sending_messages_tail, |
@@ -924,7 +924,7 @@ send_with_fragmentation (struct MacEndpoint *endpoint, | |||
924 | 924 | ||
925 | /** | 925 | /** |
926 | * Free a MAC endpoint. | 926 | * Free a MAC endpoint. |
927 | * | 927 | * |
928 | * @param endpoint pointer to the MacEndpoint to free | 928 | * @param endpoint pointer to the MacEndpoint to free |
929 | */ | 929 | */ |
930 | static void | 930 | static void |
@@ -940,8 +940,8 @@ free_macendpoint (struct MacEndpoint *endpoint) | |||
940 | free_session (session); | 940 | free_session (session); |
941 | while (NULL != (fm = endpoint->sending_messages_head)) | 941 | while (NULL != (fm = endpoint->sending_messages_head)) |
942 | free_fragment_message (fm); | 942 | free_fragment_message (fm); |
943 | GNUNET_CONTAINER_DLL_remove (plugin->mac_head, | 943 | GNUNET_CONTAINER_DLL_remove (plugin->mac_head, |
944 | plugin->mac_tail, | 944 | plugin->mac_tail, |
945 | endpoint); | 945 | endpoint); |
946 | 946 | ||
947 | if (NULL != endpoint->defrag) | 947 | if (NULL != endpoint->defrag) |
@@ -974,7 +974,7 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
974 | 974 | ||
975 | endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 975 | endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
976 | timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout); | 976 | timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout); |
977 | if (0 == timeout.rel_value_us) | 977 | if (0 == timeout.rel_value_us) |
978 | { | 978 | { |
979 | free_macendpoint (endpoint); | 979 | free_macendpoint (endpoint); |
980 | return; | 980 | return; |
@@ -1000,14 +1000,14 @@ create_macendpoint (struct Plugin *plugin, | |||
1000 | 1000 | ||
1001 | for (pos = plugin->mac_head; NULL != pos; pos = pos->next) | 1001 | for (pos = plugin->mac_head; NULL != pos; pos = pos->next) |
1002 | if (0 == memcmp (addr, &pos->addr, sizeof (struct WlanAddress))) | 1002 | if (0 == memcmp (addr, &pos->addr, sizeof (struct WlanAddress))) |
1003 | return pos; | 1003 | return pos; |
1004 | pos = GNUNET_malloc (sizeof (struct MacEndpoint)); | 1004 | pos = GNUNET_malloc (sizeof (struct MacEndpoint)); |
1005 | pos->addr = *addr; | 1005 | pos->addr = *addr; |
1006 | pos->plugin = plugin; | 1006 | pos->plugin = plugin; |
1007 | pos->defrag = | 1007 | pos->defrag = |
1008 | GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU, | 1008 | GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU, |
1009 | MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, | 1009 | MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, |
1010 | pos, | 1010 | pos, |
1011 | &bluetooth_data_message_handler, | 1011 | &bluetooth_data_message_handler, |
1012 | &send_ack); | 1012 | &send_ack); |
1013 | 1013 | ||
@@ -1022,7 +1022,7 @@ create_macendpoint (struct Plugin *plugin, | |||
1022 | plugin->mac_count++; | 1022 | plugin->mac_count++; |
1023 | GNUNET_STATISTICS_update (plugin->env->stats, _("# Bluetooth MAC endpoints allocated"), | 1023 | GNUNET_STATISTICS_update (plugin->env->stats, _("# Bluetooth MAC endpoints allocated"), |
1024 | 1, GNUNET_NO); | 1024 | 1, GNUNET_NO); |
1025 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1025 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1026 | "New MAC endpoint `%s'\n", | 1026 | "New MAC endpoint `%s'\n", |
1027 | bluetooth_plugin_address_to_string(NULL, addr, sizeof (struct WlanAddress))); | 1027 | bluetooth_plugin_address_to_string(NULL, addr, sizeof (struct WlanAddress))); |
1028 | return pos; | 1028 | return pos; |
@@ -1142,7 +1142,7 @@ bluetooth_plugin_send (void *cls, | |||
1142 | size_t size = msgbuf_size + sizeof (struct WlanHeader); | 1142 | size_t size = msgbuf_size + sizeof (struct WlanHeader); |
1143 | char buf[size] GNUNET_ALIGN; | 1143 | char buf[size] GNUNET_ALIGN; |
1144 | 1144 | ||
1145 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1145 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1146 | "Transmitting %u bytes of payload to peer `%s' (starting with %u byte message of type %u)\n", | 1146 | "Transmitting %u bytes of payload to peer `%s' (starting with %u byte message of type %u)\n", |
1147 | msgbuf_size, | 1147 | msgbuf_size, |
1148 | GNUNET_i2s (&session->target), | 1148 | GNUNET_i2s (&session->target), |
@@ -1202,7 +1202,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1202 | switch (ntohs (hdr->type)) | 1202 | switch (ntohs (hdr->type)) |
1203 | { | 1203 | { |
1204 | case GNUNET_MESSAGE_TYPE_HELLO: | 1204 | case GNUNET_MESSAGE_TYPE_HELLO: |
1205 | if (GNUNET_OK != | 1205 | if (GNUNET_OK != |
1206 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource)) | 1206 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource)) |
1207 | { | 1207 | { |
1208 | GNUNET_break_op (0); | 1208 | GNUNET_break_op (0); |
@@ -1217,9 +1217,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1217 | GNUNET_STATISTICS_update (plugin->env->stats, | 1217 | GNUNET_STATISTICS_update (plugin->env->stats, |
1218 | _("# HELLO messages received via Bluetooth"), 1, | 1218 | _("# HELLO messages received via Bluetooth"), 1, |
1219 | GNUNET_NO); | 1219 | GNUNET_NO); |
1220 | plugin->env->receive (plugin->env->cls, | 1220 | plugin->env->receive (plugin->env->cls, |
1221 | &tmpsource, | 1221 | &tmpsource, |
1222 | hdr, | 1222 | hdr, |
1223 | mas->session, | 1223 | mas->session, |
1224 | (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, | 1224 | (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, |
1225 | (mas->endpoint == NULL) ? 0 : sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); | 1225 | (mas->endpoint == NULL) ? 0 : sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); |
@@ -1236,7 +1236,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1236 | GNUNET_break (0); | 1236 | GNUNET_break (0); |
1237 | break; | 1237 | break; |
1238 | } | 1238 | } |
1239 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1239 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1240 | "Processing %u bytes of FRAGMENT from MAC %s\n", | 1240 | "Processing %u bytes of FRAGMENT from MAC %s\n", |
1241 | (unsigned int) msize, | 1241 | (unsigned int) msize, |
1242 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); | 1242 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); |
@@ -1258,7 +1258,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1258 | ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr); | 1258 | ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr); |
1259 | if (GNUNET_OK == ret) | 1259 | if (GNUNET_OK == ret) |
1260 | { | 1260 | { |
1261 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1261 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1262 | "Got last ACK, finished message transmission to `%s' (%p)\n", | 1262 | "Got last ACK, finished message transmission to `%s' (%p)\n", |
1263 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)), | 1263 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)), |
1264 | fm); | 1264 | fm); |
@@ -1273,13 +1273,13 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1273 | } | 1273 | } |
1274 | if (GNUNET_NO == ret) | 1274 | if (GNUNET_NO == ret) |
1275 | { | 1275 | { |
1276 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1276 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1277 | "Got an ACK, message transmission to `%s' not yet finished\n", | 1277 | "Got an ACK, message transmission to `%s' not yet finished\n", |
1278 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); | 1278 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); |
1279 | break; | 1279 | break; |
1280 | } | 1280 | } |
1281 | } | 1281 | } |
1282 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1282 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1283 | "ACK not matched against any active fragmentation with MAC `%s'\n", | 1283 | "ACK not matched against any active fragmentation with MAC `%s'\n", |
1284 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); | 1284 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); |
1285 | break; | 1285 | break; |
@@ -1293,13 +1293,13 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1293 | { | 1293 | { |
1294 | GNUNET_break (0); | 1294 | GNUNET_break (0); |
1295 | break; | 1295 | break; |
1296 | } | 1296 | } |
1297 | wlanheader = (const struct WlanHeader *) hdr; | 1297 | wlanheader = (const struct WlanHeader *) hdr; |
1298 | if (0 != memcmp (&wlanheader->target, | 1298 | if (0 != memcmp (&wlanheader->target, |
1299 | plugin->env->my_identity, | 1299 | plugin->env->my_identity, |
1300 | sizeof (struct GNUNET_PeerIdentity))) | 1300 | sizeof (struct GNUNET_PeerIdentity))) |
1301 | { | 1301 | { |
1302 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1302 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1303 | "Bluetooth data for `%s', not for me, ignoring\n", | 1303 | "Bluetooth data for `%s', not for me, ignoring\n", |
1304 | GNUNET_i2s (&wlanheader->target)); | 1304 | GNUNET_i2s (&wlanheader->target)); |
1305 | break; | 1305 | break; |
@@ -1314,15 +1314,15 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1314 | } | 1314 | } |
1315 | xmas.endpoint = mas->endpoint; | 1315 | xmas.endpoint = mas->endpoint; |
1316 | xmas.session = create_session (mas->endpoint, &wlanheader->sender); | 1316 | xmas.session = create_session (mas->endpoint, &wlanheader->sender); |
1317 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1317 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1318 | "Processing %u bytes of BLUETOOTH DATA from peer `%s'\n", | 1318 | "Processing %u bytes of BLUETOOTH DATA from peer `%s'\n", |
1319 | (unsigned int) msize, | 1319 | (unsigned int) msize, |
1320 | GNUNET_i2s (&wlanheader->sender)); | 1320 | GNUNET_i2s (&wlanheader->sender)); |
1321 | (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer, | 1321 | (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer, |
1322 | &xmas, | 1322 | &xmas, |
1323 | (const char *) &wlanheader[1], | 1323 | (const char *) &wlanheader[1], |
1324 | msize - sizeof (struct WlanHeader), | 1324 | msize - sizeof (struct WlanHeader), |
1325 | GNUNET_YES, GNUNET_NO); | 1325 | GNUNET_YES, GNUNET_NO); |
1326 | break; | 1326 | break; |
1327 | default: | 1327 | default: |
1328 | if (NULL == mas->endpoint) | 1328 | if (NULL == mas->endpoint) |
@@ -1340,9 +1340,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1340 | (unsigned int) msize, | 1340 | (unsigned int) msize, |
1341 | (unsigned int) ntohs (hdr->type), | 1341 | (unsigned int) ntohs (hdr->type), |
1342 | GNUNET_i2s (&mas->session->target)); | 1342 | GNUNET_i2s (&mas->session->target)); |
1343 | plugin->env->receive (plugin->env->cls, | 1343 | plugin->env->receive (plugin->env->cls, |
1344 | &mas->session->target, | 1344 | &mas->session->target, |
1345 | hdr, | 1345 | hdr, |
1346 | mas->session, | 1346 | mas->session, |
1347 | (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, | 1347 | (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, |
1348 | (mas->endpoint == NULL) ? 0 : sizeof (struct WlanAddress)); | 1348 | (mas->endpoint == NULL) ? 0 : sizeof (struct WlanAddress)); |
@@ -1416,7 +1416,7 @@ handle_helper_message (void *cls, void *client, | |||
1416 | "bluetooth"); | 1416 | "bluetooth"); |
1417 | break; | 1417 | break; |
1418 | case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER: | 1418 | case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER: |
1419 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1419 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1420 | "Got data message from helper with %u bytes\n", | 1420 | "Got data message from helper with %u bytes\n", |
1421 | msize); | 1421 | msize); |
1422 | GNUNET_STATISTICS_update (plugin->env->stats, | 1422 | GNUNET_STATISTICS_update (plugin->env->stats, |
@@ -1453,7 +1453,7 @@ handle_helper_message (void *cls, void *client, | |||
1453 | /* packet is FROM us, thus not FOR us */ | 1453 | /* packet is FROM us, thus not FOR us */ |
1454 | break; | 1454 | break; |
1455 | } | 1455 | } |
1456 | 1456 | ||
1457 | GNUNET_STATISTICS_update (plugin->env->stats, | 1457 | GNUNET_STATISTICS_update (plugin->env->stats, |
1458 | _("# Bluetooth DATA messages processed"), | 1458 | _("# Bluetooth DATA messages processed"), |
1459 | 1, GNUNET_NO); | 1459 | 1, GNUNET_NO); |
@@ -1465,7 +1465,7 @@ handle_helper_message (void *cls, void *client, | |||
1465 | wa.options = htonl (0); | 1465 | wa.options = htonl (0); |
1466 | mas.endpoint = create_macendpoint (plugin, &wa); | 1466 | mas.endpoint = create_macendpoint (plugin, &wa); |
1467 | mas.session = NULL; | 1467 | mas.session = NULL; |
1468 | (void) GNUNET_SERVER_mst_receive (plugin->helper_payload_tokenizer, | 1468 | (void) GNUNET_SERVER_mst_receive (plugin->helper_payload_tokenizer, |
1469 | &mas, | 1469 | &mas, |
1470 | (const char*) &rxinfo[1], | 1470 | (const char*) &rxinfo[1], |
1471 | msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage), | 1471 | msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage), |
@@ -1473,7 +1473,7 @@ handle_helper_message (void *cls, void *client, | |||
1473 | break; | 1473 | break; |
1474 | default: | 1474 | default: |
1475 | GNUNET_break (0); | 1475 | GNUNET_break (0); |
1476 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1476 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1477 | "Unexpected message of type %u (%u bytes)", | 1477 | "Unexpected message of type %u (%u bytes)", |
1478 | ntohs (hdr->type), ntohs (hdr->size)); | 1478 | ntohs (hdr->type), ntohs (hdr->size)); |
1479 | break; | 1479 | break; |
@@ -1506,7 +1506,7 @@ send_hello_beacon (void *cls, | |||
1506 | { | 1506 | { |
1507 | char buf[size] GNUNET_ALIGN; | 1507 | char buf[size] GNUNET_ALIGN; |
1508 | 1508 | ||
1509 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1509 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1510 | "Sending %u byte HELLO beacon\n", | 1510 | "Sending %u byte HELLO beacon\n", |
1511 | (unsigned int) size); | 1511 | (unsigned int) size); |
1512 | radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf; | 1512 | radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf; |
@@ -1550,13 +1550,13 @@ bluetooth_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) | |||
1550 | struct WlanAddress *wa = (struct WlanAddress *) addr; | 1550 | struct WlanAddress *wa = (struct WlanAddress *) addr; |
1551 | 1551 | ||
1552 | if (addrlen != sizeof (struct WlanAddress)) | 1552 | if (addrlen != sizeof (struct WlanAddress)) |
1553 | { | 1553 | { |
1554 | GNUNET_break_op (0); | 1554 | GNUNET_break_op (0); |
1555 | return GNUNET_SYSERR; | 1555 | return GNUNET_SYSERR; |
1556 | } | 1556 | } |
1557 | if (GNUNET_YES != plugin->have_mac) | 1557 | if (GNUNET_YES != plugin->have_mac) |
1558 | { | 1558 | { |
1559 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1559 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1560 | "Rejecting MAC `%s': I don't know my MAC!\n", | 1560 | "Rejecting MAC `%s': I don't know my MAC!\n", |
1561 | mac_to_string (addr)); | 1561 | mac_to_string (addr)); |
1562 | return GNUNET_NO; /* don't know my MAC */ | 1562 | return GNUNET_NO; /* don't know my MAC */ |
@@ -1565,7 +1565,7 @@ bluetooth_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) | |||
1565 | &plugin->mac_address, | 1565 | &plugin->mac_address, |
1566 | sizeof (wa->mac))) | 1566 | sizeof (wa->mac))) |
1567 | { | 1567 | { |
1568 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1568 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1569 | "Rejecting MAC `%s': not my MAC!\n", | 1569 | "Rejecting MAC `%s': not my MAC!\n", |
1570 | mac_to_string (addr)); | 1570 | mac_to_string (addr)); |
1571 | return GNUNET_NO; /* not my MAC */ | 1571 | return GNUNET_NO; /* not my MAC */ |
@@ -1643,7 +1643,7 @@ bluetooth_plugin_address_pretty_printer (void *cls, const char *type, | |||
1643 | 1643 | ||
1644 | 1644 | ||
1645 | /** | 1645 | /** |
1646 | * Exit point from the plugin. | 1646 | * Exit point from the plugin. |
1647 | * | 1647 | * |
1648 | * @param cls pointer to the api struct | 1648 | * @param cls pointer to the api struct |
1649 | */ | 1649 | */ |
@@ -1799,7 +1799,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls) | |||
1799 | 1799 | ||
1800 | testmode = 0; | 1800 | testmode = 0; |
1801 | /* check configuration */ | 1801 | /* check configuration */ |
1802 | if ( (GNUNET_YES == | 1802 | if ( (GNUNET_YES == |
1803 | GNUNET_CONFIGURATION_have_value (env->cfg, "transport-bluetooth", "TESTMODE")) && | 1803 | GNUNET_CONFIGURATION_have_value (env->cfg, "transport-bluetooth", "TESTMODE")) && |
1804 | ( (GNUNET_SYSERR == | 1804 | ( (GNUNET_SYSERR == |
1805 | GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-bluetooth", | 1805 | GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-bluetooth", |
@@ -1828,7 +1828,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls) | |||
1828 | { | 1828 | { |
1829 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 1829 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
1830 | "transport-bluetooth", "INTERFACE"); | 1830 | "transport-bluetooth", "INTERFACE"); |
1831 | return NULL; | 1831 | return NULL; |
1832 | } | 1832 | } |
1833 | 1833 | ||
1834 | plugin = GNUNET_malloc (sizeof (struct Plugin)); | 1834 | plugin = GNUNET_malloc (sizeof (struct Plugin)); |
@@ -1844,7 +1844,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls) | |||
1844 | plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); | 1844 | plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); |
1845 | plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); | 1845 | plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); |
1846 | plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); | 1846 | plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); |
1847 | plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon, | 1847 | plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon, |
1848 | plugin); | 1848 | plugin); |
1849 | 1849 | ||
1850 | plugin->options = 0; | 1850 | plugin->options = 0; |
@@ -1852,7 +1852,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls) | |||
1852 | /* some compilers do not like switch on 'long long'... */ | 1852 | /* some compilers do not like switch on 'long long'... */ |
1853 | switch ((unsigned int) testmode) | 1853 | switch ((unsigned int) testmode) |
1854 | { | 1854 | { |
1855 | case 0: /* normal */ | 1855 | case 0: /* normal */ |
1856 | plugin->helper_argv[0] = (char *) "gnunet-helper-transport-bluetooth"; | 1856 | plugin->helper_argv[0] = (char *) "gnunet-helper-transport-bluetooth"; |
1857 | plugin->helper_argv[1] = interface; | 1857 | plugin->helper_argv[1] = interface; |
1858 | plugin->helper_argv[2] = NULL; | 1858 | plugin->helper_argv[2] = NULL; |
@@ -1899,7 +1899,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls) | |||
1899 | api->address_to_string = &bluetooth_plugin_address_to_string;; | 1899 | api->address_to_string = &bluetooth_plugin_address_to_string;; |
1900 | api->string_to_address = &bluetooth_string_to_address; | 1900 | api->string_to_address = &bluetooth_string_to_address; |
1901 | api->get_network = &bluetooth_get_network; | 1901 | api->get_network = &bluetooth_get_network; |
1902 | 1902 | ||
1903 | return api; | 1903 | return api; |
1904 | } | 1904 | } |
1905 | 1905 | ||