diff options
Diffstat (limited to 'src/transport/gnunet-helper-transport-bluetooth.c')
-rw-r--r-- | src/transport/gnunet-helper-transport-bluetooth.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/transport/gnunet-helper-transport-bluetooth.c b/src/transport/gnunet-helper-transport-bluetooth.c index c0e0d9673..9b56d0922 100644 --- a/src/transport/gnunet-helper-transport-bluetooth.c +++ b/src/transport/gnunet-helper-transport-bluetooth.c | |||
@@ -446,6 +446,7 @@ do_align: | |||
446 | return ret; | 446 | return ret; |
447 | } | 447 | } |
448 | 448 | ||
449 | |||
449 | /** | 450 | /** |
450 | * Destroys a tokenizer. | 451 | * Destroys a tokenizer. |
451 | * | 452 | * |
@@ -458,6 +459,7 @@ mst_destroy (struct MessageStreamTokenizer *mst) | |||
458 | free (mst); | 459 | free (mst); |
459 | } | 460 | } |
460 | 461 | ||
462 | |||
461 | /** | 463 | /** |
462 | * Calculate crc32, the start of the calculation | 464 | * Calculate crc32, the start of the calculation |
463 | * | 465 | * |
@@ -558,14 +560,13 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
558 | 560 | ||
559 | crc = calc_crc_osdep (buf, len); | 561 | crc = calc_crc_osdep (buf, len); |
560 | buf += len; | 562 | buf += len; |
561 | if ((((crc) & 0xFF) == buf[0])&&(((crc >> 8) & 0xFF) == buf[1])&& | 563 | if ((((crc) & 0xFF) == buf[0]) && (((crc >> 8) & 0xFF) == buf[1]) && |
562 | ( ((crc >> 16) & 0xFF) == buf[2]) &&( ((crc >> 24) & 0xFF) == buf[3]) ) | 564 | ( ((crc >> 16) & 0xFF) == buf[2]) && ( ((crc >> 24) & 0xFF) == buf[3]) ) |
563 | return 0; | 565 | return 0; |
564 | return 1; | 566 | return 1; |
565 | } | 567 | } |
566 | 568 | ||
567 | 569 | ||
568 | |||
569 | /* ************** end of clone ***************** */ | 570 | /* ************** end of clone ***************** */ |
570 | #ifdef LINUX | 571 | #ifdef LINUX |
571 | /** | 572 | /** |
@@ -593,6 +594,8 @@ bind_socket (int socket, struct sockaddr_rc *addr) | |||
593 | 594 | ||
594 | return -1; | 595 | return -1; |
595 | } | 596 | } |
597 | |||
598 | |||
596 | #endif | 599 | #endif |
597 | 600 | ||
598 | /** | 601 | /** |
@@ -613,8 +616,7 @@ register_service (struct HardwareInfos *dev, int rc_channel) | |||
613 | * 5. set the name, provider and description | 616 | * 5. set the name, provider and description |
614 | * 6. register the service record to the local SDP server | 617 | * 6. register the service record to the local SDP server |
615 | * 7. cleanup | 618 | * 7. cleanup |
616 | */ | 619 | */uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
617 | uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
618 | dev->pl_mac.mac[5], dev->pl_mac.mac[4], | 620 | dev->pl_mac.mac[5], dev->pl_mac.mac[4], |
619 | dev->pl_mac.mac[3], | 621 | dev->pl_mac.mac[3], |
620 | dev->pl_mac.mac[2], dev->pl_mac.mac[1], | 622 | dev->pl_mac.mac[2], dev->pl_mac.mac[1], |
@@ -688,6 +690,7 @@ register_service (struct HardwareInfos *dev, int rc_channel) | |||
688 | return 0; | 690 | return 0; |
689 | } | 691 | } |
690 | 692 | ||
693 | |||
691 | /** | 694 | /** |
692 | * Function used for searching and browsing for a service. This will return the | 695 | * Function used for searching and browsing for a service. This will return the |
693 | * port number on which the service is running. | 696 | * port number on which the service is running. |
@@ -706,8 +709,7 @@ get_channel (struct HardwareInfos *dev, bdaddr_t dest) | |||
706 | * 2.2. get a list of service records with the specific UUID | 709 | * 2.2. get a list of service records with the specific UUID |
707 | * 2.3. for each service record get a list of the protocol sequences and get | 710 | * 2.3. for each service record get a list of the protocol sequences and get |
708 | * the port number | 711 | * the port number |
709 | */ | 712 | */uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
710 | uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
711 | dest.b[5], dest.b[4], dest.b[3], | 713 | dest.b[5], dest.b[4], dest.b[3], |
712 | dest.b[2], dest.b[1], dest.b[0] }; | 714 | dest.b[2], dest.b[1], dest.b[0] }; |
713 | sdp_session_t *session = 0; | 715 | sdp_session_t *session = 0; |
@@ -763,6 +765,7 @@ get_channel (struct HardwareInfos *dev, bdaddr_t dest) | |||
763 | return channel; | 765 | return channel; |
764 | } | 766 | } |
765 | 767 | ||
768 | |||
766 | /** | 769 | /** |
767 | * Read from the socket and put the result into the buffer for transmission to 'stdout'. | 770 | * Read from the socket and put the result into the buffer for transmission to 'stdout'. |
768 | * | 771 | * |
@@ -954,7 +957,6 @@ open_device (struct HardwareInfos *dev) | |||
954 | (void) close (fd_hci); | 957 | (void) close (fd_hci); |
955 | 958 | ||
956 | 959 | ||
957 | |||
958 | /* Bind the rfcomm socket to the interface */ | 960 | /* Bind the rfcomm socket to the interface */ |
959 | memset (&rc_addr, 0, sizeof(rc_addr)); | 961 | memset (&rc_addr, 0, sizeof(rc_addr)); |
960 | rc_addr.rc_family = AF_BLUETOOTH; | 962 | rc_addr.rc_family = AF_BLUETOOTH; |
@@ -1010,6 +1012,7 @@ mac_set (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader, | |||
1010 | taIeeeHeader->addr2 = dev->pl_mac; | 1012 | taIeeeHeader->addr2 = dev->pl_mac; |
1011 | } | 1013 | } |
1012 | 1014 | ||
1015 | |||
1013 | #ifdef LINUX | 1016 | #ifdef LINUX |
1014 | /** | 1017 | /** |
1015 | * Test if the given interface name really corresponds to a bluetooth | 1018 | * Test if the given interface name really corresponds to a bluetooth |
@@ -1038,6 +1041,8 @@ test_bluetooth_interface (const char *iface) | |||
1038 | } | 1041 | } |
1039 | return 0; | 1042 | return 0; |
1040 | } | 1043 | } |
1044 | |||
1045 | |||
1041 | #endif | 1046 | #endif |
1042 | 1047 | ||
1043 | /** | 1048 | /** |
@@ -1112,6 +1117,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1112 | write_pout.size = sendsize; | 1117 | write_pout.size = sendsize; |
1113 | } | 1118 | } |
1114 | 1119 | ||
1120 | |||
1115 | #ifdef LINUX | 1121 | #ifdef LINUX |
1116 | /** | 1122 | /** |
1117 | * Broadcast a HELLO message for peer discovery | 1123 | * Broadcast a HELLO message for peer discovery |
@@ -1127,7 +1133,7 @@ send_broadcast (struct HardwareInfos *dev, int *sendsocket) | |||
1127 | int loops = 0; | 1133 | int loops = 0; |
1128 | 1134 | ||
1129 | search_for_devices: | 1135 | search_for_devices: |
1130 | if (((neighbours.size == neighbours.pos)&&(new_device == 1)) || | 1136 | if (((neighbours.size == neighbours.pos) && (new_device == 1)) || |
1131 | (neighbours.size == 0) ) | 1137 | (neighbours.size == 0) ) |
1132 | { | 1138 | { |
1133 | inquiry_devices: // skip the conditions and force a inquiry for new devices | 1139 | inquiry_devices: // skip the conditions and force a inquiry for new devices |
@@ -1359,6 +1365,8 @@ inquiry_devices: // skip the conditions and force a inquiry for new devices | |||
1359 | 1365 | ||
1360 | return 0; | 1366 | return 0; |
1361 | } | 1367 | } |
1368 | |||
1369 | |||
1362 | #endif | 1370 | #endif |
1363 | 1371 | ||
1364 | /** | 1372 | /** |
@@ -1606,9 +1614,9 @@ main (int argc, char *argv[]) | |||
1606 | connect_retry: | 1614 | connect_retry: |
1607 | status = connect (sendsocket, (struct sockaddr *) &addr, | 1615 | status = connect (sendsocket, (struct sockaddr *) &addr, |
1608 | sizeof(addr)); | 1616 | sizeof(addr)); |
1609 | if ((0 != status) &&(errno != EAGAIN) ) | 1617 | if ((0 != status) && (errno != EAGAIN) ) |
1610 | { | 1618 | { |
1611 | if ((errno == ECONNREFUSED) &&(tries < 2) ) | 1619 | if ((errno == ECONNREFUSED) && (tries < 2) ) |
1612 | { | 1620 | { |
1613 | fprintf (stderr, "LOG : %.*s failed to connect. Trying again!\n", | 1621 | fprintf (stderr, "LOG : %.*s failed to connect. Trying again!\n", |
1614 | IFNAMSIZ, dev.iface); | 1622 | IFNAMSIZ, dev.iface); |
@@ -1668,7 +1676,7 @@ connect_retry: | |||
1668 | int retval = select (maxfd + 1, &rfds, &wfds, NULL, NULL); | 1676 | int retval = select (maxfd + 1, &rfds, &wfds, NULL, NULL); |
1669 | if ((-1 == retval) && (EINTR == errno)) | 1677 | if ((-1 == retval) && (EINTR == errno)) |
1670 | continue; | 1678 | continue; |
1671 | if ((0 > retval) &&(errno != EBADF) ) // we handle BADF errors later | 1679 | if ((0 > retval) && (errno != EBADF) ) // we handle BADF errors later |
1672 | { | 1680 | { |
1673 | fprintf (stderr, "select failed: %s\n", strerror (errno)); | 1681 | fprintf (stderr, "select failed: %s\n", strerror (errno)); |
1674 | break; | 1682 | break; |