aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/transport/Makefile.am79
-rw-r--r--src/transport/gnunet-helper-transport-bluetooth.c168
-rw-r--r--src/transport/plugin_transport_bluetooth.c22
-rw-r--r--src/transport/test_quota_compliance_bluetooth_asymmetric_peer1.conf30
-rw-r--r--src/transport/test_quota_compliance_bluetooth_asymmetric_peer2.conf29
-rw-r--r--src/transport/test_quota_compliance_bluetooth_peer1.conf30
-rw-r--r--src/transport/test_quota_compliance_bluetooth_peer2.conf29
-rw-r--r--src/transport/test_transport_api_bluetooth_peer1.conf35
-rw-r--r--src/transport/test_transport_api_bluetooth_peer2.conf34
-rw-r--r--src/transport/test_transport_api_reliability_bluetooth_peer1.conf30
-rw-r--r--src/transport/test_transport_api_reliability_bluetooth_peer2.conf29
-rw-r--r--src/transport/test_transport_api_unreliability_bluetooth_peer1.conf30
-rw-r--r--src/transport/test_transport_api_unreliability_bluetooth_peer2.conf29
13 files changed, 476 insertions, 98 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 4524f9897..358eba98b 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -71,6 +71,12 @@ if HAVE_LIBBLUETOOTH
71 AM_LDFLAGS = -lbluetooth 71 AM_LDFLAGS = -lbluetooth
72 BT_BIN = gnunet-helper-transport-bluetooth 72 BT_BIN = gnunet-helper-transport-bluetooth
73 BT_PLUGIN_LA = libgnunet_plugin_transport_bluetooth.la 73 BT_PLUGIN_LA = libgnunet_plugin_transport_bluetooth.la
74 BT_PLUGIN_TEST = test_plugin_bluetooth
75 BT_API_TEST = test_transport_api_bluetooth
76 BT_REL_TEST = test_transport_api_reliability_bluetooth
77 BT_UREL_TEST = test_transport_api_unreliability_bluetooth
78 BT_QUOTA_TEST = test_quota_compliance_bluetooth \
79 test_quota_compliance_bluetooth_asymmetric
74endif 80endif
75endif 81endif
76 82
@@ -355,6 +361,7 @@ check_PROGRAMS = \
355 test_plugin_udp \ 361 test_plugin_udp \
356 $(UNIX_TEST) \ 362 $(UNIX_TEST) \
357 $(WLAN_PLUGIN_TEST) \ 363 $(WLAN_PLUGIN_TEST) \
364 $(BT_PLUGIN_TEST) \
358 test_http_common \ 365 test_http_common \
359 $(HTTP_CLIENT_PLUGIN_TEST) \ 366 $(HTTP_CLIENT_PLUGIN_TEST) \
360 $(HTTPS_CLIENT_PLUGIN_TEST) \ 367 $(HTTPS_CLIENT_PLUGIN_TEST) \
@@ -380,6 +387,7 @@ check_PROGRAMS = \
380 $(HTTPS_API_TEST) \ 387 $(HTTPS_API_TEST) \
381 $(HTTPS_API_TIMEOUT_TEST) \ 388 $(HTTPS_API_TIMEOUT_TEST) \
382 $(WLAN_API_TEST) \ 389 $(WLAN_API_TEST) \
390 $(BT_API_TEST) \
383 test_transport_api_multi \ 391 test_transport_api_multi \
384 test_transport_blacklisting_no_bl \ 392 test_transport_blacklisting_no_bl \
385 test_transport_blacklisting_outbound_bl_full \ 393 test_transport_blacklisting_outbound_bl_full \
@@ -399,13 +407,16 @@ check_PROGRAMS = \
399 $(HTTPS_REL_TEST) \ 407 $(HTTPS_REL_TEST) \
400 $(WLAN_REL_TEST) \ 408 $(WLAN_REL_TEST) \
401 $(WLAN_UREL_TEST) \ 409 $(WLAN_UREL_TEST) \
410 $(BT_REL_TEST) \
411 $(BT_UREL_TEST) \
402 test_quota_compliance_tcp \ 412 test_quota_compliance_tcp \
403 test_quota_compliance_tcp_asymmetric \ 413 test_quota_compliance_tcp_asymmetric \
404 test_quota_compliance_udp \ 414 test_quota_compliance_udp \
405 $(UNIX_QUOTA_TEST) \ 415 $(UNIX_QUOTA_TEST) \
406 $(HTTP_QUOTA_TEST) \ 416 $(HTTP_QUOTA_TEST) \
407 $(HTTPS_QUOTA_TEST) \ 417 $(HTTPS_QUOTA_TEST) \
408 $(WLAN_QUOTA_TEST) 418 $(WLAN_QUOTA_TEST) \
419 $(BT_QUOTA_TEST)
409endif 420endif
410 421
411if ENABLE_TEST_RUN 422if ENABLE_TEST_RUN
@@ -418,6 +429,7 @@ TESTS = \
418 test_plugin_udp \ 429 test_plugin_udp \
419 $(UNIX_TEST) \ 430 $(UNIX_TEST) \
420 $(WLAN_PLUGIN_TEST) \ 431 $(WLAN_PLUGIN_TEST) \
432 $(BT_PLUGIN_TEST) \
421 test_transport_api_blacklisting \ 433 test_transport_api_blacklisting \
422 test_transport_api_disconnect_tcp \ 434 test_transport_api_disconnect_tcp \
423 test_transport_api_bidirectional_connect \ 435 test_transport_api_bidirectional_connect \
@@ -437,6 +449,7 @@ TESTS = \
437 $(HTTPS_API_TEST) \ 449 $(HTTPS_API_TEST) \
438 $(HTTPS_API_TIMEOUT_TEST) \ 450 $(HTTPS_API_TIMEOUT_TEST) \
439 $(WLAN_API_TEST) \ 451 $(WLAN_API_TEST) \
452 $(BT_API_TEST) \
440 test_transport_api_multi \ 453 test_transport_api_multi \
441 test_transport_blacklisting_no_bl \ 454 test_transport_blacklisting_no_bl \
442 test_transport_blacklisting_outbound_bl_full \ 455 test_transport_blacklisting_outbound_bl_full \
@@ -456,6 +469,8 @@ TESTS = \
456 $(HTTPS_REL_TEST) \ 469 $(HTTPS_REL_TEST) \
457 $(WLAN_REL_TEST) \ 470 $(WLAN_REL_TEST) \
458 $(WLAN_UREL_TEST) \ 471 $(WLAN_UREL_TEST) \
472 $(BT_REL_TEST) \
473 $(BT_UREL_TEST) \
459 test_quota_compliance_tcp \ 474 test_quota_compliance_tcp \
460 test_quota_compliance_tcp_asymmetric \ 475 test_quota_compliance_tcp_asymmetric \
461 test_quota_compliance_udp \ 476 test_quota_compliance_udp \
@@ -606,6 +621,14 @@ test_plugin_wlan_LDADD = \
606 $(top_builddir)/src/util/libgnunetutil.la \ 621 $(top_builddir)/src/util/libgnunetutil.la \
607 $(top_builddir)/src/transport/libgnunettransporttesting.la 622 $(top_builddir)/src/transport/libgnunettransporttesting.la
608 623
624test_plugin_bluetooth_SOURCES = \
625 test_plugin_transport.c
626test_plugin_bluetooth_LDADD = \
627 $(top_builddir)/src/transport/libgnunettransport.la \
628 $(top_builddir)/src/statistics/libgnunetstatistics.la \
629 $(top_builddir)/src/hello/libgnunethello.la \
630 $(top_builddir)/src/util/libgnunetutil.la \
631 $(top_builddir)/src/transport/libgnunettransporttesting.la
609 632
610test_http_common_SOURCES = \ 633test_http_common_SOURCES = \
611 test_http_common.c plugin_transport_http_common.c 634 test_http_common.c plugin_transport_http_common.c
@@ -766,6 +789,14 @@ test_transport_api_reliability_wlan_LDADD = \
766 $(top_builddir)/src/transport/libgnunettransport.la \ 789 $(top_builddir)/src/transport/libgnunettransport.la \
767 $(top_builddir)/src/hello/libgnunethello.la \ 790 $(top_builddir)/src/hello/libgnunethello.la \
768 $(top_builddir)/src/util/libgnunetutil.la \ 791 $(top_builddir)/src/util/libgnunetutil.la \
792 $(top_builddir)/src/transport/libgnunettransporttesting.la
793
794test_transport_api_reliability_bluetooth_SOURCES = \
795 test_transport_api_reliability.c
796test_transport_api_reliability_bluetooth_LDADD = \
797 $(top_builddir)/src/transport/libgnunettransport.la \
798 $(top_builddir)/src/hello/libgnunethello.la \
799 $(top_builddir)/src/util/libgnunetutil.la \
769 $(top_builddir)/src/transport/libgnunettransporttesting.la 800 $(top_builddir)/src/transport/libgnunettransporttesting.la
770 801
771test_transport_api_unreliability_wlan_SOURCES = \ 802test_transport_api_unreliability_wlan_SOURCES = \
@@ -776,6 +807,14 @@ test_transport_api_unreliability_wlan_LDADD = \
776 $(top_builddir)/src/util/libgnunetutil.la \ 807 $(top_builddir)/src/util/libgnunetutil.la \
777 $(top_builddir)/src/transport/libgnunettransporttesting.la 808 $(top_builddir)/src/transport/libgnunettransporttesting.la
778 809
810test_transport_api_unreliability_bluetooth_SOURCES = \
811 test_transport_api_unreliability.c
812test_transport_api_unreliability_bluetooth_LDADD = \
813 $(top_builddir)/src/transport/libgnunettransport.la \
814 $(top_builddir)/src/hello/libgnunethello.la \
815 $(top_builddir)/src/util/libgnunetutil.la \
816 $(top_builddir)/src/transport/libgnunettransporttesting.la
817
779test_transport_api_udp_SOURCES = \ 818test_transport_api_udp_SOURCES = \
780 test_transport_api.c 819 test_transport_api.c
781test_transport_api_udp_LDADD = \ 820test_transport_api_udp_LDADD = \
@@ -933,6 +972,18 @@ test_transport_api_wlan_LDADD = \
933 $(top_builddir)/src/transport/libgnunettransporttesting.la 972 $(top_builddir)/src/transport/libgnunettransporttesting.la
934endif 973endif
935 974
975if LINUX
976if HAVE_LIBBLUETOOTH
977test_transport_api_bluetooth_SOURCES = \
978 test_transport_api.c
979test_transport_api_bluetooth_LDADD = \
980 $(top_builddir)/src/transport/libgnunettransport.la \
981 $(top_builddir)/src/hello/libgnunethello.la \
982 $(top_builddir)/src/util/libgnunetutil.la \
983 $(top_builddir)/src/transport/libgnunettransporttesting.la
984endif
985endif
986
936test_quota_compliance_tcp_SOURCES = \ 987test_quota_compliance_tcp_SOURCES = \
937 test_quota_compliance.c 988 test_quota_compliance.c
938test_quota_compliance_tcp_LDADD = \ 989test_quota_compliance_tcp_LDADD = \
@@ -989,6 +1040,22 @@ test_quota_compliance_wlan_asymmetric_LDADD = \
989 $(top_builddir)/src/util/libgnunetutil.la \ 1040 $(top_builddir)/src/util/libgnunetutil.la \
990 $(top_builddir)/src/transport/libgnunettransporttesting.la 1041 $(top_builddir)/src/transport/libgnunettransporttesting.la
991 1042
1043test_quota_compliance_bluetooth_SOURCES = \
1044 test_quota_compliance.c
1045test_quota_compliance_bluetooth_LDADD = \
1046 $(top_builddir)/src/transport/libgnunettransport.la \
1047 $(top_builddir)/src/hello/libgnunethello.la \
1048 $(top_builddir)/src/util/libgnunetutil.la \
1049 $(top_builddir)/src/transport/libgnunettransporttesting.la
1050
1051test_quota_compliance_bluetooth_asymmetric_SOURCES = \
1052 test_quota_compliance.c
1053test_quota_compliance_bluetooth_asymmetric_LDADD = \
1054 $(top_builddir)/src/transport/libgnunettransport.la \
1055 $(top_builddir)/src/hello/libgnunethello.la \
1056 $(top_builddir)/src/util/libgnunetutil.la \
1057 $(top_builddir)/src/transport/libgnunettransporttesting.la
1058
992test_transport_api_multi_SOURCES = \ 1059test_transport_api_multi_SOURCES = \
993 test_transport_api.c 1060 test_transport_api.c
994test_transport_api_multi_LDADD = \ 1061test_transport_api_multi_LDADD = \
@@ -1018,6 +1085,8 @@ test_quota_compliance_unix_peer1.conf\
1018test_quota_compliance_unix_peer2.conf\ 1085test_quota_compliance_unix_peer2.conf\
1019test_quota_compliance_wlan_peer1.conf\ 1086test_quota_compliance_wlan_peer1.conf\
1020test_quota_compliance_wlan_peer2.conf\ 1087test_quota_compliance_wlan_peer2.conf\
1088test_quota_compliance_bluetooth_peer1.conf\
1089test_quota_compliance_bluetooth_peer2.conf\
1021test_quota_compliance_http_asymmetric_peer1.conf\ 1090test_quota_compliance_http_asymmetric_peer1.conf\
1022test_quota_compliance_http_asymmetric_peer2.conf\ 1091test_quota_compliance_http_asymmetric_peer2.conf\
1023test_quota_compliance_https_asymmetric_peer1.conf\ 1092test_quota_compliance_https_asymmetric_peer1.conf\
@@ -1028,6 +1097,8 @@ test_quota_compliance_unix_asymmetric_peer1.conf\
1028test_quota_compliance_unix_asymmetric_peer2.conf\ 1097test_quota_compliance_unix_asymmetric_peer2.conf\
1029test_quota_compliance_wlan_asymmetric_peer1.conf\ 1098test_quota_compliance_wlan_asymmetric_peer1.conf\
1030test_quota_compliance_wlan_asymmetric_peer2.conf\ 1099test_quota_compliance_wlan_asymmetric_peer2.conf\
1100test_quota_compliance_bluetooth_asymmetric_peer1.conf\
1101test_quota_compliance_bluetooth_asymmetric_peer2.conf\
1031test_transport_api_data.conf\ 1102test_transport_api_data.conf\
1032test_transport_api_http_peer1.conf\ 1103test_transport_api_http_peer1.conf\
1033test_transport_api_http_peer2.conf\ 1104test_transport_api_http_peer2.conf\
@@ -1049,6 +1120,8 @@ test_transport_api_reliability_tcp_peer1.conf\
1049test_transport_api_reliability_tcp_peer2.conf\ 1120test_transport_api_reliability_tcp_peer2.conf\
1050test_transport_api_reliability_wlan_peer1.conf\ 1121test_transport_api_reliability_wlan_peer1.conf\
1051test_transport_api_reliability_wlan_peer2.conf\ 1122test_transport_api_reliability_wlan_peer2.conf\
1123test_transport_api_reliability_bluetooth_peer1.conf\
1124test_transport_api_reliability_bluetooth_peer2.conf\
1052test_transport_api_bidirectional_connect_peer1.conf\ 1125test_transport_api_bidirectional_connect_peer1.conf\
1053test_transport_api_bidirectional_connect_peer2.conf\ 1126test_transport_api_bidirectional_connect_peer2.conf\
1054test_transport_api_manipulation_send_tcp_peer1.conf\ 1127test_transport_api_manipulation_send_tcp_peer1.conf\
@@ -1077,8 +1150,12 @@ test_transport_api_unreliability_unix_peer1.conf\
1077test_transport_api_unreliability_unix_peer2.conf\ 1150test_transport_api_unreliability_unix_peer2.conf\
1078test_transport_api_unreliability_wlan_peer1.conf\ 1151test_transport_api_unreliability_wlan_peer1.conf\
1079test_transport_api_unreliability_wlan_peer2.conf\ 1152test_transport_api_unreliability_wlan_peer2.conf\
1153test_transport_api_unreliability_bluetooth_peer1.conf\
1154test_transport_api_unreliability_bluetooth_peer2.conf\
1080test_transport_api_wlan_peer1.conf\ 1155test_transport_api_wlan_peer1.conf\
1081test_transport_api_wlan_peer2.conf\ 1156test_transport_api_wlan_peer2.conf\
1157test_transport_api_bluetooth_peer1.conf\
1158test_transport_api_bluetooth_peer2.conf\
1082test_transport_defaults.conf\ 1159test_transport_defaults.conf\
1083test_transport_startonly.conf\ 1160test_transport_startonly.conf\
1084test_transport_api_disconnect_tcp_peer1.conf\ 1161test_transport_api_disconnect_tcp_peer1.conf\
diff --git a/src/transport/gnunet-helper-transport-bluetooth.c b/src/transport/gnunet-helper-transport-bluetooth.c
index 48e63dd75..1f5add92d 100644
--- a/src/transport/gnunet-helper-transport-bluetooth.c
+++ b/src/transport/gnunet-helper-transport-bluetooth.c
@@ -54,9 +54,9 @@
54 54
55 55
56/** 56/**
57 * Maximum number of loops without inquiring for a new devices. 57 * Maximum number of loops without inquiring for new devices.
58 */ 58 */
59#define MAX_LOOPS 3 59#define MAX_LOOPS 5
60 60
61/** 61/**
62 * struct for storing the information of the hardware. There is only 62 * struct for storing the information of the hardware. There is only
@@ -285,7 +285,7 @@ mst_receive (struct MessageStreamTokenizer *mst,
285do_align: 285do_align:
286 if (mst->pos < mst->off) 286 if (mst->pos < mst->off)
287 { 287 {
288 fprintf (stderr, "We processed too many bytes!\n"); 288 //fprintf (stderr, "We processed too many bytes!\n");
289 return GNUNET_SYSERR; 289 return GNUNET_SYSERR;
290 } 290 }
291 if ((mst->curr_buf - mst->off < sizeof (struct GNUNET_MessageHeader)) || 291 if ((mst->curr_buf - mst->off < sizeof (struct GNUNET_MessageHeader)) ||
@@ -696,7 +696,7 @@ static int
696get_channel(struct HardwareInfos *dev, bdaddr_t dest) 696get_channel(struct HardwareInfos *dev, bdaddr_t dest)
697{ 697{
698 /** 698 /**
699 * 1. detect all nearby devices //FIXME : Connect directly to the device with the service 699 * 1. detect all nearby devices
700 * 2. for each device: 700 * 2. for each device:
701 * 2.1. connect to the SDP server running 701 * 2.1. connect to the SDP server running
702 * 2.2. get a list of service records with the specific UUID 702 * 2.2. get a list of service records with the specific UUID
@@ -803,7 +803,7 @@ read_from_the_socket (int sock,
803 memset (ri, 0, sizeof (*ri)); 803 memset (ri, 0, sizeof (*ri));
804 ri->ri_channel = rc_addr.rc_channel; 804 ri->ri_channel = rc_addr.rc_channel;
805 805
806 /* detect CRC32 at the end */ 806 /* Detect CRC32 at the end */
807 if (0 == check_crc_buf_osdep (tmpbuf, count - sizeof (uint32_t))) 807 if (0 == check_crc_buf_osdep (tmpbuf, count - sizeof (uint32_t)))
808 { 808 {
809 count -= sizeof(uint32_t); 809 count -= sizeof(uint32_t);
@@ -822,25 +822,13 @@ read_from_the_socket (int sock,
822 */ 822 */
823static int 823static int
824open_device (struct HardwareInfos *dev) 824open_device (struct HardwareInfos *dev)
825{ 825{
826 /**
827 * 1. Open a HCI socket (if RFCOMM protocol is used. If not, the HCI socket is
828 * saved in dev->rfcomm).
829 * 2. Find the device id (request a list with all the devices and find the one
830 * with the dev->iface name)
831 * 3. If the interface is down try to get it up
832 * 4. Bind the RFCOMM socket to the interface using the bind_socket() method and register
833 * a SDP service
834 * 5. For now use a hard coded port number(channel) value
835 * FIXME : if I use HCI sockets , should I enable RAW_SOCKET MODE?!?!?!
836 */
837
838 int i, dev_id = -1, fd_hci; 826 int i, dev_id = -1, fd_hci;
839 struct 827 struct
840 { 828 {
841 struct hci_dev_list_req list; 829 struct hci_dev_list_req list;
842 struct hci_dev_req dev[HCI_MAX_DEV]; 830 struct hci_dev_req dev[HCI_MAX_DEV];
843 } request; //used for detecting the local devices 831 } request; //used for detecting the local devices
844 struct sockaddr_rc rc_addr = { 0 }; //used for binding 832 struct sockaddr_rc rc_addr = { 0 }; //used for binding
845 833
846 /* Initialize the neighbour structure */ 834 /* Initialize the neighbour structure */
@@ -848,6 +836,7 @@ open_device (struct HardwareInfos *dev)
848 for (i = 0; i < MAX_PORTS; i++) 836 for (i = 0; i < MAX_PORTS; i++)
849 neighbours.fds[i] = -1; 837 neighbours.fds[i] = -1;
850 838
839 /* Open a HCI socket */
851 fd_hci = socket (AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); 840 fd_hci = socket (AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
852 841
853 if (fd_hci < 0) 842 if (fd_hci < 0)
@@ -888,14 +877,13 @@ open_device (struct HardwareInfos *dev)
888 dev_id = dev_info.dev_id; //the device was found 877 dev_id = dev_info.dev_id; //the device was found
889 /** 878 /**
890 * Copy the MAC address to the device structure 879 * Copy the MAC address to the device structure
891 * FIXME: probably this is not the best solution
892 */ 880 */
893 memcpy (&dev->pl_mac, &dev_info.bdaddr, sizeof (bdaddr_t)); 881 memcpy (&dev->pl_mac, &dev_info.bdaddr, sizeof (bdaddr_t));
894 882
895 /* Check if the interface is UP */ 883 /* Check if the interface is UP */
896 if (hci_test_bit (HCI_UP, (void *) &dev_info.flags) == 0) 884 if (hci_test_bit (HCI_UP, (void *) &dev_info.flags) == 0)
897 { 885 {
898 /* Bring interface up */ //FIXME should I check if is HCI_RUNNING ?!?!??! 886 /* Bring interface up */
899 if (ioctl (fd_hci, HCIDEVUP, dev_info.dev_id)) 887 if (ioctl (fd_hci, HCIDEVUP, dev_info.dev_id))
900 { 888 {
901 fprintf (stderr, "ioctl(HCIDEVUP) on interface `%.*s' failed: %s\n", 889 fprintf (stderr, "ioctl(HCIDEVUP) on interface `%.*s' failed: %s\n",
@@ -923,10 +911,6 @@ open_device (struct HardwareInfos *dev)
923 } 911 }
924 912
925 } 913 }
926
927 //FIXME : Sniff mode!?!
928 //FIXME : RAW MODE?!?
929
930 break; 914 break;
931 } 915 }
932 916
@@ -969,7 +953,7 @@ open_device (struct HardwareInfos *dev)
969 { 953 {
970 fprintf (stderr, "Failed to listen on socket for interface `%.*s': %s\n", IFNAMSIZ, 954 fprintf (stderr, "Failed to listen on socket for interface `%.*s': %s\n", IFNAMSIZ,
971 dev->iface, strerror (errno)); 955 dev->iface, strerror (errno));
972 return 3; 956 return 1;
973 } 957 }
974 958
975 959
@@ -1112,8 +1096,8 @@ send_broadcast (struct HardwareInfos *dev, int *sendsocket)
1112 inquiry_devices: //skip the conditions and force a inquiry for new devices 1096 inquiry_devices: //skip the conditions and force a inquiry for new devices
1113 { 1097 {
1114 /** 1098 /**
1115 * It means that I sent HELLO message to all the devices from the list so I should search 1099 * It means that I sent HELLO messages to all the devices from the list and I should search
1116 * for another devices or that this is the first time when I do a search for devices. 1100 * for another ones or that this is the first time when I do a search.
1117 */ 1101 */
1118 inquiry_info *devices = NULL; 1102 inquiry_info *devices = NULL;
1119 int i, responses, max_responses = MAX_PORTS; 1103 int i, responses, max_responses = MAX_PORTS;
@@ -1121,7 +1105,7 @@ send_broadcast (struct HardwareInfos *dev, int *sendsocket)
1121 /* sanity checks */ 1105 /* sanity checks */
1122 if (neighbours.size >= MAX_PORTS) 1106 if (neighbours.size >= MAX_PORTS)
1123 { 1107 {
1124 fprintf (stderr, "%s reached the top limit for the discovarable devices\n", dev->iface); 1108 fprintf (stderr, "%.*s reached the top limit for the discovarable devices\n", IFNAMSIZ, dev->iface);
1125 return 2; 1109 return 2;
1126 } 1110 }
1127 1111
@@ -1134,7 +1118,7 @@ send_broadcast (struct HardwareInfos *dev, int *sendsocket)
1134 neighbours.dev_id = hci_devid (addr); 1118 neighbours.dev_id = hci_devid (addr);
1135 if (neighbours.dev_id < 0) 1119 if (neighbours.dev_id < 0)
1136 { 1120 {
1137 fprintf (stderr, "Failed to get the device id for interface %s : %s\n", 1121 fprintf (stderr, "Failed to get the device id for interface %.*s : %s\n", IFNAMSIZ,
1138 dev->iface, strerror (errno)); 1122 dev->iface, strerror (errno));
1139 return 1; 1123 return 1;
1140 } 1124 }
@@ -1143,7 +1127,7 @@ send_broadcast (struct HardwareInfos *dev, int *sendsocket)
1143 devices = malloc (max_responses * sizeof (inquiry_info)); 1127 devices = malloc (max_responses * sizeof (inquiry_info));
1144 if (devices == NULL) 1128 if (devices == NULL)
1145 { 1129 {
1146 fprintf (stderr, "Failed to allocate memory for inquiry info list on interface %s\n", 1130 fprintf (stderr, "Failed to allocate memory for inquiry info list on interface %.*s\n", IFNAMSIZ,
1147 dev->iface); 1131 dev->iface);
1148 return 1; 1132 return 1;
1149 } 1133 }
@@ -1151,15 +1135,15 @@ send_broadcast (struct HardwareInfos *dev, int *sendsocket)
1151 responses = hci_inquiry (neighbours.dev_id, 8, max_responses, NULL, &devices, IREQ_CACHE_FLUSH); 1135 responses = hci_inquiry (neighbours.dev_id, 8, max_responses, NULL, &devices, IREQ_CACHE_FLUSH);
1152 if (responses < 0) 1136 if (responses < 0)
1153 { 1137 {
1154 fprintf (stderr, "Failed to inquiry on interface %s\n", dev->iface); 1138 fprintf (stderr, "Failed to inquiry on interface %.*s\n", IFNAMSIZ, dev->iface);
1155 return 1; 1139 return 1;
1156 } 1140 }
1157 1141
1158 fprintf (stderr, "Found %d devices\n", responses); //FIXME delete it after debugging stage 1142 fprintf (stderr, "LOG : Found %d devices\n", responses); //FIXME delete it after debugging stage
1159 1143
1160 if (responses == 0) 1144 if (responses == 0)
1161 { 1145 {
1162 fprintf (stderr, "No devices discoverable\n"); 1146 fprintf (stderr, "LOG : No devices discoverable\n");
1163 return 1; 1147 return 1;
1164 } 1148 }
1165 1149
@@ -1171,7 +1155,8 @@ send_broadcast (struct HardwareInfos *dev, int *sendsocket)
1171 /* sanity check */ 1155 /* sanity check */
1172 if (i >= MAX_PORTS) 1156 if (i >= MAX_PORTS)
1173 { 1157 {
1174 fprintf (stderr, "%s reached the top limit for the discoverable devices (after inquiry)\n", dev->iface); 1158 fprintf (stderr, "%.*s reached the top limit for the discoverable devices (after inquiry)\n", IFNAMSIZ,
1159 dev->iface);
1175 return 2; 1160 return 2;
1176 } 1161 }
1177 1162
@@ -1181,7 +1166,7 @@ send_broadcast (struct HardwareInfos *dev, int *sendsocket)
1181 if (memcmp (&(devices + i)->bdaddr, &(neighbours.devices[j]), sizeof (bdaddr_t)) == 0) 1166 if (memcmp (&(devices + i)->bdaddr, &(neighbours.devices[j]), sizeof (bdaddr_t)) == 0)
1182 { 1167 {
1183 found = 1; 1168 found = 1;
1184 fprintf (stderr, "the device already exists on the list\n"); //FIXME debugging message 1169 fprintf (stderr, "LOG : the device already exists on the list\n"); //FIXME debugging message
1185 break; 1170 break;
1186 } 1171 }
1187 } 1172 }
@@ -1191,7 +1176,7 @@ send_broadcast (struct HardwareInfos *dev, int *sendsocket)
1191 char addr[19] = { 0 }; 1176 char addr[19] = { 0 };
1192 1177
1193 ba2str (&(devices +i)->bdaddr, addr); 1178 ba2str (&(devices +i)->bdaddr, addr);
1194 fprintf (stderr, "%s was added to the list\n", addr); //FIXME debugging message 1179 fprintf (stderr, "LOG : %s was added to the list\n", addr); //FIXME debugging message
1195 memcpy (&(neighbours.devices[neighbours.size++]), &(devices + i)->bdaddr, sizeof (bdaddr_t)); 1180 memcpy (&(neighbours.devices[neighbours.size++]), &(devices + i)->bdaddr, sizeof (bdaddr_t));
1196 } 1181 }
1197 } 1182 }
@@ -1218,14 +1203,14 @@ send_broadcast (struct HardwareInfos *dev, int *sendsocket)
1218 addr_rc.rc_channel = get_channel (dev, addr_rc.rc_bdaddr); 1203 addr_rc.rc_channel = get_channel (dev, addr_rc.rc_bdaddr);
1219 1204
1220 *sendsocket = socket (AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); 1205 *sendsocket = socket (AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
1221 1206 //TODO adauga un label aici si intoarcete de cateva ori daca nu reuseste
1222 if (connect (*sendsocket, (struct sockaddr *)&addr_rc, sizeof (addr_rc)) == 0) 1207 if (connect (*sendsocket, (struct sockaddr *)&addr_rc, sizeof (addr_rc)) == 0)
1223 { 1208 {
1224 neighbours.fds[neighbours.pos++] = *sendsocket; 1209 neighbours.fds[neighbours.pos++] = *sendsocket;
1225 connection_successful = 1; 1210 connection_successful = 1;
1226 char addr[19] = { 0 }; 1211 char addr[19] = { 0 };
1227 ba2str (&(neighbours.devices[neighbours.pos - 1]), addr); 1212 ba2str (&(neighbours.devices[neighbours.pos - 1]), addr);
1228 fprintf (stderr, "Connected to %s\n", addr); 1213 fprintf (stderr, "LOG : Connected to %s\n", addr);
1229 1214
1230 break; 1215 break;
1231 } 1216 }
@@ -1234,10 +1219,10 @@ send_broadcast (struct HardwareInfos *dev, int *sendsocket)
1234 char addr[19] = { 0 }; 1219 char addr[19] = { 0 };
1235 errno_copy = errno; //Save a copy for later 1220 errno_copy = errno; //Save a copy for later
1236 ba2str (&(neighbours.devices[neighbours.pos]), addr); 1221 ba2str (&(neighbours.devices[neighbours.pos]), addr);
1237 fprintf (stderr, "Couldn't connect on device %s, error : %s\n", addr, strerror(errno)); 1222 fprintf (stderr, "LOG : Couldn't connect on device %s, error : %s\n", addr, strerror(errno));
1238 if (errno != ECONNREFUSED) //FIXME nu merge! 1223 if (errno != ECONNREFUSED) //FIXME nu merge!
1239 { 1224 {
1240 fprintf (stderr, "Removes %d device from the list\n", neighbours.pos); 1225 fprintf (stderr, "LOG : Removes %d device from the list\n", neighbours.pos);
1241 /* Remove the device from the list */ 1226 /* Remove the device from the list */
1242 memcpy (&neighbours.devices[neighbours.pos], &neighbours.devices[neighbours.size - 1], sizeof (bdaddr_t)); 1227 memcpy (&neighbours.devices[neighbours.pos], &neighbours.devices[neighbours.size - 1], sizeof (bdaddr_t));
1243 memset (&neighbours.devices[neighbours.size - 1], 0, sizeof (bdaddr_t)); 1228 memset (&neighbours.devices[neighbours.size - 1], 0, sizeof (bdaddr_t));
@@ -1259,7 +1244,7 @@ send_broadcast (struct HardwareInfos *dev, int *sendsocket)
1259 } 1244 }
1260 else 1245 else
1261 { 1246 {
1262 fprintf (stderr, "Search for a new device\n"); //FIXME debugging message 1247 fprintf (stderr, "LOG : Search for a new device\n"); //FIXME debugging message
1263 neighbours.pos += 1; 1248 neighbours.pos += 1;
1264 } 1249 }
1265 } 1250 }
@@ -1272,7 +1257,7 @@ send_broadcast (struct HardwareInfos *dev, int *sendsocket)
1272 1257
1273 if (searching_devices_count == MAX_LOOPS) 1258 if (searching_devices_count == MAX_LOOPS)
1274 { 1259 {
1275 fprintf (stderr, "Force to inquiry for new devices\n"); 1260 fprintf (stderr, "LOG : Force to inquiry for new devices\n");
1276 searching_devices_count = 0; 1261 searching_devices_count = 0;
1277 goto inquiry_devices; 1262 goto inquiry_devices;
1278 } 1263 }
@@ -1290,7 +1275,7 @@ send_broadcast (struct HardwareInfos *dev, int *sendsocket)
1290 { 1275 {
1291 if (errno_copy == ECONNREFUSED) 1276 if (errno_copy == ECONNREFUSED)
1292 { 1277 {
1293 fprintf (stderr, "No device found. Go back and search again\n"); //FIXME debugging message 1278 fprintf (stderr, "LOG : No device found. Go back and search again\n"); //FIXME debugging message
1294 new_device = 1; 1279 new_device = 1;
1295 loops += 1; 1280 loops += 1;
1296 goto search_for_devices; 1281 goto search_for_devices;
@@ -1443,27 +1428,23 @@ main (int argc, char *argv[])
1443 FD_ZERO (&rfds); 1428 FD_ZERO (&rfds);
1444 if ((0 == write_pout.size) && (1 == stdin_open)) 1429 if ((0 == write_pout.size) && (1 == stdin_open))
1445 { 1430 {
1446 // fprintf (stderr, "LOG : %s adds STDIN to rfds\n", dev.iface); //FIXME: debugging message
1447 FD_SET (STDIN_FILENO, &rfds); 1431 FD_SET (STDIN_FILENO, &rfds);
1448 maxfd = MAX (maxfd, STDIN_FILENO); 1432 maxfd = MAX (maxfd, STDIN_FILENO);
1449 } 1433 }
1450 if (0 == write_std.size) 1434 if (0 == write_std.size)
1451 { 1435 {
1452 // fprintf (stderr, "LOG : %s adds fd_rfcomm to rfds\n", dev.iface); //FIXME: debugging message
1453 FD_SET (dev.fd_rfcomm, &rfds); 1436 FD_SET (dev.fd_rfcomm, &rfds);
1454 maxfd = MAX (maxfd, dev.fd_rfcomm); 1437 maxfd = MAX (maxfd, dev.fd_rfcomm);
1455 } 1438 }
1456 1439
1457 for (i = 0; i < crt_rfds; i++) // it can receive messages from multiple devices 1440 for (i = 0; i < crt_rfds; i++) // it can receive messages from multiple devices
1458 { 1441 {
1459 // fprintf (stderr, "LOG : %s adds extra fds to rfds\n", dev.iface); //FIXME: debugging message
1460 FD_SET (rfds_list[i], &rfds); 1442 FD_SET (rfds_list[i], &rfds);
1461 maxfd = MAX (maxfd, rfds_list[i]); 1443 maxfd = MAX (maxfd, rfds_list[i]);
1462 } 1444 }
1463 FD_ZERO (&wfds); 1445 FD_ZERO (&wfds);
1464 if (0 < write_std.size) 1446 if (0 < write_std.size)
1465 { 1447 {
1466 // fprintf (stderr, "LOG : %s adds STDOUT to wfds\n", dev.iface); //FIXME: debugging message
1467 FD_SET (STDOUT_FILENO, &wfds); 1448 FD_SET (STDOUT_FILENO, &wfds);
1468 maxfd = MAX (maxfd, STDOUT_FILENO); 1449 maxfd = MAX (maxfd, STDOUT_FILENO);
1469 } 1450 }
@@ -1471,14 +1452,13 @@ main (int argc, char *argv[])
1471 { 1452 {
1472 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *frame; 1453 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *frame;
1473 /* Get the destination address */ 1454 /* Get the destination address */
1474 //FIXME : not sure if this is correct
1475 frame = (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) write_pout.buf; 1455 frame = (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) write_pout.buf;
1476 1456
1477 if (memcmp (&frame->addr1, &dev.pl_mac, 1457 if (memcmp (&frame->addr1, &dev.pl_mac,
1478 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) 1458 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)
1479 { 1459 {
1480 fprintf (stderr, "LOG : %s has a message for him:)\n", dev.iface); //FIXME: debugging message 1460 broadcast = 1;
1481 memset (&write_pout, 0, sizeof (write_pout)); // clear the buffer 1461 memset (&write_pout, 0, sizeof (write_pout)); //clear the buffer
1482 } 1462 }
1483 else if (memcmp (&frame->addr1, &broadcast_address, 1463 else if (memcmp (&frame->addr1, &broadcast_address,
1484 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) 1464 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)
@@ -1491,7 +1471,7 @@ main (int argc, char *argv[])
1491 { 1471 {
1492 broadcast = 1; 1472 broadcast = 1;
1493 memset (&write_pout, 0, sizeof (write_pout)); //remove the message 1473 memset (&write_pout, 0, sizeof (write_pout)); //remove the message
1494 fprintf (stderr, "Skip the broadcast message (pos %d, size %d)\n", neighbours.pos, neighbours.size); 1474 fprintf (stderr, "LOG : Skip the broadcast message (pos %d, size %d)\n", neighbours.pos, neighbours.size);
1495 } 1475 }
1496 else 1476 else
1497 { 1477 {
@@ -1502,17 +1482,22 @@ main (int argc, char *argv[])
1502 else 1482 else
1503 { 1483 {
1504 int found = 0; 1484 int found = 0;
1485 int pos = 0;
1505 /* Search if the address already exists on the list */ 1486 /* Search if the address already exists on the list */
1506 for (i = 0; i < neighbours.size; i++) 1487 for (i = 0; i < neighbours.size; i++)
1507 { 1488 {
1508 if (memcmp (&frame->addr1, &(neighbours.devices[i]), sizeof (bdaddr_t)) == 0 && neighbours.fds[i] != -1) 1489 if (memcmp (&frame->addr1, &(neighbours.devices[i]), sizeof (bdaddr_t)) == 0)
1509 { 1490 {
1510 found = 1; 1491 pos = i;
1511 FD_SET (neighbours.fds[i], &wfds); 1492 if (neighbours.fds[i] != -1)
1512 maxfd = MAX (maxfd, neighbours.fds[i]); 1493 {
1513 sendsocket = neighbours.fds[i]; 1494 found = 1; //save the position where it was found
1514 fprintf (stderr, "LOG: the address was found in the list\n"); 1495 FD_SET (neighbours.fds[i], &wfds);
1515 break; 1496 maxfd = MAX (maxfd, neighbours.fds[i]);
1497 sendsocket = neighbours.fds[i];
1498 fprintf (stderr, "LOG: the address was found in the list\n");
1499 break;
1500 }
1516 } 1501 }
1517 } 1502 }
1518 if (found == 0) 1503 if (found == 0)
@@ -1537,11 +1522,6 @@ main (int argc, char *argv[])
1537 addr.rc_family = AF_BLUETOOTH; 1522 addr.rc_family = AF_BLUETOOTH;
1538 addr.rc_channel = get_channel (&dev, addr.rc_bdaddr); 1523 addr.rc_channel = get_channel (&dev, addr.rc_bdaddr);
1539 1524
1540 /***
1541 *TODO: use a NON-BLOCKING socket
1542 * sock_flags = fcntl (sendsocket, F_GETFL, 0);
1543 * fcntl( sendsocket, F_SETFL, sock_flags | O_NONBLOCK);
1544 */
1545 int tries = 0; 1525 int tries = 0;
1546 connect_retry: 1526 connect_retry:
1547 status = connect (sendsocket, (struct sockaddr *) &addr, sizeof (addr)); 1527 status = connect (sendsocket, (struct sockaddr *) &addr, sizeof (addr));
@@ -1549,19 +1529,19 @@ main (int argc, char *argv[])
1549 { 1529 {
1550 if (errno == ECONNREFUSED && tries < 2) 1530 if (errno == ECONNREFUSED && tries < 2)
1551 { 1531 {
1552 fprintf (stderr, "%s failed to connect. Trying again!\n", dev.iface); 1532 fprintf (stderr, "LOG : %.*s failed to connect. Trying again!\n", IFNAMSIZ, dev.iface);
1553 tries++; 1533 tries++;
1554 goto connect_retry; 1534 goto connect_retry;
1555 } 1535 }
1556 else if (errno == EBADF) 1536 else if (errno == EBADF)
1557 { 1537 {
1558 fprintf (stderr, "%s failed to connect : %s. Skip it!\n", dev.iface, strerror (errno)); 1538 fprintf (stderr, "LOG : %s failed to connect : %s. Skip it!\n", dev.iface, strerror (errno));
1559 memset (&write_pout, 0, sizeof (write_pout)); 1539 memset (&write_pout, 0, sizeof (write_pout));
1560 broadcast = 1; 1540 broadcast = 1;
1561 } 1541 }
1562 else 1542 else
1563 { 1543 {
1564 fprintf (stderr, "%s failed to connect : %s. Try again later!\n", dev.iface, strerror (errno)); 1544 fprintf (stderr, "LOG : %s failed to connect : %s. Try again later!\n", dev.iface, strerror (errno));
1565 memset (&write_pout, 0, sizeof (write_pout)); 1545 memset (&write_pout, 0, sizeof (write_pout));
1566 broadcast = 1; 1546 broadcast = 1;
1567 } 1547 }
@@ -1571,16 +1551,23 @@ main (int argc, char *argv[])
1571 { 1551 {
1572 FD_SET (sendsocket, &wfds); 1552 FD_SET (sendsocket, &wfds);
1573 maxfd = MAX (maxfd, sendsocket); 1553 maxfd = MAX (maxfd, sendsocket);
1574 fprintf (stderr, "Connection successful\n"); 1554 fprintf (stderr, "LOG : Connection successful\n");
1575 /* Add the new device to the discovered devices list */ 1555 if (pos != 0) // save the socket
1576 if (neighbours.size < MAX_PORTS)
1577 { 1556 {
1578 neighbours.fds[neighbours.size] = sendsocket; 1557 neighbours.fds[pos] = sendsocket;
1579 memcpy (&(neighbours.devices[neighbours.size++]), &addr.rc_bdaddr, sizeof (bdaddr_t));
1580 } 1558 }
1581 else 1559 else
1582 { 1560 {
1583 fprintf (stderr, "The top limit for the discovarable devices' list was reached\n"); 1561 /* Add the new device to the discovered devices list */
1562 if (neighbours.size < MAX_PORTS)
1563 {
1564 neighbours.fds[neighbours.size] = sendsocket;
1565 memcpy (&(neighbours.devices[neighbours.size++]), &addr.rc_bdaddr, sizeof (bdaddr_t));
1566 }
1567 else
1568 {
1569 fprintf (stderr, "The top limit for the discovarable devices' list was reached\n");
1570 }
1584 } 1571 }
1585 } 1572 }
1586 } 1573 }
@@ -1591,7 +1578,7 @@ main (int argc, char *argv[])
1591 { 1578 {
1592 /* Select a fd which is ready for action :) */ 1579 /* Select a fd which is ready for action :) */
1593 { 1580 {
1594 int retval = select (maxfd + 1, &rfds, &wfds, NULL, NULL); //FIXME : when a device close the connection remove the socket from the list 1581 int retval = select (maxfd + 1, &rfds, &wfds, NULL, NULL);
1595 if ((-1 == retval) && (EINTR == errno)) 1582 if ((-1 == retval) && (EINTR == errno))
1596 continue; 1583 continue;
1597 if (0 > retval && errno != EBADF) // we handle BADF errors later 1584 if (0 > retval && errno != EBADF) // we handle BADF errors later
@@ -1629,8 +1616,7 @@ main (int argc, char *argv[])
1629 if (0 > ret) //FIXME should I check first the error type? 1616 if (0 > ret) //FIXME should I check first the error type?
1630 { 1617 {
1631 fprintf (stderr, "Failed to write to bluetooth device: %s. Closing the socket!\n", 1618 fprintf (stderr, "Failed to write to bluetooth device: %s. Closing the socket!\n",
1632 strerror (errno)); 1619 strerror (errno));
1633
1634 for (i = 0; i < neighbours.size; i++) 1620 for (i = 0; i < neighbours.size; i++)
1635 { 1621 {
1636 if (neighbours.fds[i] == sendsocket) 1622 if (neighbours.fds[i] == sendsocket)
@@ -1640,15 +1626,17 @@ main (int argc, char *argv[])
1640 break; 1626 break;
1641 } 1627 }
1642 } 1628 }
1643 //memset (&(write_pout.buf + write_std.pos), 0, (write_pout.size - write_pout.pos)) // FIXME should I remove the message? or try to resend it 1629 /* Remove the message */
1644 //write_pour.pos = 0 ; write_pout.size = 0; 1630 memset (&write_pout.buf + write_std.pos, 0, (write_pout.size - write_pout.pos));
1631 write_pout.pos = 0 ;
1632 write_pout.size = 0;
1645 } 1633 }
1646 else 1634 else
1647 { 1635 {
1648 write_pout.pos += ret; 1636 write_pout.pos += ret;
1649 if ((write_pout.pos != write_pout.size) && (0 != ret)) 1637 if ((write_pout.pos != write_pout.size) && (0 != ret))
1650 { 1638 {
1651 /* we should not get partial sends with packet-oriented devices... */ 1639 /* We should not get partial sends with packet-oriented devices... */
1652 fprintf (stderr, "Write error, partial send: %u/%u\n", 1640 fprintf (stderr, "Write error, partial send: %u/%u\n",
1653 (unsigned int) write_pout.pos, 1641 (unsigned int) write_pout.pos,
1654 (unsigned int) write_pout.size); 1642 (unsigned int) write_pout.size);
@@ -1664,7 +1652,7 @@ main (int argc, char *argv[])
1664 } 1652 }
1665 } 1653 }
1666 } 1654 }
1667 for (i = 0; i <= maxfd; i++) //FIXME it should be incremented 1655 for (i = 0; i <= maxfd; i++)
1668 { 1656 {
1669 if (FD_ISSET (i, &rfds)) 1657 if (FD_ISSET (i, &rfds))
1670 { 1658 {
@@ -1675,7 +1663,7 @@ main (int argc, char *argv[])
1675 if (0 > ret) 1663 if (0 > ret)
1676 { 1664 {
1677 fprintf (stderr, "Read error from STDIN: %s\n", strerror (errno)); 1665 fprintf (stderr, "Read error from STDIN: %s\n", strerror (errno));
1678 break; 1666 break; break;
1679 } 1667 }
1680 if (0 == ret) 1668 if (0 == ret)
1681 { 1669 {
@@ -1698,9 +1686,9 @@ main (int argc, char *argv[])
1698 fprintf(stderr, "LOG : %s accepts a message\n", dev.iface); //FIXME: debugging message 1686 fprintf(stderr, "LOG : %s accepts a message\n", dev.iface); //FIXME: debugging message
1699 if (readsocket == -1) 1687 if (readsocket == -1)
1700 { 1688 {
1701 fprintf (stderr, "Failed to accept a connection on interface: %s\n", 1689 fprintf (stderr, "Failed to accept a connection on interface: %.*s\n", IFNAMSIZ,
1702 strerror (errno)); 1690 strerror (errno));
1703 return -1; //FIXME probably I should ignore the error and keep the process alive 1691 break;
1704 } 1692 }
1705 else 1693 else
1706 { 1694 {
@@ -1758,20 +1746,6 @@ main (int argc, char *argv[])
1758 - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame); 1746 - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame);
1759 rrm->header.size = htons (write_std.size); 1747 rrm->header.size = htons (write_std.size);
1760 rrm->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER); 1748 rrm->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER);
1761
1762 /* Remove the socket from the list */
1763 int j;
1764 for (j = 0; j < crt_rfds; j++)
1765 {
1766 if (i == rfds_list[crt_rfds])
1767 {
1768 rfds_list[j] ^= rfds_list[crt_rfds];
1769 rfds_list[crt_rfds] ^= rfds_list[j];
1770 rfds_list[j] ^= rfds_list[crt_rfds];
1771 crt_rfds -= 1;
1772 break;
1773 }
1774 }
1775 } 1749 }
1776 } 1750 }
1777 } 1751 }
diff --git a/src/transport/plugin_transport_bluetooth.c b/src/transport/plugin_transport_bluetooth.c
index ef8c6f1a2..36c5c8e2e 100644
--- a/src/transport/plugin_transport_bluetooth.c
+++ b/src/transport/plugin_transport_bluetooth.c
@@ -1859,6 +1859,28 @@ libgnunet_plugin_transport_bluetooth_init (void *cls)
1859 NULL, 1859 NULL,
1860 plugin); 1860 plugin);
1861 break; 1861 break;
1862 case 1: /* testmode, peer 1 */
1863 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy";
1864 plugin->helper_argv[1] = (char *) "1";
1865 plugin->helper_argv[2] = NULL;
1866 plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO,
1867 "gnunet-helper-transport-wlan-dummy",
1868 plugin->helper_argv,
1869 &handle_helper_message,
1870 NULL,
1871 plugin);
1872 break;
1873 case 2: /* testmode, peer 2 */
1874 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy";
1875 plugin->helper_argv[1] = (char *) "2";
1876 plugin->helper_argv[2] = NULL;
1877 plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO,
1878 "gnunet-helper-transport-wlan-dummy",
1879 plugin->helper_argv,
1880 &handle_helper_message,
1881 NULL,
1882 plugin);
1883 break;
1862 default: 1884 default:
1863 GNUNET_assert (0); 1885 GNUNET_assert (0);
1864 } 1886 }
diff --git a/src/transport/test_quota_compliance_bluetooth_asymmetric_peer1.conf b/src/transport/test_quota_compliance_bluetooth_asymmetric_peer1.conf
new file mode 100644
index 000000000..77d06bee4
--- /dev/null
+++ b/src/transport/test_quota_compliance_bluetooth_asymmetric_peer1.conf
@@ -0,0 +1,30 @@
1@INLINE@ template_cfg_peer1.conf
2[PATHS]
3SERVICEHOME = /tmp/test-transport/api-bluetooth-p1/
4
5[transport-bluetooth]
6INTERFACE = hci0
7TESTMODE = 1
8
9[arm]
10PORT = 12164
11UNIXPATH = /tmp/gnunet-p1-service-arm.sock
12
13[statistics]
14PORT = 12163
15UNIXPATH = /tmp/gnunet-p1-service-statistics.sock
16
17[resolver]
18PORT = 12162
19UNIXPATH = /tmp/gnunet-p1-service-resolver.sock
20
21[peerinfo]
22PORT = 12161
23UNIXPATH = /tmp/gnunet-p1-service-peerinfo.sock
24
25[transport]
26PORT = 12160
27PLUGINS = bluetooth
28UNIXPATH = /tmp/gnunet-p1-service-transport.sock
29
30
diff --git a/src/transport/test_quota_compliance_bluetooth_asymmetric_peer2.conf b/src/transport/test_quota_compliance_bluetooth_asymmetric_peer2.conf
new file mode 100644
index 000000000..f5941fdae
--- /dev/null
+++ b/src/transport/test_quota_compliance_bluetooth_asymmetric_peer2.conf
@@ -0,0 +1,29 @@
1@INLINE@ template_cfg_peer2.conf
2[PATHS]
3SERVICEHOME = /tmp/test-transport/api-bluetooth-p2/
4
5[transport-bluetooth]
6INTERFACE = hci1
7TESTMODE = 2
8
9[arm]
10PORT = 12174
11UNIXPATH = /tmp/gnunet-p2-service-arm.sock
12
13[statistics]
14PORT = 12173
15UNIXPATH = /tmp/gnunet-p2-service-statistics.sock
16
17[resolver]
18PORT = 12172
19UNIXPATH = /tmp/gnunet-p2-service-resolver.sock
20
21[peerinfo]
22PORT = 12171
23UNIXPATH = /tmp/gnunet-p2-service-peerinfo.sock
24
25[transport]
26PORT = 12170
27PLUGINS = bluetooth
28UNIXPATH = /tmp/gnunet-p2-service-transport.sock
29
diff --git a/src/transport/test_quota_compliance_bluetooth_peer1.conf b/src/transport/test_quota_compliance_bluetooth_peer1.conf
new file mode 100644
index 000000000..77d06bee4
--- /dev/null
+++ b/src/transport/test_quota_compliance_bluetooth_peer1.conf
@@ -0,0 +1,30 @@
1@INLINE@ template_cfg_peer1.conf
2[PATHS]
3SERVICEHOME = /tmp/test-transport/api-bluetooth-p1/
4
5[transport-bluetooth]
6INTERFACE = hci0
7TESTMODE = 1
8
9[arm]
10PORT = 12164
11UNIXPATH = /tmp/gnunet-p1-service-arm.sock
12
13[statistics]
14PORT = 12163
15UNIXPATH = /tmp/gnunet-p1-service-statistics.sock
16
17[resolver]
18PORT = 12162
19UNIXPATH = /tmp/gnunet-p1-service-resolver.sock
20
21[peerinfo]
22PORT = 12161
23UNIXPATH = /tmp/gnunet-p1-service-peerinfo.sock
24
25[transport]
26PORT = 12160
27PLUGINS = bluetooth
28UNIXPATH = /tmp/gnunet-p1-service-transport.sock
29
30
diff --git a/src/transport/test_quota_compliance_bluetooth_peer2.conf b/src/transport/test_quota_compliance_bluetooth_peer2.conf
new file mode 100644
index 000000000..f5941fdae
--- /dev/null
+++ b/src/transport/test_quota_compliance_bluetooth_peer2.conf
@@ -0,0 +1,29 @@
1@INLINE@ template_cfg_peer2.conf
2[PATHS]
3SERVICEHOME = /tmp/test-transport/api-bluetooth-p2/
4
5[transport-bluetooth]
6INTERFACE = hci1
7TESTMODE = 2
8
9[arm]
10PORT = 12174
11UNIXPATH = /tmp/gnunet-p2-service-arm.sock
12
13[statistics]
14PORT = 12173
15UNIXPATH = /tmp/gnunet-p2-service-statistics.sock
16
17[resolver]
18PORT = 12172
19UNIXPATH = /tmp/gnunet-p2-service-resolver.sock
20
21[peerinfo]
22PORT = 12171
23UNIXPATH = /tmp/gnunet-p2-service-peerinfo.sock
24
25[transport]
26PORT = 12170
27PLUGINS = bluetooth
28UNIXPATH = /tmp/gnunet-p2-service-transport.sock
29
diff --git a/src/transport/test_transport_api_bluetooth_peer1.conf b/src/transport/test_transport_api_bluetooth_peer1.conf
new file mode 100644
index 000000000..baf84a21b
--- /dev/null
+++ b/src/transport/test_transport_api_bluetooth_peer1.conf
@@ -0,0 +1,35 @@
1@INLINE@ template_cfg_peer1.conf
2[PATHS]
3SERVICEHOME = /tmp/test-transport/api-bluetooth-p1/
4
5[transport-bluetooth]
6INTERFACE = hci0
7TESTMODE = 1
8
9[arm]
10PORT = 12164
11UNIXPATH = /tmp/gnunet-p1-service-arm.sock
12
13[statistics]
14PORT = 12163
15UNIXPATH = /tmp/gnunet-p1-service-statistics.sock
16
17[resolver]
18PORT = 12162
19UNIXPATH = /tmp/gnunet-p1-service-resolver.sock
20
21[peerinfo]
22PORT = 12161
23UNIXPATH = /tmp/gnunet-p1-service-peerinfo.sock
24
25[transport]
26PORT = 12160
27PLUGINS = bluetooth
28UNIXPATH = /tmp/gnunet-p1-service-transport.sock
29#PREFIX = xterm -T transport2 -e gdb --command=cmd --args
30#PREFIX = valgrind --leak-check=full --show-reachable=yes --main-stacksize=104857600
31#PREFIX = valgrind --leak-check=full --show-reachable=yes
32#PREFIX = valgrind --leak-check=full
33#PREFIX = valgrind --tool=massif
34#PREFIX = gdbserver :2345
35
diff --git a/src/transport/test_transport_api_bluetooth_peer2.conf b/src/transport/test_transport_api_bluetooth_peer2.conf
new file mode 100644
index 000000000..99836a732
--- /dev/null
+++ b/src/transport/test_transport_api_bluetooth_peer2.conf
@@ -0,0 +1,34 @@
1@INLINE@ template_cfg_peer2.conf
2[PATHS]
3SERVICEHOME = /tmp/test-transport/api-bluetooth-p2/
4
5[transport-bluetooth]
6INTERFACE = hci1
7TESTMODE = 2
8
9[arm]
10PORT = 12174
11UNIXPATH = /tmp/gnunet-p2-service-arm.sock
12
13[statistics]
14PORT = 12173
15UNIXPATH = /tmp/gnunet-p2-service-statistics.sock
16
17[resolver]
18PORT = 12172
19UNIXPATH = /tmp/gnunet-p2-service-resolver.sock
20
21[peerinfo]
22PORT = 12171
23UNIXPATH = /tmp/gnunet-p2-service-peerinfo.sock
24
25[transport]
26PORT = 12170
27PLUGINS = bluetooth
28UNIXPATH = /tmp/gnunet-p2-service-transport.sock
29#PREFIX = xterm -T transport2 -e gdb --command=cmd --args
30#PREFIX = valgrind --leak-check=full --show-reachable=yes --main-stacksize=104857600
31#PREFIX = valgrind --leak-check=full --show-reachable=yes
32#PREFIX = valgrind --leak-check=full
33#PREFIX = valgrind --tool=massif
34#PREFIX = gdbserver :2345
diff --git a/src/transport/test_transport_api_reliability_bluetooth_peer1.conf b/src/transport/test_transport_api_reliability_bluetooth_peer1.conf
new file mode 100644
index 000000000..77d06bee4
--- /dev/null
+++ b/src/transport/test_transport_api_reliability_bluetooth_peer1.conf
@@ -0,0 +1,30 @@
1@INLINE@ template_cfg_peer1.conf
2[PATHS]
3SERVICEHOME = /tmp/test-transport/api-bluetooth-p1/
4
5[transport-bluetooth]
6INTERFACE = hci0
7TESTMODE = 1
8
9[arm]
10PORT = 12164
11UNIXPATH = /tmp/gnunet-p1-service-arm.sock
12
13[statistics]
14PORT = 12163
15UNIXPATH = /tmp/gnunet-p1-service-statistics.sock
16
17[resolver]
18PORT = 12162
19UNIXPATH = /tmp/gnunet-p1-service-resolver.sock
20
21[peerinfo]
22PORT = 12161
23UNIXPATH = /tmp/gnunet-p1-service-peerinfo.sock
24
25[transport]
26PORT = 12160
27PLUGINS = bluetooth
28UNIXPATH = /tmp/gnunet-p1-service-transport.sock
29
30
diff --git a/src/transport/test_transport_api_reliability_bluetooth_peer2.conf b/src/transport/test_transport_api_reliability_bluetooth_peer2.conf
new file mode 100644
index 000000000..f5941fdae
--- /dev/null
+++ b/src/transport/test_transport_api_reliability_bluetooth_peer2.conf
@@ -0,0 +1,29 @@
1@INLINE@ template_cfg_peer2.conf
2[PATHS]
3SERVICEHOME = /tmp/test-transport/api-bluetooth-p2/
4
5[transport-bluetooth]
6INTERFACE = hci1
7TESTMODE = 2
8
9[arm]
10PORT = 12174
11UNIXPATH = /tmp/gnunet-p2-service-arm.sock
12
13[statistics]
14PORT = 12173
15UNIXPATH = /tmp/gnunet-p2-service-statistics.sock
16
17[resolver]
18PORT = 12172
19UNIXPATH = /tmp/gnunet-p2-service-resolver.sock
20
21[peerinfo]
22PORT = 12171
23UNIXPATH = /tmp/gnunet-p2-service-peerinfo.sock
24
25[transport]
26PORT = 12170
27PLUGINS = bluetooth
28UNIXPATH = /tmp/gnunet-p2-service-transport.sock
29
diff --git a/src/transport/test_transport_api_unreliability_bluetooth_peer1.conf b/src/transport/test_transport_api_unreliability_bluetooth_peer1.conf
new file mode 100644
index 000000000..77d06bee4
--- /dev/null
+++ b/src/transport/test_transport_api_unreliability_bluetooth_peer1.conf
@@ -0,0 +1,30 @@
1@INLINE@ template_cfg_peer1.conf
2[PATHS]
3SERVICEHOME = /tmp/test-transport/api-bluetooth-p1/
4
5[transport-bluetooth]
6INTERFACE = hci0
7TESTMODE = 1
8
9[arm]
10PORT = 12164
11UNIXPATH = /tmp/gnunet-p1-service-arm.sock
12
13[statistics]
14PORT = 12163
15UNIXPATH = /tmp/gnunet-p1-service-statistics.sock
16
17[resolver]
18PORT = 12162
19UNIXPATH = /tmp/gnunet-p1-service-resolver.sock
20
21[peerinfo]
22PORT = 12161
23UNIXPATH = /tmp/gnunet-p1-service-peerinfo.sock
24
25[transport]
26PORT = 12160
27PLUGINS = bluetooth
28UNIXPATH = /tmp/gnunet-p1-service-transport.sock
29
30
diff --git a/src/transport/test_transport_api_unreliability_bluetooth_peer2.conf b/src/transport/test_transport_api_unreliability_bluetooth_peer2.conf
new file mode 100644
index 000000000..f5941fdae
--- /dev/null
+++ b/src/transport/test_transport_api_unreliability_bluetooth_peer2.conf
@@ -0,0 +1,29 @@
1@INLINE@ template_cfg_peer2.conf
2[PATHS]
3SERVICEHOME = /tmp/test-transport/api-bluetooth-p2/
4
5[transport-bluetooth]
6INTERFACE = hci1
7TESTMODE = 2
8
9[arm]
10PORT = 12174
11UNIXPATH = /tmp/gnunet-p2-service-arm.sock
12
13[statistics]
14PORT = 12173
15UNIXPATH = /tmp/gnunet-p2-service-statistics.sock
16
17[resolver]
18PORT = 12172
19UNIXPATH = /tmp/gnunet-p2-service-resolver.sock
20
21[peerinfo]
22PORT = 12171
23UNIXPATH = /tmp/gnunet-p2-service-peerinfo.sock
24
25[transport]
26PORT = 12170
27PLUGINS = bluetooth
28UNIXPATH = /tmp/gnunet-p2-service-transport.sock
29