diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-06 20:55:28 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-06 20:55:28 +0000 |
commit | 61c39c60565b386e0e12ea669556b030e8cd7180 (patch) | |
tree | 59109aeab8297bdc996faca8c4e38ec7426c36cf /src/transport/gnunet-helper-transport-bluetooth.c | |
parent | 780eb09dd8040ecf8649d40ddf8314464e0fc48e (diff) | |
download | gnunet-61c39c60565b386e0e12ea669556b030e8cd7180.tar.gz gnunet-61c39c60565b386e0e12ea669556b030e8cd7180.zip |
-remove trailing whitespace
Diffstat (limited to 'src/transport/gnunet-helper-transport-bluetooth.c')
-rw-r--r-- | src/transport/gnunet-helper-transport-bluetooth.c | 440 |
1 files changed, 220 insertions, 220 deletions
diff --git a/src/transport/gnunet-helper-transport-bluetooth.c b/src/transport/gnunet-helper-transport-bluetooth.c index cc8a6484e..343aacd19 100644 --- a/src/transport/gnunet-helper-transport-bluetooth.c +++ b/src/transport/gnunet-helper-transport-bluetooth.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <bluetooth/sdp.h> | 35 | #include <bluetooth/sdp.h> |
36 | #include <bluetooth/sdp_lib.h> | 36 | #include <bluetooth/sdp_lib.h> |
37 | #include <errno.h> | 37 | #include <errno.h> |
38 | #include <linux/if.h> | 38 | #include <linux/if.h> |
39 | #include <stdio.h> | 39 | #include <stdio.h> |
40 | #include <stdlib.h> | 40 | #include <stdlib.h> |
41 | #include <sys/ioctl.h> | 41 | #include <sys/ioctl.h> |
@@ -82,7 +82,7 @@ | |||
82 | UINT8 mac[MAC_ADDR_SIZE]; | 82 | UINT8 mac[MAC_ADDR_SIZE]; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * The UUID used for the SDP service. | 86 | * The UUID used for the SDP service. |
87 | * {31191E56-FA7E-4517-870E-71B86BBCC52F} | 87 | * {31191E56-FA7E-4517-870E-71B86BBCC52F} |
88 | */ | 88 | */ |
@@ -110,7 +110,7 @@ struct HardwareInfos | |||
110 | #ifdef MINGW | 110 | #ifdef MINGW |
111 | /** | 111 | /** |
112 | * socket handle | 112 | * socket handle |
113 | */ | 113 | */ |
114 | struct GNUNET_NETWORK_Handle *handle; | 114 | struct GNUNET_NETWORK_Handle *handle; |
115 | 115 | ||
116 | /** | 116 | /** |
@@ -127,7 +127,7 @@ struct HardwareInfos | |||
127 | * MAC address of our own bluetooth interface. | 127 | * MAC address of our own bluetooth interface. |
128 | */ | 128 | */ |
129 | struct GNUNET_TRANSPORT_WLAN_MacAddress pl_mac; | 129 | struct GNUNET_TRANSPORT_WLAN_MacAddress pl_mac; |
130 | 130 | ||
131 | /** | 131 | /** |
132 | * SDP session | 132 | * SDP session |
133 | */ | 133 | */ |
@@ -151,7 +151,7 @@ struct SendBuffer | |||
151 | * destination? Always smaller than 'size'. | 151 | * destination? Always smaller than 'size'. |
152 | */ | 152 | */ |
153 | size_t pos; | 153 | size_t pos; |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * Buffered data; twice the maximum allowed message size as we add some | 156 | * Buffered data; twice the maximum allowed message size as we add some |
157 | * headers. | 157 | * headers. |
@@ -161,13 +161,13 @@ struct SendBuffer | |||
161 | 161 | ||
162 | #ifdef LINUX | 162 | #ifdef LINUX |
163 | /** | 163 | /** |
164 | * Devices buffer used to keep a list with all the discoverable devices in | 164 | * Devices buffer used to keep a list with all the discoverable devices in |
165 | * order to send them HELLO messages one by one when it receive a broadcast message. | 165 | * order to send them HELLO messages one by one when it receive a broadcast message. |
166 | */ | 166 | */ |
167 | struct BroadcastMessages | 167 | struct BroadcastMessages |
168 | { | 168 | { |
169 | /* List with the discoverable devices' addresses */ | 169 | /* List with the discoverable devices' addresses */ |
170 | bdaddr_t devices[MAX_PORTS]; | 170 | bdaddr_t devices[MAX_PORTS]; |
171 | 171 | ||
172 | /* List with the open sockets */ | 172 | /* List with the open sockets */ |
173 | int fds[MAX_PORTS]; | 173 | int fds[MAX_PORTS]; |
@@ -175,7 +175,7 @@ struct SendBuffer | |||
175 | 175 | ||
176 | /* The number of the devices */ | 176 | /* The number of the devices */ |
177 | int size; | 177 | int size; |
178 | 178 | ||
179 | /* The current position */ | 179 | /* The current position */ |
180 | int pos; | 180 | int pos; |
181 | 181 | ||
@@ -207,7 +207,7 @@ static struct SendBuffer write_pout; | |||
207 | static struct SendBuffer write_std; | 207 | static struct SendBuffer write_std; |
208 | 208 | ||
209 | 209 | ||
210 | /* ****** this are the same functions as the ones used in gnunet-helper-transport-wlan.c ****** */ | 210 | /* ****** this are the same functions as the ones used in gnunet-helper-transport-wlan.c ****** */ |
211 | 211 | ||
212 | /** | 212 | /** |
213 | * To what multiple do we align messages? 8 byte should suffice for everyone | 213 | * To what multiple do we align messages? 8 byte should suffice for everyone |
@@ -228,7 +228,7 @@ static struct SendBuffer write_std; | |||
228 | * @param cls closure | 228 | * @param cls closure |
229 | * @param message the actual message | 229 | * @param message the actual message |
230 | */ | 230 | */ |
231 | typedef void (*MessageTokenizerCallback) (void *cls, | 231 | typedef void (*MessageTokenizerCallback) (void *cls, |
232 | const struct | 232 | const struct |
233 | GNUNET_MessageHeader * | 233 | GNUNET_MessageHeader * |
234 | message); | 234 | message); |
@@ -301,7 +301,7 @@ mst_create (MessageTokenizerCallback cb, | |||
301 | ret->cb = cb; | 301 | ret->cb = cb; |
302 | ret->cb_cls = cb_cls; | 302 | ret->cb_cls = cb_cls; |
303 | ret->pos = 0; | 303 | ret->pos = 0; |
304 | 304 | ||
305 | return ret; | 305 | return ret; |
306 | } | 306 | } |
307 | 307 | ||
@@ -602,7 +602,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
602 | if (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] && | 602 | if (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] && |
603 | ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]) | 603 | ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]) |
604 | return 0; | 604 | return 0; |
605 | return 1; | 605 | return 1; |
606 | } | 606 | } |
607 | 607 | ||
608 | 608 | ||
@@ -613,7 +613,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
613 | /** | 613 | /** |
614 | * Function used to get the code of last error and to print the type of error. | 614 | * Function used to get the code of last error and to print the type of error. |
615 | */ | 615 | */ |
616 | static void | 616 | static void |
617 | print_last_error() | 617 | print_last_error() |
618 | { | 618 | { |
619 | LPVOID lpMsgBuf = NULL; | 619 | LPVOID lpMsgBuf = NULL; |
@@ -644,9 +644,9 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
644 | /** | 644 | /** |
645 | * Function used to convert the GUID. | 645 | * Function used to convert the GUID. |
646 | * @param bytes the GUID represented as a char array | 646 | * @param bytes the GUID represented as a char array |
647 | * @param uuid pointer to the GUID | 647 | * @param uuid pointer to the GUID |
648 | */ | 648 | */ |
649 | static void | 649 | static void |
650 | convert_guid(char *bytes, GUID * uuid) | 650 | convert_guid(char *bytes, GUID * uuid) |
651 | { | 651 | { |
652 | int i; | 652 | int i; |
@@ -664,16 +664,16 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
664 | #ifdef LINUX | 664 | #ifdef LINUX |
665 | /** | 665 | /** |
666 | * Function for assigning a port number | 666 | * Function for assigning a port number |
667 | * | 667 | * |
668 | * @param socket the socket used to bind | 668 | * @param socket the socket used to bind |
669 | * @param addr pointer to the rfcomm address | 669 | * @param addr pointer to the rfcomm address |
670 | * @return 0 on success | 670 | * @return 0 on success |
671 | */ | 671 | */ |
672 | static int | 672 | static int |
673 | bind_socket (int socket, struct sockaddr_rc *addr) | 673 | bind_socket (int socket, struct sockaddr_rc *addr) |
674 | { | 674 | { |
675 | int port, status; | 675 | int port, status; |
676 | 676 | ||
677 | /* Bind every possible port (from 0 to 30) and stop when binding doesn't fail */ | 677 | /* Bind every possible port (from 0 to 30) and stop when binding doesn't fail */ |
678 | //FIXME : it should start from port 1, but on my computer it doesn't work :) | 678 | //FIXME : it should start from port 1, but on my computer it doesn't work :) |
679 | for (port = 3; port <= 30; port++) | 679 | for (port = 3; port <= 30; port++) |
@@ -683,8 +683,8 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
683 | if (status == 0) | 683 | if (status == 0) |
684 | return 0; | 684 | return 0; |
685 | } | 685 | } |
686 | 686 | ||
687 | return -1; | 687 | return -1; |
688 | } | 688 | } |
689 | #endif | 689 | #endif |
690 | 690 | ||
@@ -696,7 +696,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
696 | * @return 0 on success | 696 | * @return 0 on success |
697 | */ | 697 | */ |
698 | static int | 698 | static int |
699 | register_service (struct HardwareInfos *dev) | 699 | register_service (struct HardwareInfos *dev) |
700 | { | 700 | { |
701 | /* advertise the service */ | 701 | /* advertise the service */ |
702 | CSADDR_INFO addr_info; | 702 | CSADDR_INFO addr_info; |
@@ -746,7 +746,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
746 | wqs.lpcsaBuffer = &addr_info ; | 746 | wqs.lpcsaBuffer = &addr_info ; |
747 | wqs.lpBlob = 0; | 747 | wqs.lpBlob = 0; |
748 | 748 | ||
749 | if (SOCKET_ERROR == WSASetService (&wqs , RNRSERVICE_REGISTER, 0)) | 749 | if (SOCKET_ERROR == WSASetService (&wqs , RNRSERVICE_REGISTER, 0)) |
750 | { | 750 | { |
751 | fprintf (stderr, "Failed to register the SDP service: "); | 751 | fprintf (stderr, "Failed to register the SDP service: "); |
752 | print_last_error(); | 752 | print_last_error(); |
@@ -768,7 +768,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
768 | * @return 0 on success | 768 | * @return 0 on success |
769 | */ | 769 | */ |
770 | static int | 770 | static int |
771 | register_service (struct HardwareInfos *dev, int rc_channel) | 771 | register_service (struct HardwareInfos *dev, int rc_channel) |
772 | { | 772 | { |
773 | /** | 773 | /** |
774 | * 1. initializations | 774 | * 1. initializations |
@@ -779,17 +779,17 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
779 | * 6. register the service record to the local SDP server | 779 | * 6. register the service record to the local SDP server |
780 | * 7. cleanup | 780 | * 7. cleanup |
781 | */ | 781 | */ |
782 | uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 782 | uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
783 | dev->pl_mac.mac[5], dev->pl_mac.mac[4], dev->pl_mac.mac[3], | 783 | dev->pl_mac.mac[5], dev->pl_mac.mac[4], dev->pl_mac.mac[3], |
784 | dev->pl_mac.mac[2], dev->pl_mac.mac[1], dev->pl_mac.mac[0]}; | 784 | dev->pl_mac.mac[2], dev->pl_mac.mac[1], dev->pl_mac.mac[0]}; |
785 | const char *service_dsc = "Bluetooth plugin services"; | 785 | const char *service_dsc = "Bluetooth plugin services"; |
786 | const char *service_prov = "GNUnet provider"; | 786 | const char *service_prov = "GNUnet provider"; |
787 | uuid_t root_uuid, rfcomm_uuid, svc_uuid; | 787 | uuid_t root_uuid, rfcomm_uuid, svc_uuid; |
788 | sdp_list_t *root_list = 0, *rfcomm_list = 0, *proto_list = 0, | 788 | sdp_list_t *root_list = 0, *rfcomm_list = 0, *proto_list = 0, |
789 | *access_proto_list = 0, *svc_list = 0; | 789 | *access_proto_list = 0, *svc_list = 0; |
790 | sdp_record_t *record = 0; | 790 | sdp_record_t *record = 0; |
791 | sdp_data_t *channel = 0; | 791 | sdp_data_t *channel = 0; |
792 | 792 | ||
793 | record = sdp_record_alloc(); | 793 | record = sdp_record_alloc(); |
794 | 794 | ||
795 | /* Set the general service ID */ | 795 | /* Set the general service ID */ |
@@ -799,8 +799,8 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
799 | sdp_set_service_id (record, svc_uuid); | 799 | sdp_set_service_id (record, svc_uuid); |
800 | 800 | ||
801 | /* Make the service record publicly browsable */ | 801 | /* Make the service record publicly browsable */ |
802 | sdp_uuid16_create (&root_uuid, PUBLIC_BROWSE_GROUP); | 802 | sdp_uuid16_create (&root_uuid, PUBLIC_BROWSE_GROUP); |
803 | root_list = sdp_list_append (0, &root_uuid); | 803 | root_list = sdp_list_append (0, &root_uuid); |
804 | sdp_set_browse_groups (record, root_list); | 804 | sdp_set_browse_groups (record, root_list); |
805 | 805 | ||
806 | /* Register the RFCOMM channel */ | 806 | /* Register the RFCOMM channel */ |
@@ -816,10 +816,10 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
816 | 816 | ||
817 | /* Set the name, provider, and description */ | 817 | /* Set the name, provider, and description */ |
818 | sdp_set_info_attr (record, dev->iface, service_prov, service_dsc); | 818 | sdp_set_info_attr (record, dev->iface, service_prov, service_dsc); |
819 | 819 | ||
820 | /* Connect to the local SDP server */ | 820 | /* Connect to the local SDP server */ |
821 | dev->session = sdp_connect (BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY); | 821 | dev->session = sdp_connect (BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY); |
822 | 822 | ||
823 | if (!dev->session) | 823 | if (!dev->session) |
824 | { | 824 | { |
825 | fprintf (stderr, "Failed to connect to the SDP server on interface `%.*s': %s\n", | 825 | fprintf (stderr, "Failed to connect to the SDP server on interface `%.*s': %s\n", |
@@ -827,7 +827,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
827 | //FIXME exit? | 827 | //FIXME exit? |
828 | return 1; | 828 | return 1; |
829 | } | 829 | } |
830 | 830 | ||
831 | /* Register the service record */ | 831 | /* Register the service record */ |
832 | if (sdp_record_register (dev->session, record, 0) < 0) | 832 | if (sdp_record_register (dev->session, record, 0) < 0) |
833 | { | 833 | { |
@@ -836,23 +836,23 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
836 | //FIXME exit? | 836 | //FIXME exit? |
837 | return 1; | 837 | return 1; |
838 | } | 838 | } |
839 | 839 | ||
840 | /* Cleanup */ | 840 | /* Cleanup */ |
841 | sdp_data_free (channel); | 841 | sdp_data_free (channel); |
842 | sdp_list_free (root_list, 0); | 842 | sdp_list_free (root_list, 0); |
843 | sdp_list_free (rfcomm_list, 0); | 843 | sdp_list_free (rfcomm_list, 0); |
844 | sdp_list_free (proto_list, 0); | 844 | sdp_list_free (proto_list, 0); |
845 | sdp_list_free (access_proto_list, 0); | 845 | sdp_list_free (access_proto_list, 0); |
846 | sdp_list_free (svc_list, 0); | 846 | sdp_list_free (svc_list, 0); |
847 | sdp_record_free (record); | 847 | sdp_record_free (record); |
848 | 848 | ||
849 | return 0; | 849 | return 0; |
850 | } | 850 | } |
851 | #endif | 851 | #endif |
852 | 852 | ||
853 | #ifdef MINGW | 853 | #ifdef MINGW |
854 | /** | 854 | /** |
855 | * Function for searching and browsing for a service. This will return the | 855 | * Function for searching and browsing for a service. This will return the |
856 | * port number on which the service is running. | 856 | * port number on which the service is running. |
857 | * | 857 | * |
858 | * @param dest target address | 858 | * @param dest target address |
@@ -869,16 +869,16 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
869 | GUID guid; | 869 | GUID guid; |
870 | unsigned char uuid[] = GNUNET_BLUETOOTH_SDP_UUID; | 870 | unsigned char uuid[] = GNUNET_BLUETOOTH_SDP_UUID; |
871 | convert_guid ((char *) uuid, &guid); | 871 | convert_guid ((char *) uuid, &guid); |
872 | 872 | ||
873 | wqs = (WSAQUERYSET*)malloc (wqs_len); | 873 | wqs = (WSAQUERYSET*)malloc (wqs_len); |
874 | ZeroMemory (wqs, wqs_len); | 874 | ZeroMemory (wqs, wqs_len); |
875 | 875 | ||
876 | wqs->dwSize = sizeof (WSAQUERYSET) ; | 876 | wqs->dwSize = sizeof (WSAQUERYSET) ; |
877 | wqs->lpServiceClassId = &guid; | 877 | wqs->lpServiceClassId = &guid; |
878 | wqs->dwNameSpace = NS_BTH; | 878 | wqs->dwNameSpace = NS_BTH; |
879 | wqs->dwNumberOfCsAddrs = 0; | 879 | wqs->dwNumberOfCsAddrs = 0; |
880 | wqs->lpszContext = (LPSTR)dest; | 880 | wqs->lpszContext = (LPSTR)dest; |
881 | 881 | ||
882 | if (SOCKET_ERROR == WSALookupServiceBegin (wqs, LUP_FLUSHCACHE | LUP_RETURN_ALL, &h)) | 882 | if (SOCKET_ERROR == WSALookupServiceBegin (wqs, LUP_FLUSHCACHE | LUP_RETURN_ALL, &h)) |
883 | { | 883 | { |
884 | if (GetLastError() == WSASERVICE_NOT_FOUND) | 884 | if (GetLastError() == WSASERVICE_NOT_FOUND) |
@@ -894,14 +894,14 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
894 | return -1; | 894 | return -1; |
895 | } | 895 | } |
896 | } | 896 | } |
897 | 897 | ||
898 | /* search the sdp service */ | 898 | /* search the sdp service */ |
899 | while (!done) | 899 | while (!done) |
900 | { | 900 | { |
901 | if (SOCKET_ERROR == WSALookupServiceNext (h, LUP_FLUSHCACHE | LUP_RETURN_ALL, &wqs_len, wqs)) | 901 | if (SOCKET_ERROR == WSALookupServiceNext (h, LUP_FLUSHCACHE | LUP_RETURN_ALL, &wqs_len, wqs)) |
902 | { | 902 | { |
903 | int error = WSAGetLastError(); | 903 | int error = WSAGetLastError(); |
904 | 904 | ||
905 | switch (error) | 905 | switch (error) |
906 | { | 906 | { |
907 | case WSAEFAULT: | 907 | case WSAEFAULT: |
@@ -927,15 +927,15 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
927 | channel = ((SOCKADDR_BTH*)wqs->lpcsaBuffer->RemoteAddr.lpSockaddr)->port; | 927 | channel = ((SOCKADDR_BTH*)wqs->lpcsaBuffer->RemoteAddr.lpSockaddr)->port; |
928 | } | 928 | } |
929 | } | 929 | } |
930 | 930 | ||
931 | free (wqs) ; | 931 | free (wqs) ; |
932 | WSALookupServiceEnd (h); | 932 | WSALookupServiceEnd (h); |
933 | 933 | ||
934 | return channel; | 934 | return channel; |
935 | } | 935 | } |
936 | #else | 936 | #else |
937 | /** | 937 | /** |
938 | * Function used for searching and browsing for a service. This will return the | 938 | * Function used for searching and browsing for a service. This will return the |
939 | * port number on which the service is running. | 939 | * port number on which the service is running. |
940 | * | 940 | * |
941 | * @param dev pointer to the device struct | 941 | * @param dev pointer to the device struct |
@@ -943,17 +943,17 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
943 | * @return channel | 943 | * @return channel |
944 | */ | 944 | */ |
945 | static int | 945 | static int |
946 | get_channel(struct HardwareInfos *dev, bdaddr_t dest) | 946 | get_channel(struct HardwareInfos *dev, bdaddr_t dest) |
947 | { | 947 | { |
948 | /** | 948 | /** |
949 | * 1. detect all nearby devices | 949 | * 1. detect all nearby devices |
950 | * 2. for each device: | 950 | * 2. for each device: |
951 | * 2.1. connect to the SDP server running | 951 | * 2.1. connect to the SDP server running |
952 | * 2.2. get a list of service records with the specific UUID | 952 | * 2.2. get a list of service records with the specific UUID |
953 | * 2.3. for each service record get a list of the protocol sequences and get | 953 | * 2.3. for each service record get a list of the protocol sequences and get |
954 | * the port number | 954 | * the port number |
955 | */ | 955 | */ |
956 | uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 956 | uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
957 | dest.b[5], dest.b[4], dest.b[3], | 957 | dest.b[5], dest.b[4], dest.b[3], |
958 | dest.b[2], dest.b[1], dest.b[0]}; | 958 | dest.b[2], dest.b[1], dest.b[0]}; |
959 | sdp_session_t *session = 0; | 959 | sdp_session_t *session = 0; |
@@ -961,21 +961,21 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
961 | uuid_t svc_uuid; | 961 | uuid_t svc_uuid; |
962 | uint32_t range = 0x0000ffff; | 962 | uint32_t range = 0x0000ffff; |
963 | uint8_t channel = -1; | 963 | uint8_t channel = -1; |
964 | 964 | ||
965 | /* Connect to the local SDP server */ | 965 | /* Connect to the local SDP server */ |
966 | session = sdp_connect (BDADDR_ANY, &dest, 0); | 966 | session = sdp_connect (BDADDR_ANY, &dest, 0); |
967 | if (!session) | 967 | if (!session) |
968 | { | 968 | { |
969 | fprintf (stderr, "Failed to connect to the SDP server on interface `%.*s': %s\n", | 969 | fprintf (stderr, "Failed to connect to the SDP server on interface `%.*s': %s\n", |
970 | IFNAMSIZ, dev->iface, strerror (errno)); | 970 | IFNAMSIZ, dev->iface, strerror (errno)); |
971 | return -1; | 971 | return -1; |
972 | } | 972 | } |
973 | 973 | ||
974 | sdp_uuid128_create (&svc_uuid, &svc_uuid_int); | 974 | sdp_uuid128_create (&svc_uuid, &svc_uuid_int); |
975 | search_list = sdp_list_append (0, &svc_uuid); | 975 | search_list = sdp_list_append (0, &svc_uuid); |
976 | attrid_list = sdp_list_append (0, &range); | 976 | attrid_list = sdp_list_append (0, &range); |
977 | 977 | ||
978 | if (sdp_service_search_attr_req (session, search_list, | 978 | if (sdp_service_search_attr_req (session, search_list, |
979 | SDP_ATTR_REQ_RANGE, attrid_list, &response_list) == 0) | 979 | SDP_ATTR_REQ_RANGE, attrid_list, &response_list) == 0) |
980 | { | 980 | { |
981 | for (it = response_list; it; it = it->next) | 981 | for (it = response_list; it; it = it->next) |
@@ -990,24 +990,24 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
990 | sdp_record_free (record); | 990 | sdp_record_free (record); |
991 | } | 991 | } |
992 | } | 992 | } |
993 | 993 | ||
994 | sdp_list_free (search_list, 0); | 994 | sdp_list_free (search_list, 0); |
995 | sdp_list_free (attrid_list, 0); | 995 | sdp_list_free (attrid_list, 0); |
996 | sdp_list_free (response_list, 0); | 996 | sdp_list_free (response_list, 0); |
997 | 997 | ||
998 | sdp_close (session); | 998 | sdp_close (session); |
999 | 999 | ||
1000 | if (channel == -1) | 1000 | if (channel == -1) |
1001 | fprintf (stderr, "Failed to find the listening channel for interface `%.*s': %s\n", | 1001 | fprintf (stderr, "Failed to find the listening channel for interface `%.*s': %s\n", |
1002 | IFNAMSIZ, dev->iface, strerror (errno)); | 1002 | IFNAMSIZ, dev->iface, strerror (errno)); |
1003 | 1003 | ||
1004 | return channel; | 1004 | return channel; |
1005 | } | 1005 | } |
1006 | #endif | 1006 | #endif |
1007 | 1007 | ||
1008 | /** | 1008 | /** |
1009 | * Read from the socket and put the result into the buffer for transmission to 'stdout'. | 1009 | * Read from the socket and put the result into the buffer for transmission to 'stdout'. |
1010 | * | 1010 | * |
1011 | * @param sock file descriptor for reading | 1011 | * @param sock file descriptor for reading |
1012 | * @param buf buffer to read to; first bytes will be the 'struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame', | 1012 | * @param buf buffer to read to; first bytes will be the 'struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame', |
1013 | * followed by the actual payload | 1013 | * followed by the actual payload |
@@ -1015,18 +1015,18 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
1015 | * @param ri where to write radiotap_rx info | 1015 | * @param ri where to write radiotap_rx info |
1016 | * @return number of bytes written to 'buf' | 1016 | * @return number of bytes written to 'buf' |
1017 | */ | 1017 | */ |
1018 | static ssize_t | 1018 | static ssize_t |
1019 | read_from_the_socket (void *sock, | 1019 | read_from_the_socket (void *sock, |
1020 | unsigned char *buf, size_t buf_size, | 1020 | unsigned char *buf, size_t buf_size, |
1021 | struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *ri) | 1021 | struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *ri) |
1022 | { | 1022 | { |
1023 | unsigned char tmpbuf[buf_size]; | 1023 | unsigned char tmpbuf[buf_size]; |
1024 | ssize_t count; | 1024 | ssize_t count; |
1025 | 1025 | ||
1026 | #ifdef MINGW | 1026 | #ifdef MINGW |
1027 | count = GNUNET_NETWORK_socket_recv ((struct GNUNET_NETWORK_Handle *)sock, tmpbuf, buf_size); | 1027 | count = GNUNET_NETWORK_socket_recv ((struct GNUNET_NETWORK_Handle *)sock, tmpbuf, buf_size); |
1028 | #else | 1028 | #else |
1029 | count = read (*((int *)sock), tmpbuf, buf_size); | 1029 | count = read (*((int *)sock), tmpbuf, buf_size); |
1030 | #endif | 1030 | #endif |
1031 | 1031 | ||
1032 | if (0 > count) | 1032 | if (0 > count) |
@@ -1041,11 +1041,11 @@ read_from_the_socket (void *sock, | |||
1041 | 1041 | ||
1042 | return -1; | 1042 | return -1; |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | #ifdef LINUX | 1045 | #ifdef LINUX |
1046 | /* Get the channel used */ | 1046 | /* Get the channel used */ |
1047 | int len; | 1047 | int len; |
1048 | struct sockaddr_rc rc_addr = { 0 }; | 1048 | struct sockaddr_rc rc_addr = { 0 }; |
1049 | 1049 | ||
1050 | memset (&rc_addr, 0, sizeof (rc_addr)); | 1050 | memset (&rc_addr, 0, sizeof (rc_addr)); |
1051 | len = sizeof (rc_addr); | 1051 | len = sizeof (rc_addr); |
@@ -1064,9 +1064,9 @@ read_from_the_socket (void *sock, | |||
1064 | { | 1064 | { |
1065 | count -= sizeof(uint32_t); | 1065 | count -= sizeof(uint32_t); |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | memcpy (buf, tmpbuf, count); | 1068 | memcpy (buf, tmpbuf, count); |
1069 | 1069 | ||
1070 | return count; | 1070 | return count; |
1071 | } | 1071 | } |
1072 | 1072 | ||
@@ -1078,7 +1078,7 @@ read_from_the_socket (void *sock, | |||
1078 | */ | 1078 | */ |
1079 | static int | 1079 | static int |
1080 | open_device (struct HardwareInfos *dev) | 1080 | open_device (struct HardwareInfos *dev) |
1081 | { | 1081 | { |
1082 | #ifdef MINGW | 1082 | #ifdef MINGW |
1083 | SOCKADDR_BTH addr; | 1083 | SOCKADDR_BTH addr; |
1084 | 1084 | ||
@@ -1113,30 +1113,30 @@ open_device (struct HardwareInfos *dev) | |||
1113 | fprintf (stderr, "Failed to register a service: "); | 1113 | fprintf (stderr, "Failed to register a service: "); |
1114 | print_last_error(); | 1114 | print_last_error(); |
1115 | return 1; | 1115 | return 1; |
1116 | } | 1116 | } |
1117 | #else | 1117 | #else |
1118 | int i, dev_id = -1, fd_hci; | 1118 | int i, dev_id = -1, fd_hci; |
1119 | struct | 1119 | struct |
1120 | { | 1120 | { |
1121 | struct hci_dev_list_req list; | 1121 | struct hci_dev_list_req list; |
1122 | struct hci_dev_req dev[HCI_MAX_DEV]; | 1122 | struct hci_dev_req dev[HCI_MAX_DEV]; |
1123 | } request; //used for detecting the local devices | 1123 | } request; //used for detecting the local devices |
1124 | struct sockaddr_rc rc_addr = { 0 }; //used for binding | 1124 | struct sockaddr_rc rc_addr = { 0 }; //used for binding |
1125 | 1125 | ||
1126 | /* Initialize the neighbour structure */ | 1126 | /* Initialize the neighbour structure */ |
1127 | neighbours.dev_id = -1; | 1127 | neighbours.dev_id = -1; |
1128 | for (i = 0; i < MAX_PORTS; i++) | 1128 | for (i = 0; i < MAX_PORTS; i++) |
1129 | neighbours.fds[i] = -1; | 1129 | neighbours.fds[i] = -1; |
1130 | 1130 | ||
1131 | /* Open a HCI socket */ | 1131 | /* Open a HCI socket */ |
1132 | fd_hci = socket (AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); | 1132 | fd_hci = socket (AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); |
1133 | 1133 | ||
1134 | if (fd_hci < 0) | 1134 | if (fd_hci < 0) |
1135 | { | 1135 | { |
1136 | fprintf (stderr, "Failed to create HCI socket: %s\n", strerror (errno)); | 1136 | fprintf (stderr, "Failed to create HCI socket: %s\n", strerror (errno)); |
1137 | return -1; | 1137 | return -1; |
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | memset (&request, 0, sizeof(request)); | 1140 | memset (&request, 0, sizeof(request)); |
1141 | request.list.dev_num = HCI_MAX_DEV; | 1141 | request.list.dev_num = HCI_MAX_DEV; |
1142 | 1142 | ||
@@ -1146,7 +1146,7 @@ open_device (struct HardwareInfos *dev) | |||
1146 | IFNAMSIZ, dev->iface, strerror (errno)); | 1146 | IFNAMSIZ, dev->iface, strerror (errno)); |
1147 | return 1; | 1147 | return 1; |
1148 | } | 1148 | } |
1149 | 1149 | ||
1150 | /* Search for a device with dev->iface name */ | 1150 | /* Search for a device with dev->iface name */ |
1151 | for (i = 0; i < request.list.dev_num; i++) | 1151 | for (i = 0; i < request.list.dev_num; i++) |
1152 | { | 1152 | { |
@@ -1155,23 +1155,23 @@ open_device (struct HardwareInfos *dev) | |||
1155 | memset (&dev_info, 0, sizeof(struct hci_dev_info)); | 1155 | memset (&dev_info, 0, sizeof(struct hci_dev_info)); |
1156 | dev_info.dev_id = request.dev[i].dev_id; | 1156 | dev_info.dev_id = request.dev[i].dev_id; |
1157 | strncpy (dev_info.name, dev->iface, IFNAMSIZ); | 1157 | strncpy (dev_info.name, dev->iface, IFNAMSIZ); |
1158 | 1158 | ||
1159 | if (ioctl (fd_hci, HCIGETDEVINFO, (void *) &dev_info)) | 1159 | if (ioctl (fd_hci, HCIGETDEVINFO, (void *) &dev_info)) |
1160 | { | 1160 | { |
1161 | fprintf (stderr, "ioctl(HCIGETDEVINFO) on interface `%.*s' failed: %s\n", | 1161 | fprintf (stderr, "ioctl(HCIGETDEVINFO) on interface `%.*s' failed: %s\n", |
1162 | IFNAMSIZ, dev->iface, strerror (errno)); | 1162 | IFNAMSIZ, dev->iface, strerror (errno)); |
1163 | return 1; | 1163 | return 1; |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | if (strcmp (dev_info.name, dev->iface) == 0) | 1166 | if (strcmp (dev_info.name, dev->iface) == 0) |
1167 | { | 1167 | { |
1168 | 1168 | ||
1169 | dev_id = dev_info.dev_id; //the device was found | 1169 | dev_id = dev_info.dev_id; //the device was found |
1170 | /** | 1170 | /** |
1171 | * Copy the MAC address to the device structure | 1171 | * Copy the MAC address to the device structure |
1172 | */ | 1172 | */ |
1173 | memcpy (&dev->pl_mac, &dev_info.bdaddr, sizeof (bdaddr_t)); | 1173 | memcpy (&dev->pl_mac, &dev_info.bdaddr, sizeof (bdaddr_t)); |
1174 | 1174 | ||
1175 | /* Check if the interface is up */ | 1175 | /* Check if the interface is up */ |
1176 | if (hci_test_bit (HCI_UP, (void *) &dev_info.flags) == 0) | 1176 | if (hci_test_bit (HCI_UP, (void *) &dev_info.flags) == 0) |
1177 | { | 1177 | { |
@@ -1183,55 +1183,55 @@ open_device (struct HardwareInfos *dev) | |||
1183 | return 1; | 1183 | return 1; |
1184 | } | 1184 | } |
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | /* Check if the device is discoverable */ | 1187 | /* Check if the device is discoverable */ |
1188 | if (hci_test_bit (HCI_PSCAN, (void *) &dev_info.flags) == 0 || | 1188 | if (hci_test_bit (HCI_PSCAN, (void *) &dev_info.flags) == 0 || |
1189 | hci_test_bit (HCI_ISCAN, (void *) &dev_info.flags) == 0) | 1189 | hci_test_bit (HCI_ISCAN, (void *) &dev_info.flags) == 0) |
1190 | { | 1190 | { |
1191 | /* Set interface Page Scan and Inqury Scan ON */ | 1191 | /* Set interface Page Scan and Inqury Scan ON */ |
1192 | struct hci_dev_req dev_req; | 1192 | struct hci_dev_req dev_req; |
1193 | 1193 | ||
1194 | memset (&dev_req, 0, sizeof (dev_req)); | 1194 | memset (&dev_req, 0, sizeof (dev_req)); |
1195 | dev_req.dev_id = dev_info.dev_id; | 1195 | dev_req.dev_id = dev_info.dev_id; |
1196 | dev_req.dev_opt = SCAN_PAGE | SCAN_INQUIRY; | 1196 | dev_req.dev_opt = SCAN_PAGE | SCAN_INQUIRY; |
1197 | 1197 | ||
1198 | if (ioctl (fd_hci, HCISETSCAN, (unsigned long) &dev_req)) | 1198 | if (ioctl (fd_hci, HCISETSCAN, (unsigned long) &dev_req)) |
1199 | { | 1199 | { |
1200 | fprintf (stderr, "ioctl(HCISETSCAN) on interface `%.*s' failed: %s\n", | 1200 | fprintf (stderr, "ioctl(HCISETSCAN) on interface `%.*s' failed: %s\n", |
1201 | IFNAMSIZ, dev->iface, strerror (errno)); | 1201 | IFNAMSIZ, dev->iface, strerror (errno)); |
1202 | return 1; | 1202 | return 1; |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | } | 1205 | } |
1206 | break; | 1206 | break; |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | /* Check if the interface was not found */ | 1211 | /* Check if the interface was not found */ |
1212 | if (dev_id == -1) | 1212 | if (dev_id == -1) |
1213 | { | 1213 | { |
1214 | fprintf (stderr, "The interface %s was not found\n", dev->iface); | 1214 | fprintf (stderr, "The interface %s was not found\n", dev->iface); |
1215 | return 1; | 1215 | return 1; |
1216 | } | 1216 | } |
1217 | 1217 | ||
1218 | /* Close the hci socket */ | 1218 | /* Close the hci socket */ |
1219 | (void) close(fd_hci); | 1219 | (void) close(fd_hci); |
1220 | 1220 | ||
1221 | 1221 | ||
1222 | 1222 | ||
1223 | /* Bind the rfcomm socket to the interface */ | 1223 | /* Bind the rfcomm socket to the interface */ |
1224 | memset (&rc_addr, 0, sizeof (rc_addr)); | 1224 | memset (&rc_addr, 0, sizeof (rc_addr)); |
1225 | rc_addr.rc_family = AF_BLUETOOTH; | 1225 | rc_addr.rc_family = AF_BLUETOOTH; |
1226 | rc_addr.rc_bdaddr = *BDADDR_ANY; | 1226 | rc_addr.rc_bdaddr = *BDADDR_ANY; |
1227 | 1227 | ||
1228 | if (bind_socket (dev->fd_rfcomm, &rc_addr) != 0) | 1228 | if (bind_socket (dev->fd_rfcomm, &rc_addr) != 0) |
1229 | { | 1229 | { |
1230 | fprintf (stderr, "Failed to bind interface `%.*s': %s\n", IFNAMSIZ, | 1230 | fprintf (stderr, "Failed to bind interface `%.*s': %s\n", IFNAMSIZ, |
1231 | dev->iface, strerror (errno)); | 1231 | dev->iface, strerror (errno)); |
1232 | return 1; | 1232 | return 1; |
1233 | } | 1233 | } |
1234 | 1234 | ||
1235 | /* Register a SDP service */ | 1235 | /* Register a SDP service */ |
1236 | if (register_service (dev, rc_addr.rc_channel) != 0) | 1236 | if (register_service (dev, rc_addr.rc_channel) != 0) |
1237 | { | 1237 | { |
@@ -1239,7 +1239,7 @@ open_device (struct HardwareInfos *dev) | |||
1239 | dev->iface, strerror (errno)); | 1239 | dev->iface, strerror (errno)); |
1240 | return 1; | 1240 | return 1; |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | /* Switch socket in listening mode */ | 1243 | /* Switch socket in listening mode */ |
1244 | if (listen (dev->fd_rfcomm, 5) == -1) //FIXME: probably we need a bigger number | 1244 | if (listen (dev->fd_rfcomm, 5) == -1) //FIXME: probably we need a bigger number |
1245 | { | 1245 | { |
@@ -1247,7 +1247,7 @@ open_device (struct HardwareInfos *dev) | |||
1247 | dev->iface, strerror (errno)); | 1247 | dev->iface, strerror (errno)); |
1248 | return 1; | 1248 | return 1; |
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | #endif | 1251 | #endif |
1252 | 1252 | ||
1253 | return 0; | 1253 | return 0; |
@@ -1266,7 +1266,7 @@ static void | |||
1266 | mac_set (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader, | 1266 | mac_set (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader, |
1267 | const struct HardwareInfos *dev) | 1267 | const struct HardwareInfos *dev) |
1268 | { | 1268 | { |
1269 | taIeeeHeader->frame_control = htons (IEEE80211_FC0_TYPE_DATA); | 1269 | taIeeeHeader->frame_control = htons (IEEE80211_FC0_TYPE_DATA); |
1270 | taIeeeHeader->addr3 = mac_bssid_gnunet; | 1270 | taIeeeHeader->addr3 = mac_bssid_gnunet; |
1271 | 1271 | ||
1272 | #ifdef MINGW | 1272 | #ifdef MINGW |
@@ -1292,13 +1292,13 @@ mac_set (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader, | |||
1292 | struct stat sbuf; | 1292 | struct stat sbuf; |
1293 | int ret; | 1293 | int ret; |
1294 | 1294 | ||
1295 | ret = snprintf (strbuf, sizeof (strbuf), | 1295 | ret = snprintf (strbuf, sizeof (strbuf), |
1296 | "/sys/class/bluetooth/%s/subsystem", | 1296 | "/sys/class/bluetooth/%s/subsystem", |
1297 | iface); | 1297 | iface); |
1298 | if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf))) | 1298 | if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf))) |
1299 | { | 1299 | { |
1300 | fprintf (stderr, | 1300 | fprintf (stderr, |
1301 | "Did not find 802.15.1 interface `%s'. Exiting.\n", | 1301 | "Did not find 802.15.1 interface `%s'. Exiting.\n", |
1302 | iface); | 1302 | iface); |
1303 | exit (1); | 1303 | exit (1); |
1304 | } | 1304 | } |
@@ -1354,12 +1354,12 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1354 | sendsize = ntohs (hdr->size); | 1354 | sendsize = ntohs (hdr->size); |
1355 | if ( (sendsize < | 1355 | if ( (sendsize < |
1356 | sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage)) || | 1356 | sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage)) || |
1357 | (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) ) | 1357 | (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) ) |
1358 | { | 1358 | { |
1359 | fprintf (stderr, "Received malformed message\n"); | 1359 | fprintf (stderr, "Received malformed message\n"); |
1360 | exit (1); | 1360 | exit (1); |
1361 | } | 1361 | } |
1362 | sendsize -= (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) - | 1362 | sendsize -= (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) - |
1363 | sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame)); | 1363 | sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame)); |
1364 | if (MAXLINE < sendsize) | 1364 | if (MAXLINE < sendsize) |
1365 | { | 1365 | { |
@@ -1373,7 +1373,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1373 | /* payload contains MAC address, but we don't trust it, so we'll | 1373 | /* payload contains MAC address, but we don't trust it, so we'll |
1374 | * overwrite it with OUR MAC address to prevent mischief */ | 1374 | * overwrite it with OUR MAC address to prevent mischief */ |
1375 | mac_set (blueheader, dev); | 1375 | mac_set (blueheader, dev); |
1376 | memcpy (&blueheader->addr1, &header->frame.addr1, | 1376 | memcpy (&blueheader->addr1, &header->frame.addr1, |
1377 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); | 1377 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); |
1378 | write_pout.size = sendsize; | 1378 | write_pout.size = sendsize; |
1379 | } | 1379 | } |
@@ -1386,19 +1386,19 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1386 | * @param dev pointer to the socket which was added to the set | 1386 | * @param dev pointer to the socket which was added to the set |
1387 | * @return 0 on success | 1387 | * @return 0 on success |
1388 | */ | 1388 | */ |
1389 | static int | 1389 | static int |
1390 | send_broadcast (struct HardwareInfos *dev, int *sendsocket) | 1390 | send_broadcast (struct HardwareInfos *dev, int *sendsocket) |
1391 | { | 1391 | { |
1392 | int new_device = 0; | 1392 | int new_device = 0; |
1393 | int loops = 0; | 1393 | int loops = 0; |
1394 | 1394 | ||
1395 | search_for_devices: | 1395 | search_for_devices: |
1396 | if ((neighbours.size == neighbours.pos && new_device == 1) || neighbours.size == 0) | 1396 | if ((neighbours.size == neighbours.pos && new_device == 1) || neighbours.size == 0) |
1397 | { | 1397 | { |
1398 | inquiry_devices: //skip the conditions and force a inquiry for new devices | 1398 | inquiry_devices: //skip the conditions and force a inquiry for new devices |
1399 | { | 1399 | { |
1400 | /** | 1400 | /** |
1401 | * It means that I sent HELLO messages to all the devices from the list and I should search | 1401 | * It means that I sent HELLO messages to all the devices from the list and I should search |
1402 | * for new ones or that this is the first time when I do a search. | 1402 | * for new ones or that this is the first time when I do a search. |
1403 | */ | 1403 | */ |
1404 | inquiry_info *devices = NULL; | 1404 | inquiry_info *devices = NULL; |
@@ -1415,17 +1415,17 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1415 | if (neighbours.dev_id == -1) | 1415 | if (neighbours.dev_id == -1) |
1416 | { | 1416 | { |
1417 | char addr[19] = { 0 }; //the device MAC address | 1417 | char addr[19] = { 0 }; //the device MAC address |
1418 | 1418 | ||
1419 | ba2str ((bdaddr_t *) &dev->pl_mac, addr); | 1419 | ba2str ((bdaddr_t *) &dev->pl_mac, addr); |
1420 | neighbours.dev_id = hci_devid (addr); | 1420 | neighbours.dev_id = hci_devid (addr); |
1421 | if (neighbours.dev_id < 0) | 1421 | if (neighbours.dev_id < 0) |
1422 | { | 1422 | { |
1423 | fprintf (stderr, "Failed to get the device id for interface %.*s : %s\n", IFNAMSIZ, | 1423 | fprintf (stderr, "Failed to get the device id for interface %.*s : %s\n", IFNAMSIZ, |
1424 | dev->iface, strerror (errno)); | 1424 | dev->iface, strerror (errno)); |
1425 | return 1; | 1425 | return 1; |
1426 | } | 1426 | } |
1427 | } | 1427 | } |
1428 | 1428 | ||
1429 | devices = malloc (max_responses * sizeof (inquiry_info)); | 1429 | devices = malloc (max_responses * sizeof (inquiry_info)); |
1430 | if (devices == NULL) | 1430 | if (devices == NULL) |
1431 | { | 1431 | { |
@@ -1433,23 +1433,23 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1433 | dev->iface); | 1433 | dev->iface); |
1434 | return 1; | 1434 | return 1; |
1435 | } | 1435 | } |
1436 | 1436 | ||
1437 | responses = hci_inquiry (neighbours.dev_id, 8, max_responses, NULL, &devices, IREQ_CACHE_FLUSH); | 1437 | responses = hci_inquiry (neighbours.dev_id, 8, max_responses, NULL, &devices, IREQ_CACHE_FLUSH); |
1438 | if (responses < 0) | 1438 | if (responses < 0) |
1439 | { | 1439 | { |
1440 | fprintf (stderr, "Failed to inquiry on interface %.*s\n", IFNAMSIZ, dev->iface); | 1440 | fprintf (stderr, "Failed to inquiry on interface %.*s\n", IFNAMSIZ, dev->iface); |
1441 | return 1; | 1441 | return 1; |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | fprintf (stderr, "LOG : Found %d devices\n", responses); //FIXME delete it after debugging stage | 1444 | fprintf (stderr, "LOG : Found %d devices\n", responses); //FIXME delete it after debugging stage |
1445 | 1445 | ||
1446 | if (responses == 0) | 1446 | if (responses == 0) |
1447 | { | 1447 | { |
1448 | fprintf (stderr, "LOG : No devices discoverable\n"); | 1448 | fprintf (stderr, "LOG : No devices discoverable\n"); |
1449 | return 1; | 1449 | return 1; |
1450 | } | 1450 | } |
1451 | 1451 | ||
1452 | for (i = 0; i < responses; i++) | 1452 | for (i = 0; i < responses; i++) |
1453 | { | 1453 | { |
1454 | int j; | 1454 | int j; |
1455 | int found = 0; | 1455 | int found = 0; |
@@ -1461,11 +1461,11 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1461 | dev->iface); | 1461 | dev->iface); |
1462 | return 2; | 1462 | return 2; |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | /* Search if the address already exists on the list */ | 1465 | /* Search if the address already exists on the list */ |
1466 | for (j = 0; j < neighbours.size; j++) | 1466 | for (j = 0; j < neighbours.size; j++) |
1467 | { | 1467 | { |
1468 | if (memcmp (&(devices + i)->bdaddr, &(neighbours.devices[j]), sizeof (bdaddr_t)) == 0) | 1468 | if (memcmp (&(devices + i)->bdaddr, &(neighbours.devices[j]), sizeof (bdaddr_t)) == 0) |
1469 | { | 1469 | { |
1470 | found = 1; | 1470 | found = 1; |
1471 | fprintf (stderr, "LOG : the device already exists on the list\n"); //FIXME debugging message | 1471 | fprintf (stderr, "LOG : the device already exists on the list\n"); //FIXME debugging message |
@@ -1481,12 +1481,12 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1481 | fprintf (stderr, "LOG : %s was added to the list\n", addr); //FIXME debugging message | 1481 | fprintf (stderr, "LOG : %s was added to the list\n", addr); //FIXME debugging message |
1482 | memcpy (&(neighbours.devices[neighbours.size++]), &(devices + i)->bdaddr, sizeof (bdaddr_t)); | 1482 | memcpy (&(neighbours.devices[neighbours.size++]), &(devices + i)->bdaddr, sizeof (bdaddr_t)); |
1483 | } | 1483 | } |
1484 | } | 1484 | } |
1485 | 1485 | ||
1486 | free (devices); | 1486 | free (devices); |
1487 | } | 1487 | } |
1488 | } | 1488 | } |
1489 | 1489 | ||
1490 | int connection_successful = 0; | 1490 | int connection_successful = 0; |
1491 | struct sockaddr_rc addr_rc = { 0 }; | 1491 | struct sockaddr_rc addr_rc = { 0 }; |
1492 | int errno_copy = 0; | 1492 | int errno_copy = 0; |
@@ -1501,9 +1501,9 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1501 | 1501 | ||
1502 | memset (&addr_rc.rc_bdaddr, 0, sizeof (addr_rc.rc_bdaddr)); | 1502 | memset (&addr_rc.rc_bdaddr, 0, sizeof (addr_rc.rc_bdaddr)); |
1503 | memcpy (&addr_rc.rc_bdaddr, &(neighbours.devices[neighbours.pos]), sizeof (addr_rc.rc_bdaddr)); | 1503 | memcpy (&addr_rc.rc_bdaddr, &(neighbours.devices[neighbours.pos]), sizeof (addr_rc.rc_bdaddr)); |
1504 | 1504 | ||
1505 | addr_rc.rc_channel = get_channel (dev, addr_rc.rc_bdaddr); | 1505 | addr_rc.rc_channel = get_channel (dev, addr_rc.rc_bdaddr); |
1506 | 1506 | ||
1507 | *sendsocket = socket (AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); | 1507 | *sendsocket = socket (AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); |
1508 | if (connect (*sendsocket, (struct sockaddr *)&addr_rc, sizeof (addr_rc)) == 0) | 1508 | if (connect (*sendsocket, (struct sockaddr *)&addr_rc, sizeof (addr_rc)) == 0) |
1509 | { | 1509 | { |
@@ -1549,7 +1549,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1549 | neighbours.pos += 1; | 1549 | neighbours.pos += 1; |
1550 | } | 1550 | } |
1551 | } | 1551 | } |
1552 | 1552 | ||
1553 | /* Cycle on the list */ | 1553 | /* Cycle on the list */ |
1554 | if (neighbours.pos == neighbours.size) | 1554 | if (neighbours.pos == neighbours.size) |
1555 | { | 1555 | { |
@@ -1564,14 +1564,14 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1564 | } | 1564 | } |
1565 | } | 1565 | } |
1566 | /* If a new device wasn't found, search an old one */ | 1566 | /* If a new device wasn't found, search an old one */ |
1567 | if (connection_successful == 0) | 1567 | if (connection_successful == 0) |
1568 | { | 1568 | { |
1569 | int loop_check = neighbours.pos; | 1569 | int loop_check = neighbours.pos; |
1570 | while (neighbours.fds[neighbours.pos] == -1) | 1570 | while (neighbours.fds[neighbours.pos] == -1) |
1571 | { | 1571 | { |
1572 | if (neighbours.pos == neighbours.size) | 1572 | if (neighbours.pos == neighbours.size) |
1573 | neighbours.pos = 0; | 1573 | neighbours.pos = 0; |
1574 | 1574 | ||
1575 | if (neighbours.pos == loop_check) | 1575 | if (neighbours.pos == loop_check) |
1576 | { | 1576 | { |
1577 | if (errno_copy == ECONNREFUSED) | 1577 | if (errno_copy == ECONNREFUSED) |
@@ -1599,7 +1599,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1599 | 1599 | ||
1600 | /** | 1600 | /** |
1601 | * Main function of the helper. This code accesses a bluetooth interface | 1601 | * Main function of the helper. This code accesses a bluetooth interface |
1602 | * forwards traffic in both directions between the bluetooth interface and | 1602 | * forwards traffic in both directions between the bluetooth interface and |
1603 | * stdin/stdout of this process. Error messages are written to stderr. | 1603 | * stdin/stdout of this process. Error messages are written to stderr. |
1604 | * | 1604 | * |
1605 | * @param argc number of arguments, must be 2 | 1605 | * @param argc number of arguments, must be 2 |
@@ -1611,7 +1611,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1611 | int | 1611 | int |
1612 | main (int argc, char *argv[]) | 1612 | main (int argc, char *argv[]) |
1613 | { | 1613 | { |
1614 | #ifdef LINUX | 1614 | #ifdef LINUX |
1615 | struct HardwareInfos dev; | 1615 | struct HardwareInfos dev; |
1616 | char readbuf[MAXLINE]; | 1616 | char readbuf[MAXLINE]; |
1617 | int maxfd; | 1617 | int maxfd; |
@@ -1632,7 +1632,7 @@ main (int argc, char *argv[]) | |||
1632 | return 254; | 1632 | return 254; |
1633 | } | 1633 | } |
1634 | #else | 1634 | #else |
1635 | if (0 != seteuid (0)) | 1635 | if (0 != seteuid (0)) |
1636 | { | 1636 | { |
1637 | fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno)); | 1637 | fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno)); |
1638 | return 254; | 1638 | return 254; |
@@ -1710,15 +1710,15 @@ main (int argc, char *argv[]) | |||
1710 | memcpy (write_std.buf, &macmsg, sizeof (macmsg)); | 1710 | memcpy (write_std.buf, &macmsg, sizeof (macmsg)); |
1711 | write_std.size = sizeof (macmsg); | 1711 | write_std.size = sizeof (macmsg); |
1712 | } | 1712 | } |
1713 | 1713 | ||
1714 | 1714 | ||
1715 | stdin_mst = mst_create (&stdin_send_hw, &dev); | 1715 | stdin_mst = mst_create (&stdin_send_hw, &dev); |
1716 | stdin_open = 1; | 1716 | stdin_open = 1; |
1717 | 1717 | ||
1718 | /** | 1718 | /** |
1719 | * TODO : I should make the time out of a mac endpoint smaller and check if the rate | 1719 | * TODO : I should make the time out of a mac endpoint smaller and check if the rate |
1720 | * from get_wlan_header (plugin_transport_bluetooth.c) is correct. | 1720 | * from get_wlan_header (plugin_transport_bluetooth.c) is correct. |
1721 | */ | 1721 | */ |
1722 | while (1) | 1722 | while (1) |
1723 | { | 1723 | { |
1724 | maxfd = -1; | 1724 | maxfd = -1; |
@@ -1737,7 +1737,7 @@ main (int argc, char *argv[]) | |||
1737 | maxfd = MAX (maxfd, dev.fd_rfcomm); | 1737 | maxfd = MAX (maxfd, dev.fd_rfcomm); |
1738 | } | 1738 | } |
1739 | 1739 | ||
1740 | for (i = 0; i < crt_rfds; i++) // it can receive messages from multiple devices | 1740 | for (i = 0; i < crt_rfds; i++) // it can receive messages from multiple devices |
1741 | { | 1741 | { |
1742 | FD_SET (rfds_list[i], &rfds); | 1742 | FD_SET (rfds_list[i], &rfds); |
1743 | maxfd = MAX (maxfd, rfds_list[i]); | 1743 | maxfd = MAX (maxfd, rfds_list[i]); |
@@ -1749,22 +1749,22 @@ main (int argc, char *argv[]) | |||
1749 | maxfd = MAX (maxfd, STDOUT_FILENO); | 1749 | maxfd = MAX (maxfd, STDOUT_FILENO); |
1750 | } | 1750 | } |
1751 | if (0 < write_pout.size) //it can send messages only to one device per loop | 1751 | if (0 < write_pout.size) //it can send messages only to one device per loop |
1752 | { | 1752 | { |
1753 | struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *frame; | 1753 | struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *frame; |
1754 | /* Get the destination address */ | 1754 | /* Get the destination address */ |
1755 | frame = (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) write_pout.buf; | 1755 | frame = (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) write_pout.buf; |
1756 | 1756 | ||
1757 | if (memcmp (&frame->addr1, &dev.pl_mac, | 1757 | if (memcmp (&frame->addr1, &dev.pl_mac, |
1758 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) | 1758 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) |
1759 | { | 1759 | { |
1760 | broadcast = 1; | 1760 | broadcast = 1; |
1761 | memset (&write_pout, 0, sizeof (write_pout)); //clear the buffer | 1761 | memset (&write_pout, 0, sizeof (write_pout)); //clear the buffer |
1762 | } | 1762 | } |
1763 | else if (memcmp (&frame->addr1, &broadcast_address, | 1763 | else if (memcmp (&frame->addr1, &broadcast_address, |
1764 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) | 1764 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) |
1765 | { | 1765 | { |
1766 | fprintf (stderr, "LOG : %s has a broadcast message (pos %d, size %d)\n", dev.iface, neighbours.pos, neighbours.size); //FIXME: debugging message | 1766 | fprintf (stderr, "LOG : %s has a broadcast message (pos %d, size %d)\n", dev.iface, neighbours.pos, neighbours.size); //FIXME: debugging message |
1767 | 1767 | ||
1768 | if (send_broadcast(&dev, &sendsocket) != 0) //if the searching wasn't successful don't get stuck on the select stage | 1768 | if (send_broadcast(&dev, &sendsocket) != 0) //if the searching wasn't successful don't get stuck on the select stage |
1769 | { | 1769 | { |
1770 | broadcast = 1; | 1770 | broadcast = 1; |
@@ -1776,15 +1776,15 @@ main (int argc, char *argv[]) | |||
1776 | FD_SET (sendsocket, &wfds); | 1776 | FD_SET (sendsocket, &wfds); |
1777 | maxfd = MAX (maxfd, sendsocket); | 1777 | maxfd = MAX (maxfd, sendsocket); |
1778 | } | 1778 | } |
1779 | } | 1779 | } |
1780 | else | 1780 | else |
1781 | { | 1781 | { |
1782 | int found = 0; | 1782 | int found = 0; |
1783 | int pos = 0; | 1783 | int pos = 0; |
1784 | /* Search if the address already exists on the list */ | 1784 | /* Search if the address already exists on the list */ |
1785 | for (i = 0; i < neighbours.size; i++) | 1785 | for (i = 0; i < neighbours.size; i++) |
1786 | { | 1786 | { |
1787 | if (memcmp (&frame->addr1, &(neighbours.devices[i]), sizeof (bdaddr_t)) == 0) | 1787 | if (memcmp (&frame->addr1, &(neighbours.devices[i]), sizeof (bdaddr_t)) == 0) |
1788 | { | 1788 | { |
1789 | pos = i; | 1789 | pos = i; |
1790 | if (neighbours.fds[i] != -1) | 1790 | if (neighbours.fds[i] != -1) |
@@ -1802,24 +1802,24 @@ main (int argc, char *argv[]) | |||
1802 | { | 1802 | { |
1803 | int status; | 1803 | int status; |
1804 | struct sockaddr_rc addr = { 0 }; | 1804 | struct sockaddr_rc addr = { 0 }; |
1805 | 1805 | ||
1806 | fprintf (stderr, "LOG : %s has a new message for %.2X:%.2X:%.2X:%.2X:%.2X:%.2X which isn't on the broadcast list\n", dev.iface, | 1806 | fprintf (stderr, "LOG : %s has a new message for %.2X:%.2X:%.2X:%.2X:%.2X:%.2X which isn't on the broadcast list\n", dev.iface, |
1807 | frame->addr1.mac[5], frame->addr1.mac[4], frame->addr1.mac[3], | 1807 | frame->addr1.mac[5], frame->addr1.mac[4], frame->addr1.mac[3], |
1808 | frame->addr1.mac[2], frame->addr1.mac[1], frame->addr1.mac[0]); //FIXME: debugging message | 1808 | frame->addr1.mac[2], frame->addr1.mac[1], frame->addr1.mac[0]); //FIXME: debugging message |
1809 | 1809 | ||
1810 | sendsocket = socket (AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); | 1810 | sendsocket = socket (AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); |
1811 | 1811 | ||
1812 | if (sendsocket < 0) | 1812 | if (sendsocket < 0) |
1813 | { | 1813 | { |
1814 | fprintf (stderr, "Failed to create a RFCOMM socket (sending stage): %s\n", | 1814 | fprintf (stderr, "Failed to create a RFCOMM socket (sending stage): %s\n", |
1815 | strerror (errno)); | 1815 | strerror (errno)); |
1816 | return -1; | 1816 | return -1; |
1817 | } | 1817 | } |
1818 | 1818 | ||
1819 | memcpy (&addr.rc_bdaddr, &frame->addr1, sizeof (bdaddr_t)); | 1819 | memcpy (&addr.rc_bdaddr, &frame->addr1, sizeof (bdaddr_t)); |
1820 | addr.rc_family = AF_BLUETOOTH; | 1820 | addr.rc_family = AF_BLUETOOTH; |
1821 | addr.rc_channel = get_channel (&dev, addr.rc_bdaddr); | 1821 | addr.rc_channel = get_channel (&dev, addr.rc_bdaddr); |
1822 | 1822 | ||
1823 | int tries = 0; | 1823 | int tries = 0; |
1824 | connect_retry: | 1824 | connect_retry: |
1825 | status = connect (sendsocket, (struct sockaddr *) &addr, sizeof (addr)); | 1825 | status = connect (sendsocket, (struct sockaddr *) &addr, sizeof (addr)); |
@@ -1843,7 +1843,7 @@ main (int argc, char *argv[]) | |||
1843 | memset (&write_pout, 0, sizeof (write_pout)); | 1843 | memset (&write_pout, 0, sizeof (write_pout)); |
1844 | broadcast = 1; | 1844 | broadcast = 1; |
1845 | } | 1845 | } |
1846 | 1846 | ||
1847 | } | 1847 | } |
1848 | else | 1848 | else |
1849 | { | 1849 | { |
@@ -1902,19 +1902,19 @@ main (int argc, char *argv[]) | |||
1902 | write_std.size = 0; | 1902 | write_std.size = 0; |
1903 | } | 1903 | } |
1904 | fprintf (stderr, "LOG : %s sends a message to STDOUT\n", dev.iface); //FIXME: debugging message | 1904 | fprintf (stderr, "LOG : %s sends a message to STDOUT\n", dev.iface); //FIXME: debugging message |
1905 | 1905 | ||
1906 | } | 1906 | } |
1907 | if (sendsocket != -1) | 1907 | if (sendsocket != -1) |
1908 | { | 1908 | { |
1909 | if (FD_ISSET (sendsocket , &wfds)) | 1909 | if (FD_ISSET (sendsocket , &wfds)) |
1910 | { | 1910 | { |
1911 | ssize_t ret = | 1911 | ssize_t ret = |
1912 | write (sendsocket, write_pout.buf + write_std.pos, | 1912 | write (sendsocket, write_pout.buf + write_std.pos, |
1913 | write_pout.size - write_pout.pos); | 1913 | write_pout.size - write_pout.pos); |
1914 | if (0 > ret) //FIXME should I first check the error type? | 1914 | if (0 > ret) //FIXME should I first check the error type? |
1915 | { | 1915 | { |
1916 | fprintf (stderr, "Failed to write to bluetooth device: %s. Closing the socket!\n", | 1916 | fprintf (stderr, "Failed to write to bluetooth device: %s. Closing the socket!\n", |
1917 | strerror (errno)); | 1917 | strerror (errno)); |
1918 | for (i = 0; i < neighbours.size; i++) | 1918 | for (i = 0; i < neighbours.size; i++) |
1919 | { | 1919 | { |
1920 | if (neighbours.fds[i] == sendsocket) | 1920 | if (neighbours.fds[i] == sendsocket) |
@@ -1925,7 +1925,7 @@ main (int argc, char *argv[]) | |||
1925 | } | 1925 | } |
1926 | } | 1926 | } |
1927 | /* Remove the message */ | 1927 | /* Remove the message */ |
1928 | memset (&write_pout.buf + write_std.pos, 0, (write_pout.size - write_pout.pos)); | 1928 | memset (&write_pout.buf + write_std.pos, 0, (write_pout.size - write_pout.pos)); |
1929 | write_pout.pos = 0 ; | 1929 | write_pout.pos = 0 ; |
1930 | write_pout.size = 0; | 1930 | write_pout.size = 0; |
1931 | } | 1931 | } |
@@ -1940,7 +1940,7 @@ main (int argc, char *argv[]) | |||
1940 | (unsigned int) write_pout.size); | 1940 | (unsigned int) write_pout.size); |
1941 | break; | 1941 | break; |
1942 | } | 1942 | } |
1943 | 1943 | ||
1944 | if (write_pout.pos == write_pout.size) | 1944 | if (write_pout.pos == write_pout.size) |
1945 | { | 1945 | { |
1946 | write_pout.pos = 0; | 1946 | write_pout.pos = 0; |
@@ -1956,14 +1956,14 @@ main (int argc, char *argv[]) | |||
1956 | { | 1956 | { |
1957 | if (i == STDIN_FILENO) | 1957 | if (i == STDIN_FILENO) |
1958 | { | 1958 | { |
1959 | ssize_t ret = | 1959 | ssize_t ret = |
1960 | read (i, readbuf, sizeof (readbuf)); | 1960 | read (i, readbuf, sizeof (readbuf)); |
1961 | if (0 > ret) | 1961 | if (0 > ret) |
1962 | { | 1962 | { |
1963 | fprintf (stderr, | 1963 | fprintf (stderr, |
1964 | "Read error from STDIN: %s\n", | 1964 | "Read error from STDIN: %s\n", |
1965 | strerror (errno)); | 1965 | strerror (errno)); |
1966 | break; | 1966 | break; |
1967 | } | 1967 | } |
1968 | if (0 == ret) | 1968 | if (0 == ret) |
1969 | { | 1969 | { |
@@ -1975,18 +1975,18 @@ main (int argc, char *argv[]) | |||
1975 | mst_receive (stdin_mst, readbuf, ret); | 1975 | mst_receive (stdin_mst, readbuf, ret); |
1976 | fprintf (stderr, "LOG : %s receives a message from STDIN\n", dev.iface); //FIXME: debugging message | 1976 | fprintf (stderr, "LOG : %s receives a message from STDIN\n", dev.iface); //FIXME: debugging message |
1977 | } | 1977 | } |
1978 | } | 1978 | } |
1979 | else if (i == dev.fd_rfcomm) | 1979 | else if (i == dev.fd_rfcomm) |
1980 | { | 1980 | { |
1981 | int readsocket; | 1981 | int readsocket; |
1982 | struct sockaddr_rc addr = { 0 }; | 1982 | struct sockaddr_rc addr = { 0 }; |
1983 | unsigned int opt = sizeof (addr); | 1983 | unsigned int opt = sizeof (addr); |
1984 | 1984 | ||
1985 | readsocket = accept (dev.fd_rfcomm, (struct sockaddr *) &addr, &opt); | 1985 | readsocket = accept (dev.fd_rfcomm, (struct sockaddr *) &addr, &opt); |
1986 | fprintf(stderr, "LOG : %s accepts a message\n", dev.iface); //FIXME: debugging message | 1986 | fprintf(stderr, "LOG : %s accepts a message\n", dev.iface); //FIXME: debugging message |
1987 | if (readsocket == -1) | 1987 | if (readsocket == -1) |
1988 | { | 1988 | { |
1989 | fprintf (stderr, "Failed to accept a connection on interface: %.*s\n", IFNAMSIZ, | 1989 | fprintf (stderr, "Failed to accept a connection on interface: %.*s\n", IFNAMSIZ, |
1990 | strerror (errno)); | 1990 | strerror (errno)); |
1991 | break; | 1991 | break; |
1992 | } | 1992 | } |
@@ -1994,7 +1994,7 @@ main (int argc, char *argv[]) | |||
1994 | { | 1994 | { |
1995 | FD_SET (readsocket, &rfds); | 1995 | FD_SET (readsocket, &rfds); |
1996 | maxfd = MAX (maxfd, readsocket); | 1996 | maxfd = MAX (maxfd, readsocket); |
1997 | 1997 | ||
1998 | if (crt_rfds < MAX_PORTS) | 1998 | if (crt_rfds < MAX_PORTS) |
1999 | rfds_list[crt_rfds++] = readsocket; | 1999 | rfds_list[crt_rfds++] = readsocket; |
2000 | else | 2000 | else |
@@ -2004,19 +2004,19 @@ main (int argc, char *argv[]) | |||
2004 | break; | 2004 | break; |
2005 | } | 2005 | } |
2006 | } | 2006 | } |
2007 | 2007 | ||
2008 | } | 2008 | } |
2009 | else | 2009 | else |
2010 | { | 2010 | { |
2011 | struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rrm; | 2011 | struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rrm; |
2012 | ssize_t ret; | 2012 | ssize_t ret; |
2013 | fprintf (stderr, "LOG : %s reads something from the socket\n", dev.iface);//FIXME : debugging message | 2013 | fprintf (stderr, "LOG : %s reads something from the socket\n", dev.iface);//FIXME : debugging message |
2014 | rrm = (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) write_std.buf; | 2014 | rrm = (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) write_std.buf; |
2015 | ret = | 2015 | ret = |
2016 | read_from_the_socket ((void *)&i, (unsigned char *) &rrm->frame, | 2016 | read_from_the_socket ((void *)&i, (unsigned char *) &rrm->frame, |
2017 | sizeof (write_std.buf) | 2017 | sizeof (write_std.buf) |
2018 | - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) | 2018 | - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) |
2019 | + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame), | 2019 | + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame), |
2020 | rrm); | 2020 | rrm); |
2021 | if (0 >= ret) | 2021 | if (0 >= ret) |
2022 | { | 2022 | { |
@@ -2041,8 +2041,8 @@ main (int argc, char *argv[]) | |||
2041 | } | 2041 | } |
2042 | if ((0 < ret) && (0 == mac_test (&rrm->frame, &dev))) | 2042 | if ((0 < ret) && (0 == mac_test (&rrm->frame, &dev))) |
2043 | { | 2043 | { |
2044 | write_std.size = ret | 2044 | write_std.size = ret |
2045 | + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) | 2045 | + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) |
2046 | - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame); | 2046 | - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame); |
2047 | rrm->header.size = htons (write_std.size); | 2047 | rrm->header.size = htons (write_std.size); |
2048 | rrm->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER); | 2048 | rrm->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER); |
@@ -2058,7 +2058,7 @@ main (int argc, char *argv[]) | |||
2058 | sdp_close (dev.session); | 2058 | sdp_close (dev.session); |
2059 | (void) close (dev.fd_rfcomm); | 2059 | (void) close (dev.fd_rfcomm); |
2060 | (void) close (sendsocket); | 2060 | (void) close (sendsocket); |
2061 | 2061 | ||
2062 | for (i = 0; i < crt_rfds; i++) | 2062 | for (i = 0; i < crt_rfds; i++) |
2063 | (void) close (rfds_list[i]); | 2063 | (void) close (rfds_list[i]); |
2064 | 2064 | ||
@@ -2079,13 +2079,13 @@ main (int argc, char *argv[]) | |||
2079 | struct MessageStreamTokenizer *stdin_mst; | 2079 | struct MessageStreamTokenizer *stdin_mst; |
2080 | 2080 | ||
2081 | /* check the handles */ | 2081 | /* check the handles */ |
2082 | if (stdin_handle == INVALID_HANDLE_VALUE) | 2082 | if (stdin_handle == INVALID_HANDLE_VALUE) |
2083 | { | 2083 | { |
2084 | fprintf (stderr, "Failed to get the stdin handle\n"); | 2084 | fprintf (stderr, "Failed to get the stdin handle\n"); |
2085 | ExitProcess (2); | 2085 | ExitProcess (2); |
2086 | } | 2086 | } |
2087 | 2087 | ||
2088 | if (stdout_handle == INVALID_HANDLE_VALUE) | 2088 | if (stdout_handle == INVALID_HANDLE_VALUE) |
2089 | { | 2089 | { |
2090 | fprintf (stderr, "Failed to get the stdout handle\n"); | 2090 | fprintf (stderr, "Failed to get the stdout handle\n"); |
2091 | ExitProcess (2); | 2091 | ExitProcess (2); |
@@ -2111,7 +2111,7 @@ main (int argc, char *argv[]) | |||
2111 | } | 2111 | } |
2112 | 2112 | ||
2113 | 2113 | ||
2114 | if (open_device (&dev) == -1) | 2114 | if (open_device (&dev) == -1) |
2115 | { | 2115 | { |
2116 | fprintf (stderr, "Failed to open the device\n"); | 2116 | fprintf (stderr, "Failed to open the device\n"); |
2117 | print_last_error(); | 2117 | print_last_error(); |
@@ -2121,21 +2121,21 @@ main (int argc, char *argv[]) | |||
2121 | print_last_error(); | 2121 | print_last_error(); |
2122 | } | 2122 | } |
2123 | ExitProcess (2); | 2123 | ExitProcess (2); |
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | if (GNUNET_OK != GNUNET_NETWORK_socket_set_blocking (dev.handle, 1) ) | 2126 | if (GNUNET_OK != GNUNET_NETWORK_socket_set_blocking (dev.handle, 1) ) |
2127 | { | 2127 | { |
2128 | fprintf (stderr, "Failed to change the socket mode\n"); | 2128 | fprintf (stderr, "Failed to change the socket mode\n"); |
2129 | ExitProcess (2); | 2129 | ExitProcess (2); |
2130 | } | 2130 | } |
2131 | 2131 | ||
2132 | memset (&write_std, 0, sizeof (write_std)); | 2132 | memset (&write_std, 0, sizeof (write_std)); |
2133 | memset (&write_pout, 0, sizeof (write_pout)); | 2133 | memset (&write_pout, 0, sizeof (write_pout)); |
2134 | stdin_open = 1; | 2134 | stdin_open = 1; |
2135 | 2135 | ||
2136 | rfds = GNUNET_NETWORK_fdset_create (); | 2136 | rfds = GNUNET_NETWORK_fdset_create (); |
2137 | wfds = GNUNET_NETWORK_fdset_create (); | 2137 | wfds = GNUNET_NETWORK_fdset_create (); |
2138 | 2138 | ||
2139 | /* Send MAC address of the bluetooth interface to STDOUT first */ | 2139 | /* Send MAC address of the bluetooth interface to STDOUT first */ |
2140 | { | 2140 | { |
2141 | struct GNUNET_TRANSPORT_WLAN_HelperControlMessage macmsg; | 2141 | struct GNUNET_TRANSPORT_WLAN_HelperControlMessage macmsg; |
@@ -2146,9 +2146,9 @@ main (int argc, char *argv[]) | |||
2146 | memcpy (write_std.buf, &macmsg, sizeof (macmsg)); | 2146 | memcpy (write_std.buf, &macmsg, sizeof (macmsg)); |
2147 | write_std.size = sizeof (macmsg); | 2147 | write_std.size = sizeof (macmsg); |
2148 | } | 2148 | } |
2149 | 2149 | ||
2150 | 2150 | ||
2151 | stdin_mst = mst_create (&stdin_send_hw, &dev); | 2151 | stdin_mst = mst_create (&stdin_send_hw, &dev); |
2152 | stdin_open = 1; | 2152 | stdin_open = 1; |
2153 | 2153 | ||
2154 | int pos = 0; | 2154 | int pos = 0; |
@@ -2161,13 +2161,13 @@ main (int argc, char *argv[]) | |||
2161 | stdin_pos = -1; | 2161 | stdin_pos = -1; |
2162 | stdout_pos = -1; | 2162 | stdout_pos = -1; |
2163 | sendsocket = NULL; //FIXME ???memleaks | 2163 | sendsocket = NULL; //FIXME ???memleaks |
2164 | 2164 | ||
2165 | GNUNET_NETWORK_fdset_zero (rfds); | 2165 | GNUNET_NETWORK_fdset_zero (rfds); |
2166 | if ((0 == write_pout.size) && (1 == stdin_open)) | 2166 | if ((0 == write_pout.size) && (1 == stdin_open)) |
2167 | { | 2167 | { |
2168 | stdin_pos = pos; | 2168 | stdin_pos = pos; |
2169 | pos +=1; | 2169 | pos +=1; |
2170 | GNUNET_NETWORK_fdset_handle_set (rfds, (struct GNUNET_DISK_FileHandle*) &stdin_handle); | 2170 | GNUNET_NETWORK_fdset_handle_set (rfds, (struct GNUNET_DISK_FileHandle*) &stdin_handle); |
2171 | } | 2171 | } |
2172 | 2172 | ||
2173 | if (0 == write_std.size) | 2173 | if (0 == write_std.size) |
@@ -2175,7 +2175,7 @@ main (int argc, char *argv[]) | |||
2175 | pos += 1; | 2175 | pos += 1; |
2176 | GNUNET_NETWORK_fdset_set (rfds, dev.handle); | 2176 | GNUNET_NETWORK_fdset_set (rfds, dev.handle); |
2177 | } | 2177 | } |
2178 | 2178 | ||
2179 | for (i = 0; i < crt_rfds; i++) | 2179 | for (i = 0; i < crt_rfds; i++) |
2180 | { | 2180 | { |
2181 | pos += 1; | 2181 | pos += 1; |
@@ -2189,34 +2189,34 @@ main (int argc, char *argv[]) | |||
2189 | GNUNET_NETWORK_fdset_handle_set (wfds, (struct GNUNET_DISK_FileHandle*) &stdout_handle); | 2189 | GNUNET_NETWORK_fdset_handle_set (wfds, (struct GNUNET_DISK_FileHandle*) &stdout_handle); |
2190 | // printf ("%s\n", write_std.buf); | 2190 | // printf ("%s\n", write_std.buf); |
2191 | // memset (write_std.buf, 0, write_std.size); | 2191 | // memset (write_std.buf, 0, write_std.size); |
2192 | // write_std.size = 0; | 2192 | // write_std.size = 0; |
2193 | } | 2193 | } |
2194 | 2194 | ||
2195 | if (0 < write_pout.size) | 2195 | if (0 < write_pout.size) |
2196 | { | 2196 | { |
2197 | if (strcmp (argv[1], "ff:ff:ff:ff:ff:ff") == 0) { | 2197 | if (strcmp (argv[1], "ff:ff:ff:ff:ff:ff") == 0) { |
2198 | fprintf(stderr, "LOG: BROADCAST! Skipping the message\n"); | 2198 | fprintf(stderr, "LOG: BROADCAST! Skipping the message\n"); |
2199 | // skip the message | 2199 | // skip the message |
2200 | broadcast = 1; | 2200 | broadcast = 1; |
2201 | memset (write_pout.buf, 0, write_pout.size); | 2201 | memset (write_pout.buf, 0, write_pout.size); |
2202 | write_pout.size = 0; | 2202 | write_pout.size = 0; |
2203 | } | 2203 | } |
2204 | else | 2204 | else |
2205 | { | 2205 | { |
2206 | SOCKADDR_BTH addr; | 2206 | SOCKADDR_BTH addr; |
2207 | fprintf (stderr, "LOG : has a new message for %s\n", argv[1]); | 2207 | fprintf (stderr, "LOG : has a new message for %s\n", argv[1]); |
2208 | sendsocket = GNUNET_NETWORK_socket_create (AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM); | 2208 | sendsocket = GNUNET_NETWORK_socket_create (AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM); |
2209 | 2209 | ||
2210 | if (sendsocket == NULL) | 2210 | if (sendsocket == NULL) |
2211 | { | 2211 | { |
2212 | fprintf (stderr, "Failed to create RFCOMM socket: \n"); | 2212 | fprintf (stderr, "Failed to create RFCOMM socket: \n"); |
2213 | print_last_error(); | 2213 | print_last_error(); |
2214 | ExitProcess (2); | 2214 | ExitProcess (2); |
2215 | } | 2215 | } |
2216 | 2216 | ||
2217 | memset (&addr, 0, sizeof (addr)); | 2217 | memset (&addr, 0, sizeof (addr)); |
2218 | //addr.addressFamily = AF_BTH; | 2218 | //addr.addressFamily = AF_BTH; |
2219 | if (SOCKET_ERROR == | 2219 | if (SOCKET_ERROR == |
2220 | WSAStringToAddress (argv[1], AF_BTH, NULL, (LPSOCKADDR) &addr, &addr_len)) | 2220 | WSAStringToAddress (argv[1], AF_BTH, NULL, (LPSOCKADDR) &addr, &addr_len)) |
2221 | { | 2221 | { |
2222 | fprintf (stderr, "Failed to translate the address: "); | 2222 | fprintf (stderr, "Failed to translate the address: "); |
@@ -2250,7 +2250,7 @@ main (int argc, char *argv[]) | |||
2250 | } | 2250 | } |
2251 | } | 2251 | } |
2252 | } | 2252 | } |
2253 | 2253 | ||
2254 | if (broadcast == 0) | 2254 | if (broadcast == 0) |
2255 | { | 2255 | { |
2256 | int retval = GNUNET_NETWORK_socket_select (rfds, wfds, NULL, GNUNET_TIME_relative_get_forever_()); | 2256 | int retval = GNUNET_NETWORK_socket_select (rfds, wfds, NULL, GNUNET_TIME_relative_get_forever_()); |
@@ -2279,7 +2279,7 @@ main (int argc, char *argv[]) | |||
2279 | fprintf (stderr, "Failed to write to STDOUT\n"); | 2279 | fprintf (stderr, "Failed to write to STDOUT\n"); |
2280 | ExitProcess (2); | 2280 | ExitProcess (2); |
2281 | } | 2281 | } |
2282 | 2282 | ||
2283 | write_std.pos += ret; | 2283 | write_std.pos += ret; |
2284 | if (write_std.pos == write_std.size) | 2284 | if (write_std.pos == write_std.size) |
2285 | { | 2285 | { |
@@ -2292,9 +2292,9 @@ main (int argc, char *argv[]) | |||
2292 | if (GNUNET_NETWORK_fdset_isset (wfds, sendsocket)) | 2292 | if (GNUNET_NETWORK_fdset_isset (wfds, sendsocket)) |
2293 | { | 2293 | { |
2294 | ssize_t ret; | 2294 | ssize_t ret; |
2295 | ret = GNUNET_NETWORK_socket_send (sendsocket, write_pout.buf + write_pout.pos, | 2295 | ret = GNUNET_NETWORK_socket_send (sendsocket, write_pout.buf + write_pout.pos, |
2296 | write_pout.size - write_pout.pos); | 2296 | write_pout.size - write_pout.pos); |
2297 | 2297 | ||
2298 | if (GNUNET_SYSERR == ret) | 2298 | if (GNUNET_SYSERR == ret) |
2299 | { | 2299 | { |
2300 | fprintf (stderr, "Failed to send to the socket. Closing the socket. Error: \n"); | 2300 | fprintf (stderr, "Failed to send to the socket. Closing the socket. Error: \n"); |
@@ -2317,22 +2317,22 @@ main (int argc, char *argv[]) | |||
2317 | (unsigned int) write_pout.size); | 2317 | (unsigned int) write_pout.size); |
2318 | break; | 2318 | break; |
2319 | } | 2319 | } |
2320 | 2320 | ||
2321 | if (write_pout.pos == write_pout.size) | 2321 | if (write_pout.pos == write_pout.size) |
2322 | { | 2322 | { |
2323 | write_pout.pos = 0; | 2323 | write_pout.pos = 0; |
2324 | write_pout.size = 0; | 2324 | write_pout.size = 0; |
2325 | 2325 | ||
2326 | } | 2326 | } |
2327 | fprintf(stderr, "LOG : sends a message to a DEVICE\n"); //FIXME: debugging message | 2327 | fprintf(stderr, "LOG : sends a message to a DEVICE\n"); //FIXME: debugging message |
2328 | } | 2328 | } |
2329 | } | 2329 | } |
2330 | } | 2330 | } |
2331 | 2331 | ||
2332 | //if (GNUNET_NETWORK_fdset_isset (rfds, (struct GNUNET_NETWORK_Handle*)&stdin_handle)) | 2332 | //if (GNUNET_NETWORK_fdset_isset (rfds, (struct GNUNET_NETWORK_Handle*)&stdin_handle)) |
2333 | if (retval == stdin_pos) | 2333 | if (retval == stdin_pos) |
2334 | { | 2334 | { |
2335 | //ssize_t ret; | 2335 | //ssize_t ret; |
2336 | //ret = GNUNET_NETWORK_socket_recv ((struct GNUNET_NETWORK_Handle *)&stdin_handle, readbuf, sizeof (write_pout.buf)); | 2336 | //ret = GNUNET_NETWORK_socket_recv ((struct GNUNET_NETWORK_Handle *)&stdin_handle, readbuf, sizeof (write_pout.buf)); |
2337 | //ret = read (STDIN_FILENO, readbuf, sizeof (readbuf)); | 2337 | //ret = read (STDIN_FILENO, readbuf, sizeof (readbuf)); |
2338 | DWORD ret; | 2338 | DWORD ret; |
@@ -2356,7 +2356,7 @@ main (int argc, char *argv[]) | |||
2356 | { | 2356 | { |
2357 | fprintf (stderr, "LOG: accepting connection\n"); | 2357 | fprintf (stderr, "LOG: accepting connection\n"); |
2358 | struct GNUNET_NETWORK_Handle *readsocket; | 2358 | struct GNUNET_NETWORK_Handle *readsocket; |
2359 | readsocket = GNUNET_NETWORK_socket_accept (dev.handle, (LPSOCKADDR)&acc_addr, &addr_len); | 2359 | readsocket = GNUNET_NETWORK_socket_accept (dev.handle, (LPSOCKADDR)&acc_addr, &addr_len); |
2360 | if (readsocket == NULL) | 2360 | if (readsocket == NULL) |
2361 | { | 2361 | { |
2362 | fprintf (stderr, "Accept error %d: ", GetLastError()); | 2362 | fprintf (stderr, "Accept error %d: ", GetLastError()); |
@@ -2386,14 +2386,14 @@ main (int argc, char *argv[]) | |||
2386 | { | 2386 | { |
2387 | if (GNUNET_NETWORK_fdset_isset (rfds, rfds_list[i])) | 2387 | if (GNUNET_NETWORK_fdset_isset (rfds, rfds_list[i])) |
2388 | { | 2388 | { |
2389 | struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rrm; | 2389 | struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rrm; |
2390 | ssize_t ret; | 2390 | ssize_t ret; |
2391 | fprintf (stderr, "LOG: reading something from the socket\n");//FIXME : debugging message | 2391 | fprintf (stderr, "LOG: reading something from the socket\n");//FIXME : debugging message |
2392 | rrm = (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) write_std.buf; | 2392 | rrm = (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) write_std.buf; |
2393 | ret = read_from_the_socket (rfds_list[i], (unsigned char *) &rrm->frame, | 2393 | ret = read_from_the_socket (rfds_list[i], (unsigned char *) &rrm->frame, |
2394 | sizeof (write_std.buf) | 2394 | sizeof (write_std.buf) |
2395 | - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) | 2395 | - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) |
2396 | + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame), | 2396 | + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame), |
2397 | rrm); | 2397 | rrm); |
2398 | if (0 >= ret) | 2398 | if (0 >= ret) |
2399 | { | 2399 | { |
@@ -2408,22 +2408,22 @@ main (int argc, char *argv[]) | |||
2408 | fprintf (stderr, "Read error from raw socket: "); | 2408 | fprintf (stderr, "Read error from raw socket: "); |
2409 | print_last_error(); | 2409 | print_last_error(); |
2410 | break; | 2410 | break; |
2411 | 2411 | ||
2412 | } | 2412 | } |
2413 | if ((0 < ret) && (0 == mac_test (&rrm->frame, &dev))) | 2413 | if ((0 < ret) && (0 == mac_test (&rrm->frame, &dev))) |
2414 | { | 2414 | { |
2415 | write_std.size = ret | 2415 | write_std.size = ret |
2416 | + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) | 2416 | + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) |
2417 | - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame); | 2417 | - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame); |
2418 | rrm->header.size = htons (write_std.size); | 2418 | rrm->header.size = htons (write_std.size); |
2419 | rrm->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER); | 2419 | rrm->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER); |
2420 | } | 2420 | } |
2421 | break; | 2421 | break; |
2422 | } | 2422 | } |
2423 | } | 2423 | } |
2424 | } | 2424 | } |
2425 | } | 2425 | } |
2426 | 2426 | ||
2427 | mst_destroy (stdin_mst); | 2427 | mst_destroy (stdin_mst); |
2428 | stdin_mst = NULL; | 2428 | stdin_mst = NULL; |
2429 | 2429 | ||