diff options
Diffstat (limited to 'src/transport')
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 @@ #include <bluetooth/sdp.h> #include <bluetooth/sdp_lib.h> #include <errno.h> - #include <linux/if.h> + #include <linux/if.h> #include <stdio.h> #include <stdlib.h> #include <sys/ioctl.h> @@ -82,7 +82,7 @@ UINT8 mac[MAC_ADDR_SIZE]; }; - /** + /** * The UUID used for the SDP service. * {31191E56-FA7E-4517-870E-71B86BBCC52F} */ @@ -110,7 +110,7 @@ struct HardwareInfos #ifdef MINGW /** * socket handle - */ + */ struct GNUNET_NETWORK_Handle *handle; /** @@ -127,7 +127,7 @@ struct HardwareInfos * MAC address of our own bluetooth interface. */ struct GNUNET_TRANSPORT_WLAN_MacAddress pl_mac; - + /** * SDP session */ @@ -151,7 +151,7 @@ struct SendBuffer * destination? Always smaller than 'size'. */ size_t pos; - + /** * Buffered data; twice the maximum allowed message size as we add some * headers. @@ -161,13 +161,13 @@ struct SendBuffer #ifdef LINUX /** - * Devices buffer used to keep a list with all the discoverable devices in + * Devices buffer used to keep a list with all the discoverable devices in * order to send them HELLO messages one by one when it receive a broadcast message. - */ + */ struct BroadcastMessages { /* List with the discoverable devices' addresses */ - bdaddr_t devices[MAX_PORTS]; + bdaddr_t devices[MAX_PORTS]; /* List with the open sockets */ int fds[MAX_PORTS]; @@ -175,7 +175,7 @@ struct SendBuffer /* The number of the devices */ int size; - + /* The current position */ int pos; @@ -207,7 +207,7 @@ static struct SendBuffer write_pout; static struct SendBuffer write_std; -/* ****** this are the same functions as the ones used in gnunet-helper-transport-wlan.c ****** */ +/* ****** this are the same functions as the ones used in gnunet-helper-transport-wlan.c ****** */ /** * To what multiple do we align messages? 8 byte should suffice for everyone @@ -228,7 +228,7 @@ static struct SendBuffer write_std; * @param cls closure * @param message the actual message */ -typedef void (*MessageTokenizerCallback) (void *cls, +typedef void (*MessageTokenizerCallback) (void *cls, const struct GNUNET_MessageHeader * message); @@ -301,7 +301,7 @@ mst_create (MessageTokenizerCallback cb, ret->cb = cb; ret->cb_cls = cb_cls; ret->pos = 0; - + return ret; } @@ -602,7 +602,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) if (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] && ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]) return 0; - return 1; + return 1; } @@ -613,7 +613,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) /** * Function used to get the code of last error and to print the type of error. */ - static void + static void print_last_error() { LPVOID lpMsgBuf = NULL; @@ -644,9 +644,9 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) /** * Function used to convert the GUID. * @param bytes the GUID represented as a char array - * @param uuid pointer to the GUID + * @param uuid pointer to the GUID */ - static void + static void convert_guid(char *bytes, GUID * uuid) { int i; @@ -664,16 +664,16 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) #ifdef LINUX /** * Function for assigning a port number - * + * * @param socket the socket used to bind * @param addr pointer to the rfcomm address - * @return 0 on success - */ + * @return 0 on success + */ static int bind_socket (int socket, struct sockaddr_rc *addr) { int port, status; - + /* Bind every possible port (from 0 to 30) and stop when binding doesn't fail */ //FIXME : it should start from port 1, but on my computer it doesn't work :) for (port = 3; port <= 30; port++) @@ -683,8 +683,8 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) if (status == 0) return 0; } - - return -1; + + return -1; } #endif @@ -696,7 +696,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) * @return 0 on success */ static int - register_service (struct HardwareInfos *dev) + register_service (struct HardwareInfos *dev) { /* advertise the service */ CSADDR_INFO addr_info; @@ -746,7 +746,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) wqs.lpcsaBuffer = &addr_info ; wqs.lpBlob = 0; - if (SOCKET_ERROR == WSASetService (&wqs , RNRSERVICE_REGISTER, 0)) + if (SOCKET_ERROR == WSASetService (&wqs , RNRSERVICE_REGISTER, 0)) { fprintf (stderr, "Failed to register the SDP service: "); print_last_error(); @@ -768,7 +768,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) * @return 0 on success */ static int - register_service (struct HardwareInfos *dev, int rc_channel) + register_service (struct HardwareInfos *dev, int rc_channel) { /** * 1. initializations @@ -779,17 +779,17 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) * 6. register the service record to the local SDP server * 7. cleanup */ - uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, dev->pl_mac.mac[5], dev->pl_mac.mac[4], dev->pl_mac.mac[3], dev->pl_mac.mac[2], dev->pl_mac.mac[1], dev->pl_mac.mac[0]}; const char *service_dsc = "Bluetooth plugin services"; - const char *service_prov = "GNUnet provider"; - uuid_t root_uuid, rfcomm_uuid, svc_uuid; + const char *service_prov = "GNUnet provider"; + uuid_t root_uuid, rfcomm_uuid, svc_uuid; sdp_list_t *root_list = 0, *rfcomm_list = 0, *proto_list = 0, *access_proto_list = 0, *svc_list = 0; sdp_record_t *record = 0; sdp_data_t *channel = 0; - + record = sdp_record_alloc(); /* Set the general service ID */ @@ -799,8 +799,8 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) sdp_set_service_id (record, svc_uuid); /* Make the service record publicly browsable */ - sdp_uuid16_create (&root_uuid, PUBLIC_BROWSE_GROUP); - root_list = sdp_list_append (0, &root_uuid); + sdp_uuid16_create (&root_uuid, PUBLIC_BROWSE_GROUP); + root_list = sdp_list_append (0, &root_uuid); sdp_set_browse_groups (record, root_list); /* Register the RFCOMM channel */ @@ -816,10 +816,10 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) /* Set the name, provider, and description */ sdp_set_info_attr (record, dev->iface, service_prov, service_dsc); - + /* Connect to the local SDP server */ dev->session = sdp_connect (BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY); - + if (!dev->session) { 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) //FIXME exit? return 1; } - + /* Register the service record */ if (sdp_record_register (dev->session, record, 0) < 0) { @@ -836,23 +836,23 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) //FIXME exit? return 1; } - + /* Cleanup */ - sdp_data_free (channel); + sdp_data_free (channel); sdp_list_free (root_list, 0); sdp_list_free (rfcomm_list, 0); sdp_list_free (proto_list, 0); sdp_list_free (access_proto_list, 0); sdp_list_free (svc_list, 0); sdp_record_free (record); - + return 0; } #endif #ifdef MINGW /** - * Function for searching and browsing for a service. This will return the + * Function for searching and browsing for a service. This will return the * port number on which the service is running. * * @param dest target address @@ -869,16 +869,16 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) GUID guid; unsigned char uuid[] = GNUNET_BLUETOOTH_SDP_UUID; convert_guid ((char *) uuid, &guid); - + wqs = (WSAQUERYSET*)malloc (wqs_len); ZeroMemory (wqs, wqs_len); - + wqs->dwSize = sizeof (WSAQUERYSET) ; wqs->lpServiceClassId = &guid; wqs->dwNameSpace = NS_BTH; wqs->dwNumberOfCsAddrs = 0; wqs->lpszContext = (LPSTR)dest; - + if (SOCKET_ERROR == WSALookupServiceBegin (wqs, LUP_FLUSHCACHE | LUP_RETURN_ALL, &h)) { if (GetLastError() == WSASERVICE_NOT_FOUND) @@ -894,14 +894,14 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) return -1; } } - + /* search the sdp service */ while (!done) { if (SOCKET_ERROR == WSALookupServiceNext (h, LUP_FLUSHCACHE | LUP_RETURN_ALL, &wqs_len, wqs)) { int error = WSAGetLastError(); - + switch (error) { case WSAEFAULT: @@ -927,15 +927,15 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) channel = ((SOCKADDR_BTH*)wqs->lpcsaBuffer->RemoteAddr.lpSockaddr)->port; } } - + free (wqs) ; WSALookupServiceEnd (h); - + return channel; } #else /** - * Function used for searching and browsing for a service. This will return the + * Function used for searching and browsing for a service. This will return the * port number on which the service is running. * * @param dev pointer to the device struct @@ -943,17 +943,17 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) * @return channel */ static int - get_channel(struct HardwareInfos *dev, bdaddr_t dest) + get_channel(struct HardwareInfos *dev, bdaddr_t dest) { /** * 1. detect all nearby devices * 2. for each device: * 2.1. connect to the SDP server running * 2.2. get a list of service records with the specific UUID - * 2.3. for each service record get a list of the protocol sequences and get + * 2.3. for each service record get a list of the protocol sequences and get * the port number */ - uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, dest.b[5], dest.b[4], dest.b[3], dest.b[2], dest.b[1], dest.b[0]}; sdp_session_t *session = 0; @@ -961,21 +961,21 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) uuid_t svc_uuid; uint32_t range = 0x0000ffff; uint8_t channel = -1; - + /* Connect to the local SDP server */ - session = sdp_connect (BDADDR_ANY, &dest, 0); + session = sdp_connect (BDADDR_ANY, &dest, 0); if (!session) { fprintf (stderr, "Failed to connect to the SDP server on interface `%.*s': %s\n", IFNAMSIZ, dev->iface, strerror (errno)); return -1; } - + sdp_uuid128_create (&svc_uuid, &svc_uuid_int); search_list = sdp_list_append (0, &svc_uuid); attrid_list = sdp_list_append (0, &range); - - if (sdp_service_search_attr_req (session, search_list, + + if (sdp_service_search_attr_req (session, search_list, SDP_ATTR_REQ_RANGE, attrid_list, &response_list) == 0) { for (it = response_list; it; it = it->next) @@ -990,24 +990,24 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) sdp_record_free (record); } } - + sdp_list_free (search_list, 0); sdp_list_free (attrid_list, 0); sdp_list_free (response_list, 0); - + sdp_close (session); - + if (channel == -1) fprintf (stderr, "Failed to find the listening channel for interface `%.*s': %s\n", IFNAMSIZ, dev->iface, strerror (errno)); - + return channel; } #endif /** * Read from the socket and put the result into the buffer for transmission to 'stdout'. - * + * * @param sock file descriptor for reading * @param buf buffer to read to; first bytes will be the 'struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame', * followed by the actual payload @@ -1015,18 +1015,18 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) * @param ri where to write radiotap_rx info * @return number of bytes written to 'buf' */ -static ssize_t -read_from_the_socket (void *sock, +static ssize_t +read_from_the_socket (void *sock, unsigned char *buf, size_t buf_size, struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *ri) { unsigned char tmpbuf[buf_size]; ssize_t count; - + #ifdef MINGW count = GNUNET_NETWORK_socket_recv ((struct GNUNET_NETWORK_Handle *)sock, tmpbuf, buf_size); #else - count = read (*((int *)sock), tmpbuf, buf_size); + count = read (*((int *)sock), tmpbuf, buf_size); #endif if (0 > count) @@ -1041,11 +1041,11 @@ read_from_the_socket (void *sock, return -1; } - + #ifdef LINUX /* Get the channel used */ int len; - struct sockaddr_rc rc_addr = { 0 }; + struct sockaddr_rc rc_addr = { 0 }; memset (&rc_addr, 0, sizeof (rc_addr)); len = sizeof (rc_addr); @@ -1064,9 +1064,9 @@ read_from_the_socket (void *sock, { count -= sizeof(uint32_t); } - + memcpy (buf, tmpbuf, count); - + return count; } @@ -1078,7 +1078,7 @@ read_from_the_socket (void *sock, */ static int open_device (struct HardwareInfos *dev) -{ +{ #ifdef MINGW SOCKADDR_BTH addr; @@ -1113,30 +1113,30 @@ open_device (struct HardwareInfos *dev) fprintf (stderr, "Failed to register a service: "); print_last_error(); return 1; - } + } #else int i, dev_id = -1, fd_hci; - struct + struct { struct hci_dev_list_req list; struct hci_dev_req dev[HCI_MAX_DEV]; } request; //used for detecting the local devices struct sockaddr_rc rc_addr = { 0 }; //used for binding - + /* Initialize the neighbour structure */ neighbours.dev_id = -1; for (i = 0; i < MAX_PORTS; i++) neighbours.fds[i] = -1; - + /* Open a HCI socket */ fd_hci = socket (AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); - if (fd_hci < 0) + if (fd_hci < 0) { fprintf (stderr, "Failed to create HCI socket: %s\n", strerror (errno)); return -1; } - + memset (&request, 0, sizeof(request)); request.list.dev_num = HCI_MAX_DEV; @@ -1146,7 +1146,7 @@ open_device (struct HardwareInfos *dev) IFNAMSIZ, dev->iface, strerror (errno)); return 1; } - + /* Search for a device with dev->iface name */ for (i = 0; i < request.list.dev_num; i++) { @@ -1155,23 +1155,23 @@ open_device (struct HardwareInfos *dev) memset (&dev_info, 0, sizeof(struct hci_dev_info)); dev_info.dev_id = request.dev[i].dev_id; strncpy (dev_info.name, dev->iface, IFNAMSIZ); - + if (ioctl (fd_hci, HCIGETDEVINFO, (void *) &dev_info)) { fprintf (stderr, "ioctl(HCIGETDEVINFO) on interface `%.*s' failed: %s\n", IFNAMSIZ, dev->iface, strerror (errno)); return 1; } - + if (strcmp (dev_info.name, dev->iface) == 0) { - + dev_id = dev_info.dev_id; //the device was found /** * Copy the MAC address to the device structure */ memcpy (&dev->pl_mac, &dev_info.bdaddr, sizeof (bdaddr_t)); - + /* Check if the interface is up */ if (hci_test_bit (HCI_UP, (void *) &dev_info.flags) == 0) { @@ -1183,55 +1183,55 @@ open_device (struct HardwareInfos *dev) return 1; } } - + /* Check if the device is discoverable */ if (hci_test_bit (HCI_PSCAN, (void *) &dev_info.flags) == 0 || hci_test_bit (HCI_ISCAN, (void *) &dev_info.flags) == 0) { /* Set interface Page Scan and Inqury Scan ON */ struct hci_dev_req dev_req; - + memset (&dev_req, 0, sizeof (dev_req)); dev_req.dev_id = dev_info.dev_id; dev_req.dev_opt = SCAN_PAGE | SCAN_INQUIRY; - + if (ioctl (fd_hci, HCISETSCAN, (unsigned long) &dev_req)) - { + { fprintf (stderr, "ioctl(HCISETSCAN) on interface `%.*s' failed: %s\n", IFNAMSIZ, dev->iface, strerror (errno)); return 1; } - + } break; } - + } - + /* Check if the interface was not found */ if (dev_id == -1) { fprintf (stderr, "The interface %s was not found\n", dev->iface); return 1; } - + /* Close the hci socket */ (void) close(fd_hci); - - - + + + /* Bind the rfcomm socket to the interface */ - memset (&rc_addr, 0, sizeof (rc_addr)); + memset (&rc_addr, 0, sizeof (rc_addr)); rc_addr.rc_family = AF_BLUETOOTH; rc_addr.rc_bdaddr = *BDADDR_ANY; - + if (bind_socket (dev->fd_rfcomm, &rc_addr) != 0) { fprintf (stderr, "Failed to bind interface `%.*s': %s\n", IFNAMSIZ, dev->iface, strerror (errno)); return 1; } - + /* Register a SDP service */ if (register_service (dev, rc_addr.rc_channel) != 0) { @@ -1239,7 +1239,7 @@ open_device (struct HardwareInfos *dev) dev->iface, strerror (errno)); return 1; } - + /* Switch socket in listening mode */ if (listen (dev->fd_rfcomm, 5) == -1) //FIXME: probably we need a bigger number { @@ -1247,7 +1247,7 @@ open_device (struct HardwareInfos *dev) dev->iface, strerror (errno)); return 1; } - + #endif return 0; @@ -1266,7 +1266,7 @@ static void mac_set (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader, const struct HardwareInfos *dev) { - taIeeeHeader->frame_control = htons (IEEE80211_FC0_TYPE_DATA); + taIeeeHeader->frame_control = htons (IEEE80211_FC0_TYPE_DATA); taIeeeHeader->addr3 = mac_bssid_gnunet; #ifdef MINGW @@ -1292,13 +1292,13 @@ mac_set (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader, struct stat sbuf; int ret; - ret = snprintf (strbuf, sizeof (strbuf), + ret = snprintf (strbuf, sizeof (strbuf), "/sys/class/bluetooth/%s/subsystem", iface); if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf))) { - fprintf (stderr, - "Did not find 802.15.1 interface `%s'. Exiting.\n", + fprintf (stderr, + "Did not find 802.15.1 interface `%s'. Exiting.\n", iface); exit (1); } @@ -1354,12 +1354,12 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) sendsize = ntohs (hdr->size); if ( (sendsize < sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage)) || - (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) ) + (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) ) { fprintf (stderr, "Received malformed message\n"); exit (1); } - sendsize -= (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) - + sendsize -= (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame)); if (MAXLINE < sendsize) { @@ -1373,7 +1373,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) /* payload contains MAC address, but we don't trust it, so we'll * overwrite it with OUR MAC address to prevent mischief */ mac_set (blueheader, dev); - memcpy (&blueheader->addr1, &header->frame.addr1, + memcpy (&blueheader->addr1, &header->frame.addr1, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); write_pout.size = sendsize; } @@ -1386,19 +1386,19 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) * @param dev pointer to the socket which was added to the set * @return 0 on success */ - static int - send_broadcast (struct HardwareInfos *dev, int *sendsocket) + static int + send_broadcast (struct HardwareInfos *dev, int *sendsocket) { int new_device = 0; int loops = 0; search_for_devices: - if ((neighbours.size == neighbours.pos && new_device == 1) || neighbours.size == 0) - { + if ((neighbours.size == neighbours.pos && new_device == 1) || neighbours.size == 0) + { inquiry_devices: //skip the conditions and force a inquiry for new devices { - /** - * It means that I sent HELLO messages to all the devices from the list and I should search + /** + * It means that I sent HELLO messages to all the devices from the list and I should search * for new ones or that this is the first time when I do a search. */ inquiry_info *devices = NULL; @@ -1415,17 +1415,17 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) if (neighbours.dev_id == -1) { char addr[19] = { 0 }; //the device MAC address - - ba2str ((bdaddr_t *) &dev->pl_mac, addr); + + ba2str ((bdaddr_t *) &dev->pl_mac, addr); neighbours.dev_id = hci_devid (addr); if (neighbours.dev_id < 0) - { + { fprintf (stderr, "Failed to get the device id for interface %.*s : %s\n", IFNAMSIZ, dev->iface, strerror (errno)); return 1; } } - + devices = malloc (max_responses * sizeof (inquiry_info)); if (devices == NULL) { @@ -1433,23 +1433,23 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) dev->iface); return 1; } - + responses = hci_inquiry (neighbours.dev_id, 8, max_responses, NULL, &devices, IREQ_CACHE_FLUSH); if (responses < 0) { fprintf (stderr, "Failed to inquiry on interface %.*s\n", IFNAMSIZ, dev->iface); return 1; } - + fprintf (stderr, "LOG : Found %d devices\n", responses); //FIXME delete it after debugging stage - + if (responses == 0) { fprintf (stderr, "LOG : No devices discoverable\n"); return 1; } - - for (i = 0; i < responses; i++) + + for (i = 0; i < responses; i++) { int j; int found = 0; @@ -1461,11 +1461,11 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) dev->iface); return 2; } - + /* Search if the address already exists on the list */ for (j = 0; j < neighbours.size; j++) { - if (memcmp (&(devices + i)->bdaddr, &(neighbours.devices[j]), sizeof (bdaddr_t)) == 0) + if (memcmp (&(devices + i)->bdaddr, &(neighbours.devices[j]), sizeof (bdaddr_t)) == 0) { found = 1; 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) fprintf (stderr, "LOG : %s was added to the list\n", addr); //FIXME debugging message memcpy (&(neighbours.devices[neighbours.size++]), &(devices + i)->bdaddr, sizeof (bdaddr_t)); } - } - + } + free (devices); } } - + int connection_successful = 0; struct sockaddr_rc addr_rc = { 0 }; int errno_copy = 0; @@ -1501,9 +1501,9 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) memset (&addr_rc.rc_bdaddr, 0, sizeof (addr_rc.rc_bdaddr)); memcpy (&addr_rc.rc_bdaddr, &(neighbours.devices[neighbours.pos]), sizeof (addr_rc.rc_bdaddr)); - + addr_rc.rc_channel = get_channel (dev, addr_rc.rc_bdaddr); - + *sendsocket = socket (AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); if (connect (*sendsocket, (struct sockaddr *)&addr_rc, sizeof (addr_rc)) == 0) { @@ -1549,7 +1549,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) neighbours.pos += 1; } } - + /* Cycle on the list */ if (neighbours.pos == neighbours.size) { @@ -1564,14 +1564,14 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) } } /* If a new device wasn't found, search an old one */ - if (connection_successful == 0) + if (connection_successful == 0) { int loop_check = neighbours.pos; while (neighbours.fds[neighbours.pos] == -1) { if (neighbours.pos == neighbours.size) neighbours.pos = 0; - + if (neighbours.pos == loop_check) { if (errno_copy == ECONNREFUSED) @@ -1599,7 +1599,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) /** * Main function of the helper. This code accesses a bluetooth interface - * forwards traffic in both directions between the bluetooth interface and + * forwards traffic in both directions between the bluetooth interface and * stdin/stdout of this process. Error messages are written to stderr. * * @param argc number of arguments, must be 2 @@ -1611,7 +1611,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) int main (int argc, char *argv[]) { -#ifdef LINUX +#ifdef LINUX struct HardwareInfos dev; char readbuf[MAXLINE]; int maxfd; @@ -1632,7 +1632,7 @@ main (int argc, char *argv[]) return 254; } #else - if (0 != seteuid (0)) + if (0 != seteuid (0)) { fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno)); return 254; @@ -1710,15 +1710,15 @@ main (int argc, char *argv[]) memcpy (write_std.buf, &macmsg, sizeof (macmsg)); write_std.size = sizeof (macmsg); } - - - stdin_mst = mst_create (&stdin_send_hw, &dev); + + + stdin_mst = mst_create (&stdin_send_hw, &dev); stdin_open = 1; - + /** - * TODO : I should make the time out of a mac endpoint smaller and check if the rate + * TODO : I should make the time out of a mac endpoint smaller and check if the rate * from get_wlan_header (plugin_transport_bluetooth.c) is correct. - */ + */ while (1) { maxfd = -1; @@ -1737,7 +1737,7 @@ main (int argc, char *argv[]) maxfd = MAX (maxfd, dev.fd_rfcomm); } - for (i = 0; i < crt_rfds; i++) // it can receive messages from multiple devices + for (i = 0; i < crt_rfds; i++) // it can receive messages from multiple devices { FD_SET (rfds_list[i], &rfds); maxfd = MAX (maxfd, rfds_list[i]); @@ -1749,22 +1749,22 @@ main (int argc, char *argv[]) maxfd = MAX (maxfd, STDOUT_FILENO); } if (0 < write_pout.size) //it can send messages only to one device per loop - { + { struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *frame; /* Get the destination address */ frame = (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) write_pout.buf; - - if (memcmp (&frame->addr1, &dev.pl_mac, + + if (memcmp (&frame->addr1, &dev.pl_mac, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) { broadcast = 1; - memset (&write_pout, 0, sizeof (write_pout)); //clear the buffer - } - else if (memcmp (&frame->addr1, &broadcast_address, + memset (&write_pout, 0, sizeof (write_pout)); //clear the buffer + } + else if (memcmp (&frame->addr1, &broadcast_address, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) { fprintf (stderr, "LOG : %s has a broadcast message (pos %d, size %d)\n", dev.iface, neighbours.pos, neighbours.size); //FIXME: debugging message - + if (send_broadcast(&dev, &sendsocket) != 0) //if the searching wasn't successful don't get stuck on the select stage { broadcast = 1; @@ -1776,15 +1776,15 @@ main (int argc, char *argv[]) FD_SET (sendsocket, &wfds); maxfd = MAX (maxfd, sendsocket); } - } - else + } + else { int found = 0; int pos = 0; /* Search if the address already exists on the list */ for (i = 0; i < neighbours.size; i++) { - if (memcmp (&frame->addr1, &(neighbours.devices[i]), sizeof (bdaddr_t)) == 0) + if (memcmp (&frame->addr1, &(neighbours.devices[i]), sizeof (bdaddr_t)) == 0) { pos = i; if (neighbours.fds[i] != -1) @@ -1802,24 +1802,24 @@ main (int argc, char *argv[]) { int status; struct sockaddr_rc addr = { 0 }; - - 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, + + 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, frame->addr1.mac[5], frame->addr1.mac[4], frame->addr1.mac[3], - frame->addr1.mac[2], frame->addr1.mac[1], frame->addr1.mac[0]); //FIXME: debugging message - + frame->addr1.mac[2], frame->addr1.mac[1], frame->addr1.mac[0]); //FIXME: debugging message + sendsocket = socket (AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); - - if (sendsocket < 0) + + if (sendsocket < 0) { - fprintf (stderr, "Failed to create a RFCOMM socket (sending stage): %s\n", + fprintf (stderr, "Failed to create a RFCOMM socket (sending stage): %s\n", strerror (errno)); return -1; } - + memcpy (&addr.rc_bdaddr, &frame->addr1, sizeof (bdaddr_t)); addr.rc_family = AF_BLUETOOTH; addr.rc_channel = get_channel (&dev, addr.rc_bdaddr); - + int tries = 0; connect_retry: status = connect (sendsocket, (struct sockaddr *) &addr, sizeof (addr)); @@ -1843,7 +1843,7 @@ main (int argc, char *argv[]) memset (&write_pout, 0, sizeof (write_pout)); broadcast = 1; } - + } else { @@ -1902,19 +1902,19 @@ main (int argc, char *argv[]) write_std.size = 0; } fprintf (stderr, "LOG : %s sends a message to STDOUT\n", dev.iface); //FIXME: debugging message - - } + + } if (sendsocket != -1) { if (FD_ISSET (sendsocket , &wfds)) { ssize_t ret = - write (sendsocket, write_pout.buf + write_std.pos, + write (sendsocket, write_pout.buf + write_std.pos, write_pout.size - write_pout.pos); if (0 > ret) //FIXME should I first check the error type? { fprintf (stderr, "Failed to write to bluetooth device: %s. Closing the socket!\n", - strerror (errno)); + strerror (errno)); for (i = 0; i < neighbours.size; i++) { if (neighbours.fds[i] == sendsocket) @@ -1925,7 +1925,7 @@ main (int argc, char *argv[]) } } /* Remove the message */ - memset (&write_pout.buf + write_std.pos, 0, (write_pout.size - write_pout.pos)); + memset (&write_pout.buf + write_std.pos, 0, (write_pout.size - write_pout.pos)); write_pout.pos = 0 ; write_pout.size = 0; } @@ -1940,7 +1940,7 @@ main (int argc, char *argv[]) (unsigned int) write_pout.size); break; } - + if (write_pout.pos == write_pout.size) { write_pout.pos = 0; @@ -1956,14 +1956,14 @@ main (int argc, char *argv[]) { if (i == STDIN_FILENO) { - ssize_t ret = + ssize_t ret = read (i, readbuf, sizeof (readbuf)); if (0 > ret) { fprintf (stderr, "Read error from STDIN: %s\n", strerror (errno)); - break; + break; } if (0 == ret) { @@ -1975,18 +1975,18 @@ main (int argc, char *argv[]) mst_receive (stdin_mst, readbuf, ret); fprintf (stderr, "LOG : %s receives a message from STDIN\n", dev.iface); //FIXME: debugging message } - } - else if (i == dev.fd_rfcomm) + } + else if (i == dev.fd_rfcomm) { int readsocket; struct sockaddr_rc addr = { 0 }; unsigned int opt = sizeof (addr); - + readsocket = accept (dev.fd_rfcomm, (struct sockaddr *) &addr, &opt); fprintf(stderr, "LOG : %s accepts a message\n", dev.iface); //FIXME: debugging message if (readsocket == -1) { - fprintf (stderr, "Failed to accept a connection on interface: %.*s\n", IFNAMSIZ, + fprintf (stderr, "Failed to accept a connection on interface: %.*s\n", IFNAMSIZ, strerror (errno)); break; } @@ -1994,7 +1994,7 @@ main (int argc, char *argv[]) { FD_SET (readsocket, &rfds); maxfd = MAX (maxfd, readsocket); - + if (crt_rfds < MAX_PORTS) rfds_list[crt_rfds++] = readsocket; else @@ -2004,19 +2004,19 @@ main (int argc, char *argv[]) break; } } - - } - else + + } + else { struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rrm; ssize_t ret; - fprintf (stderr, "LOG : %s reads something from the socket\n", dev.iface);//FIXME : debugging message + fprintf (stderr, "LOG : %s reads something from the socket\n", dev.iface);//FIXME : debugging message rrm = (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) write_std.buf; ret = read_from_the_socket ((void *)&i, (unsigned char *) &rrm->frame, - sizeof (write_std.buf) - - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) - + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame), + sizeof (write_std.buf) + - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) + + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame), rrm); if (0 >= ret) { @@ -2041,8 +2041,8 @@ main (int argc, char *argv[]) } if ((0 < ret) && (0 == mac_test (&rrm->frame, &dev))) { - write_std.size = ret - + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) + write_std.size = ret + + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame); rrm->header.size = htons (write_std.size); rrm->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER); @@ -2058,7 +2058,7 @@ main (int argc, char *argv[]) sdp_close (dev.session); (void) close (dev.fd_rfcomm); (void) close (sendsocket); - + for (i = 0; i < crt_rfds; i++) (void) close (rfds_list[i]); @@ -2079,13 +2079,13 @@ main (int argc, char *argv[]) struct MessageStreamTokenizer *stdin_mst; /* check the handles */ - if (stdin_handle == INVALID_HANDLE_VALUE) + if (stdin_handle == INVALID_HANDLE_VALUE) { fprintf (stderr, "Failed to get the stdin handle\n"); ExitProcess (2); } - if (stdout_handle == INVALID_HANDLE_VALUE) + if (stdout_handle == INVALID_HANDLE_VALUE) { fprintf (stderr, "Failed to get the stdout handle\n"); ExitProcess (2); @@ -2111,7 +2111,7 @@ main (int argc, char *argv[]) } - if (open_device (&dev) == -1) + if (open_device (&dev) == -1) { fprintf (stderr, "Failed to open the device\n"); print_last_error(); @@ -2121,21 +2121,21 @@ main (int argc, char *argv[]) print_last_error(); } ExitProcess (2); - } + } if (GNUNET_OK != GNUNET_NETWORK_socket_set_blocking (dev.handle, 1) ) { fprintf (stderr, "Failed to change the socket mode\n"); ExitProcess (2); } - + memset (&write_std, 0, sizeof (write_std)); - memset (&write_pout, 0, sizeof (write_pout)); + memset (&write_pout, 0, sizeof (write_pout)); stdin_open = 1; rfds = GNUNET_NETWORK_fdset_create (); wfds = GNUNET_NETWORK_fdset_create (); - + /* Send MAC address of the bluetooth interface to STDOUT first */ { struct GNUNET_TRANSPORT_WLAN_HelperControlMessage macmsg; @@ -2146,9 +2146,9 @@ main (int argc, char *argv[]) memcpy (write_std.buf, &macmsg, sizeof (macmsg)); write_std.size = sizeof (macmsg); } - - - stdin_mst = mst_create (&stdin_send_hw, &dev); + + + stdin_mst = mst_create (&stdin_send_hw, &dev); stdin_open = 1; int pos = 0; @@ -2161,13 +2161,13 @@ main (int argc, char *argv[]) stdin_pos = -1; stdout_pos = -1; sendsocket = NULL; //FIXME ???memleaks - - GNUNET_NETWORK_fdset_zero (rfds); + + GNUNET_NETWORK_fdset_zero (rfds); if ((0 == write_pout.size) && (1 == stdin_open)) { stdin_pos = pos; pos +=1; - GNUNET_NETWORK_fdset_handle_set (rfds, (struct GNUNET_DISK_FileHandle*) &stdin_handle); + GNUNET_NETWORK_fdset_handle_set (rfds, (struct GNUNET_DISK_FileHandle*) &stdin_handle); } if (0 == write_std.size) @@ -2175,7 +2175,7 @@ main (int argc, char *argv[]) pos += 1; GNUNET_NETWORK_fdset_set (rfds, dev.handle); } - + for (i = 0; i < crt_rfds; i++) { pos += 1; @@ -2189,34 +2189,34 @@ main (int argc, char *argv[]) GNUNET_NETWORK_fdset_handle_set (wfds, (struct GNUNET_DISK_FileHandle*) &stdout_handle); // printf ("%s\n", write_std.buf); // memset (write_std.buf, 0, write_std.size); - // write_std.size = 0; + // write_std.size = 0; } if (0 < write_pout.size) - { + { if (strcmp (argv[1], "ff:ff:ff:ff:ff:ff") == 0) { fprintf(stderr, "LOG: BROADCAST! Skipping the message\n"); // skip the message broadcast = 1; memset (write_pout.buf, 0, write_pout.size); write_pout.size = 0; - } - else + } + else { SOCKADDR_BTH addr; fprintf (stderr, "LOG : has a new message for %s\n", argv[1]); sendsocket = GNUNET_NETWORK_socket_create (AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM); - - if (sendsocket == NULL) + + if (sendsocket == NULL) { fprintf (stderr, "Failed to create RFCOMM socket: \n"); print_last_error(); ExitProcess (2); } - + memset (&addr, 0, sizeof (addr)); //addr.addressFamily = AF_BTH; - if (SOCKET_ERROR == + if (SOCKET_ERROR == WSAStringToAddress (argv[1], AF_BTH, NULL, (LPSOCKADDR) &addr, &addr_len)) { fprintf (stderr, "Failed to translate the address: "); @@ -2250,7 +2250,7 @@ main (int argc, char *argv[]) } } } - + if (broadcast == 0) { int retval = GNUNET_NETWORK_socket_select (rfds, wfds, NULL, GNUNET_TIME_relative_get_forever_()); @@ -2279,7 +2279,7 @@ main (int argc, char *argv[]) fprintf (stderr, "Failed to write to STDOUT\n"); ExitProcess (2); } - + write_std.pos += ret; if (write_std.pos == write_std.size) { @@ -2292,9 +2292,9 @@ main (int argc, char *argv[]) if (GNUNET_NETWORK_fdset_isset (wfds, sendsocket)) { ssize_t ret; - ret = GNUNET_NETWORK_socket_send (sendsocket, write_pout.buf + write_pout.pos, + ret = GNUNET_NETWORK_socket_send (sendsocket, write_pout.buf + write_pout.pos, write_pout.size - write_pout.pos); - + if (GNUNET_SYSERR == ret) { fprintf (stderr, "Failed to send to the socket. Closing the socket. Error: \n"); @@ -2317,22 +2317,22 @@ main (int argc, char *argv[]) (unsigned int) write_pout.size); break; } - + if (write_pout.pos == write_pout.size) { write_pout.pos = 0; write_pout.size = 0; - + } fprintf(stderr, "LOG : sends a message to a DEVICE\n"); //FIXME: debugging message } } } - + //if (GNUNET_NETWORK_fdset_isset (rfds, (struct GNUNET_NETWORK_Handle*)&stdin_handle)) if (retval == stdin_pos) { - //ssize_t ret; + //ssize_t ret; //ret = GNUNET_NETWORK_socket_recv ((struct GNUNET_NETWORK_Handle *)&stdin_handle, readbuf, sizeof (write_pout.buf)); //ret = read (STDIN_FILENO, readbuf, sizeof (readbuf)); DWORD ret; @@ -2356,7 +2356,7 @@ main (int argc, char *argv[]) { fprintf (stderr, "LOG: accepting connection\n"); struct GNUNET_NETWORK_Handle *readsocket; - readsocket = GNUNET_NETWORK_socket_accept (dev.handle, (LPSOCKADDR)&acc_addr, &addr_len); + readsocket = GNUNET_NETWORK_socket_accept (dev.handle, (LPSOCKADDR)&acc_addr, &addr_len); if (readsocket == NULL) { fprintf (stderr, "Accept error %d: ", GetLastError()); @@ -2386,14 +2386,14 @@ main (int argc, char *argv[]) { if (GNUNET_NETWORK_fdset_isset (rfds, rfds_list[i])) { - struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rrm; + struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rrm; ssize_t ret; fprintf (stderr, "LOG: reading something from the socket\n");//FIXME : debugging message rrm = (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) write_std.buf; ret = read_from_the_socket (rfds_list[i], (unsigned char *) &rrm->frame, - sizeof (write_std.buf) - - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) - + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame), + sizeof (write_std.buf) + - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) + + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame), rrm); if (0 >= ret) { @@ -2408,22 +2408,22 @@ main (int argc, char *argv[]) fprintf (stderr, "Read error from raw socket: "); print_last_error(); break; - + } if ((0 < ret) && (0 == mac_test (&rrm->frame, &dev))) { - write_std.size = ret - + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) + write_std.size = ret + + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame); rrm->header.size = htons (write_std.size); rrm->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER); } break; } - } + } } } - + mst_destroy (stdin_mst); stdin_mst = NULL; 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[]) erg = mkfifo (FIFO_FILE1, 0666); if ( (0 != erg) && (EEXIST != errno) ) FPRINTF (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE1, - strerror (errno)); + strerror (errno)); } } 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 @@ #include "plugin_transport_wlan.h" /** - * Packet format type for the messages we receive from + * Packet format type for the messages we receive from * the kernel. This is for Ethernet 10Mbps format (no * performance information included). */ -#define ARPHRD_ETHER 1 +#define ARPHRD_ETHER 1 /** - * Packet format type for the messages we receive from + * Packet format type for the messages we receive from * the kernel. This is for plain messages (with no * performance information included). */ @@ -156,13 +156,13 @@ /** - * Packet format type for the messages we receive from + * Packet format type for the messages we receive from * the kernel. This is for the PRISM format. */ #define ARPHRD_IEEE80211_PRISM 802 /** - * Packet format type for the messages we receive from + * Packet format type for the messages we receive from * the kernel. This is for messages with a * 'struct Ieee80211RadiotapHeader' (see below). */ @@ -195,35 +195,35 @@ * Drivers appear to use a 64bit counter to hold mactime internal * the then fill the prism header with the lower 32 bits */ -#define PRISM_DID_MACTIME 0x2041 +#define PRISM_DID_MACTIME 0x2041 /** * Channel element */ -#define PRISM_DID_CHANNEL 0x3041 +#define PRISM_DID_CHANNEL 0x3041 /** * Signal element. Should be the signal strength in dbm, some people * suggest that instead "100 - (strength in dbm)" is used (to make this * a positive integer). */ -#define PRISM_DID_SIGNAL 0x6041 +#define PRISM_DID_SIGNAL 0x6041 /** * Noise element */ -#define PRISM_DID_NOISE 0x7041 +#define PRISM_DID_NOISE 0x7041 /** * Rate element, in units/multiples of 500Khz */ -#define PRISM_DID_RATE 0x8041 +#define PRISM_DID_RATE 0x8041 /** * Value is set (supplied) */ -#define PRISM_STATUS_OK 0 +#define PRISM_STATUS_OK 0 /** * Value not supplied. @@ -240,24 +240,24 @@ struct PrismValue * This has a different ID for each parameter, see * PRISM_DID_* constants. */ - uint32_t did; - + uint32_t did; + /** * See PRISM_STATUS_*-constants. Note that they are unusual: 0 = set; 1 = not set */ - uint16_t status; - + uint16_t status; + /** * length of data (which is always a uint32_t, but presumably this can be used * to specify that fewer bytes are used (with values in 'len' from 0-4). We * ignore this field. */ - uint16_t len; + uint16_t len; /** * The data value */ - uint32_t data; + uint32_t data; } __attribute__ ((packed)); @@ -271,11 +271,11 @@ struct PrismHeader * We expect this to be a PRISM_MSGCODE_*. */ uint32_t msgcode; - + /** * The length of the entire header. */ - uint32_t msglen; + uint32_t msglen; /** * Name of the device that captured the packet. @@ -402,7 +402,7 @@ enum RadiotapType */ IEEE80211_RADIOTAP_DBM_TX_POWER = 10, - /** + /** * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index * * Unitless indication of the Rx/Tx antenna for this packet. @@ -433,10 +433,10 @@ enum RadiotapType */ IEEE80211_RADIOTAP_RX_FLAGS = 14, - /** + /** * IEEE80211_RADIOTAP_TX_FLAGS __le16 bitmap * - * Properties of transmitted frames. See flags defined below. + * Properties of transmitted frames. See flags defined below. */ IEEE80211_RADIOTAP_TX_FLAGS = 15, @@ -462,7 +462,7 @@ enum RadiotapType }; /** - * Bitmask indicating an extension of the bitmask is used. + * Bitmask indicating an extension of the bitmask is used. * (Mask corresponding to IEEE80211_RADIOTAP_EXT). */ #define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK (1 << IEEE80211_RADIOTAP_EXT) @@ -487,7 +487,7 @@ enum RadiotapType * * Frame was sent/received with short preamble */ -#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 +#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /** * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get @@ -497,7 +497,7 @@ enum RadiotapType * * Frame was sent/received with WEP encryption */ -#define IEEE80211_RADIOTAP_F_WEP 0x04 +#define IEEE80211_RADIOTAP_F_WEP 0x04 /** * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get @@ -507,7 +507,7 @@ enum RadiotapType * * Frame was sent/received with fragmentation */ -#define IEEE80211_RADIOTAP_F_FRAG 0x08 +#define IEEE80211_RADIOTAP_F_FRAG 0x08 /** * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get @@ -517,7 +517,7 @@ enum RadiotapType * * Frame includes FCS (CRC at the end that needs to be removeD). */ -#define IEEE80211_RADIOTAP_F_FCS 0x10 +#define IEEE80211_RADIOTAP_F_FCS 0x10 /** * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get @@ -528,32 +528,32 @@ enum RadiotapType * Frame has padding between 802.11 header and payload * (to 32-bit boundary) */ -#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 +#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /** * For IEEE80211_RADIOTAP_RX_FLAGS: * frame failed crc check */ -#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 +#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /** * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): * failed due to excessive retries */ -#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 +#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /** * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): * used cts 'protection' */ -#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 +#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /** * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): - * used rts/cts handshake + * used rts/cts handshake */ -#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 +#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /** * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): @@ -563,7 +563,7 @@ enum RadiotapType /** * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): - * sequence number handled by userspace + * sequence number handled by userspace */ #define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010 @@ -591,7 +591,7 @@ struct Ieee80211RadiotapHeader uint8_t it_version; /** - * Padding. Set to 0. + * Padding. Set to 0. */ uint8_t it_pad; @@ -611,7 +611,7 @@ struct Ieee80211RadiotapHeader /** - * Format of the header we need to prepend to messages to be sent to the + * Format of the header we need to prepend to messages to be sent to the * Kernel. */ struct RadiotapTransmissionHeader @@ -752,7 +752,7 @@ struct SendBuffer * destination? Always smaller than 'size'. */ size_t pos; - + /** * Buffered data; twice the maximum allowed message size as we add some * headers. @@ -794,7 +794,7 @@ static struct SendBuffer write_std; * @param cls closure * @param message the actual message */ -typedef void (*MessageTokenizerCallback) (void *cls, +typedef void (*MessageTokenizerCallback) (void *cls, const struct GNUNET_MessageHeader * message); @@ -1059,7 +1059,7 @@ mst_destroy (struct MessageStreamTokenizer *mst) */ static int ieee80211_radiotap_iterator_init (struct Ieee80211RadiotapHeaderIterator *iterator, - const struct Ieee80211RadiotapHeader *radiotap_header, + const struct Ieee80211RadiotapHeader *radiotap_header, size_t max_length) { if ( (iterator == NULL) || @@ -1204,26 +1204,26 @@ ieee80211_radiotap_iterator_next (struct Ieee80211RadiotapHeaderIterator *iterat /* need padding (by 'wanted_alignment - unalignment') */ iterator->arg_index += wanted_alignment - unalignment; } - + /* * this is what we will return to user, but we need to * move on first so next call has something fresh to test - */ + */ iterator->this_arg_index = iterator->arg_index; iterator->this_arg = iterator->arg; /* internally move on the size of this arg (using lower nybble from - the table) */ + the table) */ iterator->arg += rt_sizes[iterator->arg_index] & 0x0f; - + /* * check for insanity where we are given a bitmap that * claims to have more arg content than the length of the * radiotap section. We will normally end up equalling this * max_length on the last arg, never exceeding it. - */ + */ if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) > iterator->max_length) - return -1; + return -1; } /* Now, move on to next bit / next entry */ @@ -1245,7 +1245,7 @@ ieee80211_radiotap_iterator_next (struct Ieee80211RadiotapHeaderIterator *iterat } } else - { + { /* just try the next bit (while loop will move on) */ iterator->bitmap_shifter >>= 1; } @@ -1364,7 +1364,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) if (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] && ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]) return 0; - return 1; + return 1; } @@ -1431,7 +1431,7 @@ linux_get_channel (const struct HardwareInfos *dev) * @return number of bytes written to 'buf' */ static ssize_t -linux_read (struct HardwareInfos *dev, +linux_read (struct HardwareInfos *dev, unsigned char *buf, size_t buf_size, struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *ri) { @@ -1452,7 +1452,7 @@ linux_read (struct HardwareInfos *dev, return -1; } - memset (ri, 0, sizeof (*ri)); + memset (ri, 0, sizeof (*ri)); switch (dev->arptype_in) { case ARPHRD_IEEE80211_PRISM: @@ -1511,7 +1511,7 @@ linux_read (struct HardwareInfos *dev, break; } } - } + } if ( (n < 8) || (n >= caplen) ) return 0; /* invalid format */ } @@ -1540,7 +1540,7 @@ linux_read (struct HardwareInfos *dev, if (!got_signal) { ri->ri_power = * ((int8_t*) iterator.this_arg); - got_signal = 1; + got_signal = 1; } break; case IEEE80211_RADIOTAP_DB_ANTSIGNAL: @@ -1594,7 +1594,7 @@ linux_read (struct HardwareInfos *dev, break; } /* end of 'switch' */ } /* end of the 'while' loop */ - } + } break; case ARPHRD_IEEE80211: n = 0; /* no header */ @@ -1607,7 +1607,7 @@ linux_read (struct HardwareInfos *dev, tmpbuf + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame), caplen - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) - 4 /* 4 byte FCS */); return caplen - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) - 4; - } + } default: errno = ENOTSUP; /* unsupported format */ return -1; @@ -1617,8 +1617,8 @@ linux_read (struct HardwareInfos *dev, ri->ri_channel = linux_get_channel (dev); /* detect CRC32 at the end, even if the flag wasn't set and remove it */ - if ( (0 == fcs_removed) && - (0 == check_crc_buf_osdep (tmpbuf + n, caplen - sizeof (uint32_t))) ) + if ( (0 == fcs_removed) && + (0 == check_crc_buf_osdep (tmpbuf + n, caplen - sizeof (uint32_t))) ) { /* NOTE: this heuristic can of course fail if there happens to be a matching checksum at the end. Would be good to have @@ -1751,9 +1751,9 @@ open_device_raw (struct HardwareInfos *dev) setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr, sizeof (mr))) { - fprintf (stderr, + fprintf (stderr, "Failed to enable promiscuous mode on interface `%.*s'\n", - IFNAMSIZ, + IFNAMSIZ, dev->iface); return 1; } @@ -1775,13 +1775,13 @@ test_wlan_interface (const char *iface) struct stat sbuf; int ret; - ret = snprintf (strbuf, sizeof (strbuf), + ret = snprintf (strbuf, sizeof (strbuf), "/sys/class/net/%s/phy80211/subsystem", iface); if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf))) { - fprintf (stderr, - "Did not find 802.11 interface `%s'. Exiting.\n", + fprintf (stderr, + "Did not find 802.11 interface `%s'. Exiting.\n", iface); exit (1); } @@ -1852,7 +1852,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) sendsize = ntohs (hdr->size); if ( (sendsize < sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage)) || - (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) ) + (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) ) { fprintf (stderr, "Received malformed message\n"); exit (1); @@ -1870,10 +1870,10 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) case ARPHRD_IEEE80211_FULL: case ARPHRD_IEEE80211: rtheader.header.it_version = 0; - rtheader.header.it_pad = 0; + rtheader.header.it_pad = 0; rtheader.header.it_len = GNUNET_htole16 (sizeof (rtheader)); rtheader.header.it_present = GNUNET_htole16 (IEEE80211_RADIOTAP_OUR_TRANSMISSION_HEADER_MASK); - rtheader.rate = header->rate; + rtheader.rate = header->rate; rtheader.pad1 = 0; rtheader.txflags = GNUNET_htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ); memcpy (write_pout.buf, &rtheader, sizeof (rtheader)); @@ -1934,7 +1934,7 @@ main (int argc, char *argv[]) return 254; } #else - if (0 != seteuid (0)) + if (0 != seteuid (0)) { fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno)); return 254; @@ -2012,9 +2012,9 @@ main (int argc, char *argv[]) memcpy (&macmsg.mac, &dev.pl_mac, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); memcpy (write_std.buf, &macmsg, sizeof (macmsg)); write_std.size = sizeof (macmsg); - } + } - stdin_mst = mst_create (&stdin_send_hw, &dev); + stdin_mst = mst_create (&stdin_send_hw, &dev); stdin_open = 1; while (1) { @@ -2071,7 +2071,7 @@ main (int argc, char *argv[]) if (FD_ISSET (dev.fd_raw, &wfds)) { ssize_t ret = - write (dev.fd_raw, write_pout.buf + write_std.pos, + write (dev.fd_raw, write_pout.buf + write_std.pos, write_pout.size - write_pout.pos); if (0 > ret) { @@ -2097,7 +2097,7 @@ main (int argc, char *argv[]) if (FD_ISSET (STDIN_FILENO, &rfds)) { - ssize_t ret = + ssize_t ret = read (STDIN_FILENO, readbuf, sizeof (readbuf)); if (0 > ret) { @@ -2120,9 +2120,9 @@ main (int argc, char *argv[]) rrm = (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) write_std.buf; ret = linux_read (&dev, (unsigned char *) &rrm->frame, - sizeof (write_std.buf) - - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) - + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame), + sizeof (write_std.buf) + - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) + + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame), rrm); if (0 > ret) { @@ -2131,8 +2131,8 @@ main (int argc, char *argv[]) } if ((0 < ret) && (0 == mac_test (&rrm->frame, &dev))) { - write_std.size = ret - + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) + write_std.size = ret + + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame); rrm->header.size = htons (write_std.size); 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, end: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Allowing receive from peer %s to continue in %s\n", - GNUNET_i2s (peer), + GNUNET_i2s (peer), GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES)); return ret; } 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) * @param option name of the option * @param value value of the option */ -static void +static void blacklist_cfg_iter (void *cls, const char *section, const char *option, const char *value) @@ -255,10 +255,10 @@ blacklist_cfg_iter (void *cls, const char *section, char *pos; if (GNUNET_OK != GNUNET_CRYPTO_ecc_public_sign_key_from_string (option, - strlen (option), + strlen (option), &peer.public_key)) return; - + if ((NULL == value) || (0 == strcmp(value, ""))) { /* Blacklist whole peer */ @@ -295,9 +295,9 @@ read_blacklist_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg, char cfg_sect[512]; unsigned int res = 0; - GNUNET_snprintf (cfg_sect, + GNUNET_snprintf (cfg_sect, sizeof (cfg_sect), - "transport-blacklist-%s", + "transport-blacklist-%s", GNUNET_i2s_full (my_id)); GNUNET_CONFIGURATION_iterate_section_values (cfg, cfg_sect, &blacklist_cfg_iter, &res); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -636,7 +636,7 @@ GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer, blacklist = GNUNET_CONTAINER_multipeermap_create (TRANSPORT_BLACKLIST_HT_SIZE, GNUNET_NO); - + GNUNET_CONTAINER_multipeermap_put (blacklist, peer, transport, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); @@ -653,7 +653,7 @@ GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer, * @return #GNUNET_OK if the entry does not match, #GNUNET_NO if it matches */ static int -test_blacklisted (void *cls, +test_blacklisted (void *cls, const struct GNUNET_PeerIdentity *key, void *value) { 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, setup_monitoring_client (client, &msg->peer); else GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, - GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); + GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); } 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) friend_only = GNUNET_HELLO_is_friend_only (our_hello); GNUNET_free (our_hello); our_hello = GNUNET_HELLO_create (&GST_my_identity.public_key, - &address_generator, + &address_generator, &gc, friend_only); GNUNET_assert (NULL != our_hello); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -215,7 +215,7 @@ GST_hello_start (int friend_only, GST_HelloCallback cb, void *cb_cls) { hello_cb = cb; hello_cb_cls = cb_cls; - our_hello = GNUNET_HELLO_create (&GST_my_identity.public_key, + our_hello = GNUNET_HELLO_create (&GST_my_identity.public_key, NULL, NULL, friend_only); GNUNET_assert (NULL != our_hello); 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, tmp->metrics[c][c2] = UINT32_MAX; } } - GNUNET_CONTAINER_multipeermap_put (man_handle.peers, + GNUNET_CONTAINER_multipeermap_put (man_handle.peers, &tm->peer, tmp, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); } @@ -581,64 +581,64 @@ GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg) { unsigned long long tmp; struct GNUNET_TIME_Relative delay; - + if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg, "transport", "MANIPULATE_DISTANCE_IN", - &tmp)) && + &tmp)) && (tmp > 0) ) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting inbound distance_in to %llu\n", (unsigned long long) tmp); set_metric (&man_handle.general, TM_RECEIVE, GNUNET_ATS_QUALITY_NET_DISTANCE, tmp); } - + if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg, - "transport", + "transport", "MANIPULATE_DISTANCE_OUT", &tmp)) && (tmp > 0) ) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting outbound distance_in to %llu\n", (unsigned long long) tmp); - set_metric (&man_handle.general, TM_SEND, + set_metric (&man_handle.general, TM_SEND, GNUNET_ATS_QUALITY_NET_DISTANCE, tmp); } - + if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (GST_cfg, "transport", "MANIPULATE_DELAY_IN", - &delay)) && + &delay)) && (delay.rel_value_us > 0) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Delaying inbound traffic for %s\n", GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); set_metric (&man_handle.general, TM_RECEIVE, - GNUNET_ATS_QUALITY_NET_DELAY, + GNUNET_ATS_QUALITY_NET_DELAY, delay.rel_value_us); } if ( (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (GST_cfg, "transport", "MANIPULATE_DELAY_OUT", - &delay)) && + &delay)) && (delay.rel_value_us > 0) ) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Delaying outbound traffic for %s\n", GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); - set_metric (&man_handle.general, + set_metric (&man_handle.general, TM_SEND, - GNUNET_ATS_QUALITY_NET_DELAY, + GNUNET_ATS_QUALITY_NET_DELAY, delay.rel_value_us); - } + } man_handle.peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); } -static int +static int free_tmps (void *cls, const struct GNUNET_PeerIdentity *key, 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 @@ #define SETUP_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) /** - * How long are we willing to wait for a successful reconnect if + * How long are we willing to wait for a successful reconnect if * an existing connection went down? Much shorter than the * usual SETUP_CONNECTION_TIMEOUT as we do not inform the * higher layers about the disconnect during this period. @@ -271,7 +271,7 @@ GNUNET_NETWORK_STRUCT_BEGIN * setup a connection/session for data exchange. A 'SESSION_CONNECT' * should be answered with a 'SESSION_CONNECT_ACK' with the same body * to confirm. A 'SESSION_CONNECT_ACK' should then be followed with - * a 'SESSION_ACK'. Once the 'SESSION_ACK' is received, both peers + * a 'SESSION_ACK'. Once the 'SESSION_ACK' is received, both peers * should be connected. */ struct SessionConnectMessage @@ -298,7 +298,7 @@ struct SessionConnectMessage /** * Message we send to the other peer to notify him that we intentionally - * are disconnecting (to reduce timeouts). This is just a friendly + * are disconnecting (to reduce timeouts). This is just a friendly * notification, peers must not rely on always receiving disconnect * messages. */ @@ -448,8 +448,8 @@ struct MessageQueue * and set the 'send_connect_ack' to 2. If we then receive a * 'SESSION_ACK', we go to 'S_CONNECTED' (and reset 'send_connect_ack' * to 0). - * - */ + * + */ enum State { /** @@ -525,7 +525,7 @@ enum State */ S_CONNECTED_SWITCHING_BLACKLIST, - /** + /** * We have some primary connection, but ATS suggested we switch * to some alternative; we now sent a CONNECT message for the * alternative session to the other peer and waiting for a @@ -589,7 +589,7 @@ struct NeighbourAddress * Did we tell ATS that this is our 'active' address? */ int ats_active; - + }; @@ -644,7 +644,7 @@ struct NeighbourMapEntry struct GNUNET_TIME_Absolute keep_alive_time; /** - * At what time did we sent the last keep-alive message? Used + * At what time did we sent the last keep-alive message? Used * to calculate round-trip time ("latency"). */ struct GNUNET_TIME_Absolute last_keep_alive_time; @@ -713,7 +713,7 @@ struct NeighbourMapEntry */ struct BlackListCheckContext { - + /** * We keep blacklist checks in a DLL. */ @@ -954,7 +954,7 @@ set_address (struct NeighbourAddress *na, int is_active) { struct GNUNET_TRANSPORT_PluginFunctions *papi; - if (NULL == (papi = GST_plugins_find (address->transport_name))) + if (NULL == (papi = GST_plugins_find (address->transport_name))) { GNUNET_break (0); return; @@ -976,17 +976,17 @@ set_address (struct NeighbourAddress *na, /* FIXME: is this the right place to set quotas? */ GST_neighbours_set_incoming_quota (&address->peer, bandwidth_in); send_outbound_quota (&address->peer, bandwidth_out); - } + } return; } free_address (na); if (NULL == session) - session = papi->get_session (papi->cls, address); + session = papi->get_session (papi->cls, address); if (NULL == session) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to obtain new session for peer `%s' and address '%s'\n", - GNUNET_i2s (&address->peer), GST_plugins_a2s (address)); + GNUNET_i2s (&address->peer), GST_plugins_a2s (address)); GNUNET_ATS_address_destroyed (GST_ats, address, NULL); return; } @@ -1037,8 +1037,8 @@ free_neighbour (struct NeighbourMapEntry *n, int keep_sessions) least internally we need to get clean... */ if (GNUNET_YES == test_connected (n)) { - GNUNET_STATISTICS_set (GST_stats, - gettext_noop ("# peers connected"), + GNUNET_STATISTICS_set (GST_stats, + gettext_noop ("# peers connected"), --neighbours_connected, GNUNET_NO); disconnect_notify_cb (callback_cls, &n->id); @@ -1226,7 +1226,7 @@ send_disconnect (struct NeighbourMapEntry *n) static void disconnect_neighbour (struct NeighbourMapEntry *n) { - /* depending on state, notify neighbour and/or upper layers of this peer + /* depending on state, notify neighbour and/or upper layers of this peer about disconnect */ switch (n->state) { @@ -1238,7 +1238,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n) free_neighbour (n, GNUNET_NO); return; case S_CONNECT_SENT: - send_disconnect (n); + send_disconnect (n); n->state = S_DISCONNECT; break; case S_CONNECT_RECV_BLACKLIST_INBOUND: @@ -1250,9 +1250,9 @@ disconnect_neighbour (struct NeighbourMapEntry *n) return; case S_CONNECT_RECV_ACK: /* we DID ACK the other peer's request, must send DISCONNECT */ - send_disconnect (n); + send_disconnect (n); n->state = S_DISCONNECT; - break; + break; case S_CONNECTED: case S_RECONNECT_BLACKLIST: case S_RECONNECT_SENT: @@ -1261,8 +1261,8 @@ disconnect_neighbour (struct NeighbourMapEntry *n) /* we are currently connected, need to send disconnect and do internal notifications and update statistics */ send_disconnect (n); - GNUNET_STATISTICS_set (GST_stats, - gettext_noop ("# peers connected"), + GNUNET_STATISTICS_set (GST_stats, + gettext_noop ("# peers connected"), --neighbours_connected, GNUNET_NO); disconnect_notify_cb (callback_cls, &n->id); @@ -1326,7 +1326,7 @@ transmit_send_continuation (void *cls, n->is_active = NULL; if (GNUNET_SCHEDULER_NO_TASK != n->task) GNUNET_SCHEDULER_cancel (n->task); - n->task = GNUNET_SCHEDULER_add_now (&master_task, n); + n->task = GNUNET_SCHEDULER_add_now (&master_task, n); } if (bytes_in_send_queue < mq->message_buf_size) { @@ -1355,7 +1355,7 @@ transmit_send_continuation (void *cls, gettext_noop ("# transmission failures for messages to other peers"), 1, GNUNET_NO); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message to `%s' of type %u was a %s\n", GNUNET_i2s (receiver), ntohs (((struct GNUNET_MessageHeader *) mq->message_buf)->type), @@ -1389,7 +1389,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) GNUNET_break (0); return; } - if ((0 == n->primary_address.address->address_length) && + if ((0 == n->primary_address.address->address_length) && (NULL == n->primary_address.session)) { /* no address, why are we here? */ @@ -1399,7 +1399,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) if (NULL != n->is_active) { /* transmission already pending */ - return; + return; } /* timeout messages from the queue that are past their due date */ @@ -1535,7 +1535,7 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour) n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Latency for peer `%s' is %s\n", - GNUNET_i2s (&n->id), + GNUNET_i2s (&n->id), GNUNET_STRINGS_relative_time_to_string (n->latency, GNUNET_YES)); /* append latency */ @@ -1570,7 +1570,7 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity { struct NeighbourMapEntry *n; struct GNUNET_TIME_Relative ret; - + if (NULL == neighbours) { *do_forward = GNUNET_NO; @@ -1634,7 +1634,7 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES)); GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# ms throttling suggested"), - (int64_t) ret.rel_value_us / 1000LL, + (int64_t) ret.rel_value_us / 1000LL, GNUNET_NO); } return ret; @@ -1708,13 +1708,13 @@ send_session_connect (struct NeighbourAddress *na) struct GNUNET_TRANSPORT_PluginFunctions *papi; struct SessionConnectMessage connect_msg; - if (NULL == (papi = GST_plugins_find (na->address->transport_name))) + if (NULL == (papi = GST_plugins_find (na->address->transport_name))) { GNUNET_break (0); return; } if (NULL == na->session) - na->session = papi->get_session (papi->cls, na->address); + na->session = papi->get_session (papi->cls, na->address); if (NULL == na->session) { GNUNET_break (0); @@ -1750,13 +1750,13 @@ send_session_connect_ack_message (const struct GNUNET_HELLO_Address *address, struct GNUNET_TRANSPORT_PluginFunctions *papi; struct SessionConnectMessage connect_msg; - if (NULL == (papi = GST_plugins_find (address->transport_name))) + if (NULL == (papi = GST_plugins_find (address->transport_name))) { GNUNET_break (0); return; } if (NULL == session) - session = papi->get_session (papi->cls, address); + session = papi->get_session (papi->cls, address); if (NULL == session) { GNUNET_break (0); @@ -1788,7 +1788,7 @@ setup_neighbour (const struct GNUNET_PeerIdentity *peer) struct NeighbourMapEntry *n; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Creating new neighbour entry for `%s'\n", + "Creating new neighbour entry for `%s'\n", GNUNET_i2s (peer)); n = MEMDEBUG_malloc (sizeof (struct NeighbourMapEntry), __LINE__); n->id = *peer; @@ -1842,7 +1842,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) { struct NeighbourMapEntry *n; - if (NULL == neighbours) + if (NULL == neighbours) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to connect to peer `%s' during shutdown\n", @@ -1881,7 +1881,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) "Ignoring request to try to connect to `%s', already trying!\n", GNUNET_i2s (target)); return; /* already trying */ - case S_CONNECTED: + case S_CONNECTED: case S_RECONNECT_ATS: case S_RECONNECT_BLACKLIST: case S_RECONNECT_SENT: @@ -1896,8 +1896,8 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) free_neighbour (n, GNUNET_NO); break; case S_DISCONNECT_FINISHED: - /* should not be possible */ - GNUNET_assert (0); + /* should not be possible */ + GNUNET_assert (0); default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state)); GNUNET_break (0); @@ -1905,8 +1905,8 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) break; } } - n = setup_neighbour (target); - n->state = S_INIT_ATS; + n = setup_neighbour (target); + n->state = S_INIT_ATS; n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT); GNUNET_ATS_reset_backoff (GST_ats, target); @@ -1988,7 +1988,7 @@ handle_test_blacklist_cont (void *cls, n->primary_address.session, n->connect_ack_timestamp); } - break; + break; case S_CONNECT_RECV_BLACKLIST_INBOUND: if (GNUNET_OK == result) GST_ats_add_address (bcc->na.address, bcc->na.session); @@ -2011,7 +2011,7 @@ handle_test_blacklist_cont (void *cls, send_session_connect_ack_message (bcc->na.address, bcc->na.session, n->connect_ack_timestamp); - if (1 == n->send_connect_ack) + if (1 == n->send_connect_ack) n->send_connect_ack = 2; } else @@ -2038,13 +2038,13 @@ handle_test_blacklist_cont (void *cls, n->primary_address.session, n->connect_ack_timestamp); } - break; + break; case S_CONNECTED: /* already connected, don't care about blacklist */ break; case S_RECONNECT_ATS: /* still waiting on ATS suggestion, don't care about blacklist */ - break; + break; case S_RECONNECT_BLACKLIST: if ( (GNUNET_OK == result) && (1 == n->send_connect_ack) ) @@ -2083,7 +2083,7 @@ handle_test_blacklist_cont (void *cls, n->primary_address.session, n->connect_ack_timestamp); } - break; + break; case S_CONNECTED_SWITCHING_BLACKLIST: if (GNUNET_YES != address_matches (&bcc->na, &n->alternative_address)) break; /* result for an address we currently don't care about */ @@ -2111,7 +2111,7 @@ handle_test_blacklist_cont (void *cls, n->primary_address.session, n->connect_ack_timestamp); } - break; + break; case S_DISCONNECT: /* Nothing to do here, ATS will already do what can be done */ break; @@ -2163,10 +2163,10 @@ check_blacklist (const struct GNUNET_PeerIdentity *peer, GNUNET_CONTAINER_DLL_insert (bc_head, bc_tail, bcc); - if (NULL != (bc = GST_blacklist_test_allowed (peer, + if (NULL != (bc = GST_blacklist_test_allowed (peer, address->transport_name, &handle_test_blacklist_cont, bcc))) - bcc->bc = bc; + bcc->bc = bc; /* if NULL == bc, 'cont' was already called and 'bcc' already free'd, so we must only store 'bc' if 'bc' is non-NULL... */ } @@ -2193,7 +2193,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, struct GNUNET_TIME_Absolute ts; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received CONNECT message from peer `%s'\n", + "Received CONNECT message from peer `%s'\n", GNUNET_i2s (peer)); if (ntohs (message->size) != sizeof (struct SessionConnectMessage)) @@ -2213,7 +2213,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, n->connect_ack_timestamp = ts; switch (n->state) - { + { case S_NOT_CONNECTED: n->state = S_CONNECT_RECV_BLACKLIST_INBOUND; /* Do a blacklist check for the new address */ @@ -2229,7 +2229,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, case S_CONNECT_RECV_ATS: case S_CONNECT_RECV_BLACKLIST: case S_CONNECT_RECV_ACK: - /* It can never hurt to have an alternative address in the above cases, + /* It can never hurt to have an alternative address in the above cases, see if it is allowed */ check_blacklist (peer, ts, address, session); break; @@ -2247,7 +2247,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, case S_RECONNECT_ATS: case S_RECONNECT_BLACKLIST: case S_RECONNECT_SENT: - /* It can never hurt to have an alternative address in the above cases, + /* It can never hurt to have an alternative address in the above cases, see if it is allowed */ check_blacklist (peer, ts, address, session); break; @@ -2286,7 +2286,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, /** * For an existing neighbour record, set the active connection to - * use the given address. + * use the given address. * * @param peer identity of the peer to switch the address for * @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, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to obtain new session for peer `%s' and address '%s'\n", - GNUNET_i2s (&address->peer), GST_plugins_a2s (address)); + GNUNET_i2s (&address->peer), GST_plugins_a2s (address)); GNUNET_ATS_address_destroyed (GST_ats, address, NULL); return; } @@ -2529,7 +2529,7 @@ master_task (void *cls, struct GNUNET_TIME_Relative delay; n->task = GNUNET_SCHEDULER_NO_TASK; - delay = GNUNET_TIME_absolute_get_remaining (n->timeout); + delay = GNUNET_TIME_absolute_get_remaining (n->timeout); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Master task runs for neighbour `%s' in state %s with timeout in %s\n", GNUNET_i2s (&n->id), @@ -2698,11 +2698,11 @@ master_task (void *cls, default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state)); GNUNET_break (0); - break; + break; } if ( (S_CONNECTED_SWITCHING_CONNECT_SENT == n->state) || (S_CONNECTED_SWITCHING_BLACKLIST == n->state) || - (S_CONNECTED == n->state) ) + (S_CONNECTED == n->state) ) { /* if we are *now* in one of these three states, we're sending keep alive messages, so we need to consider the keepalive @@ -2789,14 +2789,14 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, gettext_noop ("# unexpected CONNECT_ACK messages (not ready)"), 1, GNUNET_NO); - break; + break; case S_CONNECT_SENT: if (ts.abs_value_us != n->primary_address.connect_timestamp.abs_value_us) break; /* ACK does not match our original CONNECT message */ n->state = S_CONNECTED; n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); - GNUNET_STATISTICS_set (GST_stats, - gettext_noop ("# peers connected"), + GNUNET_STATISTICS_set (GST_stats, + gettext_noop ("# peers connected"), ++neighbours_connected, GNUNET_NO); connect_notify_cb (callback_cls, &n->id, @@ -2858,7 +2858,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, GNUNET_YES); free_address (&n->alternative_address); send_session_ack_message (n); - break; + break; case S_DISCONNECT: GNUNET_STATISTICS_update (GST_stats, gettext_noop @@ -2871,7 +2871,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s' \n",print_state (n->state)); GNUNET_break (0); - break; + break; } } @@ -2945,7 +2945,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, &n->id); break; case S_CONNECT_RECV_BLACKLIST_INBOUND: - case S_CONNECT_RECV_ATS: + case S_CONNECT_RECV_ATS: case S_CONNECT_RECV_BLACKLIST: case S_CONNECT_RECV_ACK: /* error on inbound session; free neighbour entirely */ @@ -2972,7 +2972,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, break; case S_CONNECTED_SWITCHING_BLACKLIST: /* primary went down while we were checking secondary against - blacklist, adopt secondary as primary */ + blacklist, adopt secondary as primary */ free_address (&n->primary_address); n->primary_address = n->alternative_address; memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress)); @@ -2981,7 +2981,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, break; case S_CONNECTED_SWITCHING_CONNECT_SENT: /* primary went down while we were waiting for CONNECT_ACK on secondary; - secondary as primary */ + secondary as primary */ free_address (&n->primary_address); n->primary_address = n->alternative_address; memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress)); @@ -3026,7 +3026,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, { struct NeighbourMapEntry *n; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received SESSION_ACK message from peer `%s'\n", GNUNET_i2s (peer)); if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader)) @@ -3049,8 +3049,8 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, } n->state = S_CONNECTED; n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); - GNUNET_STATISTICS_set (GST_stats, - gettext_noop ("# peers connected"), + GNUNET_STATISTICS_set (GST_stats, + gettext_noop ("# peers connected"), ++neighbours_connected, GNUNET_NO); connect_notify_cb (callback_cls, &n->id, @@ -3263,7 +3263,7 @@ GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls) { struct IteratorContext ic; - if (NULL == neighbours) + if (NULL == neighbours) return; /* can happen during shutdown */ ic.cb = cb; ic.cb_cls = cb_cls; @@ -3296,7 +3296,7 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target) * Obtain current latency information for the given neighbour. * * @param peer to get the latency for - * @return observed latency of the address, FOREVER if the + * @return observed latency of the address, FOREVER if the * the connection is not up */ struct GNUNET_TIME_Relative @@ -3305,7 +3305,7 @@ GST_neighbour_get_latency (const struct GNUNET_PeerIdentity *peer) struct NeighbourMapEntry *n; n = lookup_neighbour (peer); - if (NULL == n) + if (NULL == n) return GNUNET_TIME_UNIT_FOREVER_REL; switch (n->state) { @@ -3332,7 +3332,7 @@ GST_neighbour_get_latency (const struct GNUNET_PeerIdentity *peer) GNUNET_break (0); break; } - return GNUNET_TIME_UNIT_FOREVER_REL; + return GNUNET_TIME_UNIT_FOREVER_REL; } @@ -3388,13 +3388,13 @@ GST_neighbours_start (void *cls, * @return GNUNET_OK (continue to iterate) */ static int -disconnect_all_neighbours (void *cls, - const struct GNUNET_PeerIdentity *key, +disconnect_all_neighbours (void *cls, + const struct GNUNET_PeerIdentity *key, void *value) { struct NeighbourMapEntry *n = value; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n", GNUNET_i2s (&n->id), "SHUTDOWN_TASK"); n->state = S_DISCONNECT_FINISHED; @@ -3411,7 +3411,7 @@ GST_neighbours_stop () { if (NULL == neighbours) return; - GNUNET_CONTAINER_multipeermap_iterate (neighbours, + GNUNET_CONTAINER_multipeermap_iterate (neighbours, &disconnect_all_neighbours, NULL); 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) validations_fast_start_threshold = (max_fds / 2); validations_running = 0; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Validation uses a fast start threshold of %u connections and a delay between of %s\n ", - validations_fast_start_threshold, + validations_fast_start_threshold, GNUNET_STRINGS_relative_time_to_string (validation_delay, GNUNET_YES)); validation_map = GNUNET_CONTAINER_multipeermap_create (VALIDATION_MAP_SIZE, @@ -855,7 +855,7 @@ GST_validation_stop () */ static void multicast_pong (void *cls, - const struct GNUNET_CRYPTO_EccPublicSignKey *public_key, + const struct GNUNET_CRYPTO_EccPublicSignKey *public_key, struct GNUNET_TIME_Absolute valid_until, struct GNUNET_TIME_Absolute validation_block, const struct GNUNET_HELLO_Address *address) @@ -1075,7 +1075,7 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, pong->expiration = GNUNET_TIME_absolute_hton (*sig_cache_exp); } pong->signature = *sig_cache; - + GNUNET_assert (sender_address != NULL); /* 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 @@ static void -removecerts (const char *file1, +removecerts (const char *file1, const char *file2) { if (GNUNET_YES == GNUNET_DISK_file_test (file1)) @@ -55,7 +55,7 @@ main (int argc, char **argv) if (3 != argc) { - fprintf (stderr, + fprintf (stderr, "Invalid arguments.\n"); return 1; } @@ -68,7 +68,7 @@ main (int argc, char **argv) "-out", argv[1], "1024", NULL); if (NULL == openssl) { - fprintf (stderr, + fprintf (stderr, "Failed to run openssl. Is openssl installed?\n"); return 2; } @@ -83,7 +83,7 @@ main (int argc, char **argv) "-new", "-x509", "-key", argv[1], NULL); if (NULL == openssl) { - fprintf (stderr, + fprintf (stderr, "Failed to create self-signed certificate with openssl.\n"); return 3; } 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[]) /* Setup communication pipeline first */ if (pipe (commpipe)) { - fprintf (stderr, + fprintf (stderr, "Failed to create pipe: %s\n", STRERROR (errno)); exit (1); @@ -62,8 +62,8 @@ main (int argc, char *argv[]) /* Attempt to fork and check for errors */ if ((pid = fork ()) == -1) { - fprintf (stderr, "Failed to fork: %s\n", - STRERROR (errno)); + fprintf (stderr, "Failed to fork: %s\n", + STRERROR (errno)); exit (1); } @@ -90,7 +90,7 @@ main (int argc, char *argv[]) { bytes_per_s = count / (akt - start); bytes_per_s /= 1024; - printf ("recv %f kb/s\n", bytes_per_s); + printf ("recv %f kb/s\n", bytes_per_s); start = akt; count = 0; } 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, * @return GNUNET_YES if there was no error */ static int -getWlanHeader (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *Header, +getWlanHeader (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *Header, const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac, unsigned int size) { @@ -148,14 +148,14 @@ main (int argc, char *argv[]) /* Setup communication pipeline first */ if (pipe (commpipe)) { - fprintf (stderr, + fprintf (stderr, "Failed to create pipe: %s\n", STRERROR (errno)); exit (1); } if (pipe (macpipe)) { - fprintf (stderr, + fprintf (stderr, "Failed to create pipe: %s\n", STRERROR (errno)); exit (1); @@ -164,8 +164,8 @@ main (int argc, char *argv[]) /* Attempt to fork and check for errors */ if ((pid = fork ()) == -1) { - fprintf (stderr, "Failed to fork: %s\n", - STRERROR (errno)); + fprintf (stderr, "Failed to fork: %s\n", + STRERROR (errno)); exit (1); } memset (msg_buf, 0x42, sizeof (msg_buf)); @@ -183,12 +183,12 @@ main (int argc, char *argv[]) "Failed to close fd: %s\n", strerror (errno)); if (sizeof (hcm) != read (macpipe[0], &hcm, sizeof (hcm))) - fprintf (stderr, + fprintf (stderr, "Failed to read hcm...\n"); fprintf (stderr, - "Got MAC %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", + "Got MAC %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", hcm.mac.mac[0], hcm.mac.mac[1], - hcm.mac.mac[2], hcm.mac.mac[3], hcm.mac.mac[4], hcm.mac.mac[5]); + hcm.mac.mac[2], hcm.mac.mac[3], hcm.mac.mac[4], hcm.mac.mac[5]); radiotap = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) msg_buf; getRadiotapHeader (radiotap, WLAN_MTU); getWlanHeader (&radiotap->frame, &outmac, &inmac, @@ -212,7 +212,7 @@ main (int argc, char *argv[]) printf ("send %f kbytes/s\n", bytes_per_s); start = akt; count = 0; - } + } } } 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) if (try_connect) { /* all done, terminate instantly */ - FPRINTF (stdout, - _("Successfully connected to `%s'\n"), + FPRINTF (stdout, + _("Successfully connected to `%s'\n"), GNUNET_i2s_full (peer)); ret = 0; @@ -803,12 +803,12 @@ testservice_task (void *cls, if (GNUNET_YES != result) { - FPRINTF (stderr, + FPRINTF (stderr, _("Service `%s' is not running\n"), "transport"); return; } - if ( (NULL != cpid) && + if ( (NULL != cpid) && (GNUNET_OK != GNUNET_CRYPTO_ecc_public_sign_key_from_string (cpid, strlen (cpid), &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 /** * Header for messages which need fragmentation. This is the format of * a message we obtain AFTER defragmentation. We then need to check - * the CRC and then tokenize the payload and pass it to the + * the CRC and then tokenize the payload and pass it to the * 'receive' callback. */ struct WlanHeader @@ -397,7 +397,7 @@ struct Plugin /** * Handle to helper process for priviledged operations. - */ + */ struct GNUNET_HELPER_Handle *suid_helper; /** @@ -559,7 +559,7 @@ get_radiotap_header (struct MacEndpoint *endpoint, static void get_wlan_header (struct Plugin *plugin, struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *header, - const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, + const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, unsigned int size) { const int rate = 11000000; @@ -599,12 +599,12 @@ send_ack (void *cls, uint32_t msg_id, GNUNET_break (0); return; } - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending ACK to helper\n"); radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf; get_radiotap_header (endpoint, radio_header, size); get_wlan_header (endpoint->plugin, - &radio_header->frame, + &radio_header->frame, &endpoint->addr.mac, size); memcpy (&radio_header[1], hdr, msize); @@ -612,7 +612,7 @@ send_ack (void *cls, uint32_t msg_id, GNUNET_HELPER_send (endpoint->plugin->suid_helper, &radio_header->header, GNUNET_NO /* dropping ACKs is bad */, - NULL, NULL)) + NULL, NULL)) GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# Bluetooth ACKs sent"), 1, GNUNET_NO); } @@ -636,7 +636,7 @@ bluetooth_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hd GNUNET_NO); mas.session = NULL; mas.endpoint = endpoint; - (void) GNUNET_SERVER_mst_receive (plugin->fragment_data_tokenizer, + (void) GNUNET_SERVER_mst_receive (plugin->fragment_data_tokenizer, &mas, (const char *) hdr, ntohs (hdr->size), @@ -654,7 +654,7 @@ free_session (struct Session *session) { struct MacEndpoint *endpoint = session->mac; struct PendingMessage *pm; - + endpoint->plugin->env->session_end (endpoint->plugin->env->cls, &session->target, session); @@ -670,7 +670,7 @@ free_session (struct Session *session) GNUNET_free (pm->msg); GNUNET_free (pm); } - GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, + GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, endpoint->sessions_tail, session); if (session->timeout_task != GNUNET_SCHEDULER_NO_TASK) @@ -698,7 +698,7 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) session->timeout_task = GNUNET_SCHEDULER_NO_TASK; timeout = GNUNET_TIME_absolute_get_remaining (session->timeout); - if (0 == timeout.rel_value_us) + if (0 == timeout.rel_value_us) { free_session (session); return; @@ -739,7 +739,7 @@ create_session (struct MacEndpoint *endpoint, session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); session->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, session); - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Created new session for peer `%s' with endpoint %s\n", GNUNET_i2s (peer), mac_to_string (&endpoint->addr.mac)); @@ -752,7 +752,7 @@ create_session (struct MacEndpoint *endpoint, * message to the SUID helper process and we are thus ready for * the next fragment. * - * @param cls the 'struct FragmentMessage' + * @param cls the 'struct FragmentMessage' * @param result result of the operation (GNUNET_OK on success, GNUNET_NO if the helper died, GNUNET_SYSERR * if the helper was stopped) */ @@ -772,7 +772,7 @@ fragment_transmission_done (void *cls, * Transmit a fragment of a message. * * @param cls 'struct FragmentMessage' this fragment message belongs to - * @param hdr pointer to the start of the fragment message + * @param hdr pointer to the start of the fragment message */ static void transmit_fragment (void *cls, @@ -792,7 +792,7 @@ transmit_fragment (void *cls, radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf; get_radiotap_header (endpoint, radio_header, size); get_wlan_header (endpoint->plugin, - &radio_header->frame, + &radio_header->frame, &endpoint->addr.mac, size); memcpy (&radio_header[1], hdr, msize); @@ -827,7 +827,7 @@ free_fragment_message (struct FragmentMessage *fm) { struct MacEndpoint *endpoint = fm->macendpoint; - GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# Bluetooth messages pending (with fragmentation)"), + GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# Bluetooth messages pending (with fragmentation)"), -1, GNUNET_NO); GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head, endpoint->sending_messages_tail, fm); @@ -887,7 +887,7 @@ fragmentmessage_timeout (void *cls, static void send_with_fragmentation (struct MacEndpoint *endpoint, struct GNUNET_TIME_Relative timeout, - const struct GNUNET_PeerIdentity *target, + const struct GNUNET_PeerIdentity *target, const struct GNUNET_MessageHeader *msg, size_t payload_size, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) @@ -914,7 +914,7 @@ send_with_fragmentation (struct MacEndpoint *endpoint, msg, &transmit_fragment, fm); fm->timeout_task = - GNUNET_SCHEDULER_add_delayed (timeout, + GNUNET_SCHEDULER_add_delayed (timeout, &fragmentmessage_timeout, fm); GNUNET_CONTAINER_DLL_insert_tail (endpoint->sending_messages_head, endpoint->sending_messages_tail, @@ -924,7 +924,7 @@ send_with_fragmentation (struct MacEndpoint *endpoint, /** * Free a MAC endpoint. - * + * * @param endpoint pointer to the MacEndpoint to free */ static void @@ -940,8 +940,8 @@ free_macendpoint (struct MacEndpoint *endpoint) free_session (session); while (NULL != (fm = endpoint->sending_messages_head)) free_fragment_message (fm); - GNUNET_CONTAINER_DLL_remove (plugin->mac_head, - plugin->mac_tail, + GNUNET_CONTAINER_DLL_remove (plugin->mac_head, + plugin->mac_tail, endpoint); if (NULL != endpoint->defrag) @@ -974,7 +974,7 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK; timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout); - if (0 == timeout.rel_value_us) + if (0 == timeout.rel_value_us) { free_macendpoint (endpoint); return; @@ -1000,14 +1000,14 @@ create_macendpoint (struct Plugin *plugin, for (pos = plugin->mac_head; NULL != pos; pos = pos->next) if (0 == memcmp (addr, &pos->addr, sizeof (struct WlanAddress))) - return pos; + return pos; pos = GNUNET_malloc (sizeof (struct MacEndpoint)); pos->addr = *addr; pos->plugin = plugin; pos->defrag = GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU, MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, - pos, + pos, &bluetooth_data_message_handler, &send_ack); @@ -1022,7 +1022,7 @@ create_macendpoint (struct Plugin *plugin, plugin->mac_count++; GNUNET_STATISTICS_update (plugin->env->stats, _("# Bluetooth MAC endpoints allocated"), 1, GNUNET_NO); - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "New MAC endpoint `%s'\n", bluetooth_plugin_address_to_string(NULL, addr, sizeof (struct WlanAddress))); return pos; @@ -1142,7 +1142,7 @@ bluetooth_plugin_send (void *cls, size_t size = msgbuf_size + sizeof (struct WlanHeader); char buf[size] GNUNET_ALIGN; - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting %u bytes of payload to peer `%s' (starting with %u byte message of type %u)\n", msgbuf_size, GNUNET_i2s (&session->target), @@ -1202,7 +1202,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) switch (ntohs (hdr->type)) { case GNUNET_MESSAGE_TYPE_HELLO: - if (GNUNET_OK != + if (GNUNET_OK != GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource)) { GNUNET_break_op (0); @@ -1217,9 +1217,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) GNUNET_STATISTICS_update (plugin->env->stats, _("# HELLO messages received via Bluetooth"), 1, GNUNET_NO); - plugin->env->receive (plugin->env->cls, + plugin->env->receive (plugin->env->cls, &tmpsource, - hdr, + hdr, mas->session, (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, (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) GNUNET_break (0); break; } - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing %u bytes of FRAGMENT from MAC %s\n", (unsigned int) msize, 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) ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr); if (GNUNET_OK == ret) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Got last ACK, finished message transmission to `%s' (%p)\n", bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)), fm); @@ -1273,13 +1273,13 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) } if (GNUNET_NO == ret) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Got an ACK, message transmission to `%s' not yet finished\n", bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); break; } } - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "ACK not matched against any active fragmentation with MAC `%s'\n", bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); break; @@ -1293,13 +1293,13 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) { GNUNET_break (0); break; - } + } wlanheader = (const struct WlanHeader *) hdr; if (0 != memcmp (&wlanheader->target, plugin->env->my_identity, sizeof (struct GNUNET_PeerIdentity))) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Bluetooth data for `%s', not for me, ignoring\n", GNUNET_i2s (&wlanheader->target)); break; @@ -1314,15 +1314,15 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) } xmas.endpoint = mas->endpoint; xmas.session = create_session (mas->endpoint, &wlanheader->sender); - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing %u bytes of BLUETOOTH DATA from peer `%s'\n", (unsigned int) msize, GNUNET_i2s (&wlanheader->sender)); - (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer, + (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer, &xmas, (const char *) &wlanheader[1], msize - sizeof (struct WlanHeader), - GNUNET_YES, GNUNET_NO); + GNUNET_YES, GNUNET_NO); break; default: if (NULL == mas->endpoint) @@ -1340,9 +1340,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) (unsigned int) msize, (unsigned int) ntohs (hdr->type), GNUNET_i2s (&mas->session->target)); - plugin->env->receive (plugin->env->cls, + plugin->env->receive (plugin->env->cls, &mas->session->target, - hdr, + hdr, mas->session, (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, (mas->endpoint == NULL) ? 0 : sizeof (struct WlanAddress)); @@ -1416,7 +1416,7 @@ handle_helper_message (void *cls, void *client, "bluetooth"); break; case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER: - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Got data message from helper with %u bytes\n", msize); GNUNET_STATISTICS_update (plugin->env->stats, @@ -1453,7 +1453,7 @@ handle_helper_message (void *cls, void *client, /* packet is FROM us, thus not FOR us */ break; } - + GNUNET_STATISTICS_update (plugin->env->stats, _("# Bluetooth DATA messages processed"), 1, GNUNET_NO); @@ -1465,7 +1465,7 @@ handle_helper_message (void *cls, void *client, wa.options = htonl (0); mas.endpoint = create_macendpoint (plugin, &wa); mas.session = NULL; - (void) GNUNET_SERVER_mst_receive (plugin->helper_payload_tokenizer, + (void) GNUNET_SERVER_mst_receive (plugin->helper_payload_tokenizer, &mas, (const char*) &rxinfo[1], msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage), @@ -1473,7 +1473,7 @@ handle_helper_message (void *cls, void *client, break; default: GNUNET_break (0); - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Unexpected message of type %u (%u bytes)", ntohs (hdr->type), ntohs (hdr->size)); break; @@ -1506,7 +1506,7 @@ send_hello_beacon (void *cls, { char buf[size] GNUNET_ALIGN; - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending %u byte HELLO beacon\n", (unsigned int) size); radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf; @@ -1550,13 +1550,13 @@ bluetooth_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) struct WlanAddress *wa = (struct WlanAddress *) addr; if (addrlen != sizeof (struct WlanAddress)) - { + { GNUNET_break_op (0); return GNUNET_SYSERR; } if (GNUNET_YES != plugin->have_mac) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Rejecting MAC `%s': I don't know my MAC!\n", mac_to_string (addr)); return GNUNET_NO; /* don't know my MAC */ @@ -1565,7 +1565,7 @@ bluetooth_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) &plugin->mac_address, sizeof (wa->mac))) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Rejecting MAC `%s': not my MAC!\n", mac_to_string (addr)); return GNUNET_NO; /* not my MAC */ @@ -1643,7 +1643,7 @@ bluetooth_plugin_address_pretty_printer (void *cls, const char *type, /** - * Exit point from the plugin. + * Exit point from the plugin. * * @param cls pointer to the api struct */ @@ -1799,7 +1799,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls) testmode = 0; /* check configuration */ - if ( (GNUNET_YES == + if ( (GNUNET_YES == GNUNET_CONFIGURATION_have_value (env->cfg, "transport-bluetooth", "TESTMODE")) && ( (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-bluetooth", @@ -1828,7 +1828,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "transport-bluetooth", "INTERFACE"); - return NULL; + return NULL; } plugin = GNUNET_malloc (sizeof (struct Plugin)); @@ -1844,7 +1844,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls) plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); - plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon, + plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon, plugin); plugin->options = 0; @@ -1852,7 +1852,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls) /* some compilers do not like switch on 'long long'... */ switch ((unsigned int) testmode) { - case 0: /* normal */ + case 0: /* normal */ plugin->helper_argv[0] = (char *) "gnunet-helper-transport-bluetooth"; plugin->helper_argv[1] = interface; plugin->helper_argv[2] = NULL; @@ -1899,7 +1899,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls) api->address_to_string = &bluetooth_plugin_address_to_string;; api->string_to_address = &bluetooth_string_to_address; api->get_network = &bluetooth_get_network; - + return api; } 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, * @param added length of created address * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ -int +int http_string_to_address (void *cls, const char *addr, uint16_t addrlen, @@ -363,7 +363,7 @@ lookup_session_old (struct Plugin *plugin, const struct GNUNET_PeerIdentity *tar e_peer = GNUNET_YES; if ( (addrlen == t->addrlen) && (0 == memcmp (addr, t->addr, addrlen)) ) - e_addr = GNUNET_YES; + e_addr = GNUNET_YES; if ( (t == session) && (t->addrlen == session->addrlen) && (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; /** * A connection handle - * + * */ struct ConnectionHandle { /** - * The curl easy handle + * The curl easy handle */ CURL *easyhandle; - + /** - * The related session + * The related session */ struct Session *s; }; @@ -363,7 +363,7 @@ client_schedule (struct HTTP_Client_Plugin *plugin, int now); /** - * Connect a HTTP put connection + * Connect a HTTP put connection * * @param s the session to connect * @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) * @return always 0 */ static int -client_log (CURL *curl, curl_infotype type, +client_log (CURL *curl, curl_infotype type, const char *data, size_t size, void *cls) { struct ConnectionHandle *ch = cls; @@ -755,7 +755,7 @@ http_client_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *targ /** * Check if a sessions exists for an specific address - * + * * @param plugin the plugin * @param address the address * @return the session or NULL @@ -946,7 +946,7 @@ client_receive_mst_cb (void *cls, void *client, "Client: peer `%s' address `%s' next read delayed for %s\n", GNUNET_i2s (&s->target), http_common_plugin_address_to_string (NULL, - s->plugin->protocol, + s->plugin->protocol, s->addr, s->addrlen), GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); @@ -1002,7 +1002,7 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls) GNUNET_TIME_absolute_get_difference (now, s->next_receive); GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, "Session %p / connection %p: No inbound bandwidth available! Next read was delayed for %s\n", - s, s->client_get, + s, s->client_get, GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_YES)); if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK) @@ -1231,7 +1231,7 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /** * Connect GET connection for a session - * + * * @param s the session to connect * @return GNUNET_OK on success, GNUNET_SYSERR otherwise */ @@ -1306,7 +1306,7 @@ client_connect_get (struct Session *s) } /** - * Connect a HTTP put connection + * Connect a HTTP put connection * * @param s the session to connect * @return GNUNET_SYSERR for hard failure, GNUNET_OK for ok @@ -1383,7 +1383,7 @@ client_connect_put (struct Session *s) /** * Connect both PUT and GET connection for a session - * + * * @param s the session to connect * @return GNUNET_OK on success, GNUNET_SYSERR otherwise */ @@ -1627,7 +1627,7 @@ client_start_session_timeout (struct Session *s) s); GNUNET_log (TIMEOUT_LOG, "Timeout for session %p set to %s\n", - s, + s, GNUNET_STRINGS_relative_time_to_string (CLIENT_SESSION_TIMEOUT, GNUNET_YES)); } 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) * @param to timeout in seconds */ static void -server_mhd_connection_timeout (struct HTTP_Server_Plugin *plugin, +server_mhd_connection_timeout (struct HTTP_Server_Plugin *plugin, struct Session *s, unsigned int to) { @@ -925,7 +925,7 @@ server_mhd_connection_timeout (struct HTTP_Server_Plugin *plugin, static int server_parse_url (struct HTTP_Server_Plugin *plugin, const char *url, - struct GNUNET_PeerIdentity *target, + struct GNUNET_PeerIdentity *target, uint32_t *tag) { char * tag_start = NULL; @@ -1012,7 +1012,7 @@ server_parse_url (struct HTTP_Server_Plugin *plugin, if (DEBUG_URL_PARSE) GNUNET_break (0); return GNUNET_SYSERR; } - if (GNUNET_OK != + if (GNUNET_OK != GNUNET_CRYPTO_ecc_public_sign_key_from_string (target_start, hash_length, &target->public_key)) @@ -1021,9 +1021,9 @@ server_parse_url (struct HTTP_Server_Plugin *plugin, if (DEBUG_URL_PARSE) GNUNET_break (0); return GNUNET_SYSERR; } - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, - "Found target `%s' in URL\n", + "Found target `%s' in URL\n", GNUNET_i2s_full (target)); return GNUNET_OK; } @@ -1181,7 +1181,7 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin, if ((NULL == s->server_recv) || (NULL == s->server_send)) { to = (HTTP_SERVER_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL / 1000LL); - MHD_set_connection_option (mhd_connection, + MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, to); server_reschedule (plugin, sc->mhd_daemon, GNUNET_NO); } @@ -2902,7 +2902,7 @@ server_session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc s->timeout_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_log (TIMEOUT_LOG, "Session %p was idle for %s, disconnecting\n", - s, + s, GNUNET_STRINGS_relative_time_to_string (SERVER_SESSION_TIMEOUT, GNUNET_YES)); 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); static unsigned int sessions; -static void +static void inc_sessions (struct Plugin *plugin, struct Session *session, int line) { sessions++; @@ -471,7 +471,7 @@ inc_sessions (struct Plugin *plugin, struct Session *session, int line) } -static void +static void dec_sessions (struct Plugin *plugin, struct Session *session, int line) { GNUNET_assert (sessions > 0); @@ -607,7 +607,7 @@ tcp_address_to_string (void *cls, const void *addr, size_t addrlen) memcpy (&a6, &t6->ipv6_addr, sizeof (a6)); sb = &a6; break; - case sizeof (struct IPv4TcpAddress): + case sizeof (struct IPv4TcpAddress): t4 = addr; af = AF_INET; port = ntohs (t4->t4_port); @@ -724,7 +724,7 @@ tcp_string_to_address (void *cls, const char *addr, uint16_t addrlen, *added = sizeof (struct IPv4TcpAddress); return GNUNET_OK; } - case AF_INET6: + case AF_INET6: { struct IPv6TcpAddress *t6; struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &socket_address; @@ -749,7 +749,7 @@ struct SessionClientCtx }; -static int +static int session_lookup_by_client_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) @@ -810,7 +810,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, else GNUNET_assert (NULL == client); - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Creating new session for peer `%4s'\n", GNUNET_i2s (target)); session = GNUNET_malloc (sizeof (struct Session)); @@ -886,7 +886,7 @@ do_transmit (void *cls, size_t size, void *buf) plugin = session->plugin; if (NULL == buf) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Timeout trying to transmit to peer `%4s', discarding message queue.\n", GNUNET_i2s (&session->target)); /* timeout; cancel all messages that have already expired */ @@ -940,7 +940,7 @@ do_transmit (void *cls, size_t size, void *buf) GNUNET_CONTAINER_DLL_remove (session->pending_messages_head, session->pending_messages_tail, pos); GNUNET_assert (size >= pos->message_size); - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting message of type %u\n", ntohs (((struct GNUNET_MessageHeader *) pos->msg)->type)); /* FIXME: this memcpy can be up to 7% of our total runtime */ @@ -1017,7 +1017,7 @@ disconnect_session (struct Session *session) struct PendingMessage *pm; struct Plugin * plugin = session->plugin; - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting session of peer `%s' address `%s'\n", GNUNET_i2s (&session->target), tcp_address_to_string (NULL, session->addr, session->addrlen)); @@ -1050,7 +1050,7 @@ disconnect_session (struct Session *session) while (NULL != (pm = session->pending_messages_head)) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, pm->transmit_cont != NULL ? "Could not deliver message to `%4s'.\n" : "Could not deliver message to `%4s', notifying.\n", @@ -1094,7 +1094,7 @@ struct FindSessionContext }; -static int +static int session_it (void *cls, const struct GNUNET_PeerIdentity * key, void *value) @@ -1190,12 +1190,12 @@ tcp_plugin_send (void *cls, pm->transmit_cont = cont; pm->transmit_cont_cls = cont_cls; - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to transmit %u bytes to `%s', added message to list.\n", msgbuf_size, GNUNET_i2s (&session->target)); - if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains_value (plugin->sessionmap, - &session->target, + if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains_value (plugin->sessionmap, + &session->target, session)) { GNUNET_assert (session->client != NULL); @@ -1215,7 +1215,7 @@ tcp_plugin_send (void *cls, } else if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains_value(plugin->nat_wait_conns, &session->target, session)) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "This NAT WAIT session for peer `%s' is not yet ready!\n", GNUNET_i2s (&session->target)); reschedule_session_timeout (session); @@ -1249,7 +1249,7 @@ struct SessionItCtx }; -static int +static int session_lookup_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) @@ -1340,14 +1340,14 @@ tcp_plugin_get_session (void *cls, GNUNET_assert (plugin != NULL); GNUNET_assert (address != NULL); addrlen = address->address_length; - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to get session for `%s' address of peer `%s'\n", tcp_address_to_string(NULL, address->address, address->address_length), GNUNET_i2s (&address->peer)); /* look for existing session */ - if (GNUNET_YES == - GNUNET_CONTAINER_multipeermap_contains (plugin->sessionmap, + if (GNUNET_YES == + GNUNET_CONTAINER_multipeermap_contains (plugin->sessionmap, &address->peer)) { struct SessionItCtx si_ctx; @@ -1357,8 +1357,8 @@ tcp_plugin_get_session (void *cls, si_ctx.result = NULL; - GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap, - &address->peer, + GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap, + &address->peer, &session_lookup_it, &si_ctx); if (si_ctx.result != NULL) { @@ -1447,7 +1447,7 @@ tcp_plugin_get_session (void *cls, GNUNET_CONTAINER_multipeermap_contains (plugin->nat_wait_conns, &address->peer))) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Found valid IPv4 NAT address (creating session)!\n") ; session = create_session (plugin, &address->peer, NULL, GNUNET_YES); session->addrlen = 0; @@ -1458,12 +1458,12 @@ tcp_plugin_get_session (void *cls, session); GNUNET_assert (session != NULL); GNUNET_assert (GNUNET_OK == - GNUNET_CONTAINER_multipeermap_put (plugin->nat_wait_conns, - &session->target, + GNUNET_CONTAINER_multipeermap_put (plugin->nat_wait_conns, + &session->target, session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Created NAT WAIT connection to `%4s' at `%s'\n", GNUNET_i2s (&session->target), GNUNET_a2s (sb, sbs)); @@ -1471,7 +1471,7 @@ tcp_plugin_get_session (void *cls, return session; else { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Running NAT client for `%4s' at `%s' failed\n", GNUNET_i2s (&session->target), GNUNET_a2s (sb, sbs)); disconnect_session (session); @@ -1484,7 +1484,7 @@ tcp_plugin_get_session (void *cls, sa = GNUNET_CONNECTION_create_from_sockaddr (af, sb, sbs); if (sa == NULL) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Failed to create connection to `%4s' at `%s'\n", GNUNET_i2s (&address->peer), GNUNET_a2s (sb, sbs)); return NULL; @@ -1506,8 +1506,8 @@ tcp_plugin_get_session (void *cls, session->addrlen = addrlen; session->ats_address_network_type = ats.value; - GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap, - &session->target, + GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap, + &session->target, session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); inc_sessions (plugin, session, __LINE__); LOG (GNUNET_ERROR_TYPE_DEBUG, @@ -1522,7 +1522,7 @@ tcp_plugin_get_session (void *cls, } -static int +static int session_disconnect_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) @@ -1559,9 +1559,9 @@ tcp_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) { struct Plugin *plugin = cls; - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s'\n", GNUNET_i2s (target)); - GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap, target, + GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap, target, &session_disconnect_it, plugin); GNUNET_CONTAINER_multipeermap_get_multiple (plugin->nat_wait_conns, target, &session_disconnect_it, plugin); @@ -1944,12 +1944,12 @@ handle_tcp_nat_probe (void *cls, struct GNUNET_SERVER_Client *client, clientIdentity); if (session == NULL) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Did NOT find session for NAT probe!\n"); GNUNET_SERVER_receive_done (client, GNUNET_OK); return; } - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Found session for NAT probe!\n"); if (session->nat_connection_timeout != GNUNET_SCHEDULER_NO_TASK) @@ -1970,11 +1970,11 @@ handle_tcp_nat_probe (void *cls, struct GNUNET_SERVER_Client *client, &tcp_nat_probe->clientIdentity, session) == GNUNET_YES); GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap, - &session->target, session, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); + &session->target, session, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); session->last_activity = GNUNET_TIME_absolute_get (); session->inbound = GNUNET_NO; - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Found address `%s' for incoming connection\n", GNUNET_a2s (vaddr, alen)); switch (((const struct sockaddr *) vaddr)->sa_family) @@ -1999,7 +1999,7 @@ handle_tcp_nat_probe (void *cls, struct GNUNET_SERVER_Client *client, break; default: GNUNET_break_op (0); - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Bad address for incoming connection!\n"); GNUNET_free (vaddr); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); @@ -2124,7 +2124,7 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client, } else { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Did not obtain TCP socket address for incoming connection\n"); GNUNET_break (0); } @@ -2207,9 +2207,9 @@ handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client, /* No inbound session found */ void *vaddr; size_t alen; - + GNUNET_SERVER_client_get_address (client, &vaddr, &alen); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_ERROR, "Received unexpected %u bytes of type %u from `%s'\n", (unsigned int) ntohs (message->size), (unsigned int) ntohs (message->type), @@ -2226,7 +2226,7 @@ handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client, size_t alen; GNUNET_SERVER_client_get_address (client, &vaddr, &alen); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_ERROR, "Received unexpected %u bytes of type %u from `%s'\n", (unsigned int) ntohs (message->size), (unsigned int) ntohs (message->type), @@ -2238,7 +2238,7 @@ handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client, } session->last_activity = GNUNET_TIME_absolute_get (); - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Passing %u bytes of type %u from `%4s' to transport service.\n", (unsigned int) ntohs (message->size), (unsigned int) ntohs (message->type), @@ -2277,7 +2277,7 @@ handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client, } else { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Throttling receiving from `%s' for %s\n", GNUNET_i2s (&session->target), GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); @@ -2450,7 +2450,7 @@ start_session_timeout (struct Session *s) s); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Timeout for session %p set to %s\n", - s, + s, GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_YES)); } @@ -2471,7 +2471,7 @@ reschedule_session_timeout (struct Session *s) s); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Timeout rescheduled for session %p set to %s\n", - s, + s, GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_YES)); } @@ -2571,7 +2571,7 @@ libgnunet_plugin_transport_tcp_init (void *cls) "ADVERTISED-PORT", &aport)) && (aport > 65535))) { - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_ERROR, _ ("Require valid port number for service `%s' in configuration!\n"), "transport-tcp"); @@ -2613,7 +2613,7 @@ libgnunet_plugin_transport_tcp_init (void *cls) { for (ret = ret_s-1; ret >= 0; ret--) LOG (GNUNET_ERROR_TYPE_INFO, - "Binding to address `%s'\n", + "Binding to address `%s'\n", GNUNET_a2s (addrs[ret], addrlens[ret])); plugin->nat = GNUNET_NAT_register (env->cfg, GNUNET_YES, aport, (unsigned int) ret_s, @@ -2679,14 +2679,14 @@ libgnunet_plugin_transport_tcp_init (void *cls) GNUNET_SERVER_disconnect_notify (plugin->server, &disconnect_notify, plugin); plugin->nat_wait_conns = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); if (bport != 0) - LOG (GNUNET_ERROR_TYPE_INFO, + LOG (GNUNET_ERROR_TYPE_INFO, _("TCP transport listening on port %llu\n"), bport); else - LOG (GNUNET_ERROR_TYPE_INFO, + LOG (GNUNET_ERROR_TYPE_INFO, _ ("TCP transport not listening on any port (client only)\n")); if (aport != bport) - LOG (GNUNET_ERROR_TYPE_INFO, + LOG (GNUNET_ERROR_TYPE_INFO, _ ("TCP transport advertises itself as being on port %llu\n"), 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) * @return the network type in HBO or GNUNET_SYSERR */ static enum GNUNET_ATS_Network_Type -template_plugin_get_network (void *cls, +template_plugin_get_network (void *cls, struct Session *session) { 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 * DLL */ struct PrettyPrinterContext *next; - + /** * DLL */ @@ -502,7 +502,7 @@ schedule_select (struct Plugin *plugin) for (udpw = plugin->ipv4_queue_head; NULL != udpw; udpw = udpw->next) min_delay = GNUNET_TIME_relative_min (min_delay, GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer)); - + if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel(plugin->select_task); @@ -514,7 +514,7 @@ schedule_select (struct Plugin *plugin) (0 == min_delay.rel_value_us) ? GNUNET_TIME_UNIT_FOREVER_REL : min_delay, plugin->rs_v4, (0 == min_delay.rel_value_us) ? plugin->ws_v4 : NULL, - &udp_plugin_select, plugin); + &udp_plugin_select, plugin); } if ((GNUNET_YES == plugin->enable_ipv6) && (NULL != plugin->sockv6)) { @@ -522,7 +522,7 @@ schedule_select (struct Plugin *plugin) for (udpw = plugin->ipv6_queue_head; NULL != udpw; udpw = udpw->next) min_delay = GNUNET_TIME_relative_min (min_delay, GNUNET_TIME_absolute_get_remaining (udpw->session->flow_delay_from_other_peer)); - + if (GNUNET_SCHEDULER_NO_TASK != plugin->select_task_v6) GNUNET_SCHEDULER_cancel(plugin->select_task_v6); plugin->select_task_v6 = @@ -589,7 +589,7 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen) } inet_ntop (af, sb, buf, INET6_ADDRSTRLEN); - GNUNET_snprintf (rbuf, sizeof (rbuf), + GNUNET_snprintf (rbuf, sizeof (rbuf), (af == AF_INET6) ? "%s.%u.[%s]:%u" : "%s.%u.%s:%u", PLUGIN_NAME, options, buf, port); return rbuf; @@ -1150,11 +1150,11 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result) struct UDP_MessageWrapper dummy; struct Session *s = fc->session; - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "%p : Fragmented message removed with result %s\n", fc, (result == GNUNET_SYSERR) ? "FAIL" : "SUCCESS"); - + /* Call continuation for fragmented message */ memset (&dummy, 0, sizeof (dummy)); dummy.msg_type = MSG_FRAGMENTED_COMPLETE; @@ -1376,7 +1376,7 @@ reschedule_session_timeout (struct Session *s) s); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Timeout rescheduled for session %p set to %s\n", - s, + s, GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_YES)); } @@ -1478,7 +1478,7 @@ session_cmp_it (void *cls, LOG (GNUNET_ERROR_TYPE_DEBUG, "Comparing address %s <-> %s\n", - udp_address_to_string (NULL, (void *) address->address, + udp_address_to_string (NULL, (void *) address->address, address->address_length), GNUNET_a2s (s->sock_addr, s->addrlen)); if (s->inbound != cctx->inbound) @@ -1524,7 +1524,7 @@ session_cmp_it (void *cls, * @return the network type in HBO or GNUNET_SYSERR */ static enum GNUNET_ATS_Network_Type -udp_get_network (void *cls, +udp_get_network (void *cls, struct Session *session) { return ntohl (session->ats.value); @@ -1589,8 +1589,8 @@ udp_plugin_lookup_session (void *cls, cctx.res = NULL; cctx.inbound = inbound; LOG (GNUNET_ERROR_TYPE_DEBUG, - "Looking for existing session for peer `%s' `%s' \n", - GNUNET_i2s (&address->peer), + "Looking for existing session for peer `%s' `%s' \n", + GNUNET_i2s (&address->peer), udp_address_to_string(NULL, address->address, address->address_length)); GNUNET_CONTAINER_multipeermap_get_multiple(plugin->sessions, &address->peer, session_cmp_it, &cctx); if (cctx.res != NULL) @@ -1666,7 +1666,7 @@ udp_plugin_get_session (void *cls, } -static void +static void enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) { if (plugin->bytes_in_buffer + udpw->msg_size > INT64_MAX) @@ -1708,7 +1708,7 @@ send_next_fragment (void *cls, { struct UDP_MessageWrapper *udpw = cls; - GNUNET_FRAGMENT_context_transmission_done (udpw->frag_ctx->frag); + GNUNET_FRAGMENT_context_transmission_done (udpw->frag_ctx->frag); } @@ -1728,8 +1728,8 @@ enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg) struct Plugin *plugin = frag_ctx->plugin; struct UDP_MessageWrapper * udpw; size_t msg_len = ntohs (msg->size); - - LOG (GNUNET_ERROR_TYPE_DEBUG, + + LOG (GNUNET_ERROR_TYPE_DEBUG, "Enqueuing fragment with %u bytes\n", msg_len); frag_ctx->fragments_used ++; udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msg_len); @@ -1862,11 +1862,11 @@ udp_plugin_send (void *cls, frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, UDP_MTU, &plugin->tracker, - s->last_expected_msg_delay, - s->last_expected_ack_delay, + s->last_expected_msg_delay, + s->last_expected_ack_delay, &udp->header, &enqueue_fragment, - frag_ctx); + frag_ctx); s->frag_ctx = frag_ctx; GNUNET_STATISTICS_update (plugin->env->stats, "# UDP, fragmented msgs, messages, pending", @@ -2138,8 +2138,8 @@ struct LookupContext static int -lookup_session_by_addr_it (void *cls, - const struct GNUNET_PeerIdentity *key, +lookup_session_by_addr_it (void *cls, + const struct GNUNET_PeerIdentity *key, void *value) { struct LookupContext *l_ctx = cls; @@ -2223,7 +2223,7 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) } -static void +static void read_process_msg (struct Plugin *plugin, const struct GNUNET_MessageHeader *msg, const char *addr, @@ -2239,7 +2239,7 @@ read_process_msg (struct Plugin *plugin, } -static void +static void read_process_ack (struct Plugin *plugin, const struct GNUNET_MessageHeader *msg, char *addr, @@ -2273,7 +2273,7 @@ read_process_ack (struct Plugin *plugin, flow_delay.rel_value_us = (uint64_t) ntohl (udp_ack->delay); - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "We received a sending delay of %s\n", GNUNET_STRINGS_relative_time_to_string (flow_delay, GNUNET_YES)); @@ -2310,7 +2310,7 @@ read_process_ack (struct Plugin *plugin, } -static void +static void read_process_fragment (struct Plugin *plugin, const struct GNUNET_MessageHeader *msg, char *addr, @@ -2350,7 +2350,7 @@ read_process_fragment (struct Plugin *plugin, GNUNET_CONTAINER_heap_insert (plugin->defrag_ctxs, d_ctx, (GNUNET_CONTAINER_HeapCostType) now.abs_value_us); - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Created new defragmentation context for %u-byte fragment from `%s'\n", (unsigned int) ntohs (msg->size), GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); @@ -2571,7 +2571,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, if (GNUNET_TIME_UNIT_ZERO.rel_value_us == remaining.rel_value_us) { /* this message is not delayed */ - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Message for peer `%s' (%u bytes) is not delayed \n", GNUNET_i2s(&udpw->session->target), udpw->payload_size); break; /* Found message to send, break */ @@ -2581,7 +2581,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, /* Message is delayed, try next */ LOG (GNUNET_ERROR_TYPE_DEBUG, "Message for peer `%s' (%u bytes) is delayed for %s\n", - GNUNET_i2s(&udpw->session->target), udpw->payload_size, + GNUNET_i2s(&udpw->session->target), udpw->payload_size, GNUNET_STRINGS_relative_time_to_string (remaining, GNUNET_YES)); udpw = udpw->next; @@ -2719,10 +2719,10 @@ udp_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) (GNUNET_NETWORK_fdset_isset (tc->read_ready, plugin->sockv4)) ) udp_select_read (plugin, plugin->sockv4); if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) && - (NULL != plugin->sockv4) && + (NULL != plugin->sockv4) && (NULL != plugin->ipv4_queue_head) && (GNUNET_NETWORK_fdset_isset (tc->write_ready, plugin->sockv4)) ) - udp_select_send (plugin, plugin->sockv4); + udp_select_send (plugin, plugin->sockv4); schedule_select (plugin); } @@ -2749,7 +2749,7 @@ udp_plugin_select_v6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) udp_select_read (plugin, plugin->sockv6); if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) && (NULL != plugin->sockv6) && (plugin->ipv6_queue_head != NULL) && - (GNUNET_NETWORK_fdset_isset (tc->write_ready, plugin->sockv6)) ) + (GNUNET_NETWORK_fdset_isset (tc->write_ready, plugin->sockv6)) ) udp_select_send (plugin, plugin->sockv6); schedule_select (plugin); } @@ -2760,7 +2760,7 @@ udp_plugin_select_v6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return number of sockets that were successfully bound */ static int -setup_sockets (struct Plugin *plugin, +setup_sockets (struct Plugin *plugin, const struct sockaddr_in6 *bind_v6, const struct sockaddr_in *bind_v4) { @@ -2869,23 +2869,23 @@ setup_sockets (struct Plugin *plugin, serverAddrv4.sin_addr = bind_v4->sin_addr; else serverAddrv4.sin_addr.s_addr = INADDR_ANY; - + if (0 == plugin->port) /* autodetect */ serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); else serverAddrv4.sin_port = htons (plugin->port); - - + + addrlen = sizeof (struct sockaddr_in); serverAddr = (struct sockaddr *) &serverAddrv4; - + tries = 0; while (tries < 10) { LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 `%s'\n", GNUNET_a2s (serverAddr, addrlen)); - + /* binding */ if (GNUNET_OK == GNUNET_NETWORK_socket_bind (plugin->sockv4, serverAddr, addrlen, 0)) @@ -2896,19 +2896,19 @@ setup_sockets (struct Plugin *plugin, tries = 10; /* fail */ break; /* bind failed on specific port */ } - + /* autodetect */ serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); tries ++; } - + if (tries >= 10) { GNUNET_NETWORK_socket_close (plugin->sockv4); plugin->enable_ipv4 = GNUNET_NO; plugin->sockv4 = NULL; } - + if (plugin->sockv4 != NULL) { LOG (GNUNET_ERROR_TYPE_DEBUG, @@ -2918,13 +2918,13 @@ setup_sockets (struct Plugin *plugin, sockets_created++; } else - { + { LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to bind UDP socket to %s: %s\n", GNUNET_a2s (serverAddr, addrlen), STRERROR (eno)); } } - + if (0 == sockets_created) { 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 * @param value a session * @return GNUNET_YES if not found (continue looking), GNUNET_NO on success */ -static int +static int lookup_session_it (void *cls, const struct GNUNET_PeerIdentity * key, void *value) @@ -486,8 +486,8 @@ lookup_session_it (void *cls, * @return NULL if session was not found */ static struct Session * -lookup_session (struct Plugin *plugin, - const struct GNUNET_PeerIdentity *sender, +lookup_session (struct Plugin *plugin, + const struct GNUNET_PeerIdentity *sender, const struct UnixAddress *ua, size_t ua_len) { struct LookupCtx lctx; @@ -498,7 +498,7 @@ lookup_session (struct Plugin *plugin, lctx.s = NULL; lctx.ua = ua; lctx.ua_len = ua_len; - GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, + GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, sender, &lookup_session_it, &lctx); return lctx.s; @@ -520,9 +520,9 @@ disconnect_session (struct Session *s) struct UNIXMessageWrapper *next; int removed; - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting session for peer `%s' `%s'\n", - GNUNET_i2s (&s->target), + GNUNET_i2s (&s->target), s->addr); plugin->env->session_end (plugin->env->cls, &s->target, s); removed = GNUNET_NO; @@ -539,11 +539,11 @@ disconnect_session (struct Session *s) msgw->payload, 0); GNUNET_free (msgw->msg); GNUNET_free (msgw); - removed = GNUNET_YES; + removed = GNUNET_YES; } GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multipeermap_remove (plugin->session_map, - &s->target, + GNUNET_CONTAINER_multipeermap_remove (plugin->session_map, + &s->target, s)); GNUNET_STATISTICS_set (plugin->env->stats, "# UNIX sessions active", @@ -671,7 +671,7 @@ resend: LOG (GNUNET_ERROR_TYPE_DEBUG, "UNIX transmit %u-byte message to %s (%d: %s)\n", - (unsigned int) msgbuf_size, + (unsigned int) msgbuf_size, GNUNET_a2s ((const struct sockaddr *)un, un_len), (int) sent, (sent < 0) ? STRERROR (errno) : "ok"); @@ -684,7 +684,7 @@ resend: * Closure for 'get_session_it'. */ struct GetSessionIteratorContext -{ +{ /** * Location to store the session, if found. */ @@ -711,8 +711,8 @@ struct GetSessionIteratorContext * @return GNUNET_YES if not found (continue looking), GNUNET_NO on success */ static int -get_session_it (void *cls, - const struct GNUNET_PeerIdentity *key, +get_session_it (void *cls, + const struct GNUNET_PeerIdentity *key, void *value) { struct GetSessionIteratorContext *gsi = cls; @@ -735,11 +735,11 @@ get_session_it (void *cls, * @param tc scheduler context */ static void -session_timeout (void *cls, +session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct Session *s = cls; - + s->timeout_task = GNUNET_SCHEDULER_NO_TASK; LOG (GNUNET_ERROR_TYPE_DEBUG, "Session %p was idle for %s, disconnecting\n", @@ -758,7 +758,7 @@ session_timeout (void *cls, * @return the network type in HBO or GNUNET_SYSERR */ static enum GNUNET_ATS_Network_Type -unix_get_network (void *cls, +unix_get_network (void *cls, struct Session *session) { GNUNET_assert (NULL != session); @@ -818,12 +818,12 @@ unix_plugin_get_session (void *cls, gsi.address = (const char *) address->address; gsi.addrlen = address->address_length; gsi.res = NULL; - GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, - &address->peer, + GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, + &address->peer, &get_session_it, &gsi); if (NULL != gsi.res) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Found existing session\n"); return gsi.res; } @@ -893,23 +893,23 @@ unix_plugin_send (void *cls, struct UNIXMessageWrapper *wrapper; struct UNIXMessage *message; int ssize; - + GNUNET_assert (NULL != plugin); GNUNET_assert (NULL != session); - if (GNUNET_OK != + if (GNUNET_OK != GNUNET_CONTAINER_multipeermap_contains_value (plugin->session_map, &session->target, session)) { - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_ERROR, "Invalid session for peer `%s' `%s'\n", GNUNET_i2s (&session->target), (const char *) session->addr); GNUNET_break (0); return GNUNET_SYSERR; } - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending %u bytes with session for peer `%s' `%s'\n", msgbuf_size, GNUNET_i2s (&session->target), @@ -931,13 +931,13 @@ unix_plugin_send (void *cls, wrapper->cont = cont; wrapper->cont_cls = cont_cls; wrapper->session = session; - GNUNET_CONTAINER_DLL_insert (plugin->msg_head, + GNUNET_CONTAINER_DLL_insert (plugin->msg_head, plugin->msg_tail, wrapper); plugin->bytes_in_queue += ssize; GNUNET_STATISTICS_set (plugin->env->stats, "# bytes currently in UNIX buffers", - plugin->bytes_in_queue, + plugin->bytes_in_queue, GNUNET_NO); if (GNUNET_NO == plugin->with_ws) reschedule_select (plugin); @@ -1101,25 +1101,25 @@ unix_plugin_select_write (struct Plugin *plugin) break; /* Message is ready for sending */ /* Message has a timeout */ LOG (GNUNET_ERROR_TYPE_DEBUG, - "Timeout for message with %u bytes \n", + "Timeout for message with %u bytes \n", (unsigned int) msgw->msgsize); GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw); plugin->bytes_in_queue -= msgw->msgsize; - GNUNET_STATISTICS_set (plugin->env->stats, + GNUNET_STATISTICS_set (plugin->env->stats, "# bytes currently in UNIX buffers", - plugin->bytes_in_queue, GNUNET_NO); + plugin->bytes_in_queue, GNUNET_NO); GNUNET_STATISTICS_update (plugin->env->stats, "# UNIX bytes discarded", msgw->msgsize, GNUNET_NO); if (NULL != msgw->cont) msgw->cont (msgw->cont_cls, - &msgw->session->target, - GNUNET_SYSERR, - msgw->payload, - 0); + &msgw->session->target, + GNUNET_SYSERR, + msgw->payload, + 0); GNUNET_free (msgw->msg); - GNUNET_free (msgw); + GNUNET_free (msgw); } if (NULL == msgw) return; /* Nothing to send at the moment */ @@ -1153,7 +1153,7 @@ unix_plugin_select_write (struct Plugin *plugin) GNUNET_assert (plugin->bytes_in_queue >= msgw->msgsize); plugin->bytes_in_queue -= msgw->msgsize; - GNUNET_STATISTICS_set (plugin->env->stats, + GNUNET_STATISTICS_set (plugin->env->stats, "# bytes currently in UNIX buffers", plugin->bytes_in_queue, GNUNET_NO); GNUNET_STATISTICS_update (plugin->env->stats, @@ -1167,9 +1167,9 @@ unix_plugin_select_write (struct Plugin *plugin) } /* successfully sent bytes */ GNUNET_break (sent > 0); - GNUNET_CONTAINER_DLL_remove (plugin->msg_head, - plugin->msg_tail, - msgw); + GNUNET_CONTAINER_DLL_remove (plugin->msg_head, + plugin->msg_tail, + msgw); GNUNET_assert (plugin->bytes_in_queue >= msgw->msgsize); plugin->bytes_in_queue -= msgw->msgsize; GNUNET_STATISTICS_set (plugin->env->stats, @@ -1179,12 +1179,12 @@ unix_plugin_select_write (struct Plugin *plugin) GNUNET_STATISTICS_update (plugin->env->stats, "# bytes transmitted via UNIX", msgw->msgsize, - GNUNET_NO); + GNUNET_NO); if (NULL != msgw->cont) - msgw->cont (msgw->cont_cls, &msgw->session->target, + msgw->cont (msgw->cont_cls, &msgw->session->target, GNUNET_OK, - msgw->payload, - msgw->msgsize); + msgw->payload, + msgw->msgsize); GNUNET_free (msgw->msg); GNUNET_free (msgw); } @@ -1553,8 +1553,8 @@ reschedule_session_timeout (struct Session *s) * @return GNUNET_YES (always, continue to iterate) */ static int -get_session_delete_it (void *cls, - const struct GNUNET_PeerIdentity *key, +get_session_delete_it (void *cls, + const struct GNUNET_PeerIdentity *key, void *value) { struct Session *s = value; @@ -1572,14 +1572,14 @@ get_session_delete_it (void *cls, * @return #GNUNET_OK on success, #GNUNET_SYSERR if the operation failed */ static void -unix_disconnect (void *cls, +unix_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) { struct Plugin *plugin = cls; GNUNET_assert (plugin != NULL); GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, - target, + target, &get_session_delete_it, plugin); } @@ -1618,7 +1618,7 @@ libgnunet_plugin_transport_unix_init (void *cls) plugin = GNUNET_malloc (sizeof (struct Plugin)); plugin->port = port; plugin->env = env; - GNUNET_asprintf (&plugin->unix_socket_path, + GNUNET_asprintf (&plugin->unix_socket_path, "/tmp/unix-plugin-sock.%d", plugin->port); 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 /** * Header for messages which need fragmentation. This is the format of * a message we obtain AFTER defragmentation. We then need to check - * the CRC and then tokenize the payload and pass it to the + * the CRC and then tokenize the payload and pass it to the * 'receive' callback. */ struct WlanHeader @@ -398,7 +398,7 @@ struct Plugin /** * Handle to helper process for priviledged operations. - */ + */ struct GNUNET_HELPER_Handle *suid_helper; /** @@ -560,7 +560,7 @@ get_radiotap_header (struct MacEndpoint *endpoint, static void get_wlan_header (struct Plugin *plugin, struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *header, - const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, + const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, unsigned int size) { const int rate = 11000000; @@ -606,12 +606,12 @@ send_ack (void *cls, uint32_t msg_id, GNUNET_break (0); return; } - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending ACK to helper\n"); radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf; get_radiotap_header (endpoint, radio_header, size); get_wlan_header (endpoint->plugin, - &radio_header->frame, + &radio_header->frame, &endpoint->addr.mac, size); memcpy (&radio_header[1], hdr, msize); @@ -619,7 +619,7 @@ send_ack (void *cls, uint32_t msg_id, GNUNET_HELPER_send (endpoint->plugin->suid_helper, &radio_header->header, GNUNET_NO /* dropping ACKs is bad */, - NULL, NULL)) + NULL, NULL)) GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN ACKs sent"), 1, GNUNET_NO); } @@ -643,7 +643,7 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr) GNUNET_NO); mas.session = NULL; mas.endpoint = endpoint; - (void) GNUNET_SERVER_mst_receive (plugin->fragment_data_tokenizer, + (void) GNUNET_SERVER_mst_receive (plugin->fragment_data_tokenizer, &mas, (const char *) hdr, ntohs (hdr->size), @@ -661,7 +661,7 @@ free_session (struct Session *session) { struct MacEndpoint *endpoint = session->mac; struct PendingMessage *pm; - + endpoint->plugin->env->session_end (endpoint->plugin->env->cls, &session->target, session); @@ -677,7 +677,7 @@ free_session (struct Session *session) GNUNET_free (pm->msg); GNUNET_free (pm); } - GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, + GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, endpoint->sessions_tail, session); if (session->timeout_task != GNUNET_SCHEDULER_NO_TASK) @@ -705,7 +705,7 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) session->timeout_task = GNUNET_SCHEDULER_NO_TASK; timeout = GNUNET_TIME_absolute_get_remaining (session->timeout); - if (0 == timeout.rel_value_us) + if (0 == timeout.rel_value_us) { free_session (session); return; @@ -800,7 +800,7 @@ get_session (struct MacEndpoint *endpoint, * message to the SUID helper process and we are thus ready for * the next fragment. * - * @param cls the 'struct FragmentMessage' + * @param cls the 'struct FragmentMessage' * @param result result of the operation (GNUNET_OK on success, GNUNET_NO if the helper died, GNUNET_SYSERR * if the helper was stopped) */ @@ -820,7 +820,7 @@ fragment_transmission_done (void *cls, * Transmit a fragment of a message. * * @param cls 'struct FragmentMessage' this fragment message belongs to - * @param hdr pointer to the start of the fragment message + * @param hdr pointer to the start of the fragment message */ static void transmit_fragment (void *cls, @@ -846,7 +846,7 @@ transmit_fragment (void *cls, radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf; get_radiotap_header (endpoint, radio_header, size); get_wlan_header (endpoint->plugin, - &radio_header->frame, + &radio_header->frame, &endpoint->addr.mac, size); memcpy (&radio_header[1], hdr, msize); @@ -881,7 +881,7 @@ free_fragment_message (struct FragmentMessage *fm) { struct MacEndpoint *endpoint = fm->macendpoint; - GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN messages pending (with fragmentation)"), + GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN messages pending (with fragmentation)"), -1, GNUNET_NO); GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head, endpoint->sending_messages_tail, fm); @@ -941,7 +941,7 @@ fragmentmessage_timeout (void *cls, static void send_with_fragmentation (struct MacEndpoint *endpoint, struct GNUNET_TIME_Relative timeout, - const struct GNUNET_PeerIdentity *target, + const struct GNUNET_PeerIdentity *target, const struct GNUNET_MessageHeader *msg, size_t payload_size, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) @@ -968,7 +968,7 @@ send_with_fragmentation (struct MacEndpoint *endpoint, msg, &transmit_fragment, fm); fm->timeout_task = - GNUNET_SCHEDULER_add_delayed (timeout, + GNUNET_SCHEDULER_add_delayed (timeout, &fragmentmessage_timeout, fm); GNUNET_CONTAINER_DLL_insert_tail (endpoint->sending_messages_head, endpoint->sending_messages_tail, @@ -978,7 +978,7 @@ send_with_fragmentation (struct MacEndpoint *endpoint, /** * Free a MAC endpoint. - * + * * @param endpoint pointer to the MacEndpoint to free */ static void @@ -994,8 +994,8 @@ free_macendpoint (struct MacEndpoint *endpoint) free_session (session); while (NULL != (fm = endpoint->sending_messages_head)) free_fragment_message (fm); - GNUNET_CONTAINER_DLL_remove (plugin->mac_head, - plugin->mac_tail, + GNUNET_CONTAINER_DLL_remove (plugin->mac_head, + plugin->mac_tail, endpoint); if (NULL != endpoint->defrag) @@ -1028,7 +1028,7 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK; timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout); - if (0 == timeout.rel_value_us) + if (0 == timeout.rel_value_us) { free_macendpoint (endpoint); return; @@ -1054,14 +1054,14 @@ create_macendpoint (struct Plugin *plugin, for (pos = plugin->mac_head; NULL != pos; pos = pos->next) if (0 == memcmp (addr, &pos->addr, sizeof (struct WlanAddress))) - return pos; + return pos; pos = GNUNET_malloc (sizeof (struct MacEndpoint)); pos->addr = *addr; pos->plugin = plugin; pos->defrag = GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU, MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, - pos, + pos, &wlan_data_message_handler, &send_ack); @@ -1076,7 +1076,7 @@ create_macendpoint (struct Plugin *plugin, plugin->mac_count++; GNUNET_STATISTICS_update (plugin->env->stats, _("# WLAN MAC endpoints allocated"), 1, GNUNET_NO); - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "New MAC endpoint `%s'\n", wlan_plugin_address_to_string(NULL, addr, sizeof (struct WlanAddress))); return pos; @@ -1091,7 +1091,7 @@ create_macendpoint (struct Plugin *plugin, * @return the network type in HBO or GNUNET_SYSERR */ static enum GNUNET_ATS_Network_Type -wlan_get_network (void *cls, +wlan_get_network (void *cls, struct Session *session) { GNUNET_assert (NULL != session); @@ -1196,7 +1196,7 @@ wlan_plugin_send (void *cls, size_t size = msgbuf_size + sizeof (struct WlanHeader); char buf[size] GNUNET_ALIGN; - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting %u bytes of payload to peer `%s' (starting with %u byte message of type %u)\n", msgbuf_size, GNUNET_i2s (&session->target), @@ -1256,7 +1256,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) switch (ntohs (hdr->type)) { case GNUNET_MESSAGE_TYPE_HELLO: - if (GNUNET_OK != + if (GNUNET_OK != GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource)) { GNUNET_break_op (0); @@ -1271,9 +1271,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) GNUNET_STATISTICS_update (plugin->env->stats, _("# HELLO messages received via WLAN"), 1, GNUNET_NO); - plugin->env->receive (plugin->env->cls, + plugin->env->receive (plugin->env->cls, &tmpsource, - hdr, + hdr, mas->session, (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, (mas->endpoint == NULL) ? 0 : sizeof (struct WlanAddress)); @@ -1290,7 +1290,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) GNUNET_break (0); break; } - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing %u bytes of FRAGMENT from MAC %s\n", (unsigned int) msize, 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) ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr); if (GNUNET_OK == ret) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Got last ACK, finished message transmission to `%s' (%p)\n", wlan_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)), fm); @@ -1327,13 +1327,13 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) } if (GNUNET_NO == ret) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Got an ACK, message transmission to `%s' not yet finished\n", wlan_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); break; } } - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "ACK not matched against any active fragmentation with MAC `%s'\n", wlan_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); break; @@ -1347,13 +1347,13 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) { GNUNET_break (0); break; - } + } wlanheader = (const struct WlanHeader *) hdr; if (0 != memcmp (&wlanheader->target, plugin->env->my_identity, sizeof (struct GNUNET_PeerIdentity))) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "WLAN data for `%s', not for me, ignoring\n", GNUNET_i2s (&wlanheader->target)); break; @@ -1380,11 +1380,11 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) "Processing %u bytes of WLAN DATA from peer `%s'\n", (unsigned int) msize, GNUNET_i2s (&wlanheader->sender)); - (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer, + (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer, &xmas, (const char *) &wlanheader[1], msize - sizeof (struct WlanHeader), - GNUNET_YES, GNUNET_NO); + GNUNET_YES, GNUNET_NO); break; default: if (NULL == mas->endpoint) @@ -1402,9 +1402,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) (unsigned int) msize, (unsigned int) ntohs (hdr->type), GNUNET_i2s (&mas->session->target)); - plugin->env->receive (plugin->env->cls, + plugin->env->receive (plugin->env->cls, &mas->session->target, - hdr, + hdr, mas->session, (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, (mas->endpoint == NULL) ? 0 : sizeof (struct WlanAddress)); @@ -1478,7 +1478,7 @@ handle_helper_message (void *cls, void *client, "wlan"); break; case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER: - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Got data message from helper with %u bytes\n", msize); GNUNET_STATISTICS_update (plugin->env->stats, @@ -1515,7 +1515,7 @@ handle_helper_message (void *cls, void *client, /* packet is FROM us, thus not FOR us */ break; } - + GNUNET_STATISTICS_update (plugin->env->stats, _("# WLAN DATA messages processed"), 1, GNUNET_NO); @@ -1527,7 +1527,7 @@ handle_helper_message (void *cls, void *client, wa.options = htonl (0); mas.endpoint = create_macendpoint (plugin, &wa); mas.session = NULL; - (void) GNUNET_SERVER_mst_receive (plugin->helper_payload_tokenizer, + (void) GNUNET_SERVER_mst_receive (plugin->helper_payload_tokenizer, &mas, (const char*) &rxinfo[1], msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage), @@ -1535,7 +1535,7 @@ handle_helper_message (void *cls, void *client, break; default: GNUNET_break (0); - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Unexpected message of type %u (%u bytes)", ntohs (hdr->type), ntohs (hdr->size)); break; @@ -1568,7 +1568,7 @@ send_hello_beacon (void *cls, { char buf[size] GNUNET_ALIGN; - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending %u byte HELLO beacon\n", (unsigned int) size); radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf; @@ -1612,13 +1612,13 @@ wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) struct WlanAddress *wa = (struct WlanAddress *) addr; if (addrlen != sizeof (struct WlanAddress)) - { + { GNUNET_break_op (0); return GNUNET_SYSERR; } if (GNUNET_YES != plugin->have_mac) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Rejecting MAC `%s': I don't know my MAC!\n", mac_to_string (addr)); return GNUNET_NO; /* don't know my MAC */ @@ -1627,7 +1627,7 @@ wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) &plugin->mac_address, sizeof (wa->mac))) { - LOG (GNUNET_ERROR_TYPE_DEBUG, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Rejecting MAC `%s': not my MAC!\n", mac_to_string (addr)); return GNUNET_NO; /* not my MAC */ @@ -1705,7 +1705,7 @@ wlan_plugin_address_pretty_printer (void *cls, const char *type, /** - * Exit point from the plugin. + * Exit point from the plugin. * * @param cls pointer to the api struct */ @@ -1861,7 +1861,7 @@ libgnunet_plugin_transport_wlan_init (void *cls) testmode = 0; /* check configuration */ - if ( (GNUNET_YES == + if ( (GNUNET_YES == GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "TESTMODE")) && ( (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-wlan", @@ -1890,7 +1890,7 @@ libgnunet_plugin_transport_wlan_init (void *cls) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "transport-wlan", "INTERFACE"); - return NULL; + return NULL; } plugin = GNUNET_malloc (sizeof (struct Plugin)); @@ -1906,7 +1906,7 @@ libgnunet_plugin_transport_wlan_init (void *cls) plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); - plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon, + plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon, plugin); plugin->options = 0; @@ -1914,7 +1914,7 @@ libgnunet_plugin_transport_wlan_init (void *cls) /* some compilers do not like switch on 'long long'... */ switch ((unsigned int) testmode) { - case 0: /* normal */ + case 0: /* normal */ plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan"; plugin->helper_argv[1] = interface; 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 @@ /** * Value for "Management" in the 'frame_control' field of the - * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame. + * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame. */ #define IEEE80211_FC0_TYPE_MGT 0x00 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 () } -static void +static void env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, 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[]) return ret; } -#else +#else /* cannot setrlimit */ 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 () ok = disconnects; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Had %u disconnects while waiting %s\n", - disconnects, + disconnects, GNUNET_STRINGS_relative_time_to_string (WAIT, GNUNET_YES)); } @@ -223,7 +223,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) shutdown_flag = GNUNET_NO; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting for %s\n", GNUNET_STRINGS_relative_time_to_string (WAIT, 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, * GNUNET_NO if not. */ static int -neighbour_delete (void *cls, +neighbour_delete (void *cls, const struct GNUNET_PeerIdentity *key, void *value) { struct GNUNET_TRANSPORT_Handle *handle = cls; @@ -1341,7 +1341,7 @@ GNUNET_TRANSPORT_check_neighbour_connected (struct GNUNET_TRANSPORT_Handle *hand { GNUNET_assert (NULL != handle); GNUNET_assert (NULL != peer); - + if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (handle->neighbours, peer)) return GNUNET_YES; else @@ -1364,7 +1364,7 @@ call_hello_update_cb_async (void *cls, GNUNET_assert (NULL != ghh->handle->my_hello); GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != ghh->notify_task); ghh->notify_task = GNUNET_SCHEDULER_NO_TASK; - ghh->rec (ghh->rec_cls, + ghh->rec (ghh->rec_cls, (const struct GNUNET_MessageHeader *) ghh->handle->my_hello); } @@ -1564,7 +1564,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle, delay.rel_value_us = 0; /* notify immediately (with failure) */ LOG (GNUNET_ERROR_TYPE_DEBUG, "Bandwidth tracker allows next transmission to peer %s in %s\n", - GNUNET_i2s (target), + GNUNET_i2s (target), GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); n->hn = GNUNET_CONTAINER_heap_insert (handle->ready_heap, n, delay.rel_value_us); 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 * Backoff for reconnect. */ struct GNUNET_TIME_Relative backoff; - + /** * Task ID for reconnect. */ @@ -116,7 +116,7 @@ send_request (struct GNUNET_TRANSPORT_PeerIterateContext *pal_ctx) msg.timeout = GNUNET_TIME_absolute_hton (pal_ctx->timeout); msg.peer = pal_ctx->peer; GNUNET_assert (GNUNET_OK == - GNUNET_CLIENT_transmit_and_get_response (pal_ctx->client, + GNUNET_CLIENT_transmit_and_get_response (pal_ctx->client, &msg.header, GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout), GNUNET_YES, @@ -126,7 +126,7 @@ send_request (struct GNUNET_TRANSPORT_PeerIterateContext *pal_ctx) /** * Task run to re-establish the connection. - * + * * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*' * @param tc scheduler context, unused */ @@ -329,7 +329,7 @@ GNUNET_TRANSPORT_peer_get_active_addresses (const struct pal_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); if (NULL != peer) pal_ctx->peer = *peer; - pal_ctx->one_shot = one_shot; + pal_ctx->one_shot = one_shot; pal_ctx->client = client; send_request (pal_ctx); |