diff options
author | ng0 <ng0@n0.is> | 2019-09-10 16:59:32 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-10 16:59:32 +0000 |
commit | 04b6df21cd281e8cd540139f8d9ae85defc1961c (patch) | |
tree | 6357199445df8d5c0c631bc8f10aef838b1f9f1e /src/transport | |
parent | 483b0139a218a5f8a8311bda3eb23bcd88f57688 (diff) | |
download | gnunet-04b6df21cd281e8cd540139f8d9ae85defc1961c.tar.gz gnunet-04b6df21cd281e8cd540139f8d9ae85defc1961c.zip |
remove CYGWIN codeblocks, drop vendored Windows openvpn, drop win32 specific files.
configures and builds okay.
testsuite wasn't checked, will be checked.
diff including the plibc removal is now around 14370 lines of code less.
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/Makefile.am | 18 | ||||
-rw-r--r-- | src/transport/gnunet-helper-transport-bluetooth.c | 352 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp.c | 15 | ||||
-rw-r--r-- | src/transport/plugin_transport_wlan.h | 7 | ||||
-rw-r--r-- | src/transport/tcp_service_legacy.c | 111 |
5 files changed, 27 insertions, 476 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index a9b0d19d6..0f5b2e8be 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -114,18 +114,12 @@ if HAVE_LIBBLUETOOTH | |||
114 | BT_QUOTA_TEST = test_quota_compliance_bluetooth \ | 114 | BT_QUOTA_TEST = test_quota_compliance_bluetooth \ |
115 | test_quota_compliance_bluetooth_asymmetric | 115 | test_quota_compliance_bluetooth_asymmetric |
116 | endif | 116 | endif |
117 | else | ||
118 | if MINGW | ||
119 | BT_BIN = gnunet-helper-transport-bluetooth | ||
120 | BT_PLUGIN_LA = libgnunet_plugin_transport_bluetooth.la | ||
121 | endif | ||
122 | endif | 117 | endif |
123 | 118 | ||
124 | # end of HAVE_EXPERIMENTAL | 119 | # end of HAVE_EXPERIMENTAL |
125 | endif | 120 | endif |
126 | 121 | ||
127 | 122 | ||
128 | if !MINGW | ||
129 | UNIX_PLUGIN_LA = libgnunet_plugin_transport_unix.la | 123 | UNIX_PLUGIN_LA = libgnunet_plugin_transport_unix.la |
130 | UNIX_PLUGIN_TEST = test_transport_api_unix | 124 | UNIX_PLUGIN_TEST = test_transport_api_unix |
131 | UNIX_TEST = test_plugin_unix | 125 | UNIX_TEST = test_plugin_unix |
@@ -136,7 +130,7 @@ UNIX_QUOTA_TEST = test_quota_compliance_unix \ | |||
136 | if LINUX | 130 | if LINUX |
137 | UNIX_API_ABSTRACT_TEST = test_transport_api_unix_abstract | 131 | UNIX_API_ABSTRACT_TEST = test_transport_api_unix_abstract |
138 | endif | 132 | endif |
139 | endif | 133 | |
140 | 134 | ||
141 | noinst_PROGRAMS = \ | 135 | noinst_PROGRAMS = \ |
142 | gnunet-transport-profiler \ | 136 | gnunet-transport-profiler \ |
@@ -319,13 +313,9 @@ gnunet_transport_wlan_receiver_LDADD = \ | |||
319 | 313 | ||
320 | gnunet_helper_transport_bluetooth_SOURCES = \ | 314 | gnunet_helper_transport_bluetooth_SOURCES = \ |
321 | gnunet-helper-transport-bluetooth.c | 315 | gnunet-helper-transport-bluetooth.c |
322 | if MINGW | 316 | |
323 | gnunet_helper_transport_bluetooth_LDADD = \ | 317 | gnunet_helper_transport_bluetooth_LDFLAGS = -lbluetooth |
324 | $(top_builddir)/src/util/libgnunetutil.la | 318 | |
325 | gnunet_helper_transport_bluetooth_LDFLAGS = -lws2_32 | ||
326 | else | ||
327 | gnunet_helper_transport_bluetooth_LDFLAGS = -lbluetooth | ||
328 | endif | ||
329 | 319 | ||
330 | gnunet_transport_profiler_SOURCES = \ | 320 | gnunet_transport_profiler_SOURCES = \ |
331 | gnunet-transport-profiler.c | 321 | gnunet-transport-profiler.c |
diff --git a/src/transport/gnunet-helper-transport-bluetooth.c b/src/transport/gnunet-helper-transport-bluetooth.c index 2ac705996..4696f48f8 100644 --- a/src/transport/gnunet-helper-transport-bluetooth.c +++ b/src/transport/gnunet-helper-transport-bluetooth.c | |||
@@ -21,30 +21,23 @@ | |||
21 | */ | 21 | */ |
22 | #include "gnunet_config.h" | 22 | #include "gnunet_config.h" |
23 | 23 | ||
24 | #ifdef MINGW | 24 | #define SOCKTYPE int |
25 | #include "platform.h" | 25 | #include <bluetooth/bluetooth.h> |
26 | #include "gnunet_util_lib.h" | 26 | #include <bluetooth/hci.h> |
27 | #include <bthdef.h> | 27 | #include <bluetooth/hci_lib.h> |
28 | #include <ws2bth.h> | 28 | #include <bluetooth/rfcomm.h> |
29 | #else | 29 | #include <bluetooth/sdp.h> |
30 | #define SOCKTYPE int | 30 | #include <bluetooth/sdp_lib.h> |
31 | #include <bluetooth/bluetooth.h> | 31 | #include <errno.h> |
32 | #include <bluetooth/hci.h> | 32 | #include <linux/if.h> |
33 | #include <bluetooth/hci_lib.h> | 33 | #include <stdio.h> |
34 | #include <bluetooth/rfcomm.h> | 34 | #include <stdlib.h> |
35 | #include <bluetooth/sdp.h> | 35 | #include <sys/ioctl.h> |
36 | #include <bluetooth/sdp_lib.h> | 36 | #include <sys/param.h> |
37 | #include <errno.h> | 37 | #include <sys/socket.h> |
38 | #include <linux/if.h> | 38 | #include <sys/stat.h> |
39 | #include <stdio.h> | 39 | #include <sys/types.h> |
40 | #include <stdlib.h> | 40 | #include <unistd.h> |
41 | #include <sys/ioctl.h> | ||
42 | #include <sys/param.h> | ||
43 | #include <sys/socket.h> | ||
44 | #include <sys/stat.h> | ||
45 | #include <sys/types.h> | ||
46 | #include <unistd.h> | ||
47 | #endif | ||
48 | 41 | ||
49 | #include "plugin_transport_wlan.h" | 42 | #include "plugin_transport_wlan.h" |
50 | #include "gnunet_protocols.h" | 43 | #include "gnunet_protocols.h" |
@@ -67,34 +60,6 @@ | |||
67 | */ | 60 | */ |
68 | #define MAX_LOOPS 5 | 61 | #define MAX_LOOPS 5 |
69 | 62 | ||
70 | #ifdef MINGW | ||
71 | /* Maximum size of the interface's name */ | ||
72 | #define IFNAMSIZ 16 | ||
73 | |||
74 | #ifndef NS_BTH | ||
75 | #define NS_BTH 16 | ||
76 | #endif | ||
77 | /** | ||
78 | * A copy of the MAC Address. | ||
79 | */ | ||
80 | struct GNUNET_TRANSPORT_WLAN_MacAddress_Copy { | ||
81 | UINT8 mac[MAC_ADDR_SIZE]; | ||
82 | }; | ||
83 | |||
84 | /** | ||
85 | * The UUID used for the SDP service. | ||
86 | * {31191E56-FA7E-4517-870E-71B86BBCC52F} | ||
87 | */ | ||
88 | #define GNUNET_BLUETOOTH_SDP_UUID \ | ||
89 | { \ | ||
90 | 0x31, 0x19, 0x1E, 0x56, \ | ||
91 | 0xFA, 0x7E, \ | ||
92 | 0x45, 0x17, \ | ||
93 | 0x87, 0x0E, \ | ||
94 | 0x71, 0xB8, 0x6B, 0xBC, 0xC5, 0x2F \ | ||
95 | } | ||
96 | #endif | ||
97 | |||
98 | /** | 63 | /** |
99 | * In bluez library, the maximum name length of a device is 8 | 64 | * In bluez library, the maximum name length of a device is 8 |
100 | */ | 65 | */ |
@@ -110,17 +75,6 @@ struct HardwareInfos { | |||
110 | */ | 75 | */ |
111 | char iface[IFNAMSIZ]; | 76 | char iface[IFNAMSIZ]; |
112 | 77 | ||
113 | #ifdef MINGW | ||
114 | /** | ||
115 | * socket handle | ||
116 | */ | ||
117 | struct GNUNET_NETWORK_Handle *handle; | ||
118 | |||
119 | /** | ||
120 | * MAC address of our own bluetooth interface. | ||
121 | */ | ||
122 | struct GNUNET_TRANSPORT_WLAN_MacAddress_Copy pl_mac; | ||
123 | #else | ||
124 | /** | 78 | /** |
125 | * file descriptor for the rfcomm socket | 79 | * file descriptor for the rfcomm socket |
126 | */ | 80 | */ |
@@ -135,7 +89,6 @@ struct HardwareInfos { | |||
135 | * SDP session | 89 | * SDP session |
136 | */ | 90 | */ |
137 | sdp_session_t *session; | 91 | sdp_session_t *session; |
138 | #endif | ||
139 | }; | 92 | }; |
140 | 93 | ||
141 | /** | 94 | /** |
@@ -606,61 +559,6 @@ check_crc_buf_osdep(const unsigned char *buf, size_t len) | |||
606 | 559 | ||
607 | 560 | ||
608 | /* ************** end of clone ***************** */ | 561 | /* ************** end of clone ***************** */ |
609 | |||
610 | #ifdef MINGW | ||
611 | /** | ||
612 | * Function used to get the code of last error and to print the type of error. | ||
613 | */ | ||
614 | static void | ||
615 | print_last_error() | ||
616 | { | ||
617 | LPVOID lpMsgBuf = NULL; | ||
618 | |||
619 | if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, | ||
620 | NULL, GetLastError(), 0, (LPTSTR)&lpMsgBuf, 0, NULL)) | ||
621 | fprintf(stderr, "%s\n", (char *)lpMsgBuf); | ||
622 | else | ||
623 | fprintf(stderr, "Failed to format the message for the last error! Error number : %d\n", GetLastError()); | ||
624 | } | ||
625 | |||
626 | /** | ||
627 | * Function used to initialize the Windows Sockets | ||
628 | */ | ||
629 | static void | ||
630 | initialize_windows_sockets() | ||
631 | { | ||
632 | WSADATA wsaData; | ||
633 | WORD wVersionRequested = MAKEWORD(2, 0); | ||
634 | |||
635 | if (WSAStartup(wVersionRequested, &wsaData) != NO_ERROR) | ||
636 | { | ||
637 | fprintf(stderr, "Error initializing window sockets!\n"); | ||
638 | print_last_error(); | ||
639 | ExitProcess(2); | ||
640 | } | ||
641 | } | ||
642 | |||
643 | /** | ||
644 | * Function used to convert the GUID. | ||
645 | * @param bytes the GUID represented as a char array | ||
646 | * @param uuid pointer to the GUID | ||
647 | */ | ||
648 | static void | ||
649 | convert_guid(char *bytes, GUID * uuid) | ||
650 | { | ||
651 | int i; | ||
652 | |||
653 | uuid->Data1 = ((bytes[0] << 24) & 0xff000000) | ((bytes[1] << 16) & 0x00ff0000) | ((bytes[2] << 8) & 0x0000ff00) | (bytes[3] & 0x000000ff); | ||
654 | uuid->Data2 = ((bytes[4] << 8) & 0xff00) | (bytes[5] & 0x00ff); | ||
655 | uuid->Data3 = ((bytes[6] << 8) & 0xff00) | (bytes[7] & 0x00ff); | ||
656 | |||
657 | for (i = 0; i < 8; i++) | ||
658 | { | ||
659 | uuid->Data4[i] = bytes[i + 8]; | ||
660 | } | ||
661 | } | ||
662 | #endif | ||
663 | |||
664 | #ifdef LINUX | 562 | #ifdef LINUX |
665 | /** | 563 | /** |
666 | * Function for assigning a port number | 564 | * Function for assigning a port number |
@@ -688,79 +586,6 @@ bind_socket(int socket, struct sockaddr_rc *addr) | |||
688 | } | 586 | } |
689 | #endif | 587 | #endif |
690 | 588 | ||
691 | #ifdef MINGW | ||
692 | /** | ||
693 | * Function used for creating the service record and registering it. | ||
694 | * | ||
695 | * @param dev pointer to the device struct | ||
696 | * @return 0 on success | ||
697 | */ | ||
698 | static int | ||
699 | register_service(struct HardwareInfos *dev) | ||
700 | { | ||
701 | /* advertise the service */ | ||
702 | CSADDR_INFO addr_info; | ||
703 | WSAQUERYSET wqs; | ||
704 | GUID guid; | ||
705 | unsigned char uuid[] = GNUNET_BLUETOOTH_SDP_UUID; | ||
706 | SOCKADDR_BTH addr; | ||
707 | int addr_len = sizeof(SOCKADDR_BTH); | ||
708 | int fd; | ||
709 | |||
710 | /* get the port on which we are listening on */ | ||
711 | memset(&addr, 0, sizeof(SOCKADDR_BTH)); | ||
712 | fd = GNUNET_NETWORK_get_fd(dev->handle); | ||
713 | if (fd <= 0) | ||
714 | { | ||
715 | fprintf(stderr, "Failed to get the file descriptor\n"); | ||
716 | return -1; | ||
717 | } | ||
718 | if (SOCKET_ERROR == getsockname(fd, (SOCKADDR*)&addr, &addr_len)) | ||
719 | { | ||
720 | fprintf(stderr, "Failed to get the port on which we are listening on: \n"); | ||
721 | print_last_error(); | ||
722 | return -1; | ||
723 | } | ||
724 | |||
725 | /* save the device address */ | ||
726 | GNUNET_memcpy(&dev->pl_mac, &addr.btAddr, sizeof(BTH_ADDR)); | ||
727 | |||
728 | /* set the address information */ | ||
729 | memset(&addr_info, 0, sizeof(CSADDR_INFO)); | ||
730 | addr_info.iProtocol = BTHPROTO_RFCOMM; | ||
731 | addr_info.iSocketType = SOCK_STREAM; | ||
732 | addr_info.LocalAddr.lpSockaddr = (LPSOCKADDR)&addr; | ||
733 | addr_info.LocalAddr.iSockaddrLength = sizeof(addr); | ||
734 | addr_info.RemoteAddr.lpSockaddr = (LPSOCKADDR)&addr; | ||
735 | addr_info.RemoteAddr.iSockaddrLength = sizeof(addr); | ||
736 | |||
737 | convert_guid((char *)uuid, &guid); | ||
738 | |||
739 | /* register the service */ | ||
740 | memset(&wqs, 0, sizeof(WSAQUERYSET)); | ||
741 | wqs.dwSize = sizeof(WSAQUERYSET); | ||
742 | wqs.dwNameSpace = NS_BTH; | ||
743 | wqs.lpszServiceInstanceName = "GNUnet Bluetooth Service"; | ||
744 | wqs.lpszComment = "This is the service used by the GNUnnet plugin transport"; | ||
745 | wqs.lpServiceClassId = &guid; | ||
746 | wqs.dwNumberOfCsAddrs = 1; | ||
747 | wqs.lpcsaBuffer = &addr_info; | ||
748 | wqs.lpBlob = 0; | ||
749 | |||
750 | if (SOCKET_ERROR == WSASetService(&wqs, RNRSERVICE_REGISTER, 0)) | ||
751 | { | ||
752 | fprintf(stderr, "Failed to register the SDP service: "); | ||
753 | print_last_error(); | ||
754 | return -1; | ||
755 | } | ||
756 | else | ||
757 | { | ||
758 | fprintf(stderr, "The SDP service was registered\n"); | ||
759 | } | ||
760 | |||
761 | return 0; | ||
762 | } | ||
763 | #else | ||
764 | /** | 589 | /** |
765 | * Function used for creating the service record and registering it. | 590 | * Function used for creating the service record and registering it. |
766 | * | 591 | * |
@@ -849,96 +674,7 @@ register_service(struct HardwareInfos *dev, int rc_channel) | |||
849 | 674 | ||
850 | return 0; | 675 | return 0; |
851 | } | 676 | } |
852 | #endif | ||
853 | 677 | ||
854 | #ifdef MINGW | ||
855 | /** | ||
856 | * Function for searching and browsing for a service. This will return the | ||
857 | * port number on which the service is running. | ||
858 | * | ||
859 | * @param dest target address | ||
860 | * @return channel | ||
861 | */ | ||
862 | static int | ||
863 | get_channel(const char *dest) | ||
864 | { | ||
865 | HANDLE h; | ||
866 | WSAQUERYSET *wqs; | ||
867 | DWORD wqs_len = sizeof(WSAQUERYSET); | ||
868 | int done = 0; | ||
869 | int channel = -1; | ||
870 | GUID guid; | ||
871 | unsigned char uuid[] = GNUNET_BLUETOOTH_SDP_UUID; | ||
872 | |||
873 | convert_guid((char *)uuid, &guid); | ||
874 | |||
875 | wqs = (WSAQUERYSET*)malloc(wqs_len); | ||
876 | ZeroMemory(wqs, wqs_len); | ||
877 | |||
878 | wqs->dwSize = sizeof(WSAQUERYSET); | ||
879 | wqs->lpServiceClassId = &guid; | ||
880 | wqs->dwNameSpace = NS_BTH; | ||
881 | wqs->dwNumberOfCsAddrs = 0; | ||
882 | wqs->lpszContext = (LPSTR)dest; | ||
883 | |||
884 | if (SOCKET_ERROR == WSALookupServiceBegin(wqs, LUP_FLUSHCACHE | LUP_RETURN_ALL, &h)) | ||
885 | { | ||
886 | if (GetLastError() == WSASERVICE_NOT_FOUND) | ||
887 | { | ||
888 | fprintf(stderr, "WARNING! The device with address %s wasn't found. Skipping the message!", dest); | ||
889 | return -1; | ||
890 | } | ||
891 | else | ||
892 | { | ||
893 | fprintf(stderr, "Failed to find the port number: "); | ||
894 | print_last_error(); | ||
895 | ExitProcess(2); | ||
896 | return -1; | ||
897 | } | ||
898 | } | ||
899 | |||
900 | /* search the sdp service */ | ||
901 | while (!done) | ||
902 | { | ||
903 | if (SOCKET_ERROR == WSALookupServiceNext(h, LUP_FLUSHCACHE | LUP_RETURN_ALL, &wqs_len, wqs)) | ||
904 | { | ||
905 | int error = WSAGetLastError(); | ||
906 | |||
907 | switch (error) | ||
908 | { | ||
909 | case WSAEFAULT: | ||
910 | free(wqs); | ||
911 | wqs = (WSAQUERYSET*)malloc(wqs_len); | ||
912 | break; | ||
913 | |||
914 | case WSANO_DATA: | ||
915 | fprintf(stderr, "Failed! The address was valid but there was no data record of requested type\n"); | ||
916 | done = 1; | ||
917 | break; | ||
918 | |||
919 | case WSA_E_NO_MORE: | ||
920 | done = 1; | ||
921 | break; | ||
922 | |||
923 | default: | ||
924 | fprintf(stderr, "Failed to look over the services: "); | ||
925 | print_last_error(); | ||
926 | WSALookupServiceEnd(h); | ||
927 | ExitProcess(2); | ||
928 | } | ||
929 | } | ||
930 | else | ||
931 | { | ||
932 | channel = ((SOCKADDR_BTH*)wqs->lpcsaBuffer->RemoteAddr.lpSockaddr)->port; | ||
933 | } | ||
934 | } | ||
935 | |||
936 | free(wqs); | ||
937 | WSALookupServiceEnd(h); | ||
938 | |||
939 | return channel; | ||
940 | } | ||
941 | #else | ||
942 | /** | 678 | /** |
943 | * Function used for searching and browsing for a service. This will return the | 679 | * Function used for searching and browsing for a service. This will return the |
944 | * port number on which the service is running. | 680 | * port number on which the service is running. |
@@ -1011,7 +747,6 @@ get_channel(struct HardwareInfos *dev, bdaddr_t dest) | |||
1011 | 747 | ||
1012 | return channel; | 748 | return channel; |
1013 | } | 749 | } |
1014 | #endif | ||
1015 | 750 | ||
1016 | /** | 751 | /** |
1017 | * Read from the socket and put the result into the buffer for transmission to 'stdout'. | 752 | * Read from the socket and put the result into the buffer for transmission to 'stdout'. |
@@ -1030,22 +765,14 @@ read_from_the_socket(void *sock, | |||
1030 | { | 765 | { |
1031 | unsigned char tmpbuf[buf_size]; | 766 | unsigned char tmpbuf[buf_size]; |
1032 | ssize_t count; | 767 | ssize_t count; |
1033 | |||
1034 | #ifdef MINGW | ||
1035 | count = GNUNET_NETWORK_socket_recv((struct GNUNET_NETWORK_Handle *)sock, tmpbuf, buf_size); | ||
1036 | #else | ||
1037 | count = read(*((int *)sock), tmpbuf, buf_size); | 768 | count = read(*((int *)sock), tmpbuf, buf_size); |
1038 | #endif | ||
1039 | 769 | ||
1040 | if (0 > count) | 770 | if (0 > count) |
1041 | { | 771 | { |
1042 | if (EAGAIN == errno) | 772 | if (EAGAIN == errno) |
1043 | return 0; | 773 | return 0; |
1044 | #if MINGW | 774 | |
1045 | print_last_error(); | ||
1046 | #else | ||
1047 | fprintf(stderr, "Failed to read from the HCI socket: %s\n", strerror(errno)); | 775 | fprintf(stderr, "Failed to read from the HCI socket: %s\n", strerror(errno)); |
1048 | #endif | ||
1049 | 776 | ||
1050 | return -1; | 777 | return -1; |
1051 | } | 778 | } |
@@ -1088,43 +815,6 @@ read_from_the_socket(void *sock, | |||
1088 | static int | 815 | static int |
1089 | open_device(struct HardwareInfos *dev) | 816 | open_device(struct HardwareInfos *dev) |
1090 | { | 817 | { |
1091 | #ifdef MINGW | ||
1092 | SOCKADDR_BTH addr; | ||
1093 | |||
1094 | /* bind the RFCOMM socket to the interface */ | ||
1095 | addr.addressFamily = AF_BTH; | ||
1096 | addr.btAddr = 0; | ||
1097 | addr.port = BT_PORT_ANY; | ||
1098 | |||
1099 | if (GNUNET_OK != | ||
1100 | GNUNET_NETWORK_socket_bind(dev->handle, (const SOCKADDR*)&addr, sizeof(SOCKADDR_BTH))) | ||
1101 | { | ||
1102 | fprintf(stderr, "Failed to bind the socket: "); | ||
1103 | if (GetLastError() == WSAENETDOWN) | ||
1104 | { | ||
1105 | fprintf(stderr, "Please make sure that your Bluetooth device is ON!\n"); | ||
1106 | ExitProcess(2); | ||
1107 | } | ||
1108 | print_last_error(); | ||
1109 | return -1; | ||
1110 | } | ||
1111 | |||
1112 | /* start listening on the socket */ | ||
1113 | if (GNUNET_NETWORK_socket_listen(dev->handle, 4) != GNUNET_OK) | ||
1114 | { | ||
1115 | fprintf(stderr, "Failed to listen on the socket: "); | ||
1116 | print_last_error(); | ||
1117 | return -1; | ||
1118 | } | ||
1119 | |||
1120 | /* register the sdp service */ | ||
1121 | if (register_service(dev) != 0) | ||
1122 | { | ||
1123 | fprintf(stderr, "Failed to register a service: "); | ||
1124 | print_last_error(); | ||
1125 | return 1; | ||
1126 | } | ||
1127 | #else | ||
1128 | int i, dev_id = -1, fd_hci; | 818 | int i, dev_id = -1, fd_hci; |
1129 | struct { | 819 | struct { |
1130 | struct hci_dev_list_req list; | 820 | struct hci_dev_list_req list; |
@@ -1279,7 +969,6 @@ open_device(struct HardwareInfos *dev) | |||
1279 | dev->iface, strerror(errno)); | 969 | dev->iface, strerror(errno)); |
1280 | return 1; | 970 | return 1; |
1281 | } | 971 | } |
1282 | #endif | ||
1283 | 972 | ||
1284 | return 0; | 973 | return 0; |
1285 | } | 974 | } |
@@ -1299,12 +988,7 @@ mac_set(struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader, | |||
1299 | { | 988 | { |
1300 | taIeeeHeader->frame_control = htons(IEEE80211_FC0_TYPE_DATA); | 989 | taIeeeHeader->frame_control = htons(IEEE80211_FC0_TYPE_DATA); |
1301 | taIeeeHeader->addr3 = mac_bssid_gnunet; | 990 | taIeeeHeader->addr3 = mac_bssid_gnunet; |
1302 | |||
1303 | #ifdef MINGW | ||
1304 | GNUNET_memcpy(&taIeeeHeader->addr2, &dev->pl_mac, sizeof(struct GNUNET_TRANSPORT_WLAN_MacAddress)); | ||
1305 | #else | ||
1306 | taIeeeHeader->addr2 = dev->pl_mac; | 991 | taIeeeHeader->addr2 = dev->pl_mac; |
1307 | #endif | ||
1308 | } | 992 | } |
1309 | 993 | ||
1310 | #ifdef LINUX | 994 | #ifdef LINUX |
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 755809194..c056bb79c 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -2929,20 +2929,7 @@ udp_select_read(struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
2929 | (struct sockaddr *)&addr, | 2929 | (struct sockaddr *)&addr, |
2930 | &fromlen); | 2930 | &fromlen); |
2931 | sa = (const struct sockaddr *)&addr; | 2931 | sa = (const struct sockaddr *)&addr; |
2932 | #if MINGW | 2932 | |
2933 | /* On SOCK_DGRAM UDP sockets recvfrom might fail with a | ||
2934 | * WSAECONNRESET error to indicate that previous sendto() (yes, sendto!) | ||
2935 | * on this socket has failed. | ||
2936 | * Quote from MSDN: | ||
2937 | * WSAECONNRESET - The virtual circuit was reset by the remote side | ||
2938 | * executing a hard or abortive close. The application should close | ||
2939 | * the socket; it is no longer usable. On a UDP-datagram socket this | ||
2940 | * error indicates a previous send operation resulted in an ICMP Port | ||
2941 | * Unreachable message. | ||
2942 | */ | ||
2943 | if ((-1 == size) && (ECONNRESET == errno)) | ||
2944 | return; | ||
2945 | #endif | ||
2946 | if (-1 == size) | 2933 | if (-1 == size) |
2947 | { | 2934 | { |
2948 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 2935 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/transport/plugin_transport_wlan.h b/src/transport/plugin_transport_wlan.h index cdc3e34ff..bf1a90dba 100644 --- a/src/transport/plugin_transport_wlan.h +++ b/src/transport/plugin_transport_wlan.h | |||
@@ -32,12 +32,7 @@ | |||
32 | /** | 32 | /** |
33 | * Number fo bytes in a mac address. | 33 | * Number fo bytes in a mac address. |
34 | */ | 34 | */ |
35 | #ifdef MINGW | 35 | #define MAC_ADDR_SIZE 6 |
36 | #define MAC_ADDR_SIZE 8 | ||
37 | typedef uint8_t u_int8_t; | ||
38 | #else | ||
39 | #define MAC_ADDR_SIZE 6 | ||
40 | #endif | ||
41 | 36 | ||
42 | /** | 37 | /** |
43 | * Value for "Management" in the 'frame_control' field of the | 38 | * Value for "Management" in the 'frame_control' field of the |
diff --git a/src/transport/tcp_service_legacy.c b/src/transport/tcp_service_legacy.c index 8f3f43718..129511fec 100644 --- a/src/transport/tcp_service_legacy.c +++ b/src/transport/tcp_service_legacy.c | |||
@@ -849,95 +849,6 @@ LEGACY_SERVICE_get_server_addresses( | |||
849 | } | 849 | } |
850 | 850 | ||
851 | 851 | ||
852 | #ifdef MINGW | ||
853 | /** | ||
854 | * Read listen sockets from the parent process (ARM). | ||
855 | * | ||
856 | * @param sctx service context to initialize | ||
857 | * @return #GNUNET_YES if ok, #GNUNET_NO if not ok (must bind yourself), | ||
858 | * and #GNUNET_SYSERR on error. | ||
859 | */ | ||
860 | static int | ||
861 | receive_sockets_from_parent(struct LEGACY_SERVICE_Context *sctx) | ||
862 | { | ||
863 | const char *env_buf; | ||
864 | int fail; | ||
865 | uint64_t count; | ||
866 | uint64_t i; | ||
867 | HANDLE lsocks_pipe; | ||
868 | |||
869 | env_buf = getenv("GNUNET_OS_READ_LSOCKS"); | ||
870 | if ((NULL == env_buf) || (strlen(env_buf) <= 0)) | ||
871 | return GNUNET_NO; | ||
872 | /* Using W32 API directly here, because this pipe will | ||
873 | * never be used outside of this function, and it's just too much of a bother | ||
874 | * to create a GNUnet API that boxes a HANDLE (the way it is done with socks) | ||
875 | */ | ||
876 | lsocks_pipe = (HANDLE)strtoul(env_buf, NULL, 10); | ||
877 | if ((0 == lsocks_pipe) || (INVALID_HANDLE_VALUE == lsocks_pipe)) | ||
878 | return GNUNET_NO; | ||
879 | fail = 1; | ||
880 | do | ||
881 | { | ||
882 | int ret; | ||
883 | int fail2; | ||
884 | DWORD rd; | ||
885 | |||
886 | ret = ReadFile(lsocks_pipe, &count, sizeof(count), &rd, NULL); | ||
887 | if ((0 == ret) || (sizeof(count) != rd) || (0 == count)) | ||
888 | break; | ||
889 | sctx->lsocks = | ||
890 | GNUNET_malloc(sizeof(struct GNUNET_NETWORK_Handle *) * (count + 1)); | ||
891 | |||
892 | fail2 = 1; | ||
893 | for (i = 0; i < count; i++) | ||
894 | { | ||
895 | WSAPROTOCOL_INFOA pi; | ||
896 | uint64_t size; | ||
897 | socket s; | ||
898 | |||
899 | ret = ReadFile(lsocks_pipe, &size, sizeof(size), &rd, NULL); | ||
900 | if ((0 == ret) || (sizeof(size) != rd) || (sizeof(pi) != size)) | ||
901 | break; | ||
902 | ret = ReadFile(lsocks_pipe, &pi, sizeof(pi), &rd, NULL); | ||
903 | if ((0 == ret) || (sizeof(pi) != rd)) | ||
904 | break; | ||
905 | s = WSASocketA(pi.iAddressFamily, | ||
906 | pi.iSocketType, | ||
907 | pi.iProtocol, | ||
908 | &pi, | ||
909 | 0, | ||
910 | WSA_FLAG_OVERLAPPED); | ||
911 | sctx->lsocks[i] = GNUNET_NETWORK_socket_box_native(s); | ||
912 | if (NULL == sctx->lsocks[i]) | ||
913 | break; | ||
914 | else if (i == count - 1) | ||
915 | fail2 = 0; | ||
916 | } | ||
917 | if (fail2) | ||
918 | break; | ||
919 | sctx->lsocks[count] = NULL; | ||
920 | fail = 0; | ||
921 | } | ||
922 | while (fail); | ||
923 | |||
924 | CloseHandle(lsocks_pipe); | ||
925 | |||
926 | if (fail) | ||
927 | { | ||
928 | LOG(GNUNET_ERROR_TYPE_ERROR, | ||
929 | _("Could not access a pre-bound socket, will try to bind myself\n")); | ||
930 | for (i = 0; (i < count) && (NULL != sctx->lsocks[i]); i++) | ||
931 | GNUNET_break(0 == GNUNET_NETWORK_socket_close(sctx->lsocks[i])); | ||
932 | GNUNET_free_non_null(sctx->lsocks); | ||
933 | sctx->lsocks = NULL; | ||
934 | return GNUNET_NO; | ||
935 | } | ||
936 | return GNUNET_YES; | ||
937 | } | ||
938 | #endif | ||
939 | |||
940 | |||
941 | /** | 852 | /** |
942 | * Setup addr, addrlen, idle_timeout | 853 | * Setup addr, addrlen, idle_timeout |
943 | * based on configuration! | 854 | * based on configuration! |
@@ -961,12 +872,9 @@ setup_service(struct LEGACY_SERVICE_Context *sctx) | |||
961 | { | 872 | { |
962 | struct GNUNET_TIME_Relative idleout; | 873 | struct GNUNET_TIME_Relative idleout; |
963 | int tolerant; | 874 | int tolerant; |
964 | |||
965 | #ifndef MINGW | ||
966 | const char *nfds; | 875 | const char *nfds; |
967 | unsigned int cnt; | 876 | unsigned int cnt; |
968 | int flags; | 877 | int flags; |
969 | #endif | ||
970 | 878 | ||
971 | if (GNUNET_CONFIGURATION_have_value(sctx->cfg, | 879 | if (GNUNET_CONFIGURATION_have_value(sctx->cfg, |
972 | sctx->service_name, | 880 | sctx->service_name, |
@@ -1007,7 +915,6 @@ setup_service(struct LEGACY_SERVICE_Context *sctx) | |||
1007 | else | 915 | else |
1008 | tolerant = GNUNET_NO; | 916 | tolerant = GNUNET_NO; |
1009 | 917 | ||
1010 | #ifndef MINGW | ||
1011 | errno = 0; | 918 | errno = 0; |
1012 | if ((NULL != (nfds = getenv("LISTEN_FDS"))) && | 919 | if ((NULL != (nfds = getenv("LISTEN_FDS"))) && |
1013 | (1 == sscanf(nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) && | 920 | (1 == sscanf(nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) && |
@@ -1036,13 +943,6 @@ setup_service(struct LEGACY_SERVICE_Context *sctx) | |||
1036 | } | 943 | } |
1037 | unsetenv("LISTEN_FDS"); | 944 | unsetenv("LISTEN_FDS"); |
1038 | } | 945 | } |
1039 | #else | ||
1040 | if (getenv("GNUNET_OS_READ_LSOCKS") != NULL) | ||
1041 | { | ||
1042 | receive_sockets_from_parent(sctx); | ||
1043 | putenv("GNUNET_OS_READ_LSOCKS="); | ||
1044 | } | ||
1045 | #endif | ||
1046 | 946 | ||
1047 | if ((NULL == sctx->lsocks) && | 947 | if ((NULL == sctx->lsocks) && |
1048 | (GNUNET_SYSERR == LEGACY_SERVICE_get_server_addresses(sctx->service_name, | 948 | (GNUNET_SYSERR == LEGACY_SERVICE_get_server_addresses(sctx->service_name, |
@@ -1257,7 +1157,6 @@ service_task(void *cls) | |||
1257 | static int | 1157 | static int |
1258 | detach_terminal(struct LEGACY_SERVICE_Context *sctx) | 1158 | detach_terminal(struct LEGACY_SERVICE_Context *sctx) |
1259 | { | 1159 | { |
1260 | #ifndef MINGW | ||
1261 | pid_t pid; | 1160 | pid_t pid; |
1262 | int nullfd; | 1161 | int nullfd; |
1263 | int filedes[2]; | 1162 | int filedes[2]; |
@@ -1324,11 +1223,7 @@ detach_terminal(struct LEGACY_SERVICE_Context *sctx) | |||
1324 | if (-1 == pid) | 1223 | if (-1 == pid) |
1325 | LOG_STRERROR(GNUNET_ERROR_TYPE_ERROR, "setsid"); | 1224 | LOG_STRERROR(GNUNET_ERROR_TYPE_ERROR, "setsid"); |
1326 | sctx->ready_confirm_fd = filedes[1]; | 1225 | sctx->ready_confirm_fd = filedes[1]; |
1327 | #else | 1226 | |
1328 | /* FIXME: we probably need to do something else | ||
1329 | * elsewhere in order to fork the process itself... */ | ||
1330 | FreeConsole(); | ||
1331 | #endif | ||
1332 | return GNUNET_OK; | 1227 | return GNUNET_OK; |
1333 | } | 1228 | } |
1334 | 1229 | ||
@@ -1346,7 +1241,7 @@ set_user_id(struct LEGACY_SERVICE_Context *sctx) | |||
1346 | 1241 | ||
1347 | if (NULL == (user = get_user_name(sctx))) | 1242 | if (NULL == (user = get_user_name(sctx))) |
1348 | return GNUNET_OK; /* keep */ | 1243 | return GNUNET_OK; /* keep */ |
1349 | #ifndef MINGW | 1244 | |
1350 | struct passwd *pws; | 1245 | struct passwd *pws; |
1351 | 1246 | ||
1352 | errno = 0; | 1247 | errno = 0; |
@@ -1377,7 +1272,7 @@ set_user_id(struct LEGACY_SERVICE_Context *sctx) | |||
1377 | return GNUNET_SYSERR; | 1272 | return GNUNET_SYSERR; |
1378 | } | 1273 | } |
1379 | } | 1274 | } |
1380 | #endif | 1275 | |
1381 | GNUNET_free(user); | 1276 | GNUNET_free(user); |
1382 | return GNUNET_OK; | 1277 | return GNUNET_OK; |
1383 | } | 1278 | } |