aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-helper-transport-bluetooth.c440
-rw-r--r--src/transport/gnunet-helper-transport-wlan-dummy.c2
-rw-r--r--src/transport/gnunet-helper-transport-wlan.c146
-rw-r--r--src/transport/gnunet-service-transport.c2
-rw-r--r--src/transport/gnunet-service-transport_blacklist.c14
-rw-r--r--src/transport/gnunet-service-transport_clients.c2
-rw-r--r--src/transport/gnunet-service-transport_hello.c4
-rw-r--r--src/transport/gnunet-service-transport_manipulation.c34
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c150
-rw-r--r--src/transport/gnunet-service-transport_validation.c6
-rw-r--r--src/transport/gnunet-transport-certificate-creation.c8
-rw-r--r--src/transport/gnunet-transport-wlan-receiver.c8
-rw-r--r--src/transport/gnunet-transport-wlan-sender.c18
-rw-r--r--src/transport/gnunet-transport.c8
-rw-r--r--src/transport/plugin_transport_bluetooth.c106
-rw-r--r--src/transport/plugin_transport_http.c4
-rw-r--r--src/transport/plugin_transport_http_client.c26
-rw-r--r--src/transport/plugin_transport_http_server.c14
-rw-r--r--src/transport/plugin_transport_tcp.c102
-rw-r--r--src/transport/plugin_transport_template.c2
-rw-r--r--src/transport/plugin_transport_udp.c84
-rw-r--r--src/transport/plugin_transport_unix.c92
-rw-r--r--src/transport/plugin_transport_wlan.c102
-rw-r--r--src/transport/plugin_transport_wlan.h2
-rw-r--r--src/transport/test_plugin_transport.c2
-rw-r--r--src/transport/test_transport_api_limited_sockets.c2
-rw-r--r--src/transport/test_transport_api_timeout.c4
-rw-r--r--src/transport/transport_api.c8
-rw-r--r--src/transport/transport_api_address_lookup.c8
29 files changed, 700 insertions, 700 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;
207static struct SendBuffer write_std; 207static 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 */
231typedef void (*MessageTokenizerCallback) (void *cls, 231typedef 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 */
1018static ssize_t 1018static ssize_t
1019read_from_the_socket (void *sock, 1019read_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 */
1079static int 1079static int
1080open_device (struct HardwareInfos *dev) 1080open_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
1266mac_set (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader, 1266mac_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)
1611int 1611int
1612main (int argc, char *argv[]) 1612main (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
diff --git a/src/transport/gnunet-helper-transport-wlan-dummy.c b/src/transport/gnunet-helper-transport-wlan-dummy.c
index 610b3a4c4..d07b1f8f6 100644
--- a/src/transport/gnunet-helper-transport-wlan-dummy.c
+++ b/src/transport/gnunet-helper-transport-wlan-dummy.c
@@ -238,7 +238,7 @@ main (int argc, char *argv[])
238 erg = mkfifo (FIFO_FILE1, 0666); 238 erg = mkfifo (FIFO_FILE1, 0666);
239 if ( (0 != erg) && (EEXIST != errno) ) 239 if ( (0 != erg) && (EEXIST != errno) )
240 FPRINTF (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE1, 240 FPRINTF (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE1,
241 strerror (errno)); 241 strerror (errno));
242 } 242 }
243 } 243 }
244 else 244 else
diff --git a/src/transport/gnunet-helper-transport-wlan.c b/src/transport/gnunet-helper-transport-wlan.c
index 7f472b3be..ce385b45b 100644
--- a/src/transport/gnunet-helper-transport-wlan.c
+++ b/src/transport/gnunet-helper-transport-wlan.c
@@ -140,15 +140,15 @@
140#include "plugin_transport_wlan.h" 140#include "plugin_transport_wlan.h"
141 141
142/** 142/**
143 * Packet format type for the messages we receive from 143 * Packet format type for the messages we receive from
144 * the kernel. This is for Ethernet 10Mbps format (no 144 * the kernel. This is for Ethernet 10Mbps format (no
145 * performance information included). 145 * performance information included).
146 */ 146 */
147#define ARPHRD_ETHER 1 147#define ARPHRD_ETHER 1
148 148
149 149
150/** 150/**
151 * Packet format type for the messages we receive from 151 * Packet format type for the messages we receive from
152 * the kernel. This is for plain messages (with no 152 * the kernel. This is for plain messages (with no
153 * performance information included). 153 * performance information included).
154 */ 154 */
@@ -156,13 +156,13 @@
156 156
157 157
158/** 158/**
159 * Packet format type for the messages we receive from 159 * Packet format type for the messages we receive from
160 * the kernel. This is for the PRISM format. 160 * the kernel. This is for the PRISM format.
161 */ 161 */
162#define ARPHRD_IEEE80211_PRISM 802 162#define ARPHRD_IEEE80211_PRISM 802
163 163
164/** 164/**
165 * Packet format type for the messages we receive from 165 * Packet format type for the messages we receive from
166 * the kernel. This is for messages with a 166 * the kernel. This is for messages with a
167 * 'struct Ieee80211RadiotapHeader' (see below). 167 * 'struct Ieee80211RadiotapHeader' (see below).
168 */ 168 */
@@ -195,35 +195,35 @@
195 * Drivers appear to use a 64bit counter to hold mactime internal 195 * Drivers appear to use a 64bit counter to hold mactime internal
196 * the then fill the prism header with the lower 32 bits 196 * the then fill the prism header with the lower 32 bits
197 */ 197 */
198#define PRISM_DID_MACTIME 0x2041 198#define PRISM_DID_MACTIME 0x2041
199 199
200/** 200/**
201 * Channel element 201 * Channel element
202 */ 202 */
203#define PRISM_DID_CHANNEL 0x3041 203#define PRISM_DID_CHANNEL 0x3041
204 204
205/** 205/**
206 * Signal element. Should be the signal strength in dbm, some people 206 * Signal element. Should be the signal strength in dbm, some people
207 * suggest that instead "100 - (strength in dbm)" is used (to make this 207 * suggest that instead "100 - (strength in dbm)" is used (to make this
208 * a positive integer). 208 * a positive integer).
209 */ 209 */
210#define PRISM_DID_SIGNAL 0x6041 210#define PRISM_DID_SIGNAL 0x6041
211 211
212/** 212/**
213 * Noise element 213 * Noise element
214 */ 214 */
215#define PRISM_DID_NOISE 0x7041 215#define PRISM_DID_NOISE 0x7041
216 216
217/** 217/**
218 * Rate element, in units/multiples of 500Khz 218 * Rate element, in units/multiples of 500Khz
219 */ 219 */
220#define PRISM_DID_RATE 0x8041 220#define PRISM_DID_RATE 0x8041
221 221
222 222
223/** 223/**
224 * Value is set (supplied) 224 * Value is set (supplied)
225 */ 225 */
226#define PRISM_STATUS_OK 0 226#define PRISM_STATUS_OK 0
227 227
228/** 228/**
229 * Value not supplied. 229 * Value not supplied.
@@ -240,24 +240,24 @@ struct PrismValue
240 * This has a different ID for each parameter, see 240 * This has a different ID for each parameter, see
241 * PRISM_DID_* constants. 241 * PRISM_DID_* constants.
242 */ 242 */
243 uint32_t did; 243 uint32_t did;
244 244
245 /** 245 /**
246 * See PRISM_STATUS_*-constants. Note that they are unusual: 0 = set; 1 = not set 246 * See PRISM_STATUS_*-constants. Note that they are unusual: 0 = set; 1 = not set
247 */ 247 */
248 uint16_t status; 248 uint16_t status;
249 249
250 /** 250 /**
251 * length of data (which is always a uint32_t, but presumably this can be used 251 * length of data (which is always a uint32_t, but presumably this can be used
252 * to specify that fewer bytes are used (with values in 'len' from 0-4). We 252 * to specify that fewer bytes are used (with values in 'len' from 0-4). We
253 * ignore this field. 253 * ignore this field.
254 */ 254 */
255 uint16_t len; 255 uint16_t len;
256 256
257 /** 257 /**
258 * The data value 258 * The data value
259 */ 259 */
260 uint32_t data; 260 uint32_t data;
261 261
262} __attribute__ ((packed)); 262} __attribute__ ((packed));
263 263
@@ -271,11 +271,11 @@ struct PrismHeader
271 * We expect this to be a PRISM_MSGCODE_*. 271 * We expect this to be a PRISM_MSGCODE_*.
272 */ 272 */
273 uint32_t msgcode; 273 uint32_t msgcode;
274 274
275 /** 275 /**
276 * The length of the entire header. 276 * The length of the entire header.
277 */ 277 */
278 uint32_t msglen; 278 uint32_t msglen;
279 279
280 /** 280 /**
281 * Name of the device that captured the packet. 281 * Name of the device that captured the packet.
@@ -402,7 +402,7 @@ enum RadiotapType
402 */ 402 */
403 IEEE80211_RADIOTAP_DBM_TX_POWER = 10, 403 IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
404 404
405 /** 405 /**
406 * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index 406 * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index
407 * 407 *
408 * Unitless indication of the Rx/Tx antenna for this packet. 408 * Unitless indication of the Rx/Tx antenna for this packet.
@@ -433,10 +433,10 @@ enum RadiotapType
433 */ 433 */
434 IEEE80211_RADIOTAP_RX_FLAGS = 14, 434 IEEE80211_RADIOTAP_RX_FLAGS = 14,
435 435
436 /** 436 /**
437 * IEEE80211_RADIOTAP_TX_FLAGS __le16 bitmap 437 * IEEE80211_RADIOTAP_TX_FLAGS __le16 bitmap
438 * 438 *
439 * Properties of transmitted frames. See flags defined below. 439 * Properties of transmitted frames. See flags defined below.
440 */ 440 */
441 IEEE80211_RADIOTAP_TX_FLAGS = 15, 441 IEEE80211_RADIOTAP_TX_FLAGS = 15,
442 442
@@ -462,7 +462,7 @@ enum RadiotapType
462}; 462};
463 463
464/** 464/**
465 * Bitmask indicating an extension of the bitmask is used. 465 * Bitmask indicating an extension of the bitmask is used.
466 * (Mask corresponding to IEEE80211_RADIOTAP_EXT). 466 * (Mask corresponding to IEEE80211_RADIOTAP_EXT).
467 */ 467 */
468#define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK (1 << IEEE80211_RADIOTAP_EXT) 468#define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK (1 << IEEE80211_RADIOTAP_EXT)
@@ -487,7 +487,7 @@ enum RadiotapType
487 * 487 *
488 * Frame was sent/received with short preamble 488 * Frame was sent/received with short preamble
489 */ 489 */
490#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 490#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02
491 491
492/** 492/**
493 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get 493 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get
@@ -497,7 +497,7 @@ enum RadiotapType
497 * 497 *
498 * Frame was sent/received with WEP encryption 498 * Frame was sent/received with WEP encryption
499 */ 499 */
500#define IEEE80211_RADIOTAP_F_WEP 0x04 500#define IEEE80211_RADIOTAP_F_WEP 0x04
501 501
502/** 502/**
503 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get 503 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get
@@ -507,7 +507,7 @@ enum RadiotapType
507 * 507 *
508 * Frame was sent/received with fragmentation 508 * Frame was sent/received with fragmentation
509 */ 509 */
510#define IEEE80211_RADIOTAP_F_FRAG 0x08 510#define IEEE80211_RADIOTAP_F_FRAG 0x08
511 511
512/** 512/**
513 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get 513 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get
@@ -517,7 +517,7 @@ enum RadiotapType
517 * 517 *
518 * Frame includes FCS (CRC at the end that needs to be removeD). 518 * Frame includes FCS (CRC at the end that needs to be removeD).
519 */ 519 */
520#define IEEE80211_RADIOTAP_F_FCS 0x10 520#define IEEE80211_RADIOTAP_F_FCS 0x10
521 521
522/** 522/**
523 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get 523 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get
@@ -528,32 +528,32 @@ enum RadiotapType
528 * Frame has padding between 802.11 header and payload 528 * Frame has padding between 802.11 header and payload
529 * (to 32-bit boundary) 529 * (to 32-bit boundary)
530 */ 530 */
531#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 531#define IEEE80211_RADIOTAP_F_DATAPAD 0x20
532 532
533 533
534/** 534/**
535 * For IEEE80211_RADIOTAP_RX_FLAGS: 535 * For IEEE80211_RADIOTAP_RX_FLAGS:
536 * frame failed crc check 536 * frame failed crc check
537 */ 537 */
538#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 538#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001
539 539
540/** 540/**
541 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): 541 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'):
542 * failed due to excessive retries 542 * failed due to excessive retries
543 */ 543 */
544#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 544#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001
545 545
546/** 546/**
547 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): 547 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'):
548 * used cts 'protection' 548 * used cts 'protection'
549 */ 549 */
550#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 550#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002
551 551
552/** 552/**
553 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): 553 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'):
554 * used rts/cts handshake 554 * used rts/cts handshake
555 */ 555 */
556#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 556#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004
557 557
558/** 558/**
559 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): 559 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'):
@@ -563,7 +563,7 @@ enum RadiotapType
563 563
564/** 564/**
565 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): 565 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'):
566 * sequence number handled by userspace 566 * sequence number handled by userspace
567 */ 567 */
568#define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010 568#define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010
569 569
@@ -591,7 +591,7 @@ struct Ieee80211RadiotapHeader
591 uint8_t it_version; 591 uint8_t it_version;
592 592
593 /** 593 /**
594 * Padding. Set to 0. 594 * Padding. Set to 0.
595 */ 595 */
596 uint8_t it_pad; 596 uint8_t it_pad;
597 597
@@ -611,7 +611,7 @@ struct Ieee80211RadiotapHeader
611 611
612 612
613/** 613/**
614 * Format of the header we need to prepend to messages to be sent to the 614 * Format of the header we need to prepend to messages to be sent to the
615 * Kernel. 615 * Kernel.
616 */ 616 */
617struct RadiotapTransmissionHeader 617struct RadiotapTransmissionHeader
@@ -752,7 +752,7 @@ struct SendBuffer
752 * destination? Always smaller than 'size'. 752 * destination? Always smaller than 'size'.
753 */ 753 */
754 size_t pos; 754 size_t pos;
755 755
756 /** 756 /**
757 * Buffered data; twice the maximum allowed message size as we add some 757 * Buffered data; twice the maximum allowed message size as we add some
758 * headers. 758 * headers.
@@ -794,7 +794,7 @@ static struct SendBuffer write_std;
794 * @param cls closure 794 * @param cls closure
795 * @param message the actual message 795 * @param message the actual message
796 */ 796 */
797typedef void (*MessageTokenizerCallback) (void *cls, 797typedef void (*MessageTokenizerCallback) (void *cls,
798 const struct 798 const struct
799 GNUNET_MessageHeader * 799 GNUNET_MessageHeader *
800 message); 800 message);
@@ -1059,7 +1059,7 @@ mst_destroy (struct MessageStreamTokenizer *mst)
1059 */ 1059 */
1060static int 1060static int
1061ieee80211_radiotap_iterator_init (struct Ieee80211RadiotapHeaderIterator *iterator, 1061ieee80211_radiotap_iterator_init (struct Ieee80211RadiotapHeaderIterator *iterator,
1062 const struct Ieee80211RadiotapHeader *radiotap_header, 1062 const struct Ieee80211RadiotapHeader *radiotap_header,
1063 size_t max_length) 1063 size_t max_length)
1064{ 1064{
1065 if ( (iterator == NULL) || 1065 if ( (iterator == NULL) ||
@@ -1204,26 +1204,26 @@ ieee80211_radiotap_iterator_next (struct Ieee80211RadiotapHeaderIterator *iterat
1204 /* need padding (by 'wanted_alignment - unalignment') */ 1204 /* need padding (by 'wanted_alignment - unalignment') */
1205 iterator->arg_index += wanted_alignment - unalignment; 1205 iterator->arg_index += wanted_alignment - unalignment;
1206 } 1206 }
1207 1207
1208 /* 1208 /*
1209 * this is what we will return to user, but we need to 1209 * this is what we will return to user, but we need to
1210 * move on first so next call has something fresh to test 1210 * move on first so next call has something fresh to test
1211 */ 1211 */
1212 iterator->this_arg_index = iterator->arg_index; 1212 iterator->this_arg_index = iterator->arg_index;
1213 iterator->this_arg = iterator->arg; 1213 iterator->this_arg = iterator->arg;
1214 1214
1215 /* internally move on the size of this arg (using lower nybble from 1215 /* internally move on the size of this arg (using lower nybble from
1216 the table) */ 1216 the table) */
1217 iterator->arg += rt_sizes[iterator->arg_index] & 0x0f; 1217 iterator->arg += rt_sizes[iterator->arg_index] & 0x0f;
1218 1218
1219 /* 1219 /*
1220 * check for insanity where we are given a bitmap that 1220 * check for insanity where we are given a bitmap that
1221 * claims to have more arg content than the length of the 1221 * claims to have more arg content than the length of the
1222 * radiotap section. We will normally end up equalling this 1222 * radiotap section. We will normally end up equalling this
1223 * max_length on the last arg, never exceeding it. 1223 * max_length on the last arg, never exceeding it.
1224 */ 1224 */
1225 if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) > iterator->max_length) 1225 if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) > iterator->max_length)
1226 return -1; 1226 return -1;
1227 } 1227 }
1228 1228
1229 /* Now, move on to next bit / next entry */ 1229 /* Now, move on to next bit / next entry */
@@ -1245,7 +1245,7 @@ ieee80211_radiotap_iterator_next (struct Ieee80211RadiotapHeaderIterator *iterat
1245 } 1245 }
1246 } 1246 }
1247 else 1247 else
1248 { 1248 {
1249 /* just try the next bit (while loop will move on) */ 1249 /* just try the next bit (while loop will move on) */
1250 iterator->bitmap_shifter >>= 1; 1250 iterator->bitmap_shifter >>= 1;
1251 } 1251 }
@@ -1364,7 +1364,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len)
1364 if (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] && 1364 if (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] &&
1365 ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]) 1365 ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3])
1366 return 0; 1366 return 0;
1367 return 1; 1367 return 1;
1368} 1368}
1369 1369
1370 1370
@@ -1431,7 +1431,7 @@ linux_get_channel (const struct HardwareInfos *dev)
1431 * @return number of bytes written to 'buf' 1431 * @return number of bytes written to 'buf'
1432 */ 1432 */
1433static ssize_t 1433static ssize_t
1434linux_read (struct HardwareInfos *dev, 1434linux_read (struct HardwareInfos *dev,
1435 unsigned char *buf, size_t buf_size, 1435 unsigned char *buf, size_t buf_size,
1436 struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *ri) 1436 struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *ri)
1437{ 1437{
@@ -1452,7 +1452,7 @@ linux_read (struct HardwareInfos *dev,
1452 return -1; 1452 return -1;
1453 } 1453 }
1454 1454
1455 memset (ri, 0, sizeof (*ri)); 1455 memset (ri, 0, sizeof (*ri));
1456 switch (dev->arptype_in) 1456 switch (dev->arptype_in)
1457 { 1457 {
1458 case ARPHRD_IEEE80211_PRISM: 1458 case ARPHRD_IEEE80211_PRISM:
@@ -1511,7 +1511,7 @@ linux_read (struct HardwareInfos *dev,
1511 break; 1511 break;
1512 } 1512 }
1513 } 1513 }
1514 } 1514 }
1515 if ( (n < 8) || (n >= caplen) ) 1515 if ( (n < 8) || (n >= caplen) )
1516 return 0; /* invalid format */ 1516 return 0; /* invalid format */
1517 } 1517 }
@@ -1540,7 +1540,7 @@ linux_read (struct HardwareInfos *dev,
1540 if (!got_signal) 1540 if (!got_signal)
1541 { 1541 {
1542 ri->ri_power = * ((int8_t*) iterator.this_arg); 1542 ri->ri_power = * ((int8_t*) iterator.this_arg);
1543 got_signal = 1; 1543 got_signal = 1;
1544 } 1544 }
1545 break; 1545 break;
1546 case IEEE80211_RADIOTAP_DB_ANTSIGNAL: 1546 case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
@@ -1594,7 +1594,7 @@ linux_read (struct HardwareInfos *dev,
1594 break; 1594 break;
1595 } /* end of 'switch' */ 1595 } /* end of 'switch' */
1596 } /* end of the 'while' loop */ 1596 } /* end of the 'while' loop */
1597 } 1597 }
1598 break; 1598 break;
1599 case ARPHRD_IEEE80211: 1599 case ARPHRD_IEEE80211:
1600 n = 0; /* no header */ 1600 n = 0; /* no header */
@@ -1607,7 +1607,7 @@ linux_read (struct HardwareInfos *dev,
1607 tmpbuf + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame), 1607 tmpbuf + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame),
1608 caplen - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) - 4 /* 4 byte FCS */); 1608 caplen - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) - 4 /* 4 byte FCS */);
1609 return caplen - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) - 4; 1609 return caplen - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) - 4;
1610 } 1610 }
1611 default: 1611 default:
1612 errno = ENOTSUP; /* unsupported format */ 1612 errno = ENOTSUP; /* unsupported format */
1613 return -1; 1613 return -1;
@@ -1617,8 +1617,8 @@ linux_read (struct HardwareInfos *dev,
1617 ri->ri_channel = linux_get_channel (dev); 1617 ri->ri_channel = linux_get_channel (dev);
1618 1618
1619 /* detect CRC32 at the end, even if the flag wasn't set and remove it */ 1619 /* detect CRC32 at the end, even if the flag wasn't set and remove it */
1620 if ( (0 == fcs_removed) && 1620 if ( (0 == fcs_removed) &&
1621 (0 == check_crc_buf_osdep (tmpbuf + n, caplen - sizeof (uint32_t))) ) 1621 (0 == check_crc_buf_osdep (tmpbuf + n, caplen - sizeof (uint32_t))) )
1622 { 1622 {
1623 /* NOTE: this heuristic can of course fail if there happens to 1623 /* NOTE: this heuristic can of course fail if there happens to
1624 be a matching checksum at the end. Would be good to have 1624 be a matching checksum at the end. Would be good to have
@@ -1751,9 +1751,9 @@ open_device_raw (struct HardwareInfos *dev)
1751 setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr, 1751 setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr,
1752 sizeof (mr))) 1752 sizeof (mr)))
1753 { 1753 {
1754 fprintf (stderr, 1754 fprintf (stderr,
1755 "Failed to enable promiscuous mode on interface `%.*s'\n", 1755 "Failed to enable promiscuous mode on interface `%.*s'\n",
1756 IFNAMSIZ, 1756 IFNAMSIZ,
1757 dev->iface); 1757 dev->iface);
1758 return 1; 1758 return 1;
1759 } 1759 }
@@ -1775,13 +1775,13 @@ test_wlan_interface (const char *iface)
1775 struct stat sbuf; 1775 struct stat sbuf;
1776 int ret; 1776 int ret;
1777 1777
1778 ret = snprintf (strbuf, sizeof (strbuf), 1778 ret = snprintf (strbuf, sizeof (strbuf),
1779 "/sys/class/net/%s/phy80211/subsystem", 1779 "/sys/class/net/%s/phy80211/subsystem",
1780 iface); 1780 iface);
1781 if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf))) 1781 if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf)))
1782 { 1782 {
1783 fprintf (stderr, 1783 fprintf (stderr,
1784 "Did not find 802.11 interface `%s'. Exiting.\n", 1784 "Did not find 802.11 interface `%s'. Exiting.\n",
1785 iface); 1785 iface);
1786 exit (1); 1786 exit (1);
1787 } 1787 }
@@ -1852,7 +1852,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr)
1852 sendsize = ntohs (hdr->size); 1852 sendsize = ntohs (hdr->size);
1853 if ( (sendsize < 1853 if ( (sendsize <
1854 sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage)) || 1854 sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage)) ||
1855 (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) ) 1855 (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) )
1856 { 1856 {
1857 fprintf (stderr, "Received malformed message\n"); 1857 fprintf (stderr, "Received malformed message\n");
1858 exit (1); 1858 exit (1);
@@ -1870,10 +1870,10 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr)
1870 case ARPHRD_IEEE80211_FULL: 1870 case ARPHRD_IEEE80211_FULL:
1871 case ARPHRD_IEEE80211: 1871 case ARPHRD_IEEE80211:
1872 rtheader.header.it_version = 0; 1872 rtheader.header.it_version = 0;
1873 rtheader.header.it_pad = 0; 1873 rtheader.header.it_pad = 0;
1874 rtheader.header.it_len = GNUNET_htole16 (sizeof (rtheader)); 1874 rtheader.header.it_len = GNUNET_htole16 (sizeof (rtheader));
1875 rtheader.header.it_present = GNUNET_htole16 (IEEE80211_RADIOTAP_OUR_TRANSMISSION_HEADER_MASK); 1875 rtheader.header.it_present = GNUNET_htole16 (IEEE80211_RADIOTAP_OUR_TRANSMISSION_HEADER_MASK);
1876 rtheader.rate = header->rate; 1876 rtheader.rate = header->rate;
1877 rtheader.pad1 = 0; 1877 rtheader.pad1 = 0;
1878 rtheader.txflags = GNUNET_htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ); 1878 rtheader.txflags = GNUNET_htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ);
1879 memcpy (write_pout.buf, &rtheader, sizeof (rtheader)); 1879 memcpy (write_pout.buf, &rtheader, sizeof (rtheader));
@@ -1934,7 +1934,7 @@ main (int argc, char *argv[])
1934 return 254; 1934 return 254;
1935 } 1935 }
1936#else 1936#else
1937 if (0 != seteuid (0)) 1937 if (0 != seteuid (0))
1938 { 1938 {
1939 fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno)); 1939 fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno));
1940 return 254; 1940 return 254;
@@ -2012,9 +2012,9 @@ main (int argc, char *argv[])
2012 memcpy (&macmsg.mac, &dev.pl_mac, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); 2012 memcpy (&macmsg.mac, &dev.pl_mac, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
2013 memcpy (write_std.buf, &macmsg, sizeof (macmsg)); 2013 memcpy (write_std.buf, &macmsg, sizeof (macmsg));
2014 write_std.size = sizeof (macmsg); 2014 write_std.size = sizeof (macmsg);
2015 } 2015 }
2016 2016
2017 stdin_mst = mst_create (&stdin_send_hw, &dev); 2017 stdin_mst = mst_create (&stdin_send_hw, &dev);
2018 stdin_open = 1; 2018 stdin_open = 1;
2019 while (1) 2019 while (1)
2020 { 2020 {
@@ -2071,7 +2071,7 @@ main (int argc, char *argv[])
2071 if (FD_ISSET (dev.fd_raw, &wfds)) 2071 if (FD_ISSET (dev.fd_raw, &wfds))
2072 { 2072 {
2073 ssize_t ret = 2073 ssize_t ret =
2074 write (dev.fd_raw, write_pout.buf + write_std.pos, 2074 write (dev.fd_raw, write_pout.buf + write_std.pos,
2075 write_pout.size - write_pout.pos); 2075 write_pout.size - write_pout.pos);
2076 if (0 > ret) 2076 if (0 > ret)
2077 { 2077 {
@@ -2097,7 +2097,7 @@ main (int argc, char *argv[])
2097 2097
2098 if (FD_ISSET (STDIN_FILENO, &rfds)) 2098 if (FD_ISSET (STDIN_FILENO, &rfds))
2099 { 2099 {
2100 ssize_t ret = 2100 ssize_t ret =
2101 read (STDIN_FILENO, readbuf, sizeof (readbuf)); 2101 read (STDIN_FILENO, readbuf, sizeof (readbuf));
2102 if (0 > ret) 2102 if (0 > ret)
2103 { 2103 {
@@ -2120,9 +2120,9 @@ main (int argc, char *argv[])
2120 rrm = (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) write_std.buf; 2120 rrm = (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) write_std.buf;
2121 ret = 2121 ret =
2122 linux_read (&dev, (unsigned char *) &rrm->frame, 2122 linux_read (&dev, (unsigned char *) &rrm->frame,
2123 sizeof (write_std.buf) 2123 sizeof (write_std.buf)
2124 - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) 2124 - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)
2125 + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame), 2125 + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame),
2126 rrm); 2126 rrm);
2127 if (0 > ret) 2127 if (0 > ret)
2128 { 2128 {
@@ -2131,8 +2131,8 @@ main (int argc, char *argv[])
2131 } 2131 }
2132 if ((0 < ret) && (0 == mac_test (&rrm->frame, &dev))) 2132 if ((0 < ret) && (0 == mac_test (&rrm->frame, &dev)))
2133 { 2133 {
2134 write_std.size = ret 2134 write_std.size = ret
2135 + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) 2135 + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)
2136 - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame); 2136 - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame);
2137 rrm->header.size = htons (write_std.size); 2137 rrm->header.size = htons (write_std.size);
2138 rrm->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER); 2138 rrm->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER);
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 3adf5b35d..ba88d71f4 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -281,7 +281,7 @@ GST_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
281end: 281end:
282 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 282 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
283 "Allowing receive from peer %s to continue in %s\n", 283 "Allowing receive from peer %s to continue in %s\n",
284 GNUNET_i2s (peer), 284 GNUNET_i2s (peer),
285 GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES)); 285 GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES));
286 return ret; 286 return ret;
287} 287}
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c
index 628943a42..8f45a19b8 100644
--- a/src/transport/gnunet-service-transport_blacklist.c
+++ b/src/transport/gnunet-service-transport_blacklist.c
@@ -244,7 +244,7 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client)
244 * @param option name of the option 244 * @param option name of the option
245 * @param value value of the option 245 * @param value value of the option
246 */ 246 */
247static void 247static void
248blacklist_cfg_iter (void *cls, const char *section, 248blacklist_cfg_iter (void *cls, const char *section,
249 const char *option, 249 const char *option,
250 const char *value) 250 const char *value)
@@ -255,10 +255,10 @@ blacklist_cfg_iter (void *cls, const char *section,
255 char *pos; 255 char *pos;
256 256
257 if (GNUNET_OK != GNUNET_CRYPTO_ecc_public_sign_key_from_string (option, 257 if (GNUNET_OK != GNUNET_CRYPTO_ecc_public_sign_key_from_string (option,
258 strlen (option), 258 strlen (option),
259 &peer.public_key)) 259 &peer.public_key))
260 return; 260 return;
261 261
262 if ((NULL == value) || (0 == strcmp(value, ""))) 262 if ((NULL == value) || (0 == strcmp(value, "")))
263 { 263 {
264 /* Blacklist whole peer */ 264 /* Blacklist whole peer */
@@ -295,9 +295,9 @@ read_blacklist_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg,
295 char cfg_sect[512]; 295 char cfg_sect[512];
296 unsigned int res = 0; 296 unsigned int res = 0;
297 297
298 GNUNET_snprintf (cfg_sect, 298 GNUNET_snprintf (cfg_sect,
299 sizeof (cfg_sect), 299 sizeof (cfg_sect),
300 "transport-blacklist-%s", 300 "transport-blacklist-%s",
301 GNUNET_i2s_full (my_id)); 301 GNUNET_i2s_full (my_id));
302 GNUNET_CONFIGURATION_iterate_section_values (cfg, cfg_sect, &blacklist_cfg_iter, &res); 302 GNUNET_CONFIGURATION_iterate_section_values (cfg, cfg_sect, &blacklist_cfg_iter, &res);
303 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 303 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -636,7 +636,7 @@ GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer,
636 blacklist = 636 blacklist =
637 GNUNET_CONTAINER_multipeermap_create (TRANSPORT_BLACKLIST_HT_SIZE, 637 GNUNET_CONTAINER_multipeermap_create (TRANSPORT_BLACKLIST_HT_SIZE,
638 GNUNET_NO); 638 GNUNET_NO);
639 639
640 GNUNET_CONTAINER_multipeermap_put (blacklist, peer, 640 GNUNET_CONTAINER_multipeermap_put (blacklist, peer,
641 transport, 641 transport,
642 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 642 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
@@ -653,7 +653,7 @@ GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer,
653 * @return #GNUNET_OK if the entry does not match, #GNUNET_NO if it matches 653 * @return #GNUNET_OK if the entry does not match, #GNUNET_NO if it matches
654 */ 654 */
655static int 655static int
656test_blacklisted (void *cls, 656test_blacklisted (void *cls,
657 const struct GNUNET_PeerIdentity *key, 657 const struct GNUNET_PeerIdentity *key,
658 void *value) 658 void *value)
659{ 659{
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index 5817bd2c2..b3f108675 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -978,7 +978,7 @@ clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client,
978 setup_monitoring_client (client, &msg->peer); 978 setup_monitoring_client (client, &msg->peer);
979 else 979 else
980 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, 980 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
981 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); 981 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE);
982 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); 982 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
983} 983}
984 984
diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c
index 0347d67a5..a53e26f95 100644
--- a/src/transport/gnunet-service-transport_hello.c
+++ b/src/transport/gnunet-service-transport_hello.c
@@ -171,7 +171,7 @@ refresh_hello_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
171 friend_only = GNUNET_HELLO_is_friend_only (our_hello); 171 friend_only = GNUNET_HELLO_is_friend_only (our_hello);
172 GNUNET_free (our_hello); 172 GNUNET_free (our_hello);
173 our_hello = GNUNET_HELLO_create (&GST_my_identity.public_key, 173 our_hello = GNUNET_HELLO_create (&GST_my_identity.public_key,
174 &address_generator, 174 &address_generator,
175 &gc, friend_only); 175 &gc, friend_only);
176 GNUNET_assert (NULL != our_hello); 176 GNUNET_assert (NULL != our_hello);
177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -215,7 +215,7 @@ GST_hello_start (int friend_only, GST_HelloCallback cb, void *cb_cls)
215{ 215{
216 hello_cb = cb; 216 hello_cb = cb;
217 hello_cb_cls = cb_cls; 217 hello_cb_cls = cb_cls;
218 our_hello = GNUNET_HELLO_create (&GST_my_identity.public_key, 218 our_hello = GNUNET_HELLO_create (&GST_my_identity.public_key,
219 NULL, NULL, friend_only); 219 NULL, NULL, friend_only);
220 GNUNET_assert (NULL != our_hello); 220 GNUNET_assert (NULL != our_hello);
221 refresh_hello (); 221 refresh_hello ();
diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c
index 7762d1811..1b708cb70 100644
--- a/src/transport/gnunet-service-transport_manipulation.c
+++ b/src/transport/gnunet-service-transport_manipulation.c
@@ -336,7 +336,7 @@ GST_manipulation_set_metric (void *cls, struct GNUNET_SERVER_Client *client,
336 tmp->metrics[c][c2] = UINT32_MAX; 336 tmp->metrics[c][c2] = UINT32_MAX;
337 } 337 }
338 } 338 }
339 GNUNET_CONTAINER_multipeermap_put (man_handle.peers, 339 GNUNET_CONTAINER_multipeermap_put (man_handle.peers,
340 &tm->peer, tmp, 340 &tm->peer, tmp,
341 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 341 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
342 } 342 }
@@ -581,64 +581,64 @@ GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg)
581{ 581{
582 unsigned long long tmp; 582 unsigned long long tmp;
583 struct GNUNET_TIME_Relative delay; 583 struct GNUNET_TIME_Relative delay;
584 584
585 if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg, 585 if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg,
586 "transport", 586 "transport",
587 "MANIPULATE_DISTANCE_IN", 587 "MANIPULATE_DISTANCE_IN",
588 &tmp)) && 588 &tmp)) &&
589 (tmp > 0) ) 589 (tmp > 0) )
590 { 590 {
591 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 591 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
592 "Setting inbound distance_in to %llu\n", 592 "Setting inbound distance_in to %llu\n",
593 (unsigned long long) tmp); 593 (unsigned long long) tmp);
594 set_metric (&man_handle.general, TM_RECEIVE, GNUNET_ATS_QUALITY_NET_DISTANCE, tmp); 594 set_metric (&man_handle.general, TM_RECEIVE, GNUNET_ATS_QUALITY_NET_DISTANCE, tmp);
595 } 595 }
596 596
597 if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg, 597 if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg,
598 "transport", 598 "transport",
599 "MANIPULATE_DISTANCE_OUT", 599 "MANIPULATE_DISTANCE_OUT",
600 &tmp)) && 600 &tmp)) &&
601 (tmp > 0) ) 601 (tmp > 0) )
602 { 602 {
603 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 603 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
604 "Setting outbound distance_in to %llu\n", 604 "Setting outbound distance_in to %llu\n",
605 (unsigned long long) tmp); 605 (unsigned long long) tmp);
606 set_metric (&man_handle.general, TM_SEND, 606 set_metric (&man_handle.general, TM_SEND,
607 GNUNET_ATS_QUALITY_NET_DISTANCE, tmp); 607 GNUNET_ATS_QUALITY_NET_DISTANCE, tmp);
608 } 608 }
609 609
610 if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (GST_cfg, 610 if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (GST_cfg,
611 "transport", 611 "transport",
612 "MANIPULATE_DELAY_IN", 612 "MANIPULATE_DELAY_IN",
613 &delay)) && 613 &delay)) &&
614 (delay.rel_value_us > 0) ) 614 (delay.rel_value_us > 0) )
615 { 615 {
616 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 616 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
617 "Delaying inbound traffic for %s\n", 617 "Delaying inbound traffic for %s\n",
618 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); 618 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
619 set_metric (&man_handle.general, TM_RECEIVE, 619 set_metric (&man_handle.general, TM_RECEIVE,
620 GNUNET_ATS_QUALITY_NET_DELAY, 620 GNUNET_ATS_QUALITY_NET_DELAY,
621 delay.rel_value_us); 621 delay.rel_value_us);
622 } 622 }
623 if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (GST_cfg, 623 if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (GST_cfg,
624 "transport", 624 "transport",
625 "MANIPULATE_DELAY_OUT", 625 "MANIPULATE_DELAY_OUT",
626 &delay)) && 626 &delay)) &&
627 (delay.rel_value_us > 0) ) 627 (delay.rel_value_us > 0) )
628 { 628 {
629 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 629 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
630 "Delaying outbound traffic for %s\n", 630 "Delaying outbound traffic for %s\n",
631 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); 631 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
632 set_metric (&man_handle.general, 632 set_metric (&man_handle.general,
633 TM_SEND, 633 TM_SEND,
634 GNUNET_ATS_QUALITY_NET_DELAY, 634 GNUNET_ATS_QUALITY_NET_DELAY,
635 delay.rel_value_us); 635 delay.rel_value_us);
636 } 636 }
637 man_handle.peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); 637 man_handle.peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
638} 638}
639 639
640 640
641static int 641static int
642free_tmps (void *cls, 642free_tmps (void *cls,
643 const struct GNUNET_PeerIdentity *key, 643 const struct GNUNET_PeerIdentity *key,
644 void *value) 644 void *value)
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 90f45f126..0cffe0aeb 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -79,7 +79,7 @@
79#define SETUP_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) 79#define SETUP_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
80 80
81/** 81/**
82 * How long are we willing to wait for a successful reconnect if 82 * How long are we willing to wait for a successful reconnect if
83 * an existing connection went down? Much shorter than the 83 * an existing connection went down? Much shorter than the
84 * usual SETUP_CONNECTION_TIMEOUT as we do not inform the 84 * usual SETUP_CONNECTION_TIMEOUT as we do not inform the
85 * higher layers about the disconnect during this period. 85 * higher layers about the disconnect during this period.
@@ -271,7 +271,7 @@ GNUNET_NETWORK_STRUCT_BEGIN
271 * setup a connection/session for data exchange. A 'SESSION_CONNECT' 271 * setup a connection/session for data exchange. A 'SESSION_CONNECT'
272 * should be answered with a 'SESSION_CONNECT_ACK' with the same body 272 * should be answered with a 'SESSION_CONNECT_ACK' with the same body
273 * to confirm. A 'SESSION_CONNECT_ACK' should then be followed with 273 * to confirm. A 'SESSION_CONNECT_ACK' should then be followed with
274 * a 'SESSION_ACK'. Once the 'SESSION_ACK' is received, both peers 274 * a 'SESSION_ACK'. Once the 'SESSION_ACK' is received, both peers
275 * should be connected. 275 * should be connected.
276 */ 276 */
277struct SessionConnectMessage 277struct SessionConnectMessage
@@ -298,7 +298,7 @@ struct SessionConnectMessage
298 298
299/** 299/**
300 * Message we send to the other peer to notify him that we intentionally 300 * Message we send to the other peer to notify him that we intentionally
301 * are disconnecting (to reduce timeouts). This is just a friendly 301 * are disconnecting (to reduce timeouts). This is just a friendly
302 * notification, peers must not rely on always receiving disconnect 302 * notification, peers must not rely on always receiving disconnect
303 * messages. 303 * messages.
304 */ 304 */
@@ -448,8 +448,8 @@ struct MessageQueue
448 * and set the 'send_connect_ack' to 2. If we then receive a 448 * and set the 'send_connect_ack' to 2. If we then receive a
449 * 'SESSION_ACK', we go to 'S_CONNECTED' (and reset 'send_connect_ack' 449 * 'SESSION_ACK', we go to 'S_CONNECTED' (and reset 'send_connect_ack'
450 * to 0). 450 * to 0).
451 * 451 *
452 */ 452 */
453enum State 453enum State
454{ 454{
455 /** 455 /**
@@ -525,7 +525,7 @@ enum State
525 */ 525 */
526 S_CONNECTED_SWITCHING_BLACKLIST, 526 S_CONNECTED_SWITCHING_BLACKLIST,
527 527
528 /** 528 /**
529 * We have some primary connection, but ATS suggested we switch 529 * We have some primary connection, but ATS suggested we switch
530 * to some alternative; we now sent a CONNECT message for the 530 * to some alternative; we now sent a CONNECT message for the
531 * alternative session to the other peer and waiting for a 531 * alternative session to the other peer and waiting for a
@@ -589,7 +589,7 @@ struct NeighbourAddress
589 * Did we tell ATS that this is our 'active' address? 589 * Did we tell ATS that this is our 'active' address?
590 */ 590 */
591 int ats_active; 591 int ats_active;
592 592
593}; 593};
594 594
595 595
@@ -644,7 +644,7 @@ struct NeighbourMapEntry
644 struct GNUNET_TIME_Absolute keep_alive_time; 644 struct GNUNET_TIME_Absolute keep_alive_time;
645 645
646 /** 646 /**
647 * At what time did we sent the last keep-alive message? Used 647 * At what time did we sent the last keep-alive message? Used
648 * to calculate round-trip time ("latency"). 648 * to calculate round-trip time ("latency").
649 */ 649 */
650 struct GNUNET_TIME_Absolute last_keep_alive_time; 650 struct GNUNET_TIME_Absolute last_keep_alive_time;
@@ -713,7 +713,7 @@ struct NeighbourMapEntry
713 */ 713 */
714struct BlackListCheckContext 714struct BlackListCheckContext
715{ 715{
716 716
717 /** 717 /**
718 * We keep blacklist checks in a DLL. 718 * We keep blacklist checks in a DLL.
719 */ 719 */
@@ -954,7 +954,7 @@ set_address (struct NeighbourAddress *na,
954 int is_active) 954 int is_active)
955{ 955{
956 struct GNUNET_TRANSPORT_PluginFunctions *papi; 956 struct GNUNET_TRANSPORT_PluginFunctions *papi;
957 if (NULL == (papi = GST_plugins_find (address->transport_name))) 957 if (NULL == (papi = GST_plugins_find (address->transport_name)))
958 { 958 {
959 GNUNET_break (0); 959 GNUNET_break (0);
960 return; 960 return;
@@ -976,17 +976,17 @@ set_address (struct NeighbourAddress *na,
976 /* FIXME: is this the right place to set quotas? */ 976 /* FIXME: is this the right place to set quotas? */
977 GST_neighbours_set_incoming_quota (&address->peer, bandwidth_in); 977 GST_neighbours_set_incoming_quota (&address->peer, bandwidth_in);
978 send_outbound_quota (&address->peer, bandwidth_out); 978 send_outbound_quota (&address->peer, bandwidth_out);
979 } 979 }
980 return; 980 return;
981 } 981 }
982 free_address (na); 982 free_address (na);
983 if (NULL == session) 983 if (NULL == session)
984 session = papi->get_session (papi->cls, address); 984 session = papi->get_session (papi->cls, address);
985 if (NULL == session) 985 if (NULL == session)
986 { 986 {
987 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 987 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
988 "Failed to obtain new session for peer `%s' and address '%s'\n", 988 "Failed to obtain new session for peer `%s' and address '%s'\n",
989 GNUNET_i2s (&address->peer), GST_plugins_a2s (address)); 989 GNUNET_i2s (&address->peer), GST_plugins_a2s (address));
990 GNUNET_ATS_address_destroyed (GST_ats, address, NULL); 990 GNUNET_ATS_address_destroyed (GST_ats, address, NULL);
991 return; 991 return;
992 } 992 }
@@ -1037,8 +1037,8 @@ free_neighbour (struct NeighbourMapEntry *n, int keep_sessions)
1037 least internally we need to get clean... */ 1037 least internally we need to get clean... */
1038 if (GNUNET_YES == test_connected (n)) 1038 if (GNUNET_YES == test_connected (n))
1039 { 1039 {
1040 GNUNET_STATISTICS_set (GST_stats, 1040 GNUNET_STATISTICS_set (GST_stats,
1041 gettext_noop ("# peers connected"), 1041 gettext_noop ("# peers connected"),
1042 --neighbours_connected, 1042 --neighbours_connected,
1043 GNUNET_NO); 1043 GNUNET_NO);
1044 disconnect_notify_cb (callback_cls, &n->id); 1044 disconnect_notify_cb (callback_cls, &n->id);
@@ -1226,7 +1226,7 @@ send_disconnect (struct NeighbourMapEntry *n)
1226static void 1226static void
1227disconnect_neighbour (struct NeighbourMapEntry *n) 1227disconnect_neighbour (struct NeighbourMapEntry *n)
1228{ 1228{
1229 /* depending on state, notify neighbour and/or upper layers of this peer 1229 /* depending on state, notify neighbour and/or upper layers of this peer
1230 about disconnect */ 1230 about disconnect */
1231 switch (n->state) 1231 switch (n->state)
1232 { 1232 {
@@ -1238,7 +1238,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
1238 free_neighbour (n, GNUNET_NO); 1238 free_neighbour (n, GNUNET_NO);
1239 return; 1239 return;
1240 case S_CONNECT_SENT: 1240 case S_CONNECT_SENT:
1241 send_disconnect (n); 1241 send_disconnect (n);
1242 n->state = S_DISCONNECT; 1242 n->state = S_DISCONNECT;
1243 break; 1243 break;
1244 case S_CONNECT_RECV_BLACKLIST_INBOUND: 1244 case S_CONNECT_RECV_BLACKLIST_INBOUND:
@@ -1250,9 +1250,9 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
1250 return; 1250 return;
1251 case S_CONNECT_RECV_ACK: 1251 case S_CONNECT_RECV_ACK:
1252 /* we DID ACK the other peer's request, must send DISCONNECT */ 1252 /* we DID ACK the other peer's request, must send DISCONNECT */
1253 send_disconnect (n); 1253 send_disconnect (n);
1254 n->state = S_DISCONNECT; 1254 n->state = S_DISCONNECT;
1255 break; 1255 break;
1256 case S_CONNECTED: 1256 case S_CONNECTED:
1257 case S_RECONNECT_BLACKLIST: 1257 case S_RECONNECT_BLACKLIST:
1258 case S_RECONNECT_SENT: 1258 case S_RECONNECT_SENT:
@@ -1261,8 +1261,8 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
1261 /* we are currently connected, need to send disconnect and do 1261 /* we are currently connected, need to send disconnect and do
1262 internal notifications and update statistics */ 1262 internal notifications and update statistics */
1263 send_disconnect (n); 1263 send_disconnect (n);
1264 GNUNET_STATISTICS_set (GST_stats, 1264 GNUNET_STATISTICS_set (GST_stats,
1265 gettext_noop ("# peers connected"), 1265 gettext_noop ("# peers connected"),
1266 --neighbours_connected, 1266 --neighbours_connected,
1267 GNUNET_NO); 1267 GNUNET_NO);
1268 disconnect_notify_cb (callback_cls, &n->id); 1268 disconnect_notify_cb (callback_cls, &n->id);
@@ -1326,7 +1326,7 @@ transmit_send_continuation (void *cls,
1326 n->is_active = NULL; 1326 n->is_active = NULL;
1327 if (GNUNET_SCHEDULER_NO_TASK != n->task) 1327 if (GNUNET_SCHEDULER_NO_TASK != n->task)
1328 GNUNET_SCHEDULER_cancel (n->task); 1328 GNUNET_SCHEDULER_cancel (n->task);
1329 n->task = GNUNET_SCHEDULER_add_now (&master_task, n); 1329 n->task = GNUNET_SCHEDULER_add_now (&master_task, n);
1330 } 1330 }
1331 if (bytes_in_send_queue < mq->message_buf_size) 1331 if (bytes_in_send_queue < mq->message_buf_size)
1332 { 1332 {
@@ -1355,7 +1355,7 @@ transmit_send_continuation (void *cls,
1355 gettext_noop 1355 gettext_noop
1356 ("# transmission failures for messages to other peers"), 1356 ("# transmission failures for messages to other peers"),
1357 1, GNUNET_NO); 1357 1, GNUNET_NO);
1358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1359 "Sending message to `%s' of type %u was a %s\n", 1359 "Sending message to `%s' of type %u was a %s\n",
1360 GNUNET_i2s (receiver), 1360 GNUNET_i2s (receiver),
1361 ntohs (((struct GNUNET_MessageHeader *) mq->message_buf)->type), 1361 ntohs (((struct GNUNET_MessageHeader *) mq->message_buf)->type),
@@ -1389,7 +1389,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
1389 GNUNET_break (0); 1389 GNUNET_break (0);
1390 return; 1390 return;
1391 } 1391 }
1392 if ((0 == n->primary_address.address->address_length) && 1392 if ((0 == n->primary_address.address->address_length) &&
1393 (NULL == n->primary_address.session)) 1393 (NULL == n->primary_address.session))
1394 { 1394 {
1395 /* no address, why are we here? */ 1395 /* no address, why are we here? */
@@ -1399,7 +1399,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
1399 if (NULL != n->is_active) 1399 if (NULL != n->is_active)
1400 { 1400 {
1401 /* transmission already pending */ 1401 /* transmission already pending */
1402 return; 1402 return;
1403 } 1403 }
1404 1404
1405 /* timeout messages from the queue that are past their due date */ 1405 /* timeout messages from the queue that are past their due date */
@@ -1535,7 +1535,7 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour)
1535 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 1535 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
1536 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1536 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1537 "Latency for peer `%s' is %s\n", 1537 "Latency for peer `%s' is %s\n",
1538 GNUNET_i2s (&n->id), 1538 GNUNET_i2s (&n->id),
1539 GNUNET_STRINGS_relative_time_to_string (n->latency, 1539 GNUNET_STRINGS_relative_time_to_string (n->latency,
1540 GNUNET_YES)); 1540 GNUNET_YES));
1541 /* append latency */ 1541 /* append latency */
@@ -1570,7 +1570,7 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity
1570{ 1570{
1571 struct NeighbourMapEntry *n; 1571 struct NeighbourMapEntry *n;
1572 struct GNUNET_TIME_Relative ret; 1572 struct GNUNET_TIME_Relative ret;
1573 1573
1574 if (NULL == neighbours) 1574 if (NULL == neighbours)
1575 { 1575 {
1576 *do_forward = GNUNET_NO; 1576 *do_forward = GNUNET_NO;
@@ -1634,7 +1634,7 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity
1634 GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES)); 1634 GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES));
1635 GNUNET_STATISTICS_update (GST_stats, 1635 GNUNET_STATISTICS_update (GST_stats,
1636 gettext_noop ("# ms throttling suggested"), 1636 gettext_noop ("# ms throttling suggested"),
1637 (int64_t) ret.rel_value_us / 1000LL, 1637 (int64_t) ret.rel_value_us / 1000LL,
1638 GNUNET_NO); 1638 GNUNET_NO);
1639 } 1639 }
1640 return ret; 1640 return ret;
@@ -1708,13 +1708,13 @@ send_session_connect (struct NeighbourAddress *na)
1708 struct GNUNET_TRANSPORT_PluginFunctions *papi; 1708 struct GNUNET_TRANSPORT_PluginFunctions *papi;
1709 struct SessionConnectMessage connect_msg; 1709 struct SessionConnectMessage connect_msg;
1710 1710
1711 if (NULL == (papi = GST_plugins_find (na->address->transport_name))) 1711 if (NULL == (papi = GST_plugins_find (na->address->transport_name)))
1712 { 1712 {
1713 GNUNET_break (0); 1713 GNUNET_break (0);
1714 return; 1714 return;
1715 } 1715 }
1716 if (NULL == na->session) 1716 if (NULL == na->session)
1717 na->session = papi->get_session (papi->cls, na->address); 1717 na->session = papi->get_session (papi->cls, na->address);
1718 if (NULL == na->session) 1718 if (NULL == na->session)
1719 { 1719 {
1720 GNUNET_break (0); 1720 GNUNET_break (0);
@@ -1750,13 +1750,13 @@ send_session_connect_ack_message (const struct GNUNET_HELLO_Address *address,
1750 struct GNUNET_TRANSPORT_PluginFunctions *papi; 1750 struct GNUNET_TRANSPORT_PluginFunctions *papi;
1751 struct SessionConnectMessage connect_msg; 1751 struct SessionConnectMessage connect_msg;
1752 1752
1753 if (NULL == (papi = GST_plugins_find (address->transport_name))) 1753 if (NULL == (papi = GST_plugins_find (address->transport_name)))
1754 { 1754 {
1755 GNUNET_break (0); 1755 GNUNET_break (0);
1756 return; 1756 return;
1757 } 1757 }
1758 if (NULL == session) 1758 if (NULL == session)
1759 session = papi->get_session (papi->cls, address); 1759 session = papi->get_session (papi->cls, address);
1760 if (NULL == session) 1760 if (NULL == session)
1761 { 1761 {
1762 GNUNET_break (0); 1762 GNUNET_break (0);
@@ -1788,7 +1788,7 @@ setup_neighbour (const struct GNUNET_PeerIdentity *peer)
1788 struct NeighbourMapEntry *n; 1788 struct NeighbourMapEntry *n;
1789 1789
1790 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1790 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1791 "Creating new neighbour entry for `%s'\n", 1791 "Creating new neighbour entry for `%s'\n",
1792 GNUNET_i2s (peer)); 1792 GNUNET_i2s (peer));
1793 n = MEMDEBUG_malloc (sizeof (struct NeighbourMapEntry), __LINE__); 1793 n = MEMDEBUG_malloc (sizeof (struct NeighbourMapEntry), __LINE__);
1794 n->id = *peer; 1794 n->id = *peer;
@@ -1842,7 +1842,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
1842{ 1842{
1843 struct NeighbourMapEntry *n; 1843 struct NeighbourMapEntry *n;
1844 1844
1845 if (NULL == neighbours) 1845 if (NULL == neighbours)
1846 { 1846 {
1847 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1847 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1848 "Asked to connect to peer `%s' during shutdown\n", 1848 "Asked to connect to peer `%s' during shutdown\n",
@@ -1881,7 +1881,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
1881 "Ignoring request to try to connect to `%s', already trying!\n", 1881 "Ignoring request to try to connect to `%s', already trying!\n",
1882 GNUNET_i2s (target)); 1882 GNUNET_i2s (target));
1883 return; /* already trying */ 1883 return; /* already trying */
1884 case S_CONNECTED: 1884 case S_CONNECTED:
1885 case S_RECONNECT_ATS: 1885 case S_RECONNECT_ATS:
1886 case S_RECONNECT_BLACKLIST: 1886 case S_RECONNECT_BLACKLIST:
1887 case S_RECONNECT_SENT: 1887 case S_RECONNECT_SENT:
@@ -1896,8 +1896,8 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
1896 free_neighbour (n, GNUNET_NO); 1896 free_neighbour (n, GNUNET_NO);
1897 break; 1897 break;
1898 case S_DISCONNECT_FINISHED: 1898 case S_DISCONNECT_FINISHED:
1899 /* should not be possible */ 1899 /* should not be possible */
1900 GNUNET_assert (0); 1900 GNUNET_assert (0);
1901 default: 1901 default:
1902 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state)); 1902 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state));
1903 GNUNET_break (0); 1903 GNUNET_break (0);
@@ -1905,8 +1905,8 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
1905 break; 1905 break;
1906 } 1906 }
1907 } 1907 }
1908 n = setup_neighbour (target); 1908 n = setup_neighbour (target);
1909 n->state = S_INIT_ATS; 1909 n->state = S_INIT_ATS;
1910 n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT); 1910 n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
1911 1911
1912 GNUNET_ATS_reset_backoff (GST_ats, target); 1912 GNUNET_ATS_reset_backoff (GST_ats, target);
@@ -1988,7 +1988,7 @@ handle_test_blacklist_cont (void *cls,
1988 n->primary_address.session, 1988 n->primary_address.session,
1989 n->connect_ack_timestamp); 1989 n->connect_ack_timestamp);
1990 } 1990 }
1991 break; 1991 break;
1992 case S_CONNECT_RECV_BLACKLIST_INBOUND: 1992 case S_CONNECT_RECV_BLACKLIST_INBOUND:
1993 if (GNUNET_OK == result) 1993 if (GNUNET_OK == result)
1994 GST_ats_add_address (bcc->na.address, bcc->na.session); 1994 GST_ats_add_address (bcc->na.address, bcc->na.session);
@@ -2011,7 +2011,7 @@ handle_test_blacklist_cont (void *cls,
2011 send_session_connect_ack_message (bcc->na.address, 2011 send_session_connect_ack_message (bcc->na.address,
2012 bcc->na.session, 2012 bcc->na.session,
2013 n->connect_ack_timestamp); 2013 n->connect_ack_timestamp);
2014 if (1 == n->send_connect_ack) 2014 if (1 == n->send_connect_ack)
2015 n->send_connect_ack = 2; 2015 n->send_connect_ack = 2;
2016 } 2016 }
2017 else 2017 else
@@ -2038,13 +2038,13 @@ handle_test_blacklist_cont (void *cls,
2038 n->primary_address.session, 2038 n->primary_address.session,
2039 n->connect_ack_timestamp); 2039 n->connect_ack_timestamp);
2040 } 2040 }
2041 break; 2041 break;
2042 case S_CONNECTED: 2042 case S_CONNECTED:
2043 /* already connected, don't care about blacklist */ 2043 /* already connected, don't care about blacklist */
2044 break; 2044 break;
2045 case S_RECONNECT_ATS: 2045 case S_RECONNECT_ATS:
2046 /* still waiting on ATS suggestion, don't care about blacklist */ 2046 /* still waiting on ATS suggestion, don't care about blacklist */
2047 break; 2047 break;
2048 case S_RECONNECT_BLACKLIST: 2048 case S_RECONNECT_BLACKLIST:
2049 if ( (GNUNET_OK == result) && 2049 if ( (GNUNET_OK == result) &&
2050 (1 == n->send_connect_ack) ) 2050 (1 == n->send_connect_ack) )
@@ -2083,7 +2083,7 @@ handle_test_blacklist_cont (void *cls,
2083 n->primary_address.session, 2083 n->primary_address.session,
2084 n->connect_ack_timestamp); 2084 n->connect_ack_timestamp);
2085 } 2085 }
2086 break; 2086 break;
2087 case S_CONNECTED_SWITCHING_BLACKLIST: 2087 case S_CONNECTED_SWITCHING_BLACKLIST:
2088 if (GNUNET_YES != address_matches (&bcc->na, &n->alternative_address)) 2088 if (GNUNET_YES != address_matches (&bcc->na, &n->alternative_address))
2089 break; /* result for an address we currently don't care about */ 2089 break; /* result for an address we currently don't care about */
@@ -2111,7 +2111,7 @@ handle_test_blacklist_cont (void *cls,
2111 n->primary_address.session, 2111 n->primary_address.session,
2112 n->connect_ack_timestamp); 2112 n->connect_ack_timestamp);
2113 } 2113 }
2114 break; 2114 break;
2115 case S_DISCONNECT: 2115 case S_DISCONNECT:
2116 /* Nothing to do here, ATS will already do what can be done */ 2116 /* Nothing to do here, ATS will already do what can be done */
2117 break; 2117 break;
@@ -2163,10 +2163,10 @@ check_blacklist (const struct GNUNET_PeerIdentity *peer,
2163 GNUNET_CONTAINER_DLL_insert (bc_head, 2163 GNUNET_CONTAINER_DLL_insert (bc_head,
2164 bc_tail, 2164 bc_tail,
2165 bcc); 2165 bcc);
2166 if (NULL != (bc = GST_blacklist_test_allowed (peer, 2166 if (NULL != (bc = GST_blacklist_test_allowed (peer,
2167 address->transport_name, 2167 address->transport_name,
2168 &handle_test_blacklist_cont, bcc))) 2168 &handle_test_blacklist_cont, bcc)))
2169 bcc->bc = bc; 2169 bcc->bc = bc;
2170 /* if NULL == bc, 'cont' was already called and 'bcc' already free'd, so 2170 /* if NULL == bc, 'cont' was already called and 'bcc' already free'd, so
2171 we must only store 'bc' if 'bc' is non-NULL... */ 2171 we must only store 'bc' if 'bc' is non-NULL... */
2172} 2172}
@@ -2193,7 +2193,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2193 struct GNUNET_TIME_Absolute ts; 2193 struct GNUNET_TIME_Absolute ts;
2194 2194
2195 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2195 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2196 "Received CONNECT message from peer `%s'\n", 2196 "Received CONNECT message from peer `%s'\n",
2197 GNUNET_i2s (peer)); 2197 GNUNET_i2s (peer));
2198 2198
2199 if (ntohs (message->size) != sizeof (struct SessionConnectMessage)) 2199 if (ntohs (message->size) != sizeof (struct SessionConnectMessage))
@@ -2213,7 +2213,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2213 n->connect_ack_timestamp = ts; 2213 n->connect_ack_timestamp = ts;
2214 2214
2215 switch (n->state) 2215 switch (n->state)
2216 { 2216 {
2217 case S_NOT_CONNECTED: 2217 case S_NOT_CONNECTED:
2218 n->state = S_CONNECT_RECV_BLACKLIST_INBOUND; 2218 n->state = S_CONNECT_RECV_BLACKLIST_INBOUND;
2219 /* Do a blacklist check for the new address */ 2219 /* Do a blacklist check for the new address */
@@ -2229,7 +2229,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2229 case S_CONNECT_RECV_ATS: 2229 case S_CONNECT_RECV_ATS:
2230 case S_CONNECT_RECV_BLACKLIST: 2230 case S_CONNECT_RECV_BLACKLIST:
2231 case S_CONNECT_RECV_ACK: 2231 case S_CONNECT_RECV_ACK:
2232 /* It can never hurt to have an alternative address in the above cases, 2232 /* It can never hurt to have an alternative address in the above cases,
2233 see if it is allowed */ 2233 see if it is allowed */
2234 check_blacklist (peer, ts, address, session); 2234 check_blacklist (peer, ts, address, session);
2235 break; 2235 break;
@@ -2247,7 +2247,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2247 case S_RECONNECT_ATS: 2247 case S_RECONNECT_ATS:
2248 case S_RECONNECT_BLACKLIST: 2248 case S_RECONNECT_BLACKLIST:
2249 case S_RECONNECT_SENT: 2249 case S_RECONNECT_SENT:
2250 /* It can never hurt to have an alternative address in the above cases, 2250 /* It can never hurt to have an alternative address in the above cases,
2251 see if it is allowed */ 2251 see if it is allowed */
2252 check_blacklist (peer, ts, address, session); 2252 check_blacklist (peer, ts, address, session);
2253 break; 2253 break;
@@ -2286,7 +2286,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2286 2286
2287/** 2287/**
2288 * For an existing neighbour record, set the active connection to 2288 * For an existing neighbour record, set the active connection to
2289 * use the given address. 2289 * use the given address.
2290 * 2290 *
2291 * @param peer identity of the peer to switch the address for 2291 * @param peer identity of the peer to switch the address for
2292 * @param address address of the other peer, NULL if other peer 2292 * @param address address of the other peer, NULL if other peer
@@ -2355,7 +2355,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
2355 { 2355 {
2356 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2356 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2357 "Failed to obtain new session for peer `%s' and address '%s'\n", 2357 "Failed to obtain new session for peer `%s' and address '%s'\n",
2358 GNUNET_i2s (&address->peer), GST_plugins_a2s (address)); 2358 GNUNET_i2s (&address->peer), GST_plugins_a2s (address));
2359 GNUNET_ATS_address_destroyed (GST_ats, address, NULL); 2359 GNUNET_ATS_address_destroyed (GST_ats, address, NULL);
2360 return; 2360 return;
2361 } 2361 }
@@ -2529,7 +2529,7 @@ master_task (void *cls,
2529 struct GNUNET_TIME_Relative delay; 2529 struct GNUNET_TIME_Relative delay;
2530 2530
2531 n->task = GNUNET_SCHEDULER_NO_TASK; 2531 n->task = GNUNET_SCHEDULER_NO_TASK;
2532 delay = GNUNET_TIME_absolute_get_remaining (n->timeout); 2532 delay = GNUNET_TIME_absolute_get_remaining (n->timeout);
2533 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2533 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2534 "Master task runs for neighbour `%s' in state %s with timeout in %s\n", 2534 "Master task runs for neighbour `%s' in state %s with timeout in %s\n",
2535 GNUNET_i2s (&n->id), 2535 GNUNET_i2s (&n->id),
@@ -2698,11 +2698,11 @@ master_task (void *cls,
2698 default: 2698 default:
2699 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state)); 2699 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state));
2700 GNUNET_break (0); 2700 GNUNET_break (0);
2701 break; 2701 break;
2702 } 2702 }
2703 if ( (S_CONNECTED_SWITCHING_CONNECT_SENT == n->state) || 2703 if ( (S_CONNECTED_SWITCHING_CONNECT_SENT == n->state) ||
2704 (S_CONNECTED_SWITCHING_BLACKLIST == n->state) || 2704 (S_CONNECTED_SWITCHING_BLACKLIST == n->state) ||
2705 (S_CONNECTED == n->state) ) 2705 (S_CONNECTED == n->state) )
2706 { 2706 {
2707 /* if we are *now* in one of these three states, we're sending 2707 /* if we are *now* in one of these three states, we're sending
2708 keep alive messages, so we need to consider the keepalive 2708 keep alive messages, so we need to consider the keepalive
@@ -2789,14 +2789,14 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2789 gettext_noop 2789 gettext_noop
2790 ("# unexpected CONNECT_ACK messages (not ready)"), 2790 ("# unexpected CONNECT_ACK messages (not ready)"),
2791 1, GNUNET_NO); 2791 1, GNUNET_NO);
2792 break; 2792 break;
2793 case S_CONNECT_SENT: 2793 case S_CONNECT_SENT:
2794 if (ts.abs_value_us != n->primary_address.connect_timestamp.abs_value_us) 2794 if (ts.abs_value_us != n->primary_address.connect_timestamp.abs_value_us)
2795 break; /* ACK does not match our original CONNECT message */ 2795 break; /* ACK does not match our original CONNECT message */
2796 n->state = S_CONNECTED; 2796 n->state = S_CONNECTED;
2797 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 2797 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
2798 GNUNET_STATISTICS_set (GST_stats, 2798 GNUNET_STATISTICS_set (GST_stats,
2799 gettext_noop ("# peers connected"), 2799 gettext_noop ("# peers connected"),
2800 ++neighbours_connected, 2800 ++neighbours_connected,
2801 GNUNET_NO); 2801 GNUNET_NO);
2802 connect_notify_cb (callback_cls, &n->id, 2802 connect_notify_cb (callback_cls, &n->id,
@@ -2858,7 +2858,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2858 GNUNET_YES); 2858 GNUNET_YES);
2859 free_address (&n->alternative_address); 2859 free_address (&n->alternative_address);
2860 send_session_ack_message (n); 2860 send_session_ack_message (n);
2861 break; 2861 break;
2862 case S_DISCONNECT: 2862 case S_DISCONNECT:
2863 GNUNET_STATISTICS_update (GST_stats, 2863 GNUNET_STATISTICS_update (GST_stats,
2864 gettext_noop 2864 gettext_noop
@@ -2871,7 +2871,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2871 default: 2871 default:
2872 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state)); 2872 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state));
2873 GNUNET_break (0); 2873 GNUNET_break (0);
2874 break; 2874 break;
2875 } 2875 }
2876} 2876}
2877 2877
@@ -2945,7 +2945,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
2945 n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, &n->id); 2945 n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, &n->id);
2946 break; 2946 break;
2947 case S_CONNECT_RECV_BLACKLIST_INBOUND: 2947 case S_CONNECT_RECV_BLACKLIST_INBOUND:
2948 case S_CONNECT_RECV_ATS: 2948 case S_CONNECT_RECV_ATS:
2949 case S_CONNECT_RECV_BLACKLIST: 2949 case S_CONNECT_RECV_BLACKLIST:
2950 case S_CONNECT_RECV_ACK: 2950 case S_CONNECT_RECV_ACK:
2951 /* error on inbound session; free neighbour entirely */ 2951 /* error on inbound session; free neighbour entirely */
@@ -2972,7 +2972,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
2972 break; 2972 break;
2973 case S_CONNECTED_SWITCHING_BLACKLIST: 2973 case S_CONNECTED_SWITCHING_BLACKLIST:
2974 /* primary went down while we were checking secondary against 2974 /* primary went down while we were checking secondary against
2975 blacklist, adopt secondary as primary */ 2975 blacklist, adopt secondary as primary */
2976 free_address (&n->primary_address); 2976 free_address (&n->primary_address);
2977 n->primary_address = n->alternative_address; 2977 n->primary_address = n->alternative_address;
2978 memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress)); 2978 memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress));
@@ -2981,7 +2981,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
2981 break; 2981 break;
2982 case S_CONNECTED_SWITCHING_CONNECT_SENT: 2982 case S_CONNECTED_SWITCHING_CONNECT_SENT:
2983 /* primary went down while we were waiting for CONNECT_ACK on secondary; 2983 /* primary went down while we were waiting for CONNECT_ACK on secondary;
2984 secondary as primary */ 2984 secondary as primary */
2985 free_address (&n->primary_address); 2985 free_address (&n->primary_address);
2986 n->primary_address = n->alternative_address; 2986 n->primary_address = n->alternative_address;
2987 memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress)); 2987 memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress));
@@ -3026,7 +3026,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3026{ 3026{
3027 struct NeighbourMapEntry *n; 3027 struct NeighbourMapEntry *n;
3028 3028
3029 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3029 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3030 "Received SESSION_ACK message from peer `%s'\n", 3030 "Received SESSION_ACK message from peer `%s'\n",
3031 GNUNET_i2s (peer)); 3031 GNUNET_i2s (peer));
3032 if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader)) 3032 if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader))
@@ -3049,8 +3049,8 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3049 } 3049 }
3050 n->state = S_CONNECTED; 3050 n->state = S_CONNECTED;
3051 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 3051 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
3052 GNUNET_STATISTICS_set (GST_stats, 3052 GNUNET_STATISTICS_set (GST_stats,
3053 gettext_noop ("# peers connected"), 3053 gettext_noop ("# peers connected"),
3054 ++neighbours_connected, 3054 ++neighbours_connected,
3055 GNUNET_NO); 3055 GNUNET_NO);
3056 connect_notify_cb (callback_cls, &n->id, 3056 connect_notify_cb (callback_cls, &n->id,
@@ -3263,7 +3263,7 @@ GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls)
3263{ 3263{
3264 struct IteratorContext ic; 3264 struct IteratorContext ic;
3265 3265
3266 if (NULL == neighbours) 3266 if (NULL == neighbours)
3267 return; /* can happen during shutdown */ 3267 return; /* can happen during shutdown */
3268 ic.cb = cb; 3268 ic.cb = cb;
3269 ic.cb_cls = cb_cls; 3269 ic.cb_cls = cb_cls;
@@ -3296,7 +3296,7 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target)
3296 * Obtain current latency information for the given neighbour. 3296 * Obtain current latency information for the given neighbour.
3297 * 3297 *
3298 * @param peer to get the latency for 3298 * @param peer to get the latency for
3299 * @return observed latency of the address, FOREVER if the 3299 * @return observed latency of the address, FOREVER if the
3300 * the connection is not up 3300 * the connection is not up
3301 */ 3301 */
3302struct GNUNET_TIME_Relative 3302struct GNUNET_TIME_Relative
@@ -3305,7 +3305,7 @@ GST_neighbour_get_latency (const struct GNUNET_PeerIdentity *peer)
3305 struct NeighbourMapEntry *n; 3305 struct NeighbourMapEntry *n;
3306 3306
3307 n = lookup_neighbour (peer); 3307 n = lookup_neighbour (peer);
3308 if (NULL == n) 3308 if (NULL == n)
3309 return GNUNET_TIME_UNIT_FOREVER_REL; 3309 return GNUNET_TIME_UNIT_FOREVER_REL;
3310 switch (n->state) 3310 switch (n->state)
3311 { 3311 {
@@ -3332,7 +3332,7 @@ GST_neighbour_get_latency (const struct GNUNET_PeerIdentity *peer)
3332 GNUNET_break (0); 3332 GNUNET_break (0);
3333 break; 3333 break;
3334 } 3334 }
3335 return GNUNET_TIME_UNIT_FOREVER_REL; 3335 return GNUNET_TIME_UNIT_FOREVER_REL;
3336} 3336}
3337 3337
3338 3338
@@ -3388,13 +3388,13 @@ GST_neighbours_start (void *cls,
3388 * @return GNUNET_OK (continue to iterate) 3388 * @return GNUNET_OK (continue to iterate)
3389 */ 3389 */
3390static int 3390static int
3391disconnect_all_neighbours (void *cls, 3391disconnect_all_neighbours (void *cls,
3392 const struct GNUNET_PeerIdentity *key, 3392 const struct GNUNET_PeerIdentity *key,
3393 void *value) 3393 void *value)
3394{ 3394{
3395 struct NeighbourMapEntry *n = value; 3395 struct NeighbourMapEntry *n = value;
3396 3396
3397 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3397 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3398 "Disconnecting peer `%4s', %s\n", 3398 "Disconnecting peer `%4s', %s\n",
3399 GNUNET_i2s (&n->id), "SHUTDOWN_TASK"); 3399 GNUNET_i2s (&n->id), "SHUTDOWN_TASK");
3400 n->state = S_DISCONNECT_FINISHED; 3400 n->state = S_DISCONNECT_FINISHED;
@@ -3411,7 +3411,7 @@ GST_neighbours_stop ()
3411{ 3411{
3412 if (NULL == neighbours) 3412 if (NULL == neighbours)
3413 return; 3413 return;
3414 GNUNET_CONTAINER_multipeermap_iterate (neighbours, 3414 GNUNET_CONTAINER_multipeermap_iterate (neighbours,
3415 &disconnect_all_neighbours, 3415 &disconnect_all_neighbours,
3416 NULL); 3416 NULL);
3417 GNUNET_CONTAINER_multipeermap_destroy (neighbours); 3417 GNUNET_CONTAINER_multipeermap_destroy (neighbours);
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index 54393d753..6018e2c7b 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -811,7 +811,7 @@ GST_validation_start (unsigned int max_fds)
811 validations_fast_start_threshold = (max_fds / 2); 811 validations_fast_start_threshold = (max_fds / 2);
812 validations_running = 0; 812 validations_running = 0;
813 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Validation uses a fast start threshold of %u connections and a delay between of %s\n ", 813 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Validation uses a fast start threshold of %u connections and a delay between of %s\n ",
814 validations_fast_start_threshold, 814 validations_fast_start_threshold,
815 GNUNET_STRINGS_relative_time_to_string (validation_delay, 815 GNUNET_STRINGS_relative_time_to_string (validation_delay,
816 GNUNET_YES)); 816 GNUNET_YES));
817 validation_map = GNUNET_CONTAINER_multipeermap_create (VALIDATION_MAP_SIZE, 817 validation_map = GNUNET_CONTAINER_multipeermap_create (VALIDATION_MAP_SIZE,
@@ -855,7 +855,7 @@ GST_validation_stop ()
855 */ 855 */
856static void 856static void
857multicast_pong (void *cls, 857multicast_pong (void *cls,
858 const struct GNUNET_CRYPTO_EccPublicSignKey *public_key, 858 const struct GNUNET_CRYPTO_EccPublicSignKey *public_key,
859 struct GNUNET_TIME_Absolute valid_until, 859 struct GNUNET_TIME_Absolute valid_until,
860 struct GNUNET_TIME_Absolute validation_block, 860 struct GNUNET_TIME_Absolute validation_block,
861 const struct GNUNET_HELLO_Address *address) 861 const struct GNUNET_HELLO_Address *address)
@@ -1075,7 +1075,7 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
1075 pong->expiration = GNUNET_TIME_absolute_hton (*sig_cache_exp); 1075 pong->expiration = GNUNET_TIME_absolute_hton (*sig_cache_exp);
1076 } 1076 }
1077 pong->signature = *sig_cache; 1077 pong->signature = *sig_cache;
1078 1078
1079 GNUNET_assert (sender_address != NULL); 1079 GNUNET_assert (sender_address != NULL);
1080 1080
1081 /* first see if the session we got this PING from can be used to transmit 1081 /* first see if the session we got this PING from can be used to transmit
diff --git a/src/transport/gnunet-transport-certificate-creation.c b/src/transport/gnunet-transport-certificate-creation.c
index b26d2e06d..ff9a331f1 100644
--- a/src/transport/gnunet-transport-certificate-creation.c
+++ b/src/transport/gnunet-transport-certificate-creation.c
@@ -28,7 +28,7 @@
28 28
29 29
30static void 30static void
31removecerts (const char *file1, 31removecerts (const char *file1,
32 const char *file2) 32 const char *file2)
33{ 33{
34 if (GNUNET_YES == GNUNET_DISK_file_test (file1)) 34 if (GNUNET_YES == GNUNET_DISK_file_test (file1))
@@ -55,7 +55,7 @@ main (int argc, char **argv)
55 55
56 if (3 != argc) 56 if (3 != argc)
57 { 57 {
58 fprintf (stderr, 58 fprintf (stderr,
59 "Invalid arguments.\n"); 59 "Invalid arguments.\n");
60 return 1; 60 return 1;
61 } 61 }
@@ -68,7 +68,7 @@ main (int argc, char **argv)
68 "-out", argv[1], "1024", NULL); 68 "-out", argv[1], "1024", NULL);
69 if (NULL == openssl) 69 if (NULL == openssl)
70 { 70 {
71 fprintf (stderr, 71 fprintf (stderr,
72 "Failed to run openssl. Is openssl installed?\n"); 72 "Failed to run openssl. Is openssl installed?\n");
73 return 2; 73 return 2;
74 } 74 }
@@ -83,7 +83,7 @@ main (int argc, char **argv)
83 "-new", "-x509", "-key", argv[1], NULL); 83 "-new", "-x509", "-key", argv[1], NULL);
84 if (NULL == openssl) 84 if (NULL == openssl)
85 { 85 {
86 fprintf (stderr, 86 fprintf (stderr,
87 "Failed to create self-signed certificate with openssl.\n"); 87 "Failed to create self-signed certificate with openssl.\n");
88 return 3; 88 return 3;
89 } 89 }
diff --git a/src/transport/gnunet-transport-wlan-receiver.c b/src/transport/gnunet-transport-wlan-receiver.c
index ccc1d291f..b38285123 100644
--- a/src/transport/gnunet-transport-wlan-receiver.c
+++ b/src/transport/gnunet-transport-wlan-receiver.c
@@ -53,7 +53,7 @@ main (int argc, char *argv[])
53 /* Setup communication pipeline first */ 53 /* Setup communication pipeline first */
54 if (pipe (commpipe)) 54 if (pipe (commpipe))
55 { 55 {
56 fprintf (stderr, 56 fprintf (stderr,
57 "Failed to create pipe: %s\n", 57 "Failed to create pipe: %s\n",
58 STRERROR (errno)); 58 STRERROR (errno));
59 exit (1); 59 exit (1);
@@ -62,8 +62,8 @@ main (int argc, char *argv[])
62 /* Attempt to fork and check for errors */ 62 /* Attempt to fork and check for errors */
63 if ((pid = fork ()) == -1) 63 if ((pid = fork ()) == -1)
64 { 64 {
65 fprintf (stderr, "Failed to fork: %s\n", 65 fprintf (stderr, "Failed to fork: %s\n",
66 STRERROR (errno)); 66 STRERROR (errno));
67 exit (1); 67 exit (1);
68 } 68 }
69 69
@@ -90,7 +90,7 @@ main (int argc, char *argv[])
90 { 90 {
91 bytes_per_s = count / (akt - start); 91 bytes_per_s = count / (akt - start);
92 bytes_per_s /= 1024; 92 bytes_per_s /= 1024;
93 printf ("recv %f kb/s\n", bytes_per_s); 93 printf ("recv %f kb/s\n", bytes_per_s);
94 start = akt; 94 start = akt;
95 count = 0; 95 count = 0;
96 } 96 }
diff --git a/src/transport/gnunet-transport-wlan-sender.c b/src/transport/gnunet-transport-wlan-sender.c
index 0ab6c9fd1..12989dd55 100644
--- a/src/transport/gnunet-transport-wlan-sender.c
+++ b/src/transport/gnunet-transport-wlan-sender.c
@@ -74,7 +74,7 @@ getRadiotapHeader (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header,
74 * @return GNUNET_YES if there was no error 74 * @return GNUNET_YES if there was no error
75 */ 75 */
76static int 76static int
77getWlanHeader (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *Header, 77getWlanHeader (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *Header,
78 const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, 78 const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr,
79 const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac, unsigned int size) 79 const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac, unsigned int size)
80{ 80{
@@ -148,14 +148,14 @@ main (int argc, char *argv[])
148 /* Setup communication pipeline first */ 148 /* Setup communication pipeline first */
149 if (pipe (commpipe)) 149 if (pipe (commpipe))
150 { 150 {
151 fprintf (stderr, 151 fprintf (stderr,
152 "Failed to create pipe: %s\n", 152 "Failed to create pipe: %s\n",
153 STRERROR (errno)); 153 STRERROR (errno));
154 exit (1); 154 exit (1);
155 } 155 }
156 if (pipe (macpipe)) 156 if (pipe (macpipe))
157 { 157 {
158 fprintf (stderr, 158 fprintf (stderr,
159 "Failed to create pipe: %s\n", 159 "Failed to create pipe: %s\n",
160 STRERROR (errno)); 160 STRERROR (errno));
161 exit (1); 161 exit (1);
@@ -164,8 +164,8 @@ main (int argc, char *argv[])
164 /* Attempt to fork and check for errors */ 164 /* Attempt to fork and check for errors */
165 if ((pid = fork ()) == -1) 165 if ((pid = fork ()) == -1)
166 { 166 {
167 fprintf (stderr, "Failed to fork: %s\n", 167 fprintf (stderr, "Failed to fork: %s\n",
168 STRERROR (errno)); 168 STRERROR (errno));
169 exit (1); 169 exit (1);
170 } 170 }
171 memset (msg_buf, 0x42, sizeof (msg_buf)); 171 memset (msg_buf, 0x42, sizeof (msg_buf));
@@ -183,12 +183,12 @@ main (int argc, char *argv[])
183 "Failed to close fd: %s\n", 183 "Failed to close fd: %s\n",
184 strerror (errno)); 184 strerror (errno));
185 if (sizeof (hcm) != read (macpipe[0], &hcm, sizeof (hcm))) 185 if (sizeof (hcm) != read (macpipe[0], &hcm, sizeof (hcm)))
186 fprintf (stderr, 186 fprintf (stderr,
187 "Failed to read hcm...\n"); 187 "Failed to read hcm...\n");
188 fprintf (stderr, 188 fprintf (stderr,
189 "Got MAC %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", 189 "Got MAC %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n",
190 hcm.mac.mac[0], hcm.mac.mac[1], 190 hcm.mac.mac[0], hcm.mac.mac[1],
191 hcm.mac.mac[2], hcm.mac.mac[3], hcm.mac.mac[4], hcm.mac.mac[5]); 191 hcm.mac.mac[2], hcm.mac.mac[3], hcm.mac.mac[4], hcm.mac.mac[5]);
192 radiotap = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) msg_buf; 192 radiotap = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) msg_buf;
193 getRadiotapHeader (radiotap, WLAN_MTU); 193 getRadiotapHeader (radiotap, WLAN_MTU);
194 getWlanHeader (&radiotap->frame, &outmac, &inmac, 194 getWlanHeader (&radiotap->frame, &outmac, &inmac,
@@ -212,7 +212,7 @@ main (int argc, char *argv[])
212 printf ("send %f kbytes/s\n", bytes_per_s); 212 printf ("send %f kbytes/s\n", bytes_per_s);
213 start = akt; 213 start = akt;
214 count = 0; 214 count = 0;
215 } 215 }
216 } 216 }
217 } 217 }
218 else 218 else
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index 4fc1622b3..cbda8ac6e 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -518,8 +518,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
518 if (try_connect) 518 if (try_connect)
519 { 519 {
520 /* all done, terminate instantly */ 520 /* all done, terminate instantly */
521 FPRINTF (stdout, 521 FPRINTF (stdout,
522 _("Successfully connected to `%s'\n"), 522 _("Successfully connected to `%s'\n"),
523 GNUNET_i2s_full (peer)); 523 GNUNET_i2s_full (peer));
524 ret = 0; 524 ret = 0;
525 525
@@ -803,12 +803,12 @@ testservice_task (void *cls,
803 803
804 if (GNUNET_YES != result) 804 if (GNUNET_YES != result)
805 { 805 {
806 FPRINTF (stderr, 806 FPRINTF (stderr,
807 _("Service `%s' is not running\n"), "transport"); 807 _("Service `%s' is not running\n"), "transport");
808 return; 808 return;
809 } 809 }
810 810
811 if ( (NULL != cpid) && 811 if ( (NULL != cpid) &&
812 (GNUNET_OK != GNUNET_CRYPTO_ecc_public_sign_key_from_string (cpid, 812 (GNUNET_OK != GNUNET_CRYPTO_ecc_public_sign_key_from_string (cpid,
813 strlen (cpid), 813 strlen (cpid),
814 &pid.public_key))) 814 &pid.public_key)))
diff --git a/src/transport/plugin_transport_bluetooth.c b/src/transport/plugin_transport_bluetooth.c
index a6b73c494..5ea439310 100644
--- a/src/transport/plugin_transport_bluetooth.c
+++ b/src/transport/plugin_transport_bluetooth.c
@@ -81,7 +81,7 @@ GNUNET_NETWORK_STRUCT_BEGIN
81/** 81/**
82 * Header for messages which need fragmentation. This is the format of 82 * Header for messages which need fragmentation. This is the format of
83 * a message we obtain AFTER defragmentation. We then need to check 83 * a message we obtain AFTER defragmentation. We then need to check
84 * the CRC and then tokenize the payload and pass it to the 84 * the CRC and then tokenize the payload and pass it to the
85 * 'receive' callback. 85 * 'receive' callback.
86 */ 86 */
87struct WlanHeader 87struct WlanHeader
@@ -397,7 +397,7 @@ struct Plugin
397 397
398 /** 398 /**
399 * Handle to helper process for priviledged operations. 399 * Handle to helper process for priviledged operations.
400 */ 400 */
401 struct GNUNET_HELPER_Handle *suid_helper; 401 struct GNUNET_HELPER_Handle *suid_helper;
402 402
403 /** 403 /**
@@ -559,7 +559,7 @@ get_radiotap_header (struct MacEndpoint *endpoint,
559static void 559static void
560get_wlan_header (struct Plugin *plugin, 560get_wlan_header (struct Plugin *plugin,
561 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *header, 561 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *header,
562 const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, 562 const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr,
563 unsigned int size) 563 unsigned int size)
564{ 564{
565 const int rate = 11000000; 565 const int rate = 11000000;
@@ -599,12 +599,12 @@ send_ack (void *cls, uint32_t msg_id,
599 GNUNET_break (0); 599 GNUNET_break (0);
600 return; 600 return;
601 } 601 }
602 LOG (GNUNET_ERROR_TYPE_DEBUG, 602 LOG (GNUNET_ERROR_TYPE_DEBUG,
603 "Sending ACK to helper\n"); 603 "Sending ACK to helper\n");
604 radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf; 604 radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf;
605 get_radiotap_header (endpoint, radio_header, size); 605 get_radiotap_header (endpoint, radio_header, size);
606 get_wlan_header (endpoint->plugin, 606 get_wlan_header (endpoint->plugin,
607 &radio_header->frame, 607 &radio_header->frame,
608 &endpoint->addr.mac, 608 &endpoint->addr.mac,
609 size); 609 size);
610 memcpy (&radio_header[1], hdr, msize); 610 memcpy (&radio_header[1], hdr, msize);
@@ -612,7 +612,7 @@ send_ack (void *cls, uint32_t msg_id,
612 GNUNET_HELPER_send (endpoint->plugin->suid_helper, 612 GNUNET_HELPER_send (endpoint->plugin->suid_helper,
613 &radio_header->header, 613 &radio_header->header,
614 GNUNET_NO /* dropping ACKs is bad */, 614 GNUNET_NO /* dropping ACKs is bad */,
615 NULL, NULL)) 615 NULL, NULL))
616 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# Bluetooth ACKs sent"), 616 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# Bluetooth ACKs sent"),
617 1, GNUNET_NO); 617 1, GNUNET_NO);
618} 618}
@@ -636,7 +636,7 @@ bluetooth_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hd
636 GNUNET_NO); 636 GNUNET_NO);
637 mas.session = NULL; 637 mas.session = NULL;
638 mas.endpoint = endpoint; 638 mas.endpoint = endpoint;
639 (void) GNUNET_SERVER_mst_receive (plugin->fragment_data_tokenizer, 639 (void) GNUNET_SERVER_mst_receive (plugin->fragment_data_tokenizer,
640 &mas, 640 &mas,
641 (const char *) hdr, 641 (const char *) hdr,
642 ntohs (hdr->size), 642 ntohs (hdr->size),
@@ -654,7 +654,7 @@ free_session (struct Session *session)
654{ 654{
655 struct MacEndpoint *endpoint = session->mac; 655 struct MacEndpoint *endpoint = session->mac;
656 struct PendingMessage *pm; 656 struct PendingMessage *pm;
657 657
658 endpoint->plugin->env->session_end (endpoint->plugin->env->cls, 658 endpoint->plugin->env->session_end (endpoint->plugin->env->cls,
659 &session->target, 659 &session->target,
660 session); 660 session);
@@ -670,7 +670,7 @@ free_session (struct Session *session)
670 GNUNET_free (pm->msg); 670 GNUNET_free (pm->msg);
671 GNUNET_free (pm); 671 GNUNET_free (pm);
672 } 672 }
673 GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, 673 GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head,
674 endpoint->sessions_tail, 674 endpoint->sessions_tail,
675 session); 675 session);
676 if (session->timeout_task != GNUNET_SCHEDULER_NO_TASK) 676 if (session->timeout_task != GNUNET_SCHEDULER_NO_TASK)
@@ -698,7 +698,7 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
698 698
699 session->timeout_task = GNUNET_SCHEDULER_NO_TASK; 699 session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
700 timeout = GNUNET_TIME_absolute_get_remaining (session->timeout); 700 timeout = GNUNET_TIME_absolute_get_remaining (session->timeout);
701 if (0 == timeout.rel_value_us) 701 if (0 == timeout.rel_value_us)
702 { 702 {
703 free_session (session); 703 free_session (session);
704 return; 704 return;
@@ -739,7 +739,7 @@ create_session (struct MacEndpoint *endpoint,
739 session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 739 session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
740 session->timeout_task = 740 session->timeout_task =
741 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, session); 741 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, session);
742 LOG (GNUNET_ERROR_TYPE_DEBUG, 742 LOG (GNUNET_ERROR_TYPE_DEBUG,
743 "Created new session for peer `%s' with endpoint %s\n", 743 "Created new session for peer `%s' with endpoint %s\n",
744 GNUNET_i2s (peer), 744 GNUNET_i2s (peer),
745 mac_to_string (&endpoint->addr.mac)); 745 mac_to_string (&endpoint->addr.mac));
@@ -752,7 +752,7 @@ create_session (struct MacEndpoint *endpoint,
752 * message to the SUID helper process and we are thus ready for 752 * message to the SUID helper process and we are thus ready for
753 * the next fragment. 753 * the next fragment.
754 * 754 *
755 * @param cls the 'struct FragmentMessage' 755 * @param cls the 'struct FragmentMessage'
756 * @param result result of the operation (GNUNET_OK on success, GNUNET_NO if the helper died, GNUNET_SYSERR 756 * @param result result of the operation (GNUNET_OK on success, GNUNET_NO if the helper died, GNUNET_SYSERR
757 * if the helper was stopped) 757 * if the helper was stopped)
758 */ 758 */
@@ -772,7 +772,7 @@ fragment_transmission_done (void *cls,
772 * Transmit a fragment of a message. 772 * Transmit a fragment of a message.
773 * 773 *
774 * @param cls 'struct FragmentMessage' this fragment message belongs to 774 * @param cls 'struct FragmentMessage' this fragment message belongs to
775 * @param hdr pointer to the start of the fragment message 775 * @param hdr pointer to the start of the fragment message
776 */ 776 */
777static void 777static void
778transmit_fragment (void *cls, 778transmit_fragment (void *cls,
@@ -792,7 +792,7 @@ transmit_fragment (void *cls,
792 radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf; 792 radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf;
793 get_radiotap_header (endpoint, radio_header, size); 793 get_radiotap_header (endpoint, radio_header, size);
794 get_wlan_header (endpoint->plugin, 794 get_wlan_header (endpoint->plugin,
795 &radio_header->frame, 795 &radio_header->frame,
796 &endpoint->addr.mac, 796 &endpoint->addr.mac,
797 size); 797 size);
798 memcpy (&radio_header[1], hdr, msize); 798 memcpy (&radio_header[1], hdr, msize);
@@ -827,7 +827,7 @@ free_fragment_message (struct FragmentMessage *fm)
827{ 827{
828 struct MacEndpoint *endpoint = fm->macendpoint; 828 struct MacEndpoint *endpoint = fm->macendpoint;
829 829
830 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# Bluetooth messages pending (with fragmentation)"), 830 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# Bluetooth messages pending (with fragmentation)"),
831 -1, GNUNET_NO); 831 -1, GNUNET_NO);
832 GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head, 832 GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head,
833 endpoint->sending_messages_tail, fm); 833 endpoint->sending_messages_tail, fm);
@@ -887,7 +887,7 @@ fragmentmessage_timeout (void *cls,
887static void 887static void
888send_with_fragmentation (struct MacEndpoint *endpoint, 888send_with_fragmentation (struct MacEndpoint *endpoint,
889 struct GNUNET_TIME_Relative timeout, 889 struct GNUNET_TIME_Relative timeout,
890 const struct GNUNET_PeerIdentity *target, 890 const struct GNUNET_PeerIdentity *target,
891 const struct GNUNET_MessageHeader *msg, 891 const struct GNUNET_MessageHeader *msg,
892 size_t payload_size, 892 size_t payload_size,
893 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) 893 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
@@ -914,7 +914,7 @@ send_with_fragmentation (struct MacEndpoint *endpoint,
914 msg, 914 msg,
915 &transmit_fragment, fm); 915 &transmit_fragment, fm);
916 fm->timeout_task = 916 fm->timeout_task =
917 GNUNET_SCHEDULER_add_delayed (timeout, 917 GNUNET_SCHEDULER_add_delayed (timeout,
918 &fragmentmessage_timeout, fm); 918 &fragmentmessage_timeout, fm);
919 GNUNET_CONTAINER_DLL_insert_tail (endpoint->sending_messages_head, 919 GNUNET_CONTAINER_DLL_insert_tail (endpoint->sending_messages_head,
920 endpoint->sending_messages_tail, 920 endpoint->sending_messages_tail,
@@ -924,7 +924,7 @@ send_with_fragmentation (struct MacEndpoint *endpoint,
924 924
925/** 925/**
926 * Free a MAC endpoint. 926 * Free a MAC endpoint.
927 * 927 *
928 * @param endpoint pointer to the MacEndpoint to free 928 * @param endpoint pointer to the MacEndpoint to free
929 */ 929 */
930static void 930static void
@@ -940,8 +940,8 @@ free_macendpoint (struct MacEndpoint *endpoint)
940 free_session (session); 940 free_session (session);
941 while (NULL != (fm = endpoint->sending_messages_head)) 941 while (NULL != (fm = endpoint->sending_messages_head))
942 free_fragment_message (fm); 942 free_fragment_message (fm);
943 GNUNET_CONTAINER_DLL_remove (plugin->mac_head, 943 GNUNET_CONTAINER_DLL_remove (plugin->mac_head,
944 plugin->mac_tail, 944 plugin->mac_tail,
945 endpoint); 945 endpoint);
946 946
947 if (NULL != endpoint->defrag) 947 if (NULL != endpoint->defrag)
@@ -974,7 +974,7 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
974 974
975 endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK; 975 endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK;
976 timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout); 976 timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout);
977 if (0 == timeout.rel_value_us) 977 if (0 == timeout.rel_value_us)
978 { 978 {
979 free_macendpoint (endpoint); 979 free_macendpoint (endpoint);
980 return; 980 return;
@@ -1000,14 +1000,14 @@ create_macendpoint (struct Plugin *plugin,
1000 1000
1001 for (pos = plugin->mac_head; NULL != pos; pos = pos->next) 1001 for (pos = plugin->mac_head; NULL != pos; pos = pos->next)
1002 if (0 == memcmp (addr, &pos->addr, sizeof (struct WlanAddress))) 1002 if (0 == memcmp (addr, &pos->addr, sizeof (struct WlanAddress)))
1003 return pos; 1003 return pos;
1004 pos = GNUNET_malloc (sizeof (struct MacEndpoint)); 1004 pos = GNUNET_malloc (sizeof (struct MacEndpoint));
1005 pos->addr = *addr; 1005 pos->addr = *addr;
1006 pos->plugin = plugin; 1006 pos->plugin = plugin;
1007 pos->defrag = 1007 pos->defrag =
1008 GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU, 1008 GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU,
1009 MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, 1009 MESSAGES_IN_DEFRAG_QUEUE_PER_MAC,
1010 pos, 1010 pos,
1011 &bluetooth_data_message_handler, 1011 &bluetooth_data_message_handler,
1012 &send_ack); 1012 &send_ack);
1013 1013
@@ -1022,7 +1022,7 @@ create_macendpoint (struct Plugin *plugin,
1022 plugin->mac_count++; 1022 plugin->mac_count++;
1023 GNUNET_STATISTICS_update (plugin->env->stats, _("# Bluetooth MAC endpoints allocated"), 1023 GNUNET_STATISTICS_update (plugin->env->stats, _("# Bluetooth MAC endpoints allocated"),
1024 1, GNUNET_NO); 1024 1, GNUNET_NO);
1025 LOG (GNUNET_ERROR_TYPE_DEBUG, 1025 LOG (GNUNET_ERROR_TYPE_DEBUG,
1026 "New MAC endpoint `%s'\n", 1026 "New MAC endpoint `%s'\n",
1027 bluetooth_plugin_address_to_string(NULL, addr, sizeof (struct WlanAddress))); 1027 bluetooth_plugin_address_to_string(NULL, addr, sizeof (struct WlanAddress)));
1028 return pos; 1028 return pos;
@@ -1142,7 +1142,7 @@ bluetooth_plugin_send (void *cls,
1142 size_t size = msgbuf_size + sizeof (struct WlanHeader); 1142 size_t size = msgbuf_size + sizeof (struct WlanHeader);
1143 char buf[size] GNUNET_ALIGN; 1143 char buf[size] GNUNET_ALIGN;
1144 1144
1145 LOG (GNUNET_ERROR_TYPE_DEBUG, 1145 LOG (GNUNET_ERROR_TYPE_DEBUG,
1146 "Transmitting %u bytes of payload to peer `%s' (starting with %u byte message of type %u)\n", 1146 "Transmitting %u bytes of payload to peer `%s' (starting with %u byte message of type %u)\n",
1147 msgbuf_size, 1147 msgbuf_size,
1148 GNUNET_i2s (&session->target), 1148 GNUNET_i2s (&session->target),
@@ -1202,7 +1202,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1202 switch (ntohs (hdr->type)) 1202 switch (ntohs (hdr->type))
1203 { 1203 {
1204 case GNUNET_MESSAGE_TYPE_HELLO: 1204 case GNUNET_MESSAGE_TYPE_HELLO:
1205 if (GNUNET_OK != 1205 if (GNUNET_OK !=
1206 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource)) 1206 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource))
1207 { 1207 {
1208 GNUNET_break_op (0); 1208 GNUNET_break_op (0);
@@ -1217,9 +1217,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1217 GNUNET_STATISTICS_update (plugin->env->stats, 1217 GNUNET_STATISTICS_update (plugin->env->stats,
1218 _("# HELLO messages received via Bluetooth"), 1, 1218 _("# HELLO messages received via Bluetooth"), 1,
1219 GNUNET_NO); 1219 GNUNET_NO);
1220 plugin->env->receive (plugin->env->cls, 1220 plugin->env->receive (plugin->env->cls,
1221 &tmpsource, 1221 &tmpsource,
1222 hdr, 1222 hdr,
1223 mas->session, 1223 mas->session,
1224 (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, 1224 (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr,
1225 (mas->endpoint == NULL) ? 0 : sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); 1225 (mas->endpoint == NULL) ? 0 : sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
@@ -1236,7 +1236,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1236 GNUNET_break (0); 1236 GNUNET_break (0);
1237 break; 1237 break;
1238 } 1238 }
1239 LOG (GNUNET_ERROR_TYPE_DEBUG, 1239 LOG (GNUNET_ERROR_TYPE_DEBUG,
1240 "Processing %u bytes of FRAGMENT from MAC %s\n", 1240 "Processing %u bytes of FRAGMENT from MAC %s\n",
1241 (unsigned int) msize, 1241 (unsigned int) msize,
1242 bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); 1242 bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)));
@@ -1258,7 +1258,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1258 ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr); 1258 ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr);
1259 if (GNUNET_OK == ret) 1259 if (GNUNET_OK == ret)
1260 { 1260 {
1261 LOG (GNUNET_ERROR_TYPE_DEBUG, 1261 LOG (GNUNET_ERROR_TYPE_DEBUG,
1262 "Got last ACK, finished message transmission to `%s' (%p)\n", 1262 "Got last ACK, finished message transmission to `%s' (%p)\n",
1263 bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)), 1263 bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)),
1264 fm); 1264 fm);
@@ -1273,13 +1273,13 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1273 } 1273 }
1274 if (GNUNET_NO == ret) 1274 if (GNUNET_NO == ret)
1275 { 1275 {
1276 LOG (GNUNET_ERROR_TYPE_DEBUG, 1276 LOG (GNUNET_ERROR_TYPE_DEBUG,
1277 "Got an ACK, message transmission to `%s' not yet finished\n", 1277 "Got an ACK, message transmission to `%s' not yet finished\n",
1278 bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); 1278 bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)));
1279 break; 1279 break;
1280 } 1280 }
1281 } 1281 }
1282 LOG (GNUNET_ERROR_TYPE_DEBUG, 1282 LOG (GNUNET_ERROR_TYPE_DEBUG,
1283 "ACK not matched against any active fragmentation with MAC `%s'\n", 1283 "ACK not matched against any active fragmentation with MAC `%s'\n",
1284 bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); 1284 bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)));
1285 break; 1285 break;
@@ -1293,13 +1293,13 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1293 { 1293 {
1294 GNUNET_break (0); 1294 GNUNET_break (0);
1295 break; 1295 break;
1296 } 1296 }
1297 wlanheader = (const struct WlanHeader *) hdr; 1297 wlanheader = (const struct WlanHeader *) hdr;
1298 if (0 != memcmp (&wlanheader->target, 1298 if (0 != memcmp (&wlanheader->target,
1299 plugin->env->my_identity, 1299 plugin->env->my_identity,
1300 sizeof (struct GNUNET_PeerIdentity))) 1300 sizeof (struct GNUNET_PeerIdentity)))
1301 { 1301 {
1302 LOG (GNUNET_ERROR_TYPE_DEBUG, 1302 LOG (GNUNET_ERROR_TYPE_DEBUG,
1303 "Bluetooth data for `%s', not for me, ignoring\n", 1303 "Bluetooth data for `%s', not for me, ignoring\n",
1304 GNUNET_i2s (&wlanheader->target)); 1304 GNUNET_i2s (&wlanheader->target));
1305 break; 1305 break;
@@ -1314,15 +1314,15 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1314 } 1314 }
1315 xmas.endpoint = mas->endpoint; 1315 xmas.endpoint = mas->endpoint;
1316 xmas.session = create_session (mas->endpoint, &wlanheader->sender); 1316 xmas.session = create_session (mas->endpoint, &wlanheader->sender);
1317 LOG (GNUNET_ERROR_TYPE_DEBUG, 1317 LOG (GNUNET_ERROR_TYPE_DEBUG,
1318 "Processing %u bytes of BLUETOOTH DATA from peer `%s'\n", 1318 "Processing %u bytes of BLUETOOTH DATA from peer `%s'\n",
1319 (unsigned int) msize, 1319 (unsigned int) msize,
1320 GNUNET_i2s (&wlanheader->sender)); 1320 GNUNET_i2s (&wlanheader->sender));
1321 (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer, 1321 (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer,
1322 &xmas, 1322 &xmas,
1323 (const char *) &wlanheader[1], 1323 (const char *) &wlanheader[1],
1324 msize - sizeof (struct WlanHeader), 1324 msize - sizeof (struct WlanHeader),
1325 GNUNET_YES, GNUNET_NO); 1325 GNUNET_YES, GNUNET_NO);
1326 break; 1326 break;
1327 default: 1327 default:
1328 if (NULL == mas->endpoint) 1328 if (NULL == mas->endpoint)
@@ -1340,9 +1340,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1340 (unsigned int) msize, 1340 (unsigned int) msize,
1341 (unsigned int) ntohs (hdr->type), 1341 (unsigned int) ntohs (hdr->type),
1342 GNUNET_i2s (&mas->session->target)); 1342 GNUNET_i2s (&mas->session->target));
1343 plugin->env->receive (plugin->env->cls, 1343 plugin->env->receive (plugin->env->cls,
1344 &mas->session->target, 1344 &mas->session->target,
1345 hdr, 1345 hdr,
1346 mas->session, 1346 mas->session,
1347 (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, 1347 (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr,
1348 (mas->endpoint == NULL) ? 0 : sizeof (struct WlanAddress)); 1348 (mas->endpoint == NULL) ? 0 : sizeof (struct WlanAddress));
@@ -1416,7 +1416,7 @@ handle_helper_message (void *cls, void *client,
1416 "bluetooth"); 1416 "bluetooth");
1417 break; 1417 break;
1418 case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER: 1418 case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER:
1419 LOG (GNUNET_ERROR_TYPE_DEBUG, 1419 LOG (GNUNET_ERROR_TYPE_DEBUG,
1420 "Got data message from helper with %u bytes\n", 1420 "Got data message from helper with %u bytes\n",
1421 msize); 1421 msize);
1422 GNUNET_STATISTICS_update (plugin->env->stats, 1422 GNUNET_STATISTICS_update (plugin->env->stats,
@@ -1453,7 +1453,7 @@ handle_helper_message (void *cls, void *client,
1453 /* packet is FROM us, thus not FOR us */ 1453 /* packet is FROM us, thus not FOR us */
1454 break; 1454 break;
1455 } 1455 }
1456 1456
1457 GNUNET_STATISTICS_update (plugin->env->stats, 1457 GNUNET_STATISTICS_update (plugin->env->stats,
1458 _("# Bluetooth DATA messages processed"), 1458 _("# Bluetooth DATA messages processed"),
1459 1, GNUNET_NO); 1459 1, GNUNET_NO);
@@ -1465,7 +1465,7 @@ handle_helper_message (void *cls, void *client,
1465 wa.options = htonl (0); 1465 wa.options = htonl (0);
1466 mas.endpoint = create_macendpoint (plugin, &wa); 1466 mas.endpoint = create_macendpoint (plugin, &wa);
1467 mas.session = NULL; 1467 mas.session = NULL;
1468 (void) GNUNET_SERVER_mst_receive (plugin->helper_payload_tokenizer, 1468 (void) GNUNET_SERVER_mst_receive (plugin->helper_payload_tokenizer,
1469 &mas, 1469 &mas,
1470 (const char*) &rxinfo[1], 1470 (const char*) &rxinfo[1],
1471 msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage), 1471 msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage),
@@ -1473,7 +1473,7 @@ handle_helper_message (void *cls, void *client,
1473 break; 1473 break;
1474 default: 1474 default:
1475 GNUNET_break (0); 1475 GNUNET_break (0);
1476 LOG (GNUNET_ERROR_TYPE_DEBUG, 1476 LOG (GNUNET_ERROR_TYPE_DEBUG,
1477 "Unexpected message of type %u (%u bytes)", 1477 "Unexpected message of type %u (%u bytes)",
1478 ntohs (hdr->type), ntohs (hdr->size)); 1478 ntohs (hdr->type), ntohs (hdr->size));
1479 break; 1479 break;
@@ -1506,7 +1506,7 @@ send_hello_beacon (void *cls,
1506 { 1506 {
1507 char buf[size] GNUNET_ALIGN; 1507 char buf[size] GNUNET_ALIGN;
1508 1508
1509 LOG (GNUNET_ERROR_TYPE_DEBUG, 1509 LOG (GNUNET_ERROR_TYPE_DEBUG,
1510 "Sending %u byte HELLO beacon\n", 1510 "Sending %u byte HELLO beacon\n",
1511 (unsigned int) size); 1511 (unsigned int) size);
1512 radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf; 1512 radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf;
@@ -1550,13 +1550,13 @@ bluetooth_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
1550 struct WlanAddress *wa = (struct WlanAddress *) addr; 1550 struct WlanAddress *wa = (struct WlanAddress *) addr;
1551 1551
1552 if (addrlen != sizeof (struct WlanAddress)) 1552 if (addrlen != sizeof (struct WlanAddress))
1553 { 1553 {
1554 GNUNET_break_op (0); 1554 GNUNET_break_op (0);
1555 return GNUNET_SYSERR; 1555 return GNUNET_SYSERR;
1556 } 1556 }
1557 if (GNUNET_YES != plugin->have_mac) 1557 if (GNUNET_YES != plugin->have_mac)
1558 { 1558 {
1559 LOG (GNUNET_ERROR_TYPE_DEBUG, 1559 LOG (GNUNET_ERROR_TYPE_DEBUG,
1560 "Rejecting MAC `%s': I don't know my MAC!\n", 1560 "Rejecting MAC `%s': I don't know my MAC!\n",
1561 mac_to_string (addr)); 1561 mac_to_string (addr));
1562 return GNUNET_NO; /* don't know my MAC */ 1562 return GNUNET_NO; /* don't know my MAC */
@@ -1565,7 +1565,7 @@ bluetooth_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
1565 &plugin->mac_address, 1565 &plugin->mac_address,
1566 sizeof (wa->mac))) 1566 sizeof (wa->mac)))
1567 { 1567 {
1568 LOG (GNUNET_ERROR_TYPE_DEBUG, 1568 LOG (GNUNET_ERROR_TYPE_DEBUG,
1569 "Rejecting MAC `%s': not my MAC!\n", 1569 "Rejecting MAC `%s': not my MAC!\n",
1570 mac_to_string (addr)); 1570 mac_to_string (addr));
1571 return GNUNET_NO; /* not my MAC */ 1571 return GNUNET_NO; /* not my MAC */
@@ -1643,7 +1643,7 @@ bluetooth_plugin_address_pretty_printer (void *cls, const char *type,
1643 1643
1644 1644
1645/** 1645/**
1646 * Exit point from the plugin. 1646 * Exit point from the plugin.
1647 * 1647 *
1648 * @param cls pointer to the api struct 1648 * @param cls pointer to the api struct
1649 */ 1649 */
@@ -1799,7 +1799,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls)
1799 1799
1800 testmode = 0; 1800 testmode = 0;
1801 /* check configuration */ 1801 /* check configuration */
1802 if ( (GNUNET_YES == 1802 if ( (GNUNET_YES ==
1803 GNUNET_CONFIGURATION_have_value (env->cfg, "transport-bluetooth", "TESTMODE")) && 1803 GNUNET_CONFIGURATION_have_value (env->cfg, "transport-bluetooth", "TESTMODE")) &&
1804 ( (GNUNET_SYSERR == 1804 ( (GNUNET_SYSERR ==
1805 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-bluetooth", 1805 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-bluetooth",
@@ -1828,7 +1828,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls)
1828 { 1828 {
1829 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 1829 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
1830 "transport-bluetooth", "INTERFACE"); 1830 "transport-bluetooth", "INTERFACE");
1831 return NULL; 1831 return NULL;
1832 } 1832 }
1833 1833
1834 plugin = GNUNET_malloc (sizeof (struct Plugin)); 1834 plugin = GNUNET_malloc (sizeof (struct Plugin));
@@ -1844,7 +1844,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls)
1844 plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); 1844 plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
1845 plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); 1845 plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
1846 plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); 1846 plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
1847 plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon, 1847 plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon,
1848 plugin); 1848 plugin);
1849 1849
1850 plugin->options = 0; 1850 plugin->options = 0;
@@ -1852,7 +1852,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls)
1852 /* some compilers do not like switch on 'long long'... */ 1852 /* some compilers do not like switch on 'long long'... */
1853 switch ((unsigned int) testmode) 1853 switch ((unsigned int) testmode)
1854 { 1854 {
1855 case 0: /* normal */ 1855 case 0: /* normal */
1856 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-bluetooth"; 1856 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-bluetooth";
1857 plugin->helper_argv[1] = interface; 1857 plugin->helper_argv[1] = interface;
1858 plugin->helper_argv[2] = NULL; 1858 plugin->helper_argv[2] = NULL;
@@ -1899,7 +1899,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls)
1899 api->address_to_string = &bluetooth_plugin_address_to_string;; 1899 api->address_to_string = &bluetooth_plugin_address_to_string;;
1900 api->string_to_address = &bluetooth_string_to_address; 1900 api->string_to_address = &bluetooth_string_to_address;
1901 api->get_network = &bluetooth_get_network; 1901 api->get_network = &bluetooth_get_network;
1902 1902
1903 return api; 1903 return api;
1904} 1904}
1905 1905
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index 637e74063..979978e73 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -216,7 +216,7 @@ http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
216 * @param added length of created address 216 * @param added length of created address
217 * @return GNUNET_OK on success, GNUNET_SYSERR on failure 217 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
218 */ 218 */
219int 219int
220http_string_to_address (void *cls, 220http_string_to_address (void *cls,
221 const char *addr, 221 const char *addr,
222 uint16_t addrlen, 222 uint16_t addrlen,
@@ -363,7 +363,7 @@ lookup_session_old (struct Plugin *plugin, const struct GNUNET_PeerIdentity *tar
363 e_peer = GNUNET_YES; 363 e_peer = GNUNET_YES;
364 if ( (addrlen == t->addrlen) && 364 if ( (addrlen == t->addrlen) &&
365 (0 == memcmp (addr, t->addr, addrlen)) ) 365 (0 == memcmp (addr, t->addr, addrlen)) )
366 e_addr = GNUNET_YES; 366 e_addr = GNUNET_YES;
367 if ( (t == session) && 367 if ( (t == session) &&
368 (t->addrlen == session->addrlen) && 368 (t->addrlen == session->addrlen) &&
369 (0 == memcmp (session->addr, t->addr, t->addrlen)) ) 369 (0 == memcmp (session->addr, t->addr, t->addrlen)) )
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c
index d6db3d22d..79c34c641 100644
--- a/src/transport/plugin_transport_http_client.c
+++ b/src/transport/plugin_transport_http_client.c
@@ -107,17 +107,17 @@ struct Session;
107 107
108/** 108/**
109 * A connection handle 109 * A connection handle
110 * 110 *
111 */ 111 */
112struct ConnectionHandle 112struct ConnectionHandle
113{ 113{
114 /** 114 /**
115 * The curl easy handle 115 * The curl easy handle
116 */ 116 */
117 CURL *easyhandle; 117 CURL *easyhandle;
118 118
119 /** 119 /**
120 * The related session 120 * The related session
121 */ 121 */
122 struct Session *s; 122 struct Session *s;
123}; 123};
@@ -363,7 +363,7 @@ client_schedule (struct HTTP_Client_Plugin *plugin, int now);
363 363
364 364
365/** 365/**
366 * Connect a HTTP put connection 366 * Connect a HTTP put connection
367 * 367 *
368 * @param s the session to connect 368 * @param s the session to connect
369 * @return GNUNET_SYSERR for hard failure, GNUNET_OK for success 369 * @return GNUNET_SYSERR for hard failure, GNUNET_OK for success
@@ -407,7 +407,7 @@ client_exist_session (struct HTTP_Client_Plugin *plugin, struct Session *s)
407 * @return always 0 407 * @return always 0
408 */ 408 */
409static int 409static int
410client_log (CURL *curl, curl_infotype type, 410client_log (CURL *curl, curl_infotype type,
411 const char *data, size_t size, void *cls) 411 const char *data, size_t size, void *cls)
412{ 412{
413 struct ConnectionHandle *ch = cls; 413 struct ConnectionHandle *ch = cls;
@@ -755,7 +755,7 @@ http_client_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *targ
755 755
756/** 756/**
757 * Check if a sessions exists for an specific address 757 * Check if a sessions exists for an specific address
758 * 758 *
759 * @param plugin the plugin 759 * @param plugin the plugin
760 * @param address the address 760 * @param address the address
761 * @return the session or NULL 761 * @return the session or NULL
@@ -946,7 +946,7 @@ client_receive_mst_cb (void *cls, void *client,
946 "Client: peer `%s' address `%s' next read delayed for %s\n", 946 "Client: peer `%s' address `%s' next read delayed for %s\n",
947 GNUNET_i2s (&s->target), 947 GNUNET_i2s (&s->target),
948 http_common_plugin_address_to_string (NULL, 948 http_common_plugin_address_to_string (NULL,
949 s->plugin->protocol, 949 s->plugin->protocol,
950 s->addr, s->addrlen), 950 s->addr, s->addrlen),
951 GNUNET_STRINGS_relative_time_to_string (delay, 951 GNUNET_STRINGS_relative_time_to_string (delay,
952 GNUNET_YES)); 952 GNUNET_YES));
@@ -1002,7 +1002,7 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls)
1002 GNUNET_TIME_absolute_get_difference (now, s->next_receive); 1002 GNUNET_TIME_absolute_get_difference (now, s->next_receive);
1003 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, 1003 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name,
1004 "Session %p / connection %p: No inbound bandwidth available! Next read was delayed for %s\n", 1004 "Session %p / connection %p: No inbound bandwidth available! Next read was delayed for %s\n",
1005 s, s->client_get, 1005 s, s->client_get,
1006 GNUNET_STRINGS_relative_time_to_string (delta, 1006 GNUNET_STRINGS_relative_time_to_string (delta,
1007 GNUNET_YES)); 1007 GNUNET_YES));
1008 if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK) 1008 if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK)
@@ -1231,7 +1231,7 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1231 1231
1232/** 1232/**
1233 * Connect GET connection for a session 1233 * Connect GET connection for a session
1234 * 1234 *
1235 * @param s the session to connect 1235 * @param s the session to connect
1236 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 1236 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
1237 */ 1237 */
@@ -1306,7 +1306,7 @@ client_connect_get (struct Session *s)
1306} 1306}
1307 1307
1308/** 1308/**
1309 * Connect a HTTP put connection 1309 * Connect a HTTP put connection
1310 * 1310 *
1311 * @param s the session to connect 1311 * @param s the session to connect
1312 * @return GNUNET_SYSERR for hard failure, GNUNET_OK for ok 1312 * @return GNUNET_SYSERR for hard failure, GNUNET_OK for ok
@@ -1383,7 +1383,7 @@ client_connect_put (struct Session *s)
1383 1383
1384/** 1384/**
1385 * Connect both PUT and GET connection for a session 1385 * Connect both PUT and GET connection for a session
1386 * 1386 *
1387 * @param s the session to connect 1387 * @param s the session to connect
1388 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 1388 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
1389 */ 1389 */
@@ -1627,7 +1627,7 @@ client_start_session_timeout (struct Session *s)
1627 s); 1627 s);
1628 GNUNET_log (TIMEOUT_LOG, 1628 GNUNET_log (TIMEOUT_LOG,
1629 "Timeout for session %p set to %s\n", 1629 "Timeout for session %p set to %s\n",
1630 s, 1630 s,
1631 GNUNET_STRINGS_relative_time_to_string (CLIENT_SESSION_TIMEOUT, 1631 GNUNET_STRINGS_relative_time_to_string (CLIENT_SESSION_TIMEOUT,
1632 GNUNET_YES)); 1632 GNUNET_YES));
1633} 1633}
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c
index 5695e1d7d..323379d3e 100644
--- a/src/transport/plugin_transport_http_server.c
+++ b/src/transport/plugin_transport_http_server.c
@@ -883,7 +883,7 @@ server_disconnect (struct Session *s)
883 * @param to timeout in seconds 883 * @param to timeout in seconds
884 */ 884 */
885static void 885static void
886server_mhd_connection_timeout (struct HTTP_Server_Plugin *plugin, 886server_mhd_connection_timeout (struct HTTP_Server_Plugin *plugin,
887 struct Session *s, 887 struct Session *s,
888 unsigned int to) 888 unsigned int to)
889{ 889{
@@ -925,7 +925,7 @@ server_mhd_connection_timeout (struct HTTP_Server_Plugin *plugin,
925static int 925static int
926server_parse_url (struct HTTP_Server_Plugin *plugin, 926server_parse_url (struct HTTP_Server_Plugin *plugin,
927 const char *url, 927 const char *url,
928 struct GNUNET_PeerIdentity *target, 928 struct GNUNET_PeerIdentity *target,
929 uint32_t *tag) 929 uint32_t *tag)
930{ 930{
931 char * tag_start = NULL; 931 char * tag_start = NULL;
@@ -1012,7 +1012,7 @@ server_parse_url (struct HTTP_Server_Plugin *plugin,
1012 if (DEBUG_URL_PARSE) GNUNET_break (0); 1012 if (DEBUG_URL_PARSE) GNUNET_break (0);
1013 return GNUNET_SYSERR; 1013 return GNUNET_SYSERR;
1014 } 1014 }
1015 if (GNUNET_OK != 1015 if (GNUNET_OK !=
1016 GNUNET_CRYPTO_ecc_public_sign_key_from_string (target_start, 1016 GNUNET_CRYPTO_ecc_public_sign_key_from_string (target_start,
1017 hash_length, 1017 hash_length,
1018 &target->public_key)) 1018 &target->public_key))
@@ -1021,9 +1021,9 @@ server_parse_url (struct HTTP_Server_Plugin *plugin,
1021 if (DEBUG_URL_PARSE) GNUNET_break (0); 1021 if (DEBUG_URL_PARSE) GNUNET_break (0);
1022 return GNUNET_SYSERR; 1022 return GNUNET_SYSERR;
1023 } 1023 }
1024 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1024 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1025 plugin->name, 1025 plugin->name,
1026 "Found target `%s' in URL\n", 1026 "Found target `%s' in URL\n",
1027 GNUNET_i2s_full (target)); 1027 GNUNET_i2s_full (target));
1028 return GNUNET_OK; 1028 return GNUNET_OK;
1029} 1029}
@@ -1181,7 +1181,7 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin,
1181 if ((NULL == s->server_recv) || (NULL == s->server_send)) 1181 if ((NULL == s->server_recv) || (NULL == s->server_send))
1182 { 1182 {
1183 to = (HTTP_SERVER_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL / 1000LL); 1183 to = (HTTP_SERVER_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL / 1000LL);
1184 MHD_set_connection_option (mhd_connection, 1184 MHD_set_connection_option (mhd_connection,
1185 MHD_CONNECTION_OPTION_TIMEOUT, to); 1185 MHD_CONNECTION_OPTION_TIMEOUT, to);
1186 server_reschedule (plugin, sc->mhd_daemon, GNUNET_NO); 1186 server_reschedule (plugin, sc->mhd_daemon, GNUNET_NO);
1187 } 1187 }
@@ -2902,7 +2902,7 @@ server_session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
2902 s->timeout_task = GNUNET_SCHEDULER_NO_TASK; 2902 s->timeout_task = GNUNET_SCHEDULER_NO_TASK;
2903 GNUNET_log (TIMEOUT_LOG, 2903 GNUNET_log (TIMEOUT_LOG,
2904 "Session %p was idle for %s, disconnecting\n", 2904 "Session %p was idle for %s, disconnecting\n",
2905 s, 2905 s,
2906 GNUNET_STRINGS_relative_time_to_string (SERVER_SESSION_TIMEOUT, 2906 GNUNET_STRINGS_relative_time_to_string (SERVER_SESSION_TIMEOUT,
2907 GNUNET_YES)); 2907 GNUNET_YES));
2908 2908
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 0e49300b0..113cb70c5 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -454,7 +454,7 @@ tcp_address_to_string (void *cls, const void *addr, size_t addrlen);
454static unsigned int sessions; 454static unsigned int sessions;
455 455
456 456
457static void 457static void
458inc_sessions (struct Plugin *plugin, struct Session *session, int line) 458inc_sessions (struct Plugin *plugin, struct Session *session, int line)
459{ 459{
460 sessions++; 460 sessions++;
@@ -471,7 +471,7 @@ inc_sessions (struct Plugin *plugin, struct Session *session, int line)
471} 471}
472 472
473 473
474static void 474static void
475dec_sessions (struct Plugin *plugin, struct Session *session, int line) 475dec_sessions (struct Plugin *plugin, struct Session *session, int line)
476{ 476{
477 GNUNET_assert (sessions > 0); 477 GNUNET_assert (sessions > 0);
@@ -607,7 +607,7 @@ tcp_address_to_string (void *cls, const void *addr, size_t addrlen)
607 memcpy (&a6, &t6->ipv6_addr, sizeof (a6)); 607 memcpy (&a6, &t6->ipv6_addr, sizeof (a6));
608 sb = &a6; 608 sb = &a6;
609 break; 609 break;
610 case sizeof (struct IPv4TcpAddress): 610 case sizeof (struct IPv4TcpAddress):
611 t4 = addr; 611 t4 = addr;
612 af = AF_INET; 612 af = AF_INET;
613 port = ntohs (t4->t4_port); 613 port = ntohs (t4->t4_port);
@@ -724,7 +724,7 @@ tcp_string_to_address (void *cls, const char *addr, uint16_t addrlen,
724 *added = sizeof (struct IPv4TcpAddress); 724 *added = sizeof (struct IPv4TcpAddress);
725 return GNUNET_OK; 725 return GNUNET_OK;
726 } 726 }
727 case AF_INET6: 727 case AF_INET6:
728 { 728 {
729 struct IPv6TcpAddress *t6; 729 struct IPv6TcpAddress *t6;
730 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &socket_address; 730 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &socket_address;
@@ -749,7 +749,7 @@ struct SessionClientCtx
749}; 749};
750 750
751 751
752static int 752static int
753session_lookup_by_client_it (void *cls, 753session_lookup_by_client_it (void *cls,
754 const struct GNUNET_PeerIdentity *key, 754 const struct GNUNET_PeerIdentity *key,
755 void *value) 755 void *value)
@@ -810,7 +810,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
810 else 810 else
811 GNUNET_assert (NULL == client); 811 GNUNET_assert (NULL == client);
812 812
813 LOG (GNUNET_ERROR_TYPE_DEBUG, 813 LOG (GNUNET_ERROR_TYPE_DEBUG,
814 "Creating new session for peer `%4s'\n", 814 "Creating new session for peer `%4s'\n",
815 GNUNET_i2s (target)); 815 GNUNET_i2s (target));
816 session = GNUNET_malloc (sizeof (struct Session)); 816 session = GNUNET_malloc (sizeof (struct Session));
@@ -886,7 +886,7 @@ do_transmit (void *cls, size_t size, void *buf)
886 plugin = session->plugin; 886 plugin = session->plugin;
887 if (NULL == buf) 887 if (NULL == buf)
888 { 888 {
889 LOG (GNUNET_ERROR_TYPE_DEBUG, 889 LOG (GNUNET_ERROR_TYPE_DEBUG,
890 "Timeout trying to transmit to peer `%4s', discarding message queue.\n", 890 "Timeout trying to transmit to peer `%4s', discarding message queue.\n",
891 GNUNET_i2s (&session->target)); 891 GNUNET_i2s (&session->target));
892 /* timeout; cancel all messages that have already expired */ 892 /* timeout; cancel all messages that have already expired */
@@ -940,7 +940,7 @@ do_transmit (void *cls, size_t size, void *buf)
940 GNUNET_CONTAINER_DLL_remove (session->pending_messages_head, 940 GNUNET_CONTAINER_DLL_remove (session->pending_messages_head,
941 session->pending_messages_tail, pos); 941 session->pending_messages_tail, pos);
942 GNUNET_assert (size >= pos->message_size); 942 GNUNET_assert (size >= pos->message_size);
943 LOG (GNUNET_ERROR_TYPE_DEBUG, 943 LOG (GNUNET_ERROR_TYPE_DEBUG,
944 "Transmitting message of type %u\n", 944 "Transmitting message of type %u\n",
945 ntohs (((struct GNUNET_MessageHeader *) pos->msg)->type)); 945 ntohs (((struct GNUNET_MessageHeader *) pos->msg)->type));
946 /* FIXME: this memcpy can be up to 7% of our total runtime */ 946 /* FIXME: this memcpy can be up to 7% of our total runtime */
@@ -1017,7 +1017,7 @@ disconnect_session (struct Session *session)
1017 struct PendingMessage *pm; 1017 struct PendingMessage *pm;
1018 struct Plugin * plugin = session->plugin; 1018 struct Plugin * plugin = session->plugin;
1019 1019
1020 LOG (GNUNET_ERROR_TYPE_DEBUG, 1020 LOG (GNUNET_ERROR_TYPE_DEBUG,
1021 "Disconnecting session of peer `%s' address `%s'\n", 1021 "Disconnecting session of peer `%s' address `%s'\n",
1022 GNUNET_i2s (&session->target), 1022 GNUNET_i2s (&session->target),
1023 tcp_address_to_string (NULL, session->addr, session->addrlen)); 1023 tcp_address_to_string (NULL, session->addr, session->addrlen));
@@ -1050,7 +1050,7 @@ disconnect_session (struct Session *session)
1050 1050
1051 while (NULL != (pm = session->pending_messages_head)) 1051 while (NULL != (pm = session->pending_messages_head))
1052 { 1052 {
1053 LOG (GNUNET_ERROR_TYPE_DEBUG, 1053 LOG (GNUNET_ERROR_TYPE_DEBUG,
1054 pm->transmit_cont != 1054 pm->transmit_cont !=
1055 NULL ? "Could not deliver message to `%4s'.\n" : 1055 NULL ? "Could not deliver message to `%4s'.\n" :
1056 "Could not deliver message to `%4s', notifying.\n", 1056 "Could not deliver message to `%4s', notifying.\n",
@@ -1094,7 +1094,7 @@ struct FindSessionContext
1094}; 1094};
1095 1095
1096 1096
1097static int 1097static int
1098session_it (void *cls, 1098session_it (void *cls,
1099 const struct GNUNET_PeerIdentity * key, 1099 const struct GNUNET_PeerIdentity * key,
1100 void *value) 1100 void *value)
@@ -1190,12 +1190,12 @@ tcp_plugin_send (void *cls,
1190 pm->transmit_cont = cont; 1190 pm->transmit_cont = cont;
1191 pm->transmit_cont_cls = cont_cls; 1191 pm->transmit_cont_cls = cont_cls;
1192 1192
1193 LOG (GNUNET_ERROR_TYPE_DEBUG, 1193 LOG (GNUNET_ERROR_TYPE_DEBUG,
1194 "Asked to transmit %u bytes to `%s', added message to list.\n", 1194 "Asked to transmit %u bytes to `%s', added message to list.\n",
1195 msgbuf_size, GNUNET_i2s (&session->target)); 1195 msgbuf_size, GNUNET_i2s (&session->target));
1196 1196
1197 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains_value (plugin->sessionmap, 1197 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains_value (plugin->sessionmap,
1198 &session->target, 1198 &session->target,
1199 session)) 1199 session))
1200 { 1200 {
1201 GNUNET_assert (session->client != NULL); 1201 GNUNET_assert (session->client != NULL);
@@ -1215,7 +1215,7 @@ tcp_plugin_send (void *cls,
1215 } 1215 }
1216 else if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains_value(plugin->nat_wait_conns, &session->target, session)) 1216 else if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains_value(plugin->nat_wait_conns, &session->target, session))
1217 { 1217 {
1218 LOG (GNUNET_ERROR_TYPE_DEBUG, 1218 LOG (GNUNET_ERROR_TYPE_DEBUG,
1219 "This NAT WAIT session for peer `%s' is not yet ready!\n", 1219 "This NAT WAIT session for peer `%s' is not yet ready!\n",
1220 GNUNET_i2s (&session->target)); 1220 GNUNET_i2s (&session->target));
1221 reschedule_session_timeout (session); 1221 reschedule_session_timeout (session);
@@ -1249,7 +1249,7 @@ struct SessionItCtx
1249}; 1249};
1250 1250
1251 1251
1252static int 1252static int
1253session_lookup_it (void *cls, 1253session_lookup_it (void *cls,
1254 const struct GNUNET_PeerIdentity *key, 1254 const struct GNUNET_PeerIdentity *key,
1255 void *value) 1255 void *value)
@@ -1340,14 +1340,14 @@ tcp_plugin_get_session (void *cls,
1340 GNUNET_assert (plugin != NULL); 1340 GNUNET_assert (plugin != NULL);
1341 GNUNET_assert (address != NULL); 1341 GNUNET_assert (address != NULL);
1342 addrlen = address->address_length; 1342 addrlen = address->address_length;
1343 LOG (GNUNET_ERROR_TYPE_DEBUG, 1343 LOG (GNUNET_ERROR_TYPE_DEBUG,
1344 "Trying to get session for `%s' address of peer `%s'\n", 1344 "Trying to get session for `%s' address of peer `%s'\n",
1345 tcp_address_to_string(NULL, address->address, address->address_length), 1345 tcp_address_to_string(NULL, address->address, address->address_length),
1346 GNUNET_i2s (&address->peer)); 1346 GNUNET_i2s (&address->peer));
1347 1347
1348 /* look for existing session */ 1348 /* look for existing session */
1349 if (GNUNET_YES == 1349 if (GNUNET_YES ==
1350 GNUNET_CONTAINER_multipeermap_contains (plugin->sessionmap, 1350 GNUNET_CONTAINER_multipeermap_contains (plugin->sessionmap,
1351 &address->peer)) 1351 &address->peer))
1352 { 1352 {
1353 struct SessionItCtx si_ctx; 1353 struct SessionItCtx si_ctx;
@@ -1357,8 +1357,8 @@ tcp_plugin_get_session (void *cls,
1357 1357
1358 si_ctx.result = NULL; 1358 si_ctx.result = NULL;
1359 1359
1360 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap, 1360 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap,
1361 &address->peer, 1361 &address->peer,
1362 &session_lookup_it, &si_ctx); 1362 &session_lookup_it, &si_ctx);
1363 if (si_ctx.result != NULL) 1363 if (si_ctx.result != NULL)
1364 { 1364 {
@@ -1447,7 +1447,7 @@ tcp_plugin_get_session (void *cls,
1447 GNUNET_CONTAINER_multipeermap_contains (plugin->nat_wait_conns, 1447 GNUNET_CONTAINER_multipeermap_contains (plugin->nat_wait_conns,
1448 &address->peer))) 1448 &address->peer)))
1449 { 1449 {
1450 LOG (GNUNET_ERROR_TYPE_DEBUG, 1450 LOG (GNUNET_ERROR_TYPE_DEBUG,
1451 "Found valid IPv4 NAT address (creating session)!\n") ; 1451 "Found valid IPv4 NAT address (creating session)!\n") ;
1452 session = create_session (plugin, &address->peer, NULL, GNUNET_YES); 1452 session = create_session (plugin, &address->peer, NULL, GNUNET_YES);
1453 session->addrlen = 0; 1453 session->addrlen = 0;
@@ -1458,12 +1458,12 @@ tcp_plugin_get_session (void *cls,
1458 session); 1458 session);
1459 GNUNET_assert (session != NULL); 1459 GNUNET_assert (session != NULL);
1460 GNUNET_assert (GNUNET_OK == 1460 GNUNET_assert (GNUNET_OK ==
1461 GNUNET_CONTAINER_multipeermap_put (plugin->nat_wait_conns, 1461 GNUNET_CONTAINER_multipeermap_put (plugin->nat_wait_conns,
1462 &session->target, 1462 &session->target,
1463 session, 1463 session,
1464 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 1464 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
1465 1465
1466 LOG (GNUNET_ERROR_TYPE_DEBUG, 1466 LOG (GNUNET_ERROR_TYPE_DEBUG,
1467 "Created NAT WAIT connection to `%4s' at `%s'\n", 1467 "Created NAT WAIT connection to `%4s' at `%s'\n",
1468 GNUNET_i2s (&session->target), GNUNET_a2s (sb, sbs)); 1468 GNUNET_i2s (&session->target), GNUNET_a2s (sb, sbs));
1469 1469
@@ -1471,7 +1471,7 @@ tcp_plugin_get_session (void *cls,
1471 return session; 1471 return session;
1472 else 1472 else
1473 { 1473 {
1474 LOG (GNUNET_ERROR_TYPE_DEBUG, 1474 LOG (GNUNET_ERROR_TYPE_DEBUG,
1475 "Running NAT client for `%4s' at `%s' failed\n", 1475 "Running NAT client for `%4s' at `%s' failed\n",
1476 GNUNET_i2s (&session->target), GNUNET_a2s (sb, sbs)); 1476 GNUNET_i2s (&session->target), GNUNET_a2s (sb, sbs));
1477 disconnect_session (session); 1477 disconnect_session (session);
@@ -1484,7 +1484,7 @@ tcp_plugin_get_session (void *cls,
1484 sa = GNUNET_CONNECTION_create_from_sockaddr (af, sb, sbs); 1484 sa = GNUNET_CONNECTION_create_from_sockaddr (af, sb, sbs);
1485 if (sa == NULL) 1485 if (sa == NULL)
1486 { 1486 {
1487 LOG (GNUNET_ERROR_TYPE_DEBUG, 1487 LOG (GNUNET_ERROR_TYPE_DEBUG,
1488 "Failed to create connection to `%4s' at `%s'\n", 1488 "Failed to create connection to `%4s' at `%s'\n",
1489 GNUNET_i2s (&address->peer), GNUNET_a2s (sb, sbs)); 1489 GNUNET_i2s (&address->peer), GNUNET_a2s (sb, sbs));
1490 return NULL; 1490 return NULL;
@@ -1506,8 +1506,8 @@ tcp_plugin_get_session (void *cls,
1506 session->addrlen = addrlen; 1506 session->addrlen = addrlen;
1507 session->ats_address_network_type = ats.value; 1507 session->ats_address_network_type = ats.value;
1508 1508
1509 GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap, 1509 GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
1510 &session->target, 1510 &session->target,
1511 session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 1511 session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
1512 inc_sessions (plugin, session, __LINE__); 1512 inc_sessions (plugin, session, __LINE__);
1513 LOG (GNUNET_ERROR_TYPE_DEBUG, 1513 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1522,7 +1522,7 @@ tcp_plugin_get_session (void *cls,
1522} 1522}
1523 1523
1524 1524
1525static int 1525static int
1526session_disconnect_it (void *cls, 1526session_disconnect_it (void *cls,
1527 const struct GNUNET_PeerIdentity *key, 1527 const struct GNUNET_PeerIdentity *key,
1528 void *value) 1528 void *value)
@@ -1559,9 +1559,9 @@ tcp_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
1559{ 1559{
1560 struct Plugin *plugin = cls; 1560 struct Plugin *plugin = cls;
1561 1561
1562 LOG (GNUNET_ERROR_TYPE_DEBUG, 1562 LOG (GNUNET_ERROR_TYPE_DEBUG,
1563 "Disconnecting peer `%4s'\n", GNUNET_i2s (target)); 1563 "Disconnecting peer `%4s'\n", GNUNET_i2s (target));
1564 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap, target, 1564 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap, target,
1565 &session_disconnect_it, plugin); 1565 &session_disconnect_it, plugin);
1566 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->nat_wait_conns, target, 1566 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->nat_wait_conns, target,
1567 &session_disconnect_it, plugin); 1567 &session_disconnect_it, plugin);
@@ -1944,12 +1944,12 @@ handle_tcp_nat_probe (void *cls, struct GNUNET_SERVER_Client *client,
1944 clientIdentity); 1944 clientIdentity);
1945 if (session == NULL) 1945 if (session == NULL)
1946 { 1946 {
1947 LOG (GNUNET_ERROR_TYPE_DEBUG, 1947 LOG (GNUNET_ERROR_TYPE_DEBUG,
1948 "Did NOT find session for NAT probe!\n"); 1948 "Did NOT find session for NAT probe!\n");
1949 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1949 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1950 return; 1950 return;
1951 } 1951 }
1952 LOG (GNUNET_ERROR_TYPE_DEBUG, 1952 LOG (GNUNET_ERROR_TYPE_DEBUG,
1953 "Found session for NAT probe!\n"); 1953 "Found session for NAT probe!\n");
1954 1954
1955 if (session->nat_connection_timeout != GNUNET_SCHEDULER_NO_TASK) 1955 if (session->nat_connection_timeout != GNUNET_SCHEDULER_NO_TASK)
@@ -1970,11 +1970,11 @@ handle_tcp_nat_probe (void *cls, struct GNUNET_SERVER_Client *client,
1970 &tcp_nat_probe->clientIdentity, 1970 &tcp_nat_probe->clientIdentity,
1971 session) == GNUNET_YES); 1971 session) == GNUNET_YES);
1972 GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap, 1972 GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
1973 &session->target, session, 1973 &session->target, session,
1974 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 1974 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
1975 session->last_activity = GNUNET_TIME_absolute_get (); 1975 session->last_activity = GNUNET_TIME_absolute_get ();
1976 session->inbound = GNUNET_NO; 1976 session->inbound = GNUNET_NO;
1977 LOG (GNUNET_ERROR_TYPE_DEBUG, 1977 LOG (GNUNET_ERROR_TYPE_DEBUG,
1978 "Found address `%s' for incoming connection\n", 1978 "Found address `%s' for incoming connection\n",
1979 GNUNET_a2s (vaddr, alen)); 1979 GNUNET_a2s (vaddr, alen));
1980 switch (((const struct sockaddr *) vaddr)->sa_family) 1980 switch (((const struct sockaddr *) vaddr)->sa_family)
@@ -1999,7 +1999,7 @@ handle_tcp_nat_probe (void *cls, struct GNUNET_SERVER_Client *client,
1999 break; 1999 break;
2000 default: 2000 default:
2001 GNUNET_break_op (0); 2001 GNUNET_break_op (0);
2002 LOG (GNUNET_ERROR_TYPE_DEBUG, 2002 LOG (GNUNET_ERROR_TYPE_DEBUG,
2003 "Bad address for incoming connection!\n"); 2003 "Bad address for incoming connection!\n");
2004 GNUNET_free (vaddr); 2004 GNUNET_free (vaddr);
2005 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 2005 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -2124,7 +2124,7 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client,
2124 } 2124 }
2125 else 2125 else
2126 { 2126 {
2127 LOG (GNUNET_ERROR_TYPE_DEBUG, 2127 LOG (GNUNET_ERROR_TYPE_DEBUG,
2128 "Did not obtain TCP socket address for incoming connection\n"); 2128 "Did not obtain TCP socket address for incoming connection\n");
2129 GNUNET_break (0); 2129 GNUNET_break (0);
2130 } 2130 }
@@ -2207,9 +2207,9 @@ handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client,
2207 /* No inbound session found */ 2207 /* No inbound session found */
2208 void *vaddr; 2208 void *vaddr;
2209 size_t alen; 2209 size_t alen;
2210 2210
2211 GNUNET_SERVER_client_get_address (client, &vaddr, &alen); 2211 GNUNET_SERVER_client_get_address (client, &vaddr, &alen);
2212 LOG (GNUNET_ERROR_TYPE_ERROR, 2212 LOG (GNUNET_ERROR_TYPE_ERROR,
2213 "Received unexpected %u bytes of type %u from `%s'\n", 2213 "Received unexpected %u bytes of type %u from `%s'\n",
2214 (unsigned int) ntohs (message->size), 2214 (unsigned int) ntohs (message->size),
2215 (unsigned int) ntohs (message->type), 2215 (unsigned int) ntohs (message->type),
@@ -2226,7 +2226,7 @@ handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client,
2226 size_t alen; 2226 size_t alen;
2227 2227
2228 GNUNET_SERVER_client_get_address (client, &vaddr, &alen); 2228 GNUNET_SERVER_client_get_address (client, &vaddr, &alen);
2229 LOG (GNUNET_ERROR_TYPE_ERROR, 2229 LOG (GNUNET_ERROR_TYPE_ERROR,
2230 "Received unexpected %u bytes of type %u from `%s'\n", 2230 "Received unexpected %u bytes of type %u from `%s'\n",
2231 (unsigned int) ntohs (message->size), 2231 (unsigned int) ntohs (message->size),
2232 (unsigned int) ntohs (message->type), 2232 (unsigned int) ntohs (message->type),
@@ -2238,7 +2238,7 @@ handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client,
2238 } 2238 }
2239 2239
2240 session->last_activity = GNUNET_TIME_absolute_get (); 2240 session->last_activity = GNUNET_TIME_absolute_get ();
2241 LOG (GNUNET_ERROR_TYPE_DEBUG, 2241 LOG (GNUNET_ERROR_TYPE_DEBUG,
2242 "Passing %u bytes of type %u from `%4s' to transport service.\n", 2242 "Passing %u bytes of type %u from `%4s' to transport service.\n",
2243 (unsigned int) ntohs (message->size), 2243 (unsigned int) ntohs (message->size),
2244 (unsigned int) ntohs (message->type), 2244 (unsigned int) ntohs (message->type),
@@ -2277,7 +2277,7 @@ handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client,
2277 } 2277 }
2278 else 2278 else
2279 { 2279 {
2280 LOG (GNUNET_ERROR_TYPE_DEBUG, 2280 LOG (GNUNET_ERROR_TYPE_DEBUG,
2281 "Throttling receiving from `%s' for %s\n", 2281 "Throttling receiving from `%s' for %s\n",
2282 GNUNET_i2s (&session->target), 2282 GNUNET_i2s (&session->target),
2283 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); 2283 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
@@ -2450,7 +2450,7 @@ start_session_timeout (struct Session *s)
2450 s); 2450 s);
2451 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2451 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2452 "Timeout for session %p set to %s\n", 2452 "Timeout for session %p set to %s\n",
2453 s, 2453 s,
2454 GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2454 GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
2455 GNUNET_YES)); 2455 GNUNET_YES));
2456} 2456}
@@ -2471,7 +2471,7 @@ reschedule_session_timeout (struct Session *s)
2471 s); 2471 s);
2472 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2472 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2473 "Timeout rescheduled for session %p set to %s\n", 2473 "Timeout rescheduled for session %p set to %s\n",
2474 s, 2474 s,
2475 GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2475 GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
2476 GNUNET_YES)); 2476 GNUNET_YES));
2477} 2477}
@@ -2571,7 +2571,7 @@ libgnunet_plugin_transport_tcp_init (void *cls)
2571 "ADVERTISED-PORT", &aport)) && 2571 "ADVERTISED-PORT", &aport)) &&
2572 (aport > 65535))) 2572 (aport > 65535)))
2573 { 2573 {
2574 LOG (GNUNET_ERROR_TYPE_ERROR, 2574 LOG (GNUNET_ERROR_TYPE_ERROR,
2575 _ 2575 _
2576 ("Require valid port number for service `%s' in configuration!\n"), 2576 ("Require valid port number for service `%s' in configuration!\n"),
2577 "transport-tcp"); 2577 "transport-tcp");
@@ -2613,7 +2613,7 @@ libgnunet_plugin_transport_tcp_init (void *cls)
2613 { 2613 {
2614 for (ret = ret_s-1; ret >= 0; ret--) 2614 for (ret = ret_s-1; ret >= 0; ret--)
2615 LOG (GNUNET_ERROR_TYPE_INFO, 2615 LOG (GNUNET_ERROR_TYPE_INFO,
2616 "Binding to address `%s'\n", 2616 "Binding to address `%s'\n",
2617 GNUNET_a2s (addrs[ret], addrlens[ret])); 2617 GNUNET_a2s (addrs[ret], addrlens[ret]));
2618 plugin->nat = 2618 plugin->nat =
2619 GNUNET_NAT_register (env->cfg, GNUNET_YES, aport, (unsigned int) ret_s, 2619 GNUNET_NAT_register (env->cfg, GNUNET_YES, aport, (unsigned int) ret_s,
@@ -2679,14 +2679,14 @@ libgnunet_plugin_transport_tcp_init (void *cls)
2679 GNUNET_SERVER_disconnect_notify (plugin->server, &disconnect_notify, plugin); 2679 GNUNET_SERVER_disconnect_notify (plugin->server, &disconnect_notify, plugin);
2680 plugin->nat_wait_conns = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); 2680 plugin->nat_wait_conns = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES);
2681 if (bport != 0) 2681 if (bport != 0)
2682 LOG (GNUNET_ERROR_TYPE_INFO, 2682 LOG (GNUNET_ERROR_TYPE_INFO,
2683 _("TCP transport listening on port %llu\n"), bport); 2683 _("TCP transport listening on port %llu\n"), bport);
2684 else 2684 else
2685 LOG (GNUNET_ERROR_TYPE_INFO, 2685 LOG (GNUNET_ERROR_TYPE_INFO,
2686 _ 2686 _
2687 ("TCP transport not listening on any port (client only)\n")); 2687 ("TCP transport not listening on any port (client only)\n"));
2688 if (aport != bport) 2688 if (aport != bport)
2689 LOG (GNUNET_ERROR_TYPE_INFO, 2689 LOG (GNUNET_ERROR_TYPE_INFO,
2690 _ 2690 _
2691 ("TCP transport advertises itself as being on port %llu\n"), 2691 ("TCP transport advertises itself as being on port %llu\n"),
2692 aport); 2692 aport);
diff --git a/src/transport/plugin_transport_template.c b/src/transport/plugin_transport_template.c
index faee0c38d..dedc8e857 100644
--- a/src/transport/plugin_transport_template.c
+++ b/src/transport/plugin_transport_template.c
@@ -212,7 +212,7 @@ template_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
212 * @return the network type in HBO or GNUNET_SYSERR 212 * @return the network type in HBO or GNUNET_SYSERR
213 */ 213 */
214static enum GNUNET_ATS_Network_Type 214static enum GNUNET_ATS_Network_Type
215template_plugin_get_network (void *cls, 215template_plugin_get_network (void *cls,
216 struct Session *session) 216 struct Session *session)
217{ 217{
218 GNUNET_assert (NULL != session); 218 GNUNET_assert (NULL != session);
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index 4fe4d94cf..6327d744f 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -82,7 +82,7 @@ struct PrettyPrinterContext
82 * DLL 82 * DLL
83 */ 83 */
84 struct PrettyPrinterContext *next; 84 struct PrettyPrinterContext *next;
85 85
86 /** 86 /**
87 * DLL 87 * DLL
88 */ 88 */
@@ -502,7 +502,7 @@ schedule_select (struct Plugin *plugin)
502 for (udpw = plugin->ipv4_queue_head; NULL != udpw; udpw = udpw->next) 502 for (udpw = plugin->ipv4_queue_head; NULL != udpw; udpw = udpw->next)
503 min_delay = GNUNET_TIME_relative_min (min_delay, 503 min_delay = GNUNET_TIME_relative_min (min_delay,
504 GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer)); 504 GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer));
505 505
506 if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) 506 if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK)
507 GNUNET_SCHEDULER_cancel(plugin->select_task); 507 GNUNET_SCHEDULER_cancel(plugin->select_task);
508 508
@@ -514,7 +514,7 @@ schedule_select (struct Plugin *plugin)
514 (0 == min_delay.rel_value_us) ? GNUNET_TIME_UNIT_FOREVER_REL : min_delay, 514 (0 == min_delay.rel_value_us) ? GNUNET_TIME_UNIT_FOREVER_REL : min_delay,
515 plugin->rs_v4, 515 plugin->rs_v4,
516 (0 == min_delay.rel_value_us) ? plugin->ws_v4 : NULL, 516 (0 == min_delay.rel_value_us) ? plugin->ws_v4 : NULL,
517 &udp_plugin_select, plugin); 517 &udp_plugin_select, plugin);
518 } 518 }
519 if ((GNUNET_YES == plugin->enable_ipv6) && (NULL != plugin->sockv6)) 519 if ((GNUNET_YES == plugin->enable_ipv6) && (NULL != plugin->sockv6))
520 { 520 {
@@ -522,7 +522,7 @@ schedule_select (struct Plugin *plugin)
522 for (udpw = plugin->ipv6_queue_head; NULL != udpw; udpw = udpw->next) 522 for (udpw = plugin->ipv6_queue_head; NULL != udpw; udpw = udpw->next)
523 min_delay = GNUNET_TIME_relative_min (min_delay, 523 min_delay = GNUNET_TIME_relative_min (min_delay,
524 GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer)); 524 GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer));
525 525
526 if (GNUNET_SCHEDULER_NO_TASK != plugin->select_task_v6) 526 if (GNUNET_SCHEDULER_NO_TASK != plugin->select_task_v6)
527 GNUNET_SCHEDULER_cancel(plugin->select_task_v6); 527 GNUNET_SCHEDULER_cancel(plugin->select_task_v6);
528 plugin->select_task_v6 = 528 plugin->select_task_v6 =
@@ -589,7 +589,7 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen)
589 } 589 }
590 inet_ntop (af, sb, buf, INET6_ADDRSTRLEN); 590 inet_ntop (af, sb, buf, INET6_ADDRSTRLEN);
591 591
592 GNUNET_snprintf (rbuf, sizeof (rbuf), 592 GNUNET_snprintf (rbuf, sizeof (rbuf),
593 (af == AF_INET6) ? "%s.%u.[%s]:%u" : "%s.%u.%s:%u", 593 (af == AF_INET6) ? "%s.%u.[%s]:%u" : "%s.%u.%s:%u",
594 PLUGIN_NAME, options, buf, port); 594 PLUGIN_NAME, options, buf, port);
595 return rbuf; 595 return rbuf;
@@ -1150,11 +1150,11 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result)
1150 struct UDP_MessageWrapper dummy; 1150 struct UDP_MessageWrapper dummy;
1151 struct Session *s = fc->session; 1151 struct Session *s = fc->session;
1152 1152
1153 LOG (GNUNET_ERROR_TYPE_DEBUG, 1153 LOG (GNUNET_ERROR_TYPE_DEBUG,
1154 "%p : Fragmented message removed with result %s\n", 1154 "%p : Fragmented message removed with result %s\n",
1155 fc, 1155 fc,
1156 (result == GNUNET_SYSERR) ? "FAIL" : "SUCCESS"); 1156 (result == GNUNET_SYSERR) ? "FAIL" : "SUCCESS");
1157 1157
1158 /* Call continuation for fragmented message */ 1158 /* Call continuation for fragmented message */
1159 memset (&dummy, 0, sizeof (dummy)); 1159 memset (&dummy, 0, sizeof (dummy));
1160 dummy.msg_type = MSG_FRAGMENTED_COMPLETE; 1160 dummy.msg_type = MSG_FRAGMENTED_COMPLETE;
@@ -1376,7 +1376,7 @@ reschedule_session_timeout (struct Session *s)
1376 s); 1376 s);
1377 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1377 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1378 "Timeout rescheduled for session %p set to %s\n", 1378 "Timeout rescheduled for session %p set to %s\n",
1379 s, 1379 s,
1380 GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 1380 GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
1381 GNUNET_YES)); 1381 GNUNET_YES));
1382} 1382}
@@ -1478,7 +1478,7 @@ session_cmp_it (void *cls,
1478 1478
1479 LOG (GNUNET_ERROR_TYPE_DEBUG, 1479 LOG (GNUNET_ERROR_TYPE_DEBUG,
1480 "Comparing address %s <-> %s\n", 1480 "Comparing address %s <-> %s\n",
1481 udp_address_to_string (NULL, (void *) address->address, 1481 udp_address_to_string (NULL, (void *) address->address,
1482 address->address_length), 1482 address->address_length),
1483 GNUNET_a2s (s->sock_addr, s->addrlen)); 1483 GNUNET_a2s (s->sock_addr, s->addrlen));
1484 if (s->inbound != cctx->inbound) 1484 if (s->inbound != cctx->inbound)
@@ -1524,7 +1524,7 @@ session_cmp_it (void *cls,
1524 * @return the network type in HBO or GNUNET_SYSERR 1524 * @return the network type in HBO or GNUNET_SYSERR
1525 */ 1525 */
1526static enum GNUNET_ATS_Network_Type 1526static enum GNUNET_ATS_Network_Type
1527udp_get_network (void *cls, 1527udp_get_network (void *cls,
1528 struct Session *session) 1528 struct Session *session)
1529{ 1529{
1530 return ntohl (session->ats.value); 1530 return ntohl (session->ats.value);
@@ -1589,8 +1589,8 @@ udp_plugin_lookup_session (void *cls,
1589 cctx.res = NULL; 1589 cctx.res = NULL;
1590 cctx.inbound = inbound; 1590 cctx.inbound = inbound;
1591 LOG (GNUNET_ERROR_TYPE_DEBUG, 1591 LOG (GNUNET_ERROR_TYPE_DEBUG,
1592 "Looking for existing session for peer `%s' `%s' \n", 1592 "Looking for existing session for peer `%s' `%s' \n",
1593 GNUNET_i2s (&address->peer), 1593 GNUNET_i2s (&address->peer),
1594 udp_address_to_string(NULL, address->address, address->address_length)); 1594 udp_address_to_string(NULL, address->address, address->address_length));
1595 GNUNET_CONTAINER_multipeermap_get_multiple(plugin->sessions, &address->peer, session_cmp_it, &cctx); 1595 GNUNET_CONTAINER_multipeermap_get_multiple(plugin->sessions, &address->peer, session_cmp_it, &cctx);
1596 if (cctx.res != NULL) 1596 if (cctx.res != NULL)
@@ -1666,7 +1666,7 @@ udp_plugin_get_session (void *cls,
1666} 1666}
1667 1667
1668 1668
1669static void 1669static void
1670enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) 1670enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw)
1671{ 1671{
1672 if (plugin->bytes_in_buffer + udpw->msg_size > INT64_MAX) 1672 if (plugin->bytes_in_buffer + udpw->msg_size > INT64_MAX)
@@ -1708,7 +1708,7 @@ send_next_fragment (void *cls,
1708{ 1708{
1709 struct UDP_MessageWrapper *udpw = cls; 1709 struct UDP_MessageWrapper *udpw = cls;
1710 1710
1711 GNUNET_FRAGMENT_context_transmission_done (udpw->frag_ctx->frag); 1711 GNUNET_FRAGMENT_context_transmission_done (udpw->frag_ctx->frag);
1712} 1712}
1713 1713
1714 1714
@@ -1728,8 +1728,8 @@ enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg)
1728 struct Plugin *plugin = frag_ctx->plugin; 1728 struct Plugin *plugin = frag_ctx->plugin;
1729 struct UDP_MessageWrapper * udpw; 1729 struct UDP_MessageWrapper * udpw;
1730 size_t msg_len = ntohs (msg->size); 1730 size_t msg_len = ntohs (msg->size);
1731 1731
1732 LOG (GNUNET_ERROR_TYPE_DEBUG, 1732 LOG (GNUNET_ERROR_TYPE_DEBUG,
1733 "Enqueuing fragment with %u bytes\n", msg_len); 1733 "Enqueuing fragment with %u bytes\n", msg_len);
1734 frag_ctx->fragments_used ++; 1734 frag_ctx->fragments_used ++;
1735 udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msg_len); 1735 udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msg_len);
@@ -1862,11 +1862,11 @@ udp_plugin_send (void *cls,
1862 frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, 1862 frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats,
1863 UDP_MTU, 1863 UDP_MTU,
1864 &plugin->tracker, 1864 &plugin->tracker,
1865 s->last_expected_msg_delay, 1865 s->last_expected_msg_delay,
1866 s->last_expected_ack_delay, 1866 s->last_expected_ack_delay,
1867 &udp->header, 1867 &udp->header,
1868 &enqueue_fragment, 1868 &enqueue_fragment,
1869 frag_ctx); 1869 frag_ctx);
1870 s->frag_ctx = frag_ctx; 1870 s->frag_ctx = frag_ctx;
1871 GNUNET_STATISTICS_update (plugin->env->stats, 1871 GNUNET_STATISTICS_update (plugin->env->stats,
1872 "# UDP, fragmented msgs, messages, pending", 1872 "# UDP, fragmented msgs, messages, pending",
@@ -2138,8 +2138,8 @@ struct LookupContext
2138 2138
2139 2139
2140static int 2140static int
2141lookup_session_by_addr_it (void *cls, 2141lookup_session_by_addr_it (void *cls,
2142 const struct GNUNET_PeerIdentity *key, 2142 const struct GNUNET_PeerIdentity *key,
2143 void *value) 2143 void *value)
2144{ 2144{
2145 struct LookupContext *l_ctx = cls; 2145 struct LookupContext *l_ctx = cls;
@@ -2223,7 +2223,7 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg)
2223} 2223}
2224 2224
2225 2225
2226static void 2226static void
2227read_process_msg (struct Plugin *plugin, 2227read_process_msg (struct Plugin *plugin,
2228 const struct GNUNET_MessageHeader *msg, 2228 const struct GNUNET_MessageHeader *msg,
2229 const char *addr, 2229 const char *addr,
@@ -2239,7 +2239,7 @@ read_process_msg (struct Plugin *plugin,
2239} 2239}
2240 2240
2241 2241
2242static void 2242static void
2243read_process_ack (struct Plugin *plugin, 2243read_process_ack (struct Plugin *plugin,
2244 const struct GNUNET_MessageHeader *msg, 2244 const struct GNUNET_MessageHeader *msg,
2245 char *addr, 2245 char *addr,
@@ -2273,7 +2273,7 @@ read_process_ack (struct Plugin *plugin,
2273 2273
2274 2274
2275 flow_delay.rel_value_us = (uint64_t) ntohl (udp_ack->delay); 2275 flow_delay.rel_value_us = (uint64_t) ntohl (udp_ack->delay);
2276 LOG (GNUNET_ERROR_TYPE_DEBUG, 2276 LOG (GNUNET_ERROR_TYPE_DEBUG,
2277 "We received a sending delay of %s\n", 2277 "We received a sending delay of %s\n",
2278 GNUNET_STRINGS_relative_time_to_string (flow_delay, 2278 GNUNET_STRINGS_relative_time_to_string (flow_delay,
2279 GNUNET_YES)); 2279 GNUNET_YES));
@@ -2310,7 +2310,7 @@ read_process_ack (struct Plugin *plugin,
2310} 2310}
2311 2311
2312 2312
2313static void 2313static void
2314read_process_fragment (struct Plugin *plugin, 2314read_process_fragment (struct Plugin *plugin,
2315 const struct GNUNET_MessageHeader *msg, 2315 const struct GNUNET_MessageHeader *msg,
2316 char *addr, 2316 char *addr,
@@ -2350,7 +2350,7 @@ read_process_fragment (struct Plugin *plugin,
2350 GNUNET_CONTAINER_heap_insert (plugin->defrag_ctxs, d_ctx, 2350 GNUNET_CONTAINER_heap_insert (plugin->defrag_ctxs, d_ctx,
2351 (GNUNET_CONTAINER_HeapCostType) 2351 (GNUNET_CONTAINER_HeapCostType)
2352 now.abs_value_us); 2352 now.abs_value_us);
2353 LOG (GNUNET_ERROR_TYPE_DEBUG, 2353 LOG (GNUNET_ERROR_TYPE_DEBUG,
2354 "Created new defragmentation context for %u-byte fragment from `%s'\n", 2354 "Created new defragmentation context for %u-byte fragment from `%s'\n",
2355 (unsigned int) ntohs (msg->size), 2355 (unsigned int) ntohs (msg->size),
2356 GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); 2356 GNUNET_a2s ((const struct sockaddr *) addr, fromlen));
@@ -2571,7 +2571,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head,
2571 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == remaining.rel_value_us) 2571 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == remaining.rel_value_us)
2572 { 2572 {
2573 /* this message is not delayed */ 2573 /* this message is not delayed */
2574 LOG (GNUNET_ERROR_TYPE_DEBUG, 2574 LOG (GNUNET_ERROR_TYPE_DEBUG,
2575 "Message for peer `%s' (%u bytes) is not delayed \n", 2575 "Message for peer `%s' (%u bytes) is not delayed \n",
2576 GNUNET_i2s(&udpw->session->target), udpw->payload_size); 2576 GNUNET_i2s(&udpw->session->target), udpw->payload_size);
2577 break; /* Found message to send, break */ 2577 break; /* Found message to send, break */
@@ -2581,7 +2581,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head,
2581 /* Message is delayed, try next */ 2581 /* Message is delayed, try next */
2582 LOG (GNUNET_ERROR_TYPE_DEBUG, 2582 LOG (GNUNET_ERROR_TYPE_DEBUG,
2583 "Message for peer `%s' (%u bytes) is delayed for %s\n", 2583 "Message for peer `%s' (%u bytes) is delayed for %s\n",
2584 GNUNET_i2s(&udpw->session->target), udpw->payload_size, 2584 GNUNET_i2s(&udpw->session->target), udpw->payload_size,
2585 GNUNET_STRINGS_relative_time_to_string (remaining, 2585 GNUNET_STRINGS_relative_time_to_string (remaining,
2586 GNUNET_YES)); 2586 GNUNET_YES));
2587 udpw = udpw->next; 2587 udpw = udpw->next;
@@ -2719,10 +2719,10 @@ udp_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2719 (GNUNET_NETWORK_fdset_isset (tc->read_ready, plugin->sockv4)) ) 2719 (GNUNET_NETWORK_fdset_isset (tc->read_ready, plugin->sockv4)) )
2720 udp_select_read (plugin, plugin->sockv4); 2720 udp_select_read (plugin, plugin->sockv4);
2721 if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) && 2721 if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) &&
2722 (NULL != plugin->sockv4) && 2722 (NULL != plugin->sockv4) &&
2723 (NULL != plugin->ipv4_queue_head) && 2723 (NULL != plugin->ipv4_queue_head) &&
2724 (GNUNET_NETWORK_fdset_isset (tc->write_ready, plugin->sockv4)) ) 2724 (GNUNET_NETWORK_fdset_isset (tc->write_ready, plugin->sockv4)) )
2725 udp_select_send (plugin, plugin->sockv4); 2725 udp_select_send (plugin, plugin->sockv4);
2726 schedule_select (plugin); 2726 schedule_select (plugin);
2727} 2727}
2728 2728
@@ -2749,7 +2749,7 @@ udp_plugin_select_v6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2749 udp_select_read (plugin, plugin->sockv6); 2749 udp_select_read (plugin, plugin->sockv6);
2750 if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) && 2750 if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) &&
2751 (NULL != plugin->sockv6) && (plugin->ipv6_queue_head != NULL) && 2751 (NULL != plugin->sockv6) && (plugin->ipv6_queue_head != NULL) &&
2752 (GNUNET_NETWORK_fdset_isset (tc->write_ready, plugin->sockv6)) ) 2752 (GNUNET_NETWORK_fdset_isset (tc->write_ready, plugin->sockv6)) )
2753 udp_select_send (plugin, plugin->sockv6); 2753 udp_select_send (plugin, plugin->sockv6);
2754 schedule_select (plugin); 2754 schedule_select (plugin);
2755} 2755}
@@ -2760,7 +2760,7 @@ udp_plugin_select_v6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2760 * @return number of sockets that were successfully bound 2760 * @return number of sockets that were successfully bound
2761 */ 2761 */
2762static int 2762static int
2763setup_sockets (struct Plugin *plugin, 2763setup_sockets (struct Plugin *plugin,
2764 const struct sockaddr_in6 *bind_v6, 2764 const struct sockaddr_in6 *bind_v6,
2765 const struct sockaddr_in *bind_v4) 2765 const struct sockaddr_in *bind_v4)
2766{ 2766{
@@ -2869,23 +2869,23 @@ setup_sockets (struct Plugin *plugin,
2869 serverAddrv4.sin_addr = bind_v4->sin_addr; 2869 serverAddrv4.sin_addr = bind_v4->sin_addr;
2870 else 2870 else
2871 serverAddrv4.sin_addr.s_addr = INADDR_ANY; 2871 serverAddrv4.sin_addr.s_addr = INADDR_ANY;
2872 2872
2873 if (0 == plugin->port) 2873 if (0 == plugin->port)
2874 /* autodetect */ 2874 /* autodetect */
2875 serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); 2875 serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000);
2876 else 2876 else
2877 serverAddrv4.sin_port = htons (plugin->port); 2877 serverAddrv4.sin_port = htons (plugin->port);
2878 2878
2879 2879
2880 addrlen = sizeof (struct sockaddr_in); 2880 addrlen = sizeof (struct sockaddr_in);
2881 serverAddr = (struct sockaddr *) &serverAddrv4; 2881 serverAddr = (struct sockaddr *) &serverAddrv4;
2882 2882
2883 tries = 0; 2883 tries = 0;
2884 while (tries < 10) 2884 while (tries < 10)
2885 { 2885 {
2886 LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 `%s'\n", 2886 LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 `%s'\n",
2887 GNUNET_a2s (serverAddr, addrlen)); 2887 GNUNET_a2s (serverAddr, addrlen));
2888 2888
2889 /* binding */ 2889 /* binding */
2890 if (GNUNET_OK == GNUNET_NETWORK_socket_bind (plugin->sockv4, 2890 if (GNUNET_OK == GNUNET_NETWORK_socket_bind (plugin->sockv4,
2891 serverAddr, addrlen, 0)) 2891 serverAddr, addrlen, 0))
@@ -2896,19 +2896,19 @@ setup_sockets (struct Plugin *plugin,
2896 tries = 10; /* fail */ 2896 tries = 10; /* fail */
2897 break; /* bind failed on specific port */ 2897 break; /* bind failed on specific port */
2898 } 2898 }
2899 2899
2900 /* autodetect */ 2900 /* autodetect */
2901 serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); 2901 serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000);
2902 tries ++; 2902 tries ++;
2903 } 2903 }
2904 2904
2905 if (tries >= 10) 2905 if (tries >= 10)
2906 { 2906 {
2907 GNUNET_NETWORK_socket_close (plugin->sockv4); 2907 GNUNET_NETWORK_socket_close (plugin->sockv4);
2908 plugin->enable_ipv4 = GNUNET_NO; 2908 plugin->enable_ipv4 = GNUNET_NO;
2909 plugin->sockv4 = NULL; 2909 plugin->sockv4 = NULL;
2910 } 2910 }
2911 2911
2912 if (plugin->sockv4 != NULL) 2912 if (plugin->sockv4 != NULL)
2913 { 2913 {
2914 LOG (GNUNET_ERROR_TYPE_DEBUG, 2914 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2918,13 +2918,13 @@ setup_sockets (struct Plugin *plugin,
2918 sockets_created++; 2918 sockets_created++;
2919 } 2919 }
2920 else 2920 else
2921 { 2921 {
2922 LOG (GNUNET_ERROR_TYPE_ERROR, 2922 LOG (GNUNET_ERROR_TYPE_ERROR,
2923 "Failed to bind UDP socket to %s: %s\n", 2923 "Failed to bind UDP socket to %s: %s\n",
2924 GNUNET_a2s (serverAddr, addrlen), STRERROR (eno)); 2924 GNUNET_a2s (serverAddr, addrlen), STRERROR (eno));
2925 } 2925 }
2926 } 2926 }
2927 2927
2928 if (0 == sockets_created) 2928 if (0 == sockets_created)
2929 { 2929 {
2930 LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to open UDP sockets\n")); 2930 LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to open UDP sockets\n"));
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index 4e153aab4..f5ab3a694 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -452,7 +452,7 @@ struct LookupCtx
452 * @param value a session 452 * @param value a session
453 * @return GNUNET_YES if not found (continue looking), GNUNET_NO on success 453 * @return GNUNET_YES if not found (continue looking), GNUNET_NO on success
454 */ 454 */
455static int 455static int
456lookup_session_it (void *cls, 456lookup_session_it (void *cls,
457 const struct GNUNET_PeerIdentity * key, 457 const struct GNUNET_PeerIdentity * key,
458 void *value) 458 void *value)
@@ -486,8 +486,8 @@ lookup_session_it (void *cls,
486 * @return NULL if session was not found 486 * @return NULL if session was not found
487 */ 487 */
488static struct Session * 488static struct Session *
489lookup_session (struct Plugin *plugin, 489lookup_session (struct Plugin *plugin,
490 const struct GNUNET_PeerIdentity *sender, 490 const struct GNUNET_PeerIdentity *sender,
491 const struct UnixAddress *ua, size_t ua_len) 491 const struct UnixAddress *ua, size_t ua_len)
492{ 492{
493 struct LookupCtx lctx; 493 struct LookupCtx lctx;
@@ -498,7 +498,7 @@ lookup_session (struct Plugin *plugin,
498 lctx.s = NULL; 498 lctx.s = NULL;
499 lctx.ua = ua; 499 lctx.ua = ua;
500 lctx.ua_len = ua_len; 500 lctx.ua_len = ua_len;
501 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, 501 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map,
502 sender, 502 sender,
503 &lookup_session_it, &lctx); 503 &lookup_session_it, &lctx);
504 return lctx.s; 504 return lctx.s;
@@ -520,9 +520,9 @@ disconnect_session (struct Session *s)
520 struct UNIXMessageWrapper *next; 520 struct UNIXMessageWrapper *next;
521 int removed; 521 int removed;
522 522
523 LOG (GNUNET_ERROR_TYPE_DEBUG, 523 LOG (GNUNET_ERROR_TYPE_DEBUG,
524 "Disconnecting session for peer `%s' `%s'\n", 524 "Disconnecting session for peer `%s' `%s'\n",
525 GNUNET_i2s (&s->target), 525 GNUNET_i2s (&s->target),
526 s->addr); 526 s->addr);
527 plugin->env->session_end (plugin->env->cls, &s->target, s); 527 plugin->env->session_end (plugin->env->cls, &s->target, s);
528 removed = GNUNET_NO; 528 removed = GNUNET_NO;
@@ -539,11 +539,11 @@ disconnect_session (struct Session *s)
539 msgw->payload, 0); 539 msgw->payload, 0);
540 GNUNET_free (msgw->msg); 540 GNUNET_free (msgw->msg);
541 GNUNET_free (msgw); 541 GNUNET_free (msgw);
542 removed = GNUNET_YES; 542 removed = GNUNET_YES;
543 } 543 }
544 GNUNET_assert (GNUNET_YES == 544 GNUNET_assert (GNUNET_YES ==
545 GNUNET_CONTAINER_multipeermap_remove (plugin->session_map, 545 GNUNET_CONTAINER_multipeermap_remove (plugin->session_map,
546 &s->target, 546 &s->target,
547 s)); 547 s));
548 GNUNET_STATISTICS_set (plugin->env->stats, 548 GNUNET_STATISTICS_set (plugin->env->stats,
549 "# UNIX sessions active", 549 "# UNIX sessions active",
@@ -671,7 +671,7 @@ resend:
671 671
672 LOG (GNUNET_ERROR_TYPE_DEBUG, 672 LOG (GNUNET_ERROR_TYPE_DEBUG,
673 "UNIX transmit %u-byte message to %s (%d: %s)\n", 673 "UNIX transmit %u-byte message to %s (%d: %s)\n",
674 (unsigned int) msgbuf_size, 674 (unsigned int) msgbuf_size,
675 GNUNET_a2s ((const struct sockaddr *)un, un_len), 675 GNUNET_a2s ((const struct sockaddr *)un, un_len),
676 (int) sent, 676 (int) sent,
677 (sent < 0) ? STRERROR (errno) : "ok"); 677 (sent < 0) ? STRERROR (errno) : "ok");
@@ -684,7 +684,7 @@ resend:
684 * Closure for 'get_session_it'. 684 * Closure for 'get_session_it'.
685 */ 685 */
686struct GetSessionIteratorContext 686struct GetSessionIteratorContext
687{ 687{
688 /** 688 /**
689 * Location to store the session, if found. 689 * Location to store the session, if found.
690 */ 690 */
@@ -711,8 +711,8 @@ struct GetSessionIteratorContext
711 * @return GNUNET_YES if not found (continue looking), GNUNET_NO on success 711 * @return GNUNET_YES if not found (continue looking), GNUNET_NO on success
712 */ 712 */
713static int 713static int
714get_session_it (void *cls, 714get_session_it (void *cls,
715 const struct GNUNET_PeerIdentity *key, 715 const struct GNUNET_PeerIdentity *key,
716 void *value) 716 void *value)
717{ 717{
718 struct GetSessionIteratorContext *gsi = cls; 718 struct GetSessionIteratorContext *gsi = cls;
@@ -735,11 +735,11 @@ get_session_it (void *cls,
735 * @param tc scheduler context 735 * @param tc scheduler context
736 */ 736 */
737static void 737static void
738session_timeout (void *cls, 738session_timeout (void *cls,
739 const struct GNUNET_SCHEDULER_TaskContext *tc) 739 const struct GNUNET_SCHEDULER_TaskContext *tc)
740{ 740{
741 struct Session *s = cls; 741 struct Session *s = cls;
742 742
743 s->timeout_task = GNUNET_SCHEDULER_NO_TASK; 743 s->timeout_task = GNUNET_SCHEDULER_NO_TASK;
744 LOG (GNUNET_ERROR_TYPE_DEBUG, 744 LOG (GNUNET_ERROR_TYPE_DEBUG,
745 "Session %p was idle for %s, disconnecting\n", 745 "Session %p was idle for %s, disconnecting\n",
@@ -758,7 +758,7 @@ session_timeout (void *cls,
758 * @return the network type in HBO or GNUNET_SYSERR 758 * @return the network type in HBO or GNUNET_SYSERR
759 */ 759 */
760static enum GNUNET_ATS_Network_Type 760static enum GNUNET_ATS_Network_Type
761unix_get_network (void *cls, 761unix_get_network (void *cls,
762 struct Session *session) 762 struct Session *session)
763{ 763{
764 GNUNET_assert (NULL != session); 764 GNUNET_assert (NULL != session);
@@ -818,12 +818,12 @@ unix_plugin_get_session (void *cls,
818 gsi.address = (const char *) address->address; 818 gsi.address = (const char *) address->address;
819 gsi.addrlen = address->address_length; 819 gsi.addrlen = address->address_length;
820 gsi.res = NULL; 820 gsi.res = NULL;
821 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, 821 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map,
822 &address->peer, 822 &address->peer,
823 &get_session_it, &gsi); 823 &get_session_it, &gsi);
824 if (NULL != gsi.res) 824 if (NULL != gsi.res)
825 { 825 {
826 LOG (GNUNET_ERROR_TYPE_DEBUG, 826 LOG (GNUNET_ERROR_TYPE_DEBUG,
827 "Found existing session\n"); 827 "Found existing session\n");
828 return gsi.res; 828 return gsi.res;
829 } 829 }
@@ -893,23 +893,23 @@ unix_plugin_send (void *cls,
893 struct UNIXMessageWrapper *wrapper; 893 struct UNIXMessageWrapper *wrapper;
894 struct UNIXMessage *message; 894 struct UNIXMessage *message;
895 int ssize; 895 int ssize;
896 896
897 GNUNET_assert (NULL != plugin); 897 GNUNET_assert (NULL != plugin);
898 GNUNET_assert (NULL != session); 898 GNUNET_assert (NULL != session);
899 899
900 if (GNUNET_OK != 900 if (GNUNET_OK !=
901 GNUNET_CONTAINER_multipeermap_contains_value (plugin->session_map, 901 GNUNET_CONTAINER_multipeermap_contains_value (plugin->session_map,
902 &session->target, 902 &session->target,
903 session)) 903 session))
904 { 904 {
905 LOG (GNUNET_ERROR_TYPE_ERROR, 905 LOG (GNUNET_ERROR_TYPE_ERROR,
906 "Invalid session for peer `%s' `%s'\n", 906 "Invalid session for peer `%s' `%s'\n",
907 GNUNET_i2s (&session->target), 907 GNUNET_i2s (&session->target),
908 (const char *) session->addr); 908 (const char *) session->addr);
909 GNUNET_break (0); 909 GNUNET_break (0);
910 return GNUNET_SYSERR; 910 return GNUNET_SYSERR;
911 } 911 }
912 LOG (GNUNET_ERROR_TYPE_DEBUG, 912 LOG (GNUNET_ERROR_TYPE_DEBUG,
913 "Sending %u bytes with session for peer `%s' `%s'\n", 913 "Sending %u bytes with session for peer `%s' `%s'\n",
914 msgbuf_size, 914 msgbuf_size,
915 GNUNET_i2s (&session->target), 915 GNUNET_i2s (&session->target),
@@ -931,13 +931,13 @@ unix_plugin_send (void *cls,
931 wrapper->cont = cont; 931 wrapper->cont = cont;
932 wrapper->cont_cls = cont_cls; 932 wrapper->cont_cls = cont_cls;
933 wrapper->session = session; 933 wrapper->session = session;
934 GNUNET_CONTAINER_DLL_insert (plugin->msg_head, 934 GNUNET_CONTAINER_DLL_insert (plugin->msg_head,
935 plugin->msg_tail, 935 plugin->msg_tail,
936 wrapper); 936 wrapper);
937 plugin->bytes_in_queue += ssize; 937 plugin->bytes_in_queue += ssize;
938 GNUNET_STATISTICS_set (plugin->env->stats, 938 GNUNET_STATISTICS_set (plugin->env->stats,
939 "# bytes currently in UNIX buffers", 939 "# bytes currently in UNIX buffers",
940 plugin->bytes_in_queue, 940 plugin->bytes_in_queue,
941 GNUNET_NO); 941 GNUNET_NO);
942 if (GNUNET_NO == plugin->with_ws) 942 if (GNUNET_NO == plugin->with_ws)
943 reschedule_select (plugin); 943 reschedule_select (plugin);
@@ -1101,25 +1101,25 @@ unix_plugin_select_write (struct Plugin *plugin)
1101 break; /* Message is ready for sending */ 1101 break; /* Message is ready for sending */
1102 /* Message has a timeout */ 1102 /* Message has a timeout */
1103 LOG (GNUNET_ERROR_TYPE_DEBUG, 1103 LOG (GNUNET_ERROR_TYPE_DEBUG,
1104 "Timeout for message with %u bytes \n", 1104 "Timeout for message with %u bytes \n",
1105 (unsigned int) msgw->msgsize); 1105 (unsigned int) msgw->msgsize);
1106 GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw); 1106 GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw);
1107 plugin->bytes_in_queue -= msgw->msgsize; 1107 plugin->bytes_in_queue -= msgw->msgsize;
1108 GNUNET_STATISTICS_set (plugin->env->stats, 1108 GNUNET_STATISTICS_set (plugin->env->stats,
1109 "# bytes currently in UNIX buffers", 1109 "# bytes currently in UNIX buffers",
1110 plugin->bytes_in_queue, GNUNET_NO); 1110 plugin->bytes_in_queue, GNUNET_NO);
1111 GNUNET_STATISTICS_update (plugin->env->stats, 1111 GNUNET_STATISTICS_update (plugin->env->stats,
1112 "# UNIX bytes discarded", 1112 "# UNIX bytes discarded",
1113 msgw->msgsize, 1113 msgw->msgsize,
1114 GNUNET_NO); 1114 GNUNET_NO);
1115 if (NULL != msgw->cont) 1115 if (NULL != msgw->cont)
1116 msgw->cont (msgw->cont_cls, 1116 msgw->cont (msgw->cont_cls,
1117 &msgw->session->target, 1117 &msgw->session->target,
1118 GNUNET_SYSERR, 1118 GNUNET_SYSERR,
1119 msgw->payload, 1119 msgw->payload,
1120 0); 1120 0);
1121 GNUNET_free (msgw->msg); 1121 GNUNET_free (msgw->msg);
1122 GNUNET_free (msgw); 1122 GNUNET_free (msgw);
1123 } 1123 }
1124 if (NULL == msgw) 1124 if (NULL == msgw)
1125 return; /* Nothing to send at the moment */ 1125 return; /* Nothing to send at the moment */
@@ -1153,7 +1153,7 @@ unix_plugin_select_write (struct Plugin *plugin)
1153 1153
1154 GNUNET_assert (plugin->bytes_in_queue >= msgw->msgsize); 1154 GNUNET_assert (plugin->bytes_in_queue >= msgw->msgsize);
1155 plugin->bytes_in_queue -= msgw->msgsize; 1155 plugin->bytes_in_queue -= msgw->msgsize;
1156 GNUNET_STATISTICS_set (plugin->env->stats, 1156 GNUNET_STATISTICS_set (plugin->env->stats,
1157 "# bytes currently in UNIX buffers", 1157 "# bytes currently in UNIX buffers",
1158 plugin->bytes_in_queue, GNUNET_NO); 1158 plugin->bytes_in_queue, GNUNET_NO);
1159 GNUNET_STATISTICS_update (plugin->env->stats, 1159 GNUNET_STATISTICS_update (plugin->env->stats,
@@ -1167,9 +1167,9 @@ unix_plugin_select_write (struct Plugin *plugin)
1167 } 1167 }
1168 /* successfully sent bytes */ 1168 /* successfully sent bytes */
1169 GNUNET_break (sent > 0); 1169 GNUNET_break (sent > 0);
1170 GNUNET_CONTAINER_DLL_remove (plugin->msg_head, 1170 GNUNET_CONTAINER_DLL_remove (plugin->msg_head,
1171 plugin->msg_tail, 1171 plugin->msg_tail,
1172 msgw); 1172 msgw);
1173 GNUNET_assert (plugin->bytes_in_queue >= msgw->msgsize); 1173 GNUNET_assert (plugin->bytes_in_queue >= msgw->msgsize);
1174 plugin->bytes_in_queue -= msgw->msgsize; 1174 plugin->bytes_in_queue -= msgw->msgsize;
1175 GNUNET_STATISTICS_set (plugin->env->stats, 1175 GNUNET_STATISTICS_set (plugin->env->stats,
@@ -1179,12 +1179,12 @@ unix_plugin_select_write (struct Plugin *plugin)
1179 GNUNET_STATISTICS_update (plugin->env->stats, 1179 GNUNET_STATISTICS_update (plugin->env->stats,
1180 "# bytes transmitted via UNIX", 1180 "# bytes transmitted via UNIX",
1181 msgw->msgsize, 1181 msgw->msgsize,
1182 GNUNET_NO); 1182 GNUNET_NO);
1183 if (NULL != msgw->cont) 1183 if (NULL != msgw->cont)
1184 msgw->cont (msgw->cont_cls, &msgw->session->target, 1184 msgw->cont (msgw->cont_cls, &msgw->session->target,
1185 GNUNET_OK, 1185 GNUNET_OK,
1186 msgw->payload, 1186 msgw->payload,
1187 msgw->msgsize); 1187 msgw->msgsize);
1188 GNUNET_free (msgw->msg); 1188 GNUNET_free (msgw->msg);
1189 GNUNET_free (msgw); 1189 GNUNET_free (msgw);
1190} 1190}
@@ -1553,8 +1553,8 @@ reschedule_session_timeout (struct Session *s)
1553 * @return GNUNET_YES (always, continue to iterate) 1553 * @return GNUNET_YES (always, continue to iterate)
1554 */ 1554 */
1555static int 1555static int
1556get_session_delete_it (void *cls, 1556get_session_delete_it (void *cls,
1557 const struct GNUNET_PeerIdentity *key, 1557 const struct GNUNET_PeerIdentity *key,
1558 void *value) 1558 void *value)
1559{ 1559{
1560 struct Session *s = value; 1560 struct Session *s = value;
@@ -1572,14 +1572,14 @@ get_session_delete_it (void *cls,
1572 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the operation failed 1572 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the operation failed
1573 */ 1573 */
1574static void 1574static void
1575unix_disconnect (void *cls, 1575unix_disconnect (void *cls,
1576 const struct GNUNET_PeerIdentity *target) 1576 const struct GNUNET_PeerIdentity *target)
1577{ 1577{
1578 struct Plugin *plugin = cls; 1578 struct Plugin *plugin = cls;
1579 1579
1580 GNUNET_assert (plugin != NULL); 1580 GNUNET_assert (plugin != NULL);
1581 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, 1581 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map,
1582 target, 1582 target,
1583 &get_session_delete_it, plugin); 1583 &get_session_delete_it, plugin);
1584} 1584}
1585 1585
@@ -1618,7 +1618,7 @@ libgnunet_plugin_transport_unix_init (void *cls)
1618 plugin = GNUNET_malloc (sizeof (struct Plugin)); 1618 plugin = GNUNET_malloc (sizeof (struct Plugin));
1619 plugin->port = port; 1619 plugin->port = port;
1620 plugin->env = env; 1620 plugin->env = env;
1621 GNUNET_asprintf (&plugin->unix_socket_path, 1621 GNUNET_asprintf (&plugin->unix_socket_path,
1622 "/tmp/unix-plugin-sock.%d", 1622 "/tmp/unix-plugin-sock.%d",
1623 plugin->port); 1623 plugin->port);
1624 1624
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index ec0947648..932d3b762 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -75,7 +75,7 @@ GNUNET_NETWORK_STRUCT_BEGIN
75/** 75/**
76 * Header for messages which need fragmentation. This is the format of 76 * Header for messages which need fragmentation. This is the format of
77 * a message we obtain AFTER defragmentation. We then need to check 77 * a message we obtain AFTER defragmentation. We then need to check
78 * the CRC and then tokenize the payload and pass it to the 78 * the CRC and then tokenize the payload and pass it to the
79 * 'receive' callback. 79 * 'receive' callback.
80 */ 80 */
81struct WlanHeader 81struct WlanHeader
@@ -398,7 +398,7 @@ struct Plugin
398 398
399 /** 399 /**
400 * Handle to helper process for priviledged operations. 400 * Handle to helper process for priviledged operations.
401 */ 401 */
402 struct GNUNET_HELPER_Handle *suid_helper; 402 struct GNUNET_HELPER_Handle *suid_helper;
403 403
404 /** 404 /**
@@ -560,7 +560,7 @@ get_radiotap_header (struct MacEndpoint *endpoint,
560static void 560static void
561get_wlan_header (struct Plugin *plugin, 561get_wlan_header (struct Plugin *plugin,
562 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *header, 562 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *header,
563 const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, 563 const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr,
564 unsigned int size) 564 unsigned int size)
565{ 565{
566 const int rate = 11000000; 566 const int rate = 11000000;
@@ -606,12 +606,12 @@ send_ack (void *cls, uint32_t msg_id,
606 GNUNET_break (0); 606 GNUNET_break (0);
607 return; 607 return;
608 } 608 }
609 LOG (GNUNET_ERROR_TYPE_DEBUG, 609 LOG (GNUNET_ERROR_TYPE_DEBUG,
610 "Sending ACK to helper\n"); 610 "Sending ACK to helper\n");
611 radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf; 611 radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf;
612 get_radiotap_header (endpoint, radio_header, size); 612 get_radiotap_header (endpoint, radio_header, size);
613 get_wlan_header (endpoint->plugin, 613 get_wlan_header (endpoint->plugin,
614 &radio_header->frame, 614 &radio_header->frame,
615 &endpoint->addr.mac, 615 &endpoint->addr.mac,
616 size); 616 size);
617 memcpy (&radio_header[1], hdr, msize); 617 memcpy (&radio_header[1], hdr, msize);
@@ -619,7 +619,7 @@ send_ack (void *cls, uint32_t msg_id,
619 GNUNET_HELPER_send (endpoint->plugin->suid_helper, 619 GNUNET_HELPER_send (endpoint->plugin->suid_helper,
620 &radio_header->header, 620 &radio_header->header,
621 GNUNET_NO /* dropping ACKs is bad */, 621 GNUNET_NO /* dropping ACKs is bad */,
622 NULL, NULL)) 622 NULL, NULL))
623 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN ACKs sent"), 623 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN ACKs sent"),
624 1, GNUNET_NO); 624 1, GNUNET_NO);
625} 625}
@@ -643,7 +643,7 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
643 GNUNET_NO); 643 GNUNET_NO);
644 mas.session = NULL; 644 mas.session = NULL;
645 mas.endpoint = endpoint; 645 mas.endpoint = endpoint;
646 (void) GNUNET_SERVER_mst_receive (plugin->fragment_data_tokenizer, 646 (void) GNUNET_SERVER_mst_receive (plugin->fragment_data_tokenizer,
647 &mas, 647 &mas,
648 (const char *) hdr, 648 (const char *) hdr,
649 ntohs (hdr->size), 649 ntohs (hdr->size),
@@ -661,7 +661,7 @@ free_session (struct Session *session)
661{ 661{
662 struct MacEndpoint *endpoint = session->mac; 662 struct MacEndpoint *endpoint = session->mac;
663 struct PendingMessage *pm; 663 struct PendingMessage *pm;
664 664
665 endpoint->plugin->env->session_end (endpoint->plugin->env->cls, 665 endpoint->plugin->env->session_end (endpoint->plugin->env->cls,
666 &session->target, 666 &session->target,
667 session); 667 session);
@@ -677,7 +677,7 @@ free_session (struct Session *session)
677 GNUNET_free (pm->msg); 677 GNUNET_free (pm->msg);
678 GNUNET_free (pm); 678 GNUNET_free (pm);
679 } 679 }
680 GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, 680 GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head,
681 endpoint->sessions_tail, 681 endpoint->sessions_tail,
682 session); 682 session);
683 if (session->timeout_task != GNUNET_SCHEDULER_NO_TASK) 683 if (session->timeout_task != GNUNET_SCHEDULER_NO_TASK)
@@ -705,7 +705,7 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
705 705
706 session->timeout_task = GNUNET_SCHEDULER_NO_TASK; 706 session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
707 timeout = GNUNET_TIME_absolute_get_remaining (session->timeout); 707 timeout = GNUNET_TIME_absolute_get_remaining (session->timeout);
708 if (0 == timeout.rel_value_us) 708 if (0 == timeout.rel_value_us)
709 { 709 {
710 free_session (session); 710 free_session (session);
711 return; 711 return;
@@ -800,7 +800,7 @@ get_session (struct MacEndpoint *endpoint,
800 * message to the SUID helper process and we are thus ready for 800 * message to the SUID helper process and we are thus ready for
801 * the next fragment. 801 * the next fragment.
802 * 802 *
803 * @param cls the 'struct FragmentMessage' 803 * @param cls the 'struct FragmentMessage'
804 * @param result result of the operation (GNUNET_OK on success, GNUNET_NO if the helper died, GNUNET_SYSERR 804 * @param result result of the operation (GNUNET_OK on success, GNUNET_NO if the helper died, GNUNET_SYSERR
805 * if the helper was stopped) 805 * if the helper was stopped)
806 */ 806 */
@@ -820,7 +820,7 @@ fragment_transmission_done (void *cls,
820 * Transmit a fragment of a message. 820 * Transmit a fragment of a message.
821 * 821 *
822 * @param cls 'struct FragmentMessage' this fragment message belongs to 822 * @param cls 'struct FragmentMessage' this fragment message belongs to
823 * @param hdr pointer to the start of the fragment message 823 * @param hdr pointer to the start of the fragment message
824 */ 824 */
825static void 825static void
826transmit_fragment (void *cls, 826transmit_fragment (void *cls,
@@ -846,7 +846,7 @@ transmit_fragment (void *cls,
846 radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf; 846 radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf;
847 get_radiotap_header (endpoint, radio_header, size); 847 get_radiotap_header (endpoint, radio_header, size);
848 get_wlan_header (endpoint->plugin, 848 get_wlan_header (endpoint->plugin,
849 &radio_header->frame, 849 &radio_header->frame,
850 &endpoint->addr.mac, 850 &endpoint->addr.mac,
851 size); 851 size);
852 memcpy (&radio_header[1], hdr, msize); 852 memcpy (&radio_header[1], hdr, msize);
@@ -881,7 +881,7 @@ free_fragment_message (struct FragmentMessage *fm)
881{ 881{
882 struct MacEndpoint *endpoint = fm->macendpoint; 882 struct MacEndpoint *endpoint = fm->macendpoint;
883 883
884 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN messages pending (with fragmentation)"), 884 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN messages pending (with fragmentation)"),
885 -1, GNUNET_NO); 885 -1, GNUNET_NO);
886 GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head, 886 GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head,
887 endpoint->sending_messages_tail, fm); 887 endpoint->sending_messages_tail, fm);
@@ -941,7 +941,7 @@ fragmentmessage_timeout (void *cls,
941static void 941static void
942send_with_fragmentation (struct MacEndpoint *endpoint, 942send_with_fragmentation (struct MacEndpoint *endpoint,
943 struct GNUNET_TIME_Relative timeout, 943 struct GNUNET_TIME_Relative timeout,
944 const struct GNUNET_PeerIdentity *target, 944 const struct GNUNET_PeerIdentity *target,
945 const struct GNUNET_MessageHeader *msg, 945 const struct GNUNET_MessageHeader *msg,
946 size_t payload_size, 946 size_t payload_size,
947 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) 947 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
@@ -968,7 +968,7 @@ send_with_fragmentation (struct MacEndpoint *endpoint,
968 msg, 968 msg,
969 &transmit_fragment, fm); 969 &transmit_fragment, fm);
970 fm->timeout_task = 970 fm->timeout_task =
971 GNUNET_SCHEDULER_add_delayed (timeout, 971 GNUNET_SCHEDULER_add_delayed (timeout,
972 &fragmentmessage_timeout, fm); 972 &fragmentmessage_timeout, fm);
973 GNUNET_CONTAINER_DLL_insert_tail (endpoint->sending_messages_head, 973 GNUNET_CONTAINER_DLL_insert_tail (endpoint->sending_messages_head,
974 endpoint->sending_messages_tail, 974 endpoint->sending_messages_tail,
@@ -978,7 +978,7 @@ send_with_fragmentation (struct MacEndpoint *endpoint,
978 978
979/** 979/**
980 * Free a MAC endpoint. 980 * Free a MAC endpoint.
981 * 981 *
982 * @param endpoint pointer to the MacEndpoint to free 982 * @param endpoint pointer to the MacEndpoint to free
983 */ 983 */
984static void 984static void
@@ -994,8 +994,8 @@ free_macendpoint (struct MacEndpoint *endpoint)
994 free_session (session); 994 free_session (session);
995 while (NULL != (fm = endpoint->sending_messages_head)) 995 while (NULL != (fm = endpoint->sending_messages_head))
996 free_fragment_message (fm); 996 free_fragment_message (fm);
997 GNUNET_CONTAINER_DLL_remove (plugin->mac_head, 997 GNUNET_CONTAINER_DLL_remove (plugin->mac_head,
998 plugin->mac_tail, 998 plugin->mac_tail,
999 endpoint); 999 endpoint);
1000 1000
1001 if (NULL != endpoint->defrag) 1001 if (NULL != endpoint->defrag)
@@ -1028,7 +1028,7 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1028 1028
1029 endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK; 1029 endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK;
1030 timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout); 1030 timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout);
1031 if (0 == timeout.rel_value_us) 1031 if (0 == timeout.rel_value_us)
1032 { 1032 {
1033 free_macendpoint (endpoint); 1033 free_macendpoint (endpoint);
1034 return; 1034 return;
@@ -1054,14 +1054,14 @@ create_macendpoint (struct Plugin *plugin,
1054 1054
1055 for (pos = plugin->mac_head; NULL != pos; pos = pos->next) 1055 for (pos = plugin->mac_head; NULL != pos; pos = pos->next)
1056 if (0 == memcmp (addr, &pos->addr, sizeof (struct WlanAddress))) 1056 if (0 == memcmp (addr, &pos->addr, sizeof (struct WlanAddress)))
1057 return pos; 1057 return pos;
1058 pos = GNUNET_malloc (sizeof (struct MacEndpoint)); 1058 pos = GNUNET_malloc (sizeof (struct MacEndpoint));
1059 pos->addr = *addr; 1059 pos->addr = *addr;
1060 pos->plugin = plugin; 1060 pos->plugin = plugin;
1061 pos->defrag = 1061 pos->defrag =
1062 GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU, 1062 GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU,
1063 MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, 1063 MESSAGES_IN_DEFRAG_QUEUE_PER_MAC,
1064 pos, 1064 pos,
1065 &wlan_data_message_handler, 1065 &wlan_data_message_handler,
1066 &send_ack); 1066 &send_ack);
1067 1067
@@ -1076,7 +1076,7 @@ create_macendpoint (struct Plugin *plugin,
1076 plugin->mac_count++; 1076 plugin->mac_count++;
1077 GNUNET_STATISTICS_update (plugin->env->stats, _("# WLAN MAC endpoints allocated"), 1077 GNUNET_STATISTICS_update (plugin->env->stats, _("# WLAN MAC endpoints allocated"),
1078 1, GNUNET_NO); 1078 1, GNUNET_NO);
1079 LOG (GNUNET_ERROR_TYPE_DEBUG, 1079 LOG (GNUNET_ERROR_TYPE_DEBUG,
1080 "New MAC endpoint `%s'\n", 1080 "New MAC endpoint `%s'\n",
1081 wlan_plugin_address_to_string(NULL, addr, sizeof (struct WlanAddress))); 1081 wlan_plugin_address_to_string(NULL, addr, sizeof (struct WlanAddress)));
1082 return pos; 1082 return pos;
@@ -1091,7 +1091,7 @@ create_macendpoint (struct Plugin *plugin,
1091 * @return the network type in HBO or GNUNET_SYSERR 1091 * @return the network type in HBO or GNUNET_SYSERR
1092 */ 1092 */
1093static enum GNUNET_ATS_Network_Type 1093static enum GNUNET_ATS_Network_Type
1094wlan_get_network (void *cls, 1094wlan_get_network (void *cls,
1095 struct Session *session) 1095 struct Session *session)
1096{ 1096{
1097 GNUNET_assert (NULL != session); 1097 GNUNET_assert (NULL != session);
@@ -1196,7 +1196,7 @@ wlan_plugin_send (void *cls,
1196 size_t size = msgbuf_size + sizeof (struct WlanHeader); 1196 size_t size = msgbuf_size + sizeof (struct WlanHeader);
1197 char buf[size] GNUNET_ALIGN; 1197 char buf[size] GNUNET_ALIGN;
1198 1198
1199 LOG (GNUNET_ERROR_TYPE_DEBUG, 1199 LOG (GNUNET_ERROR_TYPE_DEBUG,
1200 "Transmitting %u bytes of payload to peer `%s' (starting with %u byte message of type %u)\n", 1200 "Transmitting %u bytes of payload to peer `%s' (starting with %u byte message of type %u)\n",
1201 msgbuf_size, 1201 msgbuf_size,
1202 GNUNET_i2s (&session->target), 1202 GNUNET_i2s (&session->target),
@@ -1256,7 +1256,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1256 switch (ntohs (hdr->type)) 1256 switch (ntohs (hdr->type))
1257 { 1257 {
1258 case GNUNET_MESSAGE_TYPE_HELLO: 1258 case GNUNET_MESSAGE_TYPE_HELLO:
1259 if (GNUNET_OK != 1259 if (GNUNET_OK !=
1260 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource)) 1260 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource))
1261 { 1261 {
1262 GNUNET_break_op (0); 1262 GNUNET_break_op (0);
@@ -1271,9 +1271,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1271 GNUNET_STATISTICS_update (plugin->env->stats, 1271 GNUNET_STATISTICS_update (plugin->env->stats,
1272 _("# HELLO messages received via WLAN"), 1, 1272 _("# HELLO messages received via WLAN"), 1,
1273 GNUNET_NO); 1273 GNUNET_NO);
1274 plugin->env->receive (plugin->env->cls, 1274 plugin->env->receive (plugin->env->cls,
1275 &tmpsource, 1275 &tmpsource,
1276 hdr, 1276 hdr,
1277 mas->session, 1277 mas->session,
1278 (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, 1278 (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr,
1279 (mas->endpoint == NULL) ? 0 : sizeof (struct WlanAddress)); 1279 (mas->endpoint == NULL) ? 0 : sizeof (struct WlanAddress));
@@ -1290,7 +1290,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1290 GNUNET_break (0); 1290 GNUNET_break (0);
1291 break; 1291 break;
1292 } 1292 }
1293 LOG (GNUNET_ERROR_TYPE_DEBUG, 1293 LOG (GNUNET_ERROR_TYPE_DEBUG,
1294 "Processing %u bytes of FRAGMENT from MAC %s\n", 1294 "Processing %u bytes of FRAGMENT from MAC %s\n",
1295 (unsigned int) msize, 1295 (unsigned int) msize,
1296 wlan_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); 1296 wlan_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)));
@@ -1312,7 +1312,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1312 ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr); 1312 ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr);
1313 if (GNUNET_OK == ret) 1313 if (GNUNET_OK == ret)
1314 { 1314 {
1315 LOG (GNUNET_ERROR_TYPE_DEBUG, 1315 LOG (GNUNET_ERROR_TYPE_DEBUG,
1316 "Got last ACK, finished message transmission to `%s' (%p)\n", 1316 "Got last ACK, finished message transmission to `%s' (%p)\n",
1317 wlan_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)), 1317 wlan_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)),
1318 fm); 1318 fm);
@@ -1327,13 +1327,13 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1327 } 1327 }
1328 if (GNUNET_NO == ret) 1328 if (GNUNET_NO == ret)
1329 { 1329 {
1330 LOG (GNUNET_ERROR_TYPE_DEBUG, 1330 LOG (GNUNET_ERROR_TYPE_DEBUG,
1331 "Got an ACK, message transmission to `%s' not yet finished\n", 1331 "Got an ACK, message transmission to `%s' not yet finished\n",
1332 wlan_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); 1332 wlan_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)));
1333 break; 1333 break;
1334 } 1334 }
1335 } 1335 }
1336 LOG (GNUNET_ERROR_TYPE_DEBUG, 1336 LOG (GNUNET_ERROR_TYPE_DEBUG,
1337 "ACK not matched against any active fragmentation with MAC `%s'\n", 1337 "ACK not matched against any active fragmentation with MAC `%s'\n",
1338 wlan_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); 1338 wlan_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)));
1339 break; 1339 break;
@@ -1347,13 +1347,13 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1347 { 1347 {
1348 GNUNET_break (0); 1348 GNUNET_break (0);
1349 break; 1349 break;
1350 } 1350 }
1351 wlanheader = (const struct WlanHeader *) hdr; 1351 wlanheader = (const struct WlanHeader *) hdr;
1352 if (0 != memcmp (&wlanheader->target, 1352 if (0 != memcmp (&wlanheader->target,
1353 plugin->env->my_identity, 1353 plugin->env->my_identity,
1354 sizeof (struct GNUNET_PeerIdentity))) 1354 sizeof (struct GNUNET_PeerIdentity)))
1355 { 1355 {
1356 LOG (GNUNET_ERROR_TYPE_DEBUG, 1356 LOG (GNUNET_ERROR_TYPE_DEBUG,
1357 "WLAN data for `%s', not for me, ignoring\n", 1357 "WLAN data for `%s', not for me, ignoring\n",
1358 GNUNET_i2s (&wlanheader->target)); 1358 GNUNET_i2s (&wlanheader->target));
1359 break; 1359 break;
@@ -1380,11 +1380,11 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1380 "Processing %u bytes of WLAN DATA from peer `%s'\n", 1380 "Processing %u bytes of WLAN DATA from peer `%s'\n",
1381 (unsigned int) msize, 1381 (unsigned int) msize,
1382 GNUNET_i2s (&wlanheader->sender)); 1382 GNUNET_i2s (&wlanheader->sender));
1383 (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer, 1383 (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer,
1384 &xmas, 1384 &xmas,
1385 (const char *) &wlanheader[1], 1385 (const char *) &wlanheader[1],
1386 msize - sizeof (struct WlanHeader), 1386 msize - sizeof (struct WlanHeader),
1387 GNUNET_YES, GNUNET_NO); 1387 GNUNET_YES, GNUNET_NO);
1388 break; 1388 break;
1389 default: 1389 default:
1390 if (NULL == mas->endpoint) 1390 if (NULL == mas->endpoint)
@@ -1402,9 +1402,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1402 (unsigned int) msize, 1402 (unsigned int) msize,
1403 (unsigned int) ntohs (hdr->type), 1403 (unsigned int) ntohs (hdr->type),
1404 GNUNET_i2s (&mas->session->target)); 1404 GNUNET_i2s (&mas->session->target));
1405 plugin->env->receive (plugin->env->cls, 1405 plugin->env->receive (plugin->env->cls,
1406 &mas->session->target, 1406 &mas->session->target,
1407 hdr, 1407 hdr,
1408 mas->session, 1408 mas->session,
1409 (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, 1409 (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr,
1410 (mas->endpoint == NULL) ? 0 : sizeof (struct WlanAddress)); 1410 (mas->endpoint == NULL) ? 0 : sizeof (struct WlanAddress));
@@ -1478,7 +1478,7 @@ handle_helper_message (void *cls, void *client,
1478 "wlan"); 1478 "wlan");
1479 break; 1479 break;
1480 case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER: 1480 case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER:
1481 LOG (GNUNET_ERROR_TYPE_DEBUG, 1481 LOG (GNUNET_ERROR_TYPE_DEBUG,
1482 "Got data message from helper with %u bytes\n", 1482 "Got data message from helper with %u bytes\n",
1483 msize); 1483 msize);
1484 GNUNET_STATISTICS_update (plugin->env->stats, 1484 GNUNET_STATISTICS_update (plugin->env->stats,
@@ -1515,7 +1515,7 @@ handle_helper_message (void *cls, void *client,
1515 /* packet is FROM us, thus not FOR us */ 1515 /* packet is FROM us, thus not FOR us */
1516 break; 1516 break;
1517 } 1517 }
1518 1518
1519 GNUNET_STATISTICS_update (plugin->env->stats, 1519 GNUNET_STATISTICS_update (plugin->env->stats,
1520 _("# WLAN DATA messages processed"), 1520 _("# WLAN DATA messages processed"),
1521 1, GNUNET_NO); 1521 1, GNUNET_NO);
@@ -1527,7 +1527,7 @@ handle_helper_message (void *cls, void *client,
1527 wa.options = htonl (0); 1527 wa.options = htonl (0);
1528 mas.endpoint = create_macendpoint (plugin, &wa); 1528 mas.endpoint = create_macendpoint (plugin, &wa);
1529 mas.session = NULL; 1529 mas.session = NULL;
1530 (void) GNUNET_SERVER_mst_receive (plugin->helper_payload_tokenizer, 1530 (void) GNUNET_SERVER_mst_receive (plugin->helper_payload_tokenizer,
1531 &mas, 1531 &mas,
1532 (const char*) &rxinfo[1], 1532 (const char*) &rxinfo[1],
1533 msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage), 1533 msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage),
@@ -1535,7 +1535,7 @@ handle_helper_message (void *cls, void *client,
1535 break; 1535 break;
1536 default: 1536 default:
1537 GNUNET_break (0); 1537 GNUNET_break (0);
1538 LOG (GNUNET_ERROR_TYPE_DEBUG, 1538 LOG (GNUNET_ERROR_TYPE_DEBUG,
1539 "Unexpected message of type %u (%u bytes)", 1539 "Unexpected message of type %u (%u bytes)",
1540 ntohs (hdr->type), ntohs (hdr->size)); 1540 ntohs (hdr->type), ntohs (hdr->size));
1541 break; 1541 break;
@@ -1568,7 +1568,7 @@ send_hello_beacon (void *cls,
1568 { 1568 {
1569 char buf[size] GNUNET_ALIGN; 1569 char buf[size] GNUNET_ALIGN;
1570 1570
1571 LOG (GNUNET_ERROR_TYPE_DEBUG, 1571 LOG (GNUNET_ERROR_TYPE_DEBUG,
1572 "Sending %u byte HELLO beacon\n", 1572 "Sending %u byte HELLO beacon\n",
1573 (unsigned int) size); 1573 (unsigned int) size);
1574 radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf; 1574 radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf;
@@ -1612,13 +1612,13 @@ wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
1612 struct WlanAddress *wa = (struct WlanAddress *) addr; 1612 struct WlanAddress *wa = (struct WlanAddress *) addr;
1613 1613
1614 if (addrlen != sizeof (struct WlanAddress)) 1614 if (addrlen != sizeof (struct WlanAddress))
1615 { 1615 {
1616 GNUNET_break_op (0); 1616 GNUNET_break_op (0);
1617 return GNUNET_SYSERR; 1617 return GNUNET_SYSERR;
1618 } 1618 }
1619 if (GNUNET_YES != plugin->have_mac) 1619 if (GNUNET_YES != plugin->have_mac)
1620 { 1620 {
1621 LOG (GNUNET_ERROR_TYPE_DEBUG, 1621 LOG (GNUNET_ERROR_TYPE_DEBUG,
1622 "Rejecting MAC `%s': I don't know my MAC!\n", 1622 "Rejecting MAC `%s': I don't know my MAC!\n",
1623 mac_to_string (addr)); 1623 mac_to_string (addr));
1624 return GNUNET_NO; /* don't know my MAC */ 1624 return GNUNET_NO; /* don't know my MAC */
@@ -1627,7 +1627,7 @@ wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
1627 &plugin->mac_address, 1627 &plugin->mac_address,
1628 sizeof (wa->mac))) 1628 sizeof (wa->mac)))
1629 { 1629 {
1630 LOG (GNUNET_ERROR_TYPE_DEBUG, 1630 LOG (GNUNET_ERROR_TYPE_DEBUG,
1631 "Rejecting MAC `%s': not my MAC!\n", 1631 "Rejecting MAC `%s': not my MAC!\n",
1632 mac_to_string (addr)); 1632 mac_to_string (addr));
1633 return GNUNET_NO; /* not my MAC */ 1633 return GNUNET_NO; /* not my MAC */
@@ -1705,7 +1705,7 @@ wlan_plugin_address_pretty_printer (void *cls, const char *type,
1705 1705
1706 1706
1707/** 1707/**
1708 * Exit point from the plugin. 1708 * Exit point from the plugin.
1709 * 1709 *
1710 * @param cls pointer to the api struct 1710 * @param cls pointer to the api struct
1711 */ 1711 */
@@ -1861,7 +1861,7 @@ libgnunet_plugin_transport_wlan_init (void *cls)
1861 1861
1862 testmode = 0; 1862 testmode = 0;
1863 /* check configuration */ 1863 /* check configuration */
1864 if ( (GNUNET_YES == 1864 if ( (GNUNET_YES ==
1865 GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "TESTMODE")) && 1865 GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "TESTMODE")) &&
1866 ( (GNUNET_SYSERR == 1866 ( (GNUNET_SYSERR ==
1867 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-wlan", 1867 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-wlan",
@@ -1890,7 +1890,7 @@ libgnunet_plugin_transport_wlan_init (void *cls)
1890 { 1890 {
1891 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 1891 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
1892 "transport-wlan", "INTERFACE"); 1892 "transport-wlan", "INTERFACE");
1893 return NULL; 1893 return NULL;
1894 } 1894 }
1895 1895
1896 plugin = GNUNET_malloc (sizeof (struct Plugin)); 1896 plugin = GNUNET_malloc (sizeof (struct Plugin));
@@ -1906,7 +1906,7 @@ libgnunet_plugin_transport_wlan_init (void *cls)
1906 plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); 1906 plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
1907 plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); 1907 plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
1908 plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); 1908 plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
1909 plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon, 1909 plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon,
1910 plugin); 1910 plugin);
1911 1911
1912 plugin->options = 0; 1912 plugin->options = 0;
@@ -1914,7 +1914,7 @@ libgnunet_plugin_transport_wlan_init (void *cls)
1914 /* some compilers do not like switch on 'long long'... */ 1914 /* some compilers do not like switch on 'long long'... */
1915 switch ((unsigned int) testmode) 1915 switch ((unsigned int) testmode)
1916 { 1916 {
1917 case 0: /* normal */ 1917 case 0: /* normal */
1918 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan"; 1918 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan";
1919 plugin->helper_argv[1] = interface; 1919 plugin->helper_argv[1] = interface;
1920 plugin->helper_argv[2] = NULL; 1920 plugin->helper_argv[2] = NULL;
diff --git a/src/transport/plugin_transport_wlan.h b/src/transport/plugin_transport_wlan.h
index 044c6818a..c265edcab 100644
--- a/src/transport/plugin_transport_wlan.h
+++ b/src/transport/plugin_transport_wlan.h
@@ -41,7 +41,7 @@
41 41
42/** 42/**
43 * Value for "Management" in the 'frame_control' field of the 43 * Value for "Management" in the 'frame_control' field of the
44 * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame. 44 * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame.
45 */ 45 */
46#define IEEE80211_FC0_TYPE_MGT 0x00 46#define IEEE80211_FC0_TYPE_MGT 0x00
47 47
diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c
index 816b40a2e..06cd27f9c 100644
--- a/src/transport/test_plugin_transport.c
+++ b/src/transport/test_plugin_transport.c
@@ -498,7 +498,7 @@ env_get_our_hello ()
498} 498}
499 499
500 500
501static void 501static void
502env_session_end (void *cls, 502env_session_end (void *cls,
503 const struct GNUNET_PeerIdentity *peer, 503 const struct GNUNET_PeerIdentity *peer,
504 struct Session * session) 504 struct Session * session)
diff --git a/src/transport/test_transport_api_limited_sockets.c b/src/transport/test_transport_api_limited_sockets.c
index b7a230283..511422aa6 100644
--- a/src/transport/test_transport_api_limited_sockets.c
+++ b/src/transport/test_transport_api_limited_sockets.c
@@ -339,7 +339,7 @@ main (int argc, char *argv[])
339 return ret; 339 return ret;
340} 340}
341 341
342#else 342#else
343/* cannot setrlimit */ 343/* cannot setrlimit */
344 344
345 345
diff --git a/src/transport/test_transport_api_timeout.c b/src/transport/test_transport_api_timeout.c
index 908374cb7..01af9f81b 100644
--- a/src/transport/test_transport_api_timeout.c
+++ b/src/transport/test_transport_api_timeout.c
@@ -112,7 +112,7 @@ end ()
112 ok = disconnects; 112 ok = disconnects;
113 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 113 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
114 "Fail! Had %u disconnects while waiting %s\n", 114 "Fail! Had %u disconnects while waiting %s\n",
115 disconnects, 115 disconnects,
116 GNUNET_STRINGS_relative_time_to_string (WAIT, 116 GNUNET_STRINGS_relative_time_to_string (WAIT,
117 GNUNET_YES)); 117 GNUNET_YES));
118 } 118 }
@@ -223,7 +223,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
223 223
224 shutdown_flag = GNUNET_NO; 224 shutdown_flag = GNUNET_NO;
225 225
226 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 226 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
227 "Waiting for %s\n", 227 "Waiting for %s\n",
228 GNUNET_STRINGS_relative_time_to_string (WAIT, 228 GNUNET_STRINGS_relative_time_to_string (WAIT,
229 GNUNET_YES)); 229 GNUNET_YES));
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index cb6cefdb1..86ce454e5 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -437,7 +437,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h,
437 * GNUNET_NO if not. 437 * GNUNET_NO if not.
438 */ 438 */
439static int 439static int
440neighbour_delete (void *cls, 440neighbour_delete (void *cls,
441 const struct GNUNET_PeerIdentity *key, void *value) 441 const struct GNUNET_PeerIdentity *key, void *value)
442{ 442{
443 struct GNUNET_TRANSPORT_Handle *handle = cls; 443 struct GNUNET_TRANSPORT_Handle *handle = cls;
@@ -1341,7 +1341,7 @@ GNUNET_TRANSPORT_check_neighbour_connected (struct GNUNET_TRANSPORT_Handle *hand
1341{ 1341{
1342 GNUNET_assert (NULL != handle); 1342 GNUNET_assert (NULL != handle);
1343 GNUNET_assert (NULL != peer); 1343 GNUNET_assert (NULL != peer);
1344 1344
1345 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (handle->neighbours, peer)) 1345 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (handle->neighbours, peer))
1346 return GNUNET_YES; 1346 return GNUNET_YES;
1347 else 1347 else
@@ -1364,7 +1364,7 @@ call_hello_update_cb_async (void *cls,
1364 GNUNET_assert (NULL != ghh->handle->my_hello); 1364 GNUNET_assert (NULL != ghh->handle->my_hello);
1365 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != ghh->notify_task); 1365 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != ghh->notify_task);
1366 ghh->notify_task = GNUNET_SCHEDULER_NO_TASK; 1366 ghh->notify_task = GNUNET_SCHEDULER_NO_TASK;
1367 ghh->rec (ghh->rec_cls, 1367 ghh->rec (ghh->rec_cls,
1368 (const struct GNUNET_MessageHeader *) ghh->handle->my_hello); 1368 (const struct GNUNET_MessageHeader *) ghh->handle->my_hello);
1369} 1369}
1370 1370
@@ -1564,7 +1564,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle,
1564 delay.rel_value_us = 0; /* notify immediately (with failure) */ 1564 delay.rel_value_us = 0; /* notify immediately (with failure) */
1565 LOG (GNUNET_ERROR_TYPE_DEBUG, 1565 LOG (GNUNET_ERROR_TYPE_DEBUG,
1566 "Bandwidth tracker allows next transmission to peer %s in %s\n", 1566 "Bandwidth tracker allows next transmission to peer %s in %s\n",
1567 GNUNET_i2s (target), 1567 GNUNET_i2s (target),
1568 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); 1568 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
1569 n->hn = GNUNET_CONTAINER_heap_insert (handle->ready_heap, n, delay.rel_value_us); 1569 n->hn = GNUNET_CONTAINER_heap_insert (handle->ready_heap, n, delay.rel_value_us);
1570 schedule_transmission (handle); 1570 schedule_transmission (handle);
diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c
index 9c1301ed2..515be9bf8 100644
--- a/src/transport/transport_api_address_lookup.c
+++ b/src/transport/transport_api_address_lookup.c
@@ -70,7 +70,7 @@ struct GNUNET_TRANSPORT_PeerIterateContext
70 * Backoff for reconnect. 70 * Backoff for reconnect.
71 */ 71 */
72 struct GNUNET_TIME_Relative backoff; 72 struct GNUNET_TIME_Relative backoff;
73 73
74 /** 74 /**
75 * Task ID for reconnect. 75 * Task ID for reconnect.
76 */ 76 */
@@ -116,7 +116,7 @@ send_request (struct GNUNET_TRANSPORT_PeerIterateContext *pal_ctx)
116 msg.timeout = GNUNET_TIME_absolute_hton (pal_ctx->timeout); 116 msg.timeout = GNUNET_TIME_absolute_hton (pal_ctx->timeout);
117 msg.peer = pal_ctx->peer; 117 msg.peer = pal_ctx->peer;
118 GNUNET_assert (GNUNET_OK == 118 GNUNET_assert (GNUNET_OK ==
119 GNUNET_CLIENT_transmit_and_get_response (pal_ctx->client, 119 GNUNET_CLIENT_transmit_and_get_response (pal_ctx->client,
120 &msg.header, 120 &msg.header,
121 GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout), 121 GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout),
122 GNUNET_YES, 122 GNUNET_YES,
@@ -126,7 +126,7 @@ send_request (struct GNUNET_TRANSPORT_PeerIterateContext *pal_ctx)
126 126
127/** 127/**
128 * Task run to re-establish the connection. 128 * Task run to re-establish the connection.
129 * 129 *
130 * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*' 130 * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*'
131 * @param tc scheduler context, unused 131 * @param tc scheduler context, unused
132 */ 132 */
@@ -329,7 +329,7 @@ GNUNET_TRANSPORT_peer_get_active_addresses (const struct
329 pal_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); 329 pal_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout);
330 if (NULL != peer) 330 if (NULL != peer)
331 pal_ctx->peer = *peer; 331 pal_ctx->peer = *peer;
332 pal_ctx->one_shot = one_shot; 332 pal_ctx->one_shot = one_shot;
333 pal_ctx->client = client; 333 pal_ctx->client = client;
334 send_request (pal_ctx); 334 send_request (pal_ctx);
335 335