/**
* IPv4 header.
*/
-struct ip_header
+struct ip_header
{
/**
- * Version (4 bits) + Internet header length (4 bits)
+ * Version (4 bits) + Internet header length (4 bits)
*/
- uint8_t vers_ihl;
+ uint8_t vers_ihl;
/**
* Type of service
*/
- uint8_t tos;
+ uint8_t tos;
/**
* Total length
*/
- uint16_t pkt_len;
+ uint16_t pkt_len;
/**
* Identification
*/
- uint16_t id;
+ uint16_t id;
/**
* Flags (3 bits) + Fragment offset (13 bits)
*/
- uint16_t flags_frag_offset;
+ uint16_t flags_frag_offset;
/**
* Time to live
*/
- uint8_t ttl;
+ uint8_t ttl;
/**
- * Protocol
+ * Protocol
*/
- uint8_t proto;
+ uint8_t proto;
/**
* Header checksum
*/
- uint16_t checksum;
+ uint16_t checksum;
/**
* Source address
*/
- uint32_t src_ip;
+ uint32_t src_ip;
/**
- * Destination address
+ * Destination address
*/
- uint32_t dst_ip;
+ uint32_t dst_ip;
};
/**
* Format of ICMP packet.
*/
-struct icmp_ttl_exceeded_header
+struct icmp_ttl_exceeded_header
{
uint8_t type;
/**
* Port we are listening on (communicated to the server).
- */
+ */
static uint16_t port;
* @param buf where to write the address result
* @return 1 on success
*/
-static int
-inet_pton (int af,
- const char *cp,
+static int
+inet_pton (int af,
+ const char *cp,
struct in_addr *buf)
{
buf->s_addr = inet_addr(cp);
if (buf->s_addr == INADDR_NONE)
{
- fprintf(stderr,
- "Error %d handling address %s",
- WSAGetLastError(),
+ fprintf(stderr,
+ "Error %d handling address %s",
+ WSAGetLastError(),
cp);
return 0;
}
* @param bytes number of bytes in data (must be multiple of 2)
* @return the CRC 16.
*/
-static uint16_t
-calc_checksum(const uint16_t *data,
+static uint16_t
+calc_checksum(const uint16_t *data,
unsigned int bytes)
{
uint32_t sum;
unsigned int i;
sum = 0;
- for (i=0;i<bytes/2;i++)
- sum += data[i];
+ for (i=0;i<bytes/2;i++)
+ sum += data[i];
sum = (sum & 0xffff) + (sum >> 16);
sum = htons(0xffff - sum);
return sum;
const struct in_addr *other)
{
char packet[sizeof(struct ip_header) * 2 +
- sizeof(struct icmp_ttl_exceeded_header) +
+ sizeof(struct icmp_ttl_exceeded_header) +
sizeof(struct udp_header)];
struct ip_header ip_pkt;
struct icmp_ttl_exceeded_header icmp_pkt;
ip_pkt.checksum = 0;
ip_pkt.src_ip = my_ip->s_addr;
ip_pkt.dst_ip = other->s_addr;
- ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt,
+ ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt,
sizeof (struct ip_header)));
- memcpy(&packet[off],
- &ip_pkt,
+ memcpy(&packet[off],
+ &ip_pkt,
sizeof(struct ip_header));
off += sizeof(struct ip_header);
icmp_pkt.checksum = 0;
icmp_pkt.unused = 0;
memcpy(&packet[off],
- &icmp_pkt,
+ &icmp_pkt,
sizeof(struct icmp_ttl_exceeded_header));
off += sizeof(struct icmp_ttl_exceeded_header);
ip_pkt.checksum = 0;
ip_pkt.src_ip = other->s_addr;
ip_pkt.dst_ip = dummy.s_addr;
- ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt,
+ ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt,
sizeof (struct ip_header)));
- memcpy(&packet[off],
- &ip_pkt,
+ memcpy(&packet[off],
+ &ip_pkt,
sizeof(struct ip_header));
off += sizeof(struct ip_header);
/* build UDP header */
udp_pkt.src_port = htons(NAT_TRAV_PORT);
- udp_pkt.dst_port = htons(NAT_TRAV_PORT);
+ udp_pkt.dst_port = htons(NAT_TRAV_PORT);
udp_pkt.length = htons (port);
udp_pkt.crc = 0;
- memcpy(&packet[off],
- &udp_pkt,
+ memcpy(&packet[off],
+ &udp_pkt,
sizeof(struct udp_header));
off += sizeof(struct udp_header);
/* no go back to calculate ICMP packet checksum */
icmp_pkt.checksum = htons(calc_checksum((uint16_t*)&packet[off],
- sizeof (struct icmp_ttl_exceeded_header) +
- sizeof (struct ip_header) +
+ sizeof (struct icmp_ttl_exceeded_header) +
+ sizeof (struct ip_header) +
sizeof (struct udp_header)));
- memcpy (&packet[sizeof (struct ip_header)],
- &icmp_pkt,
+ memcpy (&packet[sizeof (struct ip_header)],
+ &icmp_pkt,
sizeof (struct icmp_ttl_exceeded_header));
-
+
memset (&dst, 0, sizeof (dst));
dst.sin_family = AF_INET;
dst.sin_addr = *other;
struct icmp_ttl_exceeded_header icmp_ttl;
struct icmp_echo_header icmp_echo;
struct sockaddr_in dst;
- char packet[sizeof (struct ip_header) * 2 +
- sizeof (struct icmp_ttl_exceeded_header) +
+ char packet[sizeof (struct ip_header) * 2 +
+ sizeof (struct icmp_ttl_exceeded_header) +
sizeof(struct icmp_echo_header)];
size_t off;
int err;
ip_pkt.vers_ihl = 0x45;
ip_pkt.tos = 0;
ip_pkt.pkt_len = htons (sizeof (packet));
- ip_pkt.id = htons(256);
+ ip_pkt.id = htons(256);
ip_pkt.flags_frag_offset = 0;
ip_pkt.ttl = IPDEFTTL;
ip_pkt.proto = IPPROTO_ICMP;
- ip_pkt.checksum = 0;
+ ip_pkt.checksum = 0;
ip_pkt.src_ip = my_ip->s_addr;
ip_pkt.dst_ip = other->s_addr;
ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt,
/* icmp reply: time exceeded */
icmp_ttl.type = ICMP_TIME_EXCEEDED;
- icmp_ttl.code = 0;
+ icmp_ttl.code = 0;
icmp_ttl.reserved = 0;
icmp_ttl.checksum = 0;
memcpy (&packet[off],
ip_pkt.vers_ihl = 0x45;
ip_pkt.tos = 0;
ip_pkt.pkt_len = (sizeof (struct ip_header) + sizeof (struct icmp_echo_header));
- ip_pkt.id = htons (256);
+ ip_pkt.id = htons (256);
ip_pkt.flags_frag_offset = 0;
ip_pkt.ttl = 1; /* real TTL would be 1 on a time exceeded packet */
ip_pkt.proto = IPPROTO_ICMP;
ip_pkt.dst_ip = dummy.s_addr;
ip_pkt.checksum = 0;
ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt,
- sizeof (struct ip_header)));
- memcpy (&packet[off],
- &ip_pkt,
+ sizeof (struct ip_header)));
+ memcpy (&packet[off],
+ &ip_pkt,
sizeof (struct ip_header));
off += sizeof (struct ip_header);
icmp_echo.reserved = 0;
icmp_echo.checksum = 0;
icmp_echo.data = htons(port);
- icmp_echo.checksum = htons(calc_checksum((uint16_t*) &icmp_echo,
+ icmp_echo.checksum = htons(calc_checksum((uint16_t*) &icmp_echo,
sizeof (struct icmp_echo_header)));
memcpy (&packet[off],
- &icmp_echo,
+ &icmp_echo,
sizeof(struct icmp_echo_header));
/* no go back to calculate ICMP packet checksum */
off = sizeof (struct ip_header);
icmp_ttl.checksum = htons(calc_checksum((uint16_t*) &packet[off],
- sizeof (struct icmp_ttl_exceeded_header) +
- sizeof (struct ip_header) +
+ sizeof (struct icmp_ttl_exceeded_header) +
+ sizeof (struct ip_header) +
sizeof (struct icmp_echo_header)));
memcpy (&packet[off],
&icmp_ttl,
dst.sin_family = AF_INET;
dst.sin_addr = *other;
- err = sendto(rawsock,
+ err = sendto(rawsock,
packet,
sizeof (packet), 0,
- (struct sockaddr*)&dst,
- sizeof(dst));
+ (struct sockaddr*)&dst,
+ sizeof(dst));
- if (err < 0)
+ if (err < 0)
{
fprintf(stderr,
"sendto failed: %s\n", strerror(errno));
}
- else if (sizeof (packet) != (size_t) err)
+ else if (sizeof (packet) != (size_t) err)
{
fprintf(stderr,
"Error: partial send of ICMP message\n");
"Error opening RAW socket: %s\n",
strerror (errno));
return INVALID_SOCKET;
- }
+ }
if (0 != setsockopt(ret, SOL_SOCKET, SO_BROADCAST, (char*)&bOptVal, bOptLen))
{
- fprintf(stderr,
+ fprintf(stderr,
"Error setting SO_BROADCAST to ON: %s\n",
strerror (errno));
closesocket(rawsock);
if (0 != setsockopt(ret, IPPROTO_IP, IP_HDRINCL, (char*)&bOptVal, bOptLen))
{
- fprintf(stderr,
+ fprintf(stderr,
"Error setting IP_HDRINCL to ON: %s\n",
strerror (errno));
closesocket(rawsock);
fprintf (stderr, "Failed to find Winsock 2.1 or better.\n");
return 2;
}
- if (1 != inet_pton (AF_INET, DUMMY_IP, &dummy))
+ if (1 != inet_pton (AF_INET, DUMMY_IP, &dummy))
{
fprintf (stderr,
"Internal error converting dummy IP to binary.\n");
/**
* IPv4 header.
*/
-struct ip_header
+struct ip_header
{
/**
- * Version (4 bits) + Internet header length (4 bits)
+ * Version (4 bits) + Internet header length (4 bits)
*/
- uint8_t vers_ihl;
+ uint8_t vers_ihl;
/**
* Type of service
*/
- uint8_t tos;
+ uint8_t tos;
/**
* Total length
*/
- uint16_t pkt_len;
+ uint16_t pkt_len;
/**
* Identification
*/
- uint16_t id;
+ uint16_t id;
/**
* Flags (3 bits) + Fragment offset (13 bits)
*/
- uint16_t flags_frag_offset;
+ uint16_t flags_frag_offset;
/**
* Time to live
*/
- uint8_t ttl;
+ uint8_t ttl;
/**
- * Protocol
+ * Protocol
*/
- uint8_t proto;
+ uint8_t proto;
/**
* Header checksum
*/
- uint16_t checksum;
+ uint16_t checksum;
/**
* Source address
*/
- uint32_t src_ip;
+ uint32_t src_ip;
/**
- * Destination address
+ * Destination address
*/
- uint32_t dst_ip;
+ uint32_t dst_ip;
};
/**
* Format of ICMP packet.
*/
-struct icmp_ttl_exceeded_header
+struct icmp_ttl_exceeded_header
{
uint8_t type;
* @param bytes number of bytes in data (must be multiple of 2)
* @return the CRC 16.
*/
-static uint16_t
-calc_checksum(const uint16_t *data,
+static uint16_t
+calc_checksum(const uint16_t *data,
unsigned int bytes)
{
uint32_t sum;
unsigned int i;
sum = 0;
- for (i=0;i<bytes/2;i++)
- sum += data[i];
+ for (i=0;i<bytes/2;i++)
+ sum += data[i];
sum = (sum & 0xffff) + (sum >> 16);
sum = htons(0xffff - sum);
return sum;
* @param buf where to write the address result
* @return 1 on success
*/
-static int
-inet_pton (int af,
- const char *cp,
+static int
+inet_pton (int af,
+ const char *cp,
struct in_addr *buf)
{
buf->s_addr = inet_addr(cp);
if (buf->s_addr == INADDR_NONE)
{
- fprintf(stderr,
- "Error %d handling address %s",
- WSAGetLastError(),
+ fprintf(stderr,
+ "Error %d handling address %s",
+ WSAGetLastError(),
cp);
return 0;
}
ip_pkt.dst_ip = dummy.s_addr;
ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt,
sizeof (struct ip_header)));
- memcpy (&packet[off],
- &ip_pkt,
+ memcpy (&packet[off],
+ &ip_pkt,
sizeof (struct ip_header));
off += sizeof (struct ip_header);
icmp_echo.code = 0;
icmp_echo.reserved = 0;
icmp_echo.checksum = 0;
- icmp_echo.checksum = htons(calc_checksum((uint16_t*) &icmp_echo,
+ icmp_echo.checksum = htons(calc_checksum((uint16_t*) &icmp_echo,
sizeof (struct icmp_echo_header)));
- memcpy (&packet[off],
- &icmp_echo,
+ memcpy (&packet[off],
+ &icmp_echo,
sizeof (struct icmp_echo_header));
off += sizeof (struct icmp_echo_header);
-
+
memset (&dst, 0, sizeof (dst));
dst.sin_family = AF_INET;
dst.sin_addr = dummy;
- err = sendto(rawsock,
+ err = sendto(rawsock,
packet, off, 0,
(struct sockaddr*)&dst,
sizeof(dst));
- if (err < 0)
+ if (err < 0)
{
#if VERBOSE
fprintf(stderr,
"sendto failed: %s\n", strerror(errno));
#endif
}
- else if (err != off)
+ else if (err != off)
{
fprintf(stderr,
"Error: partial send of ICMP message\n");
{
struct sockaddr_in dst;
ssize_t err;
-
+
memset (&dst, 0, sizeof (dst));
dst.sin_family = AF_INET;
dst.sin_addr = dummy;
dst.sin_port = htons (NAT_TRAV_PORT);
- err = sendto(udpsock,
- NULL, 0, 0,
- (struct sockaddr*)&dst,
+ err = sendto(udpsock,
+ NULL, 0, 0,
+ (struct sockaddr*)&dst,
sizeof(dst));
- if (err < 0)
+ if (err < 0)
{
#if VERBOSE
fprintf(stderr,
"sendto failed: %s\n", strerror(errno));
#endif
}
- else if (0 != err)
+ else if (0 != err)
{
fprintf(stderr,
"Error: partial send of ICMP message\n");
fprintf (stderr,
"Error reading raw socket: %s\n",
strerror (errno));
- return;
+ return;
}
have_port = 0;
#if VERBOSE
}
off = 0;
memcpy (&ip_pkt,
- &buf[off],
+ &buf[off],
sizeof (struct ip_header));
off += sizeof (struct ip_header);
- memcpy(&source_ip,
- &ip_pkt.src_ip,
+ memcpy(&source_ip,
+ &ip_pkt.src_ip,
sizeof (source_ip));
- memcpy (&icmp_ttl,
- &buf[off],
+ memcpy (&icmp_ttl,
+ &buf[off],
sizeof (struct icmp_ttl_exceeded_header));
off += sizeof (struct icmp_ttl_exceeded_header);
- if ( (ICMP_TIME_EXCEEDED != icmp_ttl.type) ||
+ if ( (ICMP_TIME_EXCEEDED != icmp_ttl.type) ||
(0 != icmp_ttl.code) )
{
/* different type than what we want */
}
/* skip 2nd IP header */
memcpy (&ip_pkt,
- &buf[off],
+ &buf[off],
sizeof (struct ip_header));
off += sizeof (struct ip_header);
switch (ip_pkt.proto)
{
case IPPROTO_ICMP:
- if (have != (sizeof (struct ip_header) * 2 +
- sizeof (struct icmp_ttl_exceeded_header) +
+ if (have != (sizeof (struct ip_header) * 2 +
+ sizeof (struct icmp_ttl_exceeded_header) +
sizeof (struct icmp_echo_header)) )
{
/* malformed */
port = (uint16_t) ntohl (icmp_echo.reserved);
break;
case IPPROTO_UDP:
- if (have != (sizeof (struct ip_header) * 2 +
- sizeof (struct icmp_ttl_exceeded_header) +
+ if (have != (sizeof (struct ip_header) * 2 +
+ sizeof (struct icmp_ttl_exceeded_header) +
sizeof (struct udp_header)) )
{
/* malformed */
sizeof (struct udp_header));
port = ntohs (udp_pkt.length);
break;
- default:
+ default:
/* different type than what we want */
return;
}
-
+
ssize = sizeof(buf);
- WSAAddressToString((LPSOCKADDR)&source_ip,
+ WSAAddressToString((LPSOCKADDR)&source_ip,
sizeof(source_ip),
NULL,
- buf,
+ buf,
&ssize);
if (port == 0)
fprintf (stdout,
"Error opening RAW socket: %s\n",
strerror (errno));
return INVALID_SOCKET;
- }
+ }
return ret;
}
return INVALID_SOCKET;
}
- if (0 != setsockopt(rawsock,
- SOL_SOCKET,
- SO_BROADCAST,
+ if (0 != setsockopt(rawsock,
+ SOL_SOCKET,
+ SO_BROADCAST,
(char*)&bOptVal, bOptLen))
{
- fprintf(stderr,
+ fprintf(stderr,
"Error setting SO_BROADCAST to ON: %s\n",
strerror (errno));
closesocket(rawsock);
return INVALID_SOCKET;
}
- if (0 != setsockopt(rawsock,
- IPPROTO_IP,
- IP_HDRINCL,
+ if (0 != setsockopt(rawsock,
+ IPPROTO_IP,
+ IP_HDRINCL,
(char*)&bOptVal, bOptLen))
{
- fprintf(stderr,
+ fprintf(stderr,
"Error setting IP_HDRINCL to ON: %s\n",
strerror (errno));
closesocket(rawsock);
int
-main (int argc,
+main (int argc,
char *const *argv)
{
struct in_addr external;
argv[1], strerror (errno));
return 1;
}
- if (1 != inet_pton (AF_INET, DUMMY_IP, &dummy))
+ if (1 != inet_pton (AF_INET, DUMMY_IP, &dummy))
{
fprintf (stderr,
"Internal error converting dummy IP to binary.\n");
}
if (INVALID_SOCKET == (icmpsock = make_icmp_socket()))
{
- return 3;
+ return 3;
}
if (INVALID_SOCKET == (make_raw_socket()))
{
closesocket (icmpsock);
- return 3;
+ return 3;
}
if (INVALID_SOCKET == (udpsock = make_udp_socket(&external)))
{
closesocket (icmpsock);
closesocket (rawsock);
- return 3;
+ return 3;
}
while (1)
{
FD_ZERO (&rs);
FD_SET (icmpsock, &rs);
tv.tv_sec = 0;
- tv.tv_usec = ICMP_SEND_FREQUENCY_MS * 1000;
+ tv.tv_usec = ICMP_SEND_FREQUENCY_MS * 1000;
if (-1 == select (icmpsock + 1, &rs, NULL, NULL, &tv))
{
if (errno == EINTR)
closesocket(rawsock);
closesocket(udpsock);
WSACleanup ();
- return 4;
+ return 4;
}
#define MAX_CONNECT_RETRY 3
/**
- * Limit on the number of ready-to-run tasks when validating
- * HELLOs. If more tasks are ready to run, we will drop
+ * Limit on the number of ready-to-run tasks when validating
+ * HELLOs. If more tasks are ready to run, we will drop
* HELLOs instead of validating them.
*/
#define MAX_HELLO_LOAD 4
unsigned int connect_attempts;
/**
- * DV distance to this peer (1 if no DV is used).
+ * DV distance to this peer (1 if no DV is used).
* FIXME: need to set this from transport plugins!
*/
uint32_t distance;
* successfully transmit or receive data to a peer via a particular
* address, we set this to GNUNET_YES. If we later get an error
* (disconnect notification, transmission failure, timeout), we set
- * it back to GNUNET_NO.
+ * it back to GNUNET_NO.
*/
int8_t connected;
* Buffer for at most one payload message used when we receive
* payload data before our PING-PONG has succeeded. We then
* store such messages in this intermediary buffer until the
- * connection is fully up.
+ * connection is fully up.
*/
struct GNUNET_MessageHeader *pre_connect_message_buffer;
unsigned int quota_violation_count;
/**
- * DV distance to this peer (1 if no DV is used).
+ * DV distance to this peer (1 if no DV is used).
*/
uint32_t distance;
/**
* Size of address appended to this message (part of what is
- * being signed, hence not redundant).
+ * being signed, hence not redundant).
*/
uint32_t addrlen;
/**
* Current transmit request handle.
- */
+ */
struct GNUNET_CONNECTION_TransmitHandle *th;
/**
* NULL after we are done processing peerinfo's information.
*/
struct GNUNET_PEERINFO_IteratorContext *piter;
-
+
/**
* Was a HELLO known for this peer to peerinfo?
*/
/**
* Find an entry in the neighbour list for a particular peer.
- *
+ *
* @return NULL if not found.
*/
static struct NeighbourList *
plugin = find_transport(transport_name);
if (plugin == NULL) /* Nothing to do */
return;
- if (plugin->blacklist == NULL)
- plugin->blacklist = GNUNET_CONTAINER_multihashmap_create(TRANSPORT_BLACKLIST_HT_SIZE);
+ if (plugin->blacklist == NULL)
+ plugin->blacklist = GNUNET_CONTAINER_multihashmap_create(TRANSPORT_BLACKLIST_HT_SIZE);
GNUNET_assert(plugin->blacklist != NULL);
GNUNET_CONTAINER_multihashmap_put(plugin->blacklist, &peer->hashPubKey,
- NULL,
+ NULL,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
}
GNUNET_STATISTICS_update (stats,
gettext_noop ("# bytes discarded (could not transmit to client)"),
ntohs (((const struct GNUNET_MessageHeader*)&q[1])->size),
- GNUNET_NO);
+ GNUNET_NO);
GNUNET_CONTAINER_DLL_remove (client->message_queue_head,
client->message_queue_tail,
q);
return p->api->address_to_string (p->api->cls,
addr,
addr_len);
-}
+}
/**
("Dropping message of type %u and size %u, have %u messages pending (%u is the soft limit)\n"),
ntohs (msg->type),
ntohs (msg->size),
- client->message_count,
+ client->message_count,
MAX_PENDING);
GNUNET_STATISTICS_update (stats,
gettext_noop ("# messages dropped due to slow client"),
GNUNET_CONTAINER_DLL_insert_after (client->message_queue_head,
client->message_queue_tail,
client->message_queue_tail,
- q);
+ q);
client->message_count++;
if (client->th == NULL)
{
send_ok_msg.success = htonl (result);
send_ok_msg.latency = GNUNET_TIME_relative_hton (n->latency);
send_ok_msg.peer = n->id;
- transmit_to_client (client, &send_ok_msg.header, GNUNET_NO);
+ transmit_to_client (client, &send_ok_msg.header, GNUNET_NO);
}
{
struct MessageQueue *mq = cls;
struct NeighbourList *n;
-
+
GNUNET_STATISTICS_update (stats,
gettext_noop ("# bytes pending with plugins"),
- (int64_t) mq->message_buf_size,
GNUNET_STATISTICS_update (stats,
gettext_noop ("# bytes successfully transmitted by plugins"),
mq->message_buf_size,
- GNUNET_NO);
+ GNUNET_NO);
}
else
{
GNUNET_STATISTICS_update (stats,
gettext_noop ("# bytes with transmission failure by plugins"),
mq->message_buf_size,
- GNUNET_NO);
- }
+ GNUNET_NO);
+ }
n = find_neighbour(&mq->neighbour_id);
GNUNET_assert (n != NULL);
if (mq->specific_address != NULL)
{
- if (result == GNUNET_OK)
+ if (result == GNUNET_OK)
{
mq->specific_address->timeout =
GNUNET_TIME_relative_to_absolute
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
if (mq->specific_address->validated == GNUNET_YES)
mark_address_connected (mq->specific_address);
- }
+ }
else
{
if (mq->specific_address->connected != GNUNET_NO)
GNUNET_NO);
mq->specific_address->connected = GNUNET_NO;
}
- }
- if (! mq->internal_msg)
+ }
+ if (! mq->internal_msg)
mq->specific_address->in_transmit = GNUNET_NO;
}
if (mq->client != NULL)
addresses = head->addresses;
while (addresses != NULL)
{
- if ( (addresses->timeout.value < now.value) &&
+ if ( (addresses->timeout.value < now.value) &&
(addresses->connected == GNUNET_YES) )
{
#if DEBUG_TRANSPORT
(unsigned long long) addresses->timeout.value,
(unsigned int) addresses->distance);
#endif
- if ( ( (best_address == NULL) ||
+ if ( ( (best_address == NULL) ||
(addresses->connected == GNUNET_YES) ||
(best_address->connected == GNUNET_NO) ) &&
(addresses->in_transmit == GNUNET_NO) &&
- ( (best_address == NULL) ||
+ ( (best_address == NULL) ||
(addresses->latency.value < best_address->latency.value)) )
- best_address = addresses;
+ best_address = addresses;
/* FIXME: also give lower-latency addresses that are not
connected a chance some times... */
addresses = addresses->next;
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Best address found (`%s') has latency of %llu ms.\n",
- (best_address->addrlen > 0)
+ (best_address->addrlen > 0)
? a2s (best_address->ready_list->plugin->short_name,
best_address->addr,
best_address->addrlen)
force_address = GNUNET_YES;
if (mq->specific_address == NULL)
{
- mq->specific_address = find_ready_address(neighbour);
+ mq->specific_address = find_ready_address(neighbour);
GNUNET_STATISTICS_update (stats,
gettext_noop ("# transport selected peer address freely"),
1,
- GNUNET_NO);
+ GNUNET_NO);
force_address = GNUNET_NO;
}
if (mq->specific_address == NULL)
GNUNET_STATISTICS_update (stats,
gettext_noop ("# transport failed to selected peer address"),
1,
- GNUNET_NO);
+ GNUNET_NO);
timeout = GNUNET_TIME_absolute_get_remaining (mq->timeout);
if (timeout.value == 0)
{
GNUNET_STATISTICS_update (stats,
gettext_noop ("# bytes discarded (no destination address available)"),
mq->message_buf_size,
- GNUNET_NO);
+ GNUNET_NO);
if (mq->client != NULL)
transmit_send_ok (mq->client, neighbour, GNUNET_NO);
GNUNET_CONTAINER_DLL_remove (neighbour->messages_head,
neighbour->messages_tail,
mq);
GNUNET_free (mq);
- return; /* nobody ready */
+ return; /* nobody ready */
}
GNUNET_STATISTICS_update (stats,
gettext_noop ("# message delivery deferred (no address)"),
#endif
/* FIXME: might want to trigger peerinfo lookup here
(unless that's already pending...) */
- return;
+ return;
}
GNUNET_CONTAINER_DLL_remove (neighbour->messages_head,
neighbour->messages_tail,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending message of size %u for `%4s' to `%s' via plugin `%s'\n",
mq->message_buf_size,
- GNUNET_i2s (&neighbour->id),
+ GNUNET_i2s (&neighbour->id),
(mq->specific_address->addr != NULL)
? a2s (mq->plugin->short_name,
mq->specific_address->addr,
{
/* failure, but 'send' would not call continuation in this case,
so we need to do it here! */
- transmit_send_continuation (mq,
+ transmit_send_continuation (mq,
&mq->neighbour_id,
GNUNET_SYSERR);
}
mq->internal_msg = is_internal;
mq->priority = priority;
mq->timeout = GNUNET_TIME_relative_to_absolute (timeout);
- if (is_internal)
+ if (is_internal)
GNUNET_CONTAINER_DLL_insert (neighbour->messages_head,
neighbour->messages_tail,
mq);
GNUNET_NO);
transmit_to_peer (NULL, NULL, 0,
HELLO_ADDRESS_EXPIRATION,
- (const char *) our_hello,
+ (const char *) our_hello,
GNUNET_HELLO_size(our_hello),
GNUNET_NO, npos);
npos = npos->next;
if (prev == NULL)
plugin->addresses = pos->next;
else
- prev->next = pos->next;
+ prev->next = pos->next;
GNUNET_free (pos);
}
else
* @param value value in the hash map ('struct ValidationEntry*')
* @return GNUNET_YES (we should continue to iterate)
*/
-static int
+static int
remove_session_validations (void *cls,
const GNUNET_HashCode * key,
void *value)
/**
* We've been disconnected from the other peer (for some
- * connection-oriented transport). Either quickly
+ * connection-oriented transport). Either quickly
* re-establish the connection or signal the disconnect
* to the CORE.
*
1) ideally: our own willingness / need to connect
2) prior failures to connect to this peer (by plugin)
3) ideally: reasons why other peer terminated (as far as knowable)
-
+
Most importantly, it must be POSSIBLE for another peer to terminate
a connection for a while (without us instantly re-establishing it).
Similarly, if another peer is gone we should quickly notify CORE.
on the other end), we should reconnect in such a way that BOTH CORE
services never even notice.
Furthermore, the same mechanism (or small variation) could be used
- to switch to a better-performing plugin (ATS).
+ to switch to a better-performing plugin (ATS).
Finally, this needs to be tested throughly... */
* discard all of those sessions as well. Plugins that do not
* use sessions can simply omit calling this function and always
* use NULL wherever a session pointer is needed.
- *
+ *
* @param cls closure
- * @param peer which peer was the session for
+ * @param peer which peer was the session for
* @param session which session is being destoyed
*/
static void
add_peer_address (struct NeighbourList *neighbour,
const char *tname,
struct Session *session,
- const char *addr,
+ const char *addr,
uint16_t addrlen)
{
struct ReadyList *head;
ret->latency = GNUNET_TIME_relative_get_forever();
ret->distance = -1;
ret->timeout = GNUNET_TIME_relative_to_absolute
- (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
ret->ready_list = head;
ret->next = head->addresses;
head->addresses = ret;
* @param value value in the hash map (validation to abort)
* @return GNUNET_YES (always)
*/
-static int
+static int
abort_validation (void *cls,
const GNUNET_HashCode * key,
void *value)
GNUNET_STATISTICS_update (stats,
gettext_noop ("# valid peer addresses returned by PEERINFO"),
1,
- GNUNET_NO);
+ GNUNET_NO);
try = GNUNET_NO;
fal = find_peer_address (n, tname, NULL, addr, addrlen);
if (fal == NULL)
GNUNET_STATISTICS_update (stats,
gettext_noop ("# previously validated addresses lacking transport"),
1,
- GNUNET_NO);
+ GNUNET_NO);
}
else
{
}
if (fal->validated == GNUNET_NO)
{
- fal->validated = GNUNET_YES;
+ fal->validated = GNUNET_YES;
GNUNET_STATISTICS_update (stats,
gettext_noop ("# peer addresses considered valid"),
1,
- GNUNET_NO);
+ GNUNET_NO);
}
if (try == GNUNET_YES)
{
GNUNET_NO);
n->piter = NULL;
return;
- }
+ }
if (h == NULL)
return; /* no HELLO available */
#if DEBUG_TRANSPORT
/**
* Create a fresh entry in our neighbour list for the given peer.
- * Will try to transmit our current HELLO to the new neighbour.
+ * Will try to transmit our current HELLO to the new neighbour.
* Do not call this function directly, use 'setup_peer_check_blacklist.
*
* @param peer the peer for which we create the entry
/**
* Function called after we have checked if communicating
- * with a given peer is acceptable.
+ * with a given peer is acceptable.
*
* @param cls closure
* @param n NULL if communication is not acceptable
*/
struct BlacklistCheck
{
-
+
/**
* This is a linked list.
*/
struct BlacklistCheck *next;
-
+
/**
* This is a linked list.
*/
* Perform next action in the blacklist check.
*
* @param cls the 'struct BlacklistCheck*'
- * @param tc unused
+ * @param tc unused
*/
static void
do_blacklist_check (void *cls,
bm.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY);
bm.is_allowed = htonl (0);
bm.peer = bc->peer;
- memcpy (buf, &bm, sizeof (bm));
+ memcpy (buf, &bm, sizeof (bm));
GNUNET_SERVER_receive_done (bl->client, GNUNET_OK);
return sizeof (bm);
}
* Perform next action in the blacklist check.
*
* @param cls the 'struct BlacklistCheck*'
- * @param tc unused
+ * @param tc unused
*/
static void
do_blacklist_check (void *cls,
GNUNET_free (bc);
return;
}
- if (bl->bc == NULL)
+ if (bl->bc == NULL)
{
bl->bc = bc;
bc->th = GNUNET_SERVER_notify_transmit_ready (bl->client,
sizeof (struct BlacklistMessage),
GNUNET_TIME_UNIT_FOREVER_REL,
&transmit_blacklist_message,
- bc);
+ bc);
}
}
/**
- * Function called with the result of querying a new blacklister about
+ * Function called with the result of querying a new blacklister about
* it being allowed (or not) to continue to talk to an existing neighbour.
*
* @param cls the original 'struct NeighbourList'
bl = bl_head;
while ( (bl != NULL) &&
(bl->client != client) )
- bl = bl->next;
+ bl = bl->next;
if (bl == NULL)
{
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
bc = bl->bc;
- bl->bc = NULL;
+ bl->bc = NULL;
if (ntohl (msg->is_allowed) == GNUNET_SYSERR)
- {
+ {
bc->cont (bc->cont_cls, NULL);
GNUNET_CONTAINER_DLL_remove (bc_head, bc_tail, bc);
GNUNET_free (bc);
bc->bl_pos = bc->bl_pos->next;
bc->task = GNUNET_SCHEDULER_add_now (sched,
&do_blacklist_check,
- bc);
+ bc);
}
/* check if any other bc's are waiting for this blacklister */
bc = bc_head;
(GNUNET_SCHEDULER_NO_TASK == bc->task) )
bc->task = GNUNET_SCHEDULER_add_now (sched,
&do_blacklist_check,
- bc);
+ bc);
bc = bc->next;
}
}
* @param cls our 'struct PeriodicValidationContext*'
* @param tc task context
*/
-static void
-send_periodic_ping (void *cls,
+static void
+send_periodic_ping (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct ForeignAddressList *peer_address = cls;
peer_address->revalidate_task = GNUNET_SCHEDULER_NO_TASK;
if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
- return;
+ return;
tp = peer_address->ready_list->plugin;
neighbour = peer_address->ready_list->neighbour;
if (GNUNET_YES != neighbour->public_key_valid)
{
/* no public key yet, try again later */
- schedule_next_ping (peer_address);
+ schedule_next_ping (peer_address);
return;
}
caec.addr = peer_address->addr;
tp->short_name,
GNUNET_i2s (&neighbour->id));
#endif
- schedule_next_ping (peer_address);
+ schedule_next_ping (peer_address);
return;
}
va = GNUNET_malloc (sizeof (struct ValidationEntry) + peer_address->addrlen);
va->addrlen = peer_address->addrlen;
}
memcpy(&va->publicKey,
- &neighbour->publicKey,
+ &neighbour->publicKey,
sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
va->timeout_task = GNUNET_SCHEDULER_add_delayed (sched,
memcpy(message_buf, our_hello, hello_size);
if (peer_address->addr != NULL)
{
- ping.header.size = htons(sizeof(struct TransportPingMessage) +
- peer_address->addrlen +
+ ping.header.size = htons(sizeof(struct TransportPingMessage) +
+ peer_address->addrlen +
slen);
memcpy(&message_buf[hello_size + sizeof (struct TransportPingMessage)],
- tp->short_name,
+ tp->short_name,
slen);
memcpy(&message_buf[hello_size + sizeof (struct TransportPingMessage) + slen],
- peer_address->addr,
+ peer_address->addr,
peer_address->addrlen);
}
else
#if DEBUG_TRANSPORT_REVALIDATION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Performing re-validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s'\n",
- (peer_address->addr != NULL)
+ (peer_address->addr != NULL)
? a2s (peer_address->plugin->short_name,
peer_address->addr,
peer_address->addrlen)
{
delay = GNUNET_TIME_UNIT_ZERO;
fal->estimated = GNUNET_YES;
- }
+ }
if (GNUNET_YES == fal->connected)
{
delay = GNUNET_TIME_relative_min (delay,
CONNECTED_LATENCY_EVALUATION_MAX_DELAY);
- }
+ }
/* FIXME: also adjust delay based on how close the last
observed latency is to the latency of the best alternative */
/* bound how fast we can go */
GNUNET_TIME_UNIT_SECONDS);
/* randomize a bit (to avoid doing all at the same time) */
delay.value += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000);
- fal->revalidate_task = GNUNET_SCHEDULER_add_delayed(sched,
+ fal->revalidate_task = GNUNET_SCHEDULER_add_delayed(sched,
delay,
- &send_periodic_ping,
+ &send_periodic_ping,
fal);
}
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Received message of type %u and size %u from `%4s', sending to all clients.\n",
- ntohs (message->type),
- ntohs (message->size),
+ ntohs (message->type),
+ ntohs (message->size),
GNUNET_i2s (&n->id));
#endif
if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker,
{
n->quota_violation_count++;
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Bandwidth quota (%u b/s) violation detected (total of %u).\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Bandwidth quota (%u b/s) violation detected (total of %u).\n",
n->in_tracker.available_bytes_per_s__,
n->quota_violation_count);
#endif
GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker,
- 32 * 1024);
}
- else
+ else
{
if (n->quota_violation_count > 0)
{
if ( (ps - sizeof (struct TransportPongMessage) != ve->addrlen + slen) ||
(ve->challenge != challenge) ||
(addr[slen-1] != '\0') ||
- (0 != strcmp (addr, ve->transport_name)) ||
- (ntohl (pong->purpose.size)
+ (0 != strcmp (addr, ve->transport_name)) ||
+ (ntohl (pong->purpose.size)
!= sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
sizeof (uint32_t) +
sizeof (struct GNUNET_TIME_AbsoluteNBO) +
}
if (0 != memcmp (&pong->pid,
key,
- sizeof (struct GNUNET_PeerIdentity)))
+ sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break_op (0);
return GNUNET_NO;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN,
- &pong->purpose,
+ &pong->purpose,
&pong->signature,
- &ve->publicKey))
+ &ve->publicKey))
{
GNUNET_break_op (0);
return GNUNET_NO;
#endif
break;
case GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING:
- if (ve->addrlen != 0)
+ if (ve->addrlen != 0)
{
return GNUNET_YES; /* different entry, keep trying */
}
a2s (ve->transport_name,
&addr[slen],
alen));
- return GNUNET_NO;
+ return GNUNET_NO;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING,
- &pong->purpose,
+ &pong->purpose,
&pong->signature,
- &ve->publicKey))
+ &ve->publicKey))
{
GNUNET_break_op (0);
return GNUNET_NO;
GNUNET_STATISTICS_update (stats,
gettext_noop ("# peer addresses considered valid"),
1,
- GNUNET_NO);
+ GNUNET_NO);
fal->latency = GNUNET_TIME_absolute_get_duration (ve->send_time);
schedule_next_ping (fal);
if (n->latency.value == GNUNET_TIME_UNIT_FOREVER_REL.value)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to add peer `%4s' for plugin `%s'\n",
- GNUNET_i2s (&neighbour->id),
+ GNUNET_i2s (&neighbour->id),
va->transport_name);
GNUNET_break (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap_remove (validation_map,
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Performing validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s' (%u bytes)\n",
- (va->addrlen == 0)
+ (va->addrlen == 0)
? "<inbound>"
: a2s (va->transport_name,
(const void*) &va[1], va->addrlen),
GNUNET_STATISTICS_update (stats,
gettext_noop ("# PING messages sent for initial validation"),
1,
- GNUNET_NO);
+ GNUNET_NO);
transmit_to_peer (NULL, peer_address,
GNUNET_SCHEDULER_PRIORITY_DEFAULT,
HELLO_VERIFICATION_TIMEOUT,
run_validation (void *cls,
const char *tname,
struct GNUNET_TIME_Absolute expiration,
- const void *addr,
+ const void *addr,
uint16_t addrlen)
{
struct CheckHelloValidatedContext *chvc = cls;
GNUNET_STATISTICS_update (stats,
gettext_noop ("# peer addresses scheduled for validation"),
1,
- GNUNET_NO);
+ GNUNET_NO);
tp = find_transport (tname);
if (tp == NULL)
{
GNUNET_STATISTICS_update (stats,
gettext_noop ("# peer addresses not validated (plugin not available)"),
1,
- GNUNET_NO);
+ GNUNET_NO);
return GNUNET_OK;
}
/* check if this is one of our own addresses */
GNUNET_STATISTICS_update (stats,
gettext_noop ("# peer addresses not validated (loopback)"),
1,
- GNUNET_NO);
+ GNUNET_NO);
return GNUNET_OK;
}
oal = oal->next;
{
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Attempted to validate blacklisted peer `%s' using `%s'!\n",
- GNUNET_i2s(&id),
+ "Attempted to validate blacklisted peer `%s' using `%s'!\n",
+ GNUNET_i2s(&id),
tname);
#endif
return GNUNET_OK;
GNUNET_STATISTICS_update (stats,
gettext_noop ("# peer addresses not validated (in progress)"),
1,
- GNUNET_NO);
+ GNUNET_NO);
return GNUNET_OK;
}
va = GNUNET_malloc (sizeof (struct ValidationEntry) + addrlen);
sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
&target.hashPubKey);
plain_hello = GNUNET_HELLO_create (&pk,
- NULL,
+ NULL,
NULL);
GNUNET_PEERINFO_add_peer (peerinfo, plain_hello);
GNUNET_free (plain_hello);
GNUNET_STATISTICS_update (stats,
gettext_noop ("# new HELLOs requiring full validation"),
1,
- GNUNET_NO);
+ GNUNET_NO);
GNUNET_HELLO_iterate_addresses (chvc->hello,
- GNUNET_NO,
- &run_validation,
+ GNUNET_NO,
+ &run_validation,
chvc);
}
else
GNUNET_STATISTICS_update (stats,
gettext_noop ("# duplicate HELLO (peer known)"),
1,
- GNUNET_NO);
+ GNUNET_NO);
}
chvc->ve_count--;
if (chvc->ve_count == 0)
GNUNET_CONTAINER_DLL_remove (chvc_head,
chvc_tail,
chvc);
- GNUNET_free (chvc);
+ GNUNET_free (chvc);
}
return;
- }
+ }
if (h == NULL)
return;
#if DEBUG_TRANSPORT
GNUNET_STATISTICS_update (stats,
gettext_noop ("# no existing neighbour record (validating HELLO)"),
1,
- GNUNET_NO);
+ GNUNET_NO);
}
GNUNET_STATISTICS_update (stats,
gettext_noop ("# HELLO validations (update case)"),
1,
- GNUNET_NO);
+ GNUNET_NO);
GNUNET_HELLO_iterate_new_addresses (chvc->hello,
h,
GNUNET_TIME_relative_to_absolute (HELLO_REVALIDATION_START_TIME),
- &run_validation,
+ &run_validation,
chvc);
}
GNUNET_STATISTICS_update (stats,
gettext_noop ("# HELLOs received for validation"),
1,
- GNUNET_NO);
+ GNUNET_NO);
/* first, check if load is too high */
if (GNUNET_SCHEDULER_get_load (sched,
GNUNET_STATISTICS_update (stats,
gettext_noop ("# HELLOs ignored due to high load"),
1,
- GNUNET_NO);
+ GNUNET_NO);
#if DEBUG_TRANSPORT_HELLO
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Ignoring `%s' for `%4s', load too high.\n",
GNUNET_STATISTICS_update (stats,
gettext_noop ("# HELLOs ignored for validation (is my own HELLO)"),
1,
- GNUNET_NO);
- return GNUNET_OK;
+ GNUNET_NO);
+ return GNUNET_OK;
}
chvc = chvc_head;
while (NULL != chvc)
#if DEBUG_TRANSPORT_HELLO
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received duplicate `%s' message for `%4s'; ignored\n",
- "HELLO",
+ "HELLO",
GNUNET_i2s (&target));
#endif
return GNUNET_OK; /* validation already pending */
GNUNET_STATISTICS_update (stats,
gettext_noop ("# connected addresses"),
-1,
- GNUNET_NO);
+ GNUNET_NO);
if (GNUNET_YES == peer_pos->validated)
GNUNET_STATISTICS_update (stats,
gettext_noop ("# peer addresses considered valid"),
-1,
- GNUNET_NO);
+ GNUNET_NO);
if (GNUNET_SCHEDULER_NO_TASK != peer_pos->revalidate_task)
{
GNUNET_SCHEDULER_cancel (sched,
GNUNET_CONTAINER_DLL_remove (n->messages_head,
n->messages_tail,
mq);
- GNUNET_assert (0 == memcmp(&mq->neighbour_id,
+ GNUNET_assert (0 == memcmp(&mq->neighbour_id,
&n->id,
sizeof(struct GNUNET_PeerIdentity)));
GNUNET_free (mq);
/**
* We have received a PING message from someone. Need to send a PONG message
- * in response to the peer by any means necessary.
+ * in response to the peer by any means necessary.
*/
-static int
+static int
handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
const struct GNUNET_PeerIdentity *peer,
struct Session *session,
sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Received `%s' message not destined for me!\n"),
+ _("Received `%s' message not destined for me!\n"),
"PING");
return GNUNET_SYSERR;
}
#if DEBUG_PING_PONG
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"Processing `%s' from `%s'\n",
- "PING",
- (sender_address != NULL)
+ "PING",
+ (sender_address != NULL)
? a2s (plugin->short_name,
- (const struct sockaddr *)sender_address,
+ (const struct sockaddr *)sender_address,
sender_address_len)
: "<inbound>");
#endif
alen = ntohs (message->size) - sizeof (struct TransportPingMessage);
slen = strlen (plugin->short_name) + 1;
if (alen == 0)
- {
+ {
/* peer wants to confirm that we have an outbound connection to him */
if (session == NULL)
{
pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING);
pong->challenge = ping->challenge;
pong->addrlen = htonl(sender_address_len + slen);
- memcpy(&pong->pid,
+ memcpy(&pong->pid,
peer,
sizeof(struct GNUNET_PeerIdentity));
- memcpy (&pong[1],
- plugin->short_name,
+ memcpy (&pong[1],
+ plugin->short_name,
slen);
- memcpy (&((char*)&pong[1])[slen],
- sender_address,
+ memcpy (&((char*)&pong[1])[slen],
+ sender_address,
sender_address_len);
if (GNUNET_TIME_absolute_get_remaining (session_header->pong_sig_expires).value < PONG_SIGNATURE_LIFETIME.value / 4)
{
}
memcpy (&pong->signature,
&session_header->pong_signature,
- sizeof (struct GNUNET_CRYPTO_RsaSignature));
+ sizeof (struct GNUNET_CRYPTO_RsaSignature));
}
pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN);
pong->challenge = ping->challenge;
pong->addrlen = htonl(alen + slen);
- memcpy(&pong->pid,
- &my_identity,
+ memcpy(&pong->pid,
+ &my_identity,
sizeof(struct GNUNET_PeerIdentity));
memcpy (&pong[1], plugin->short_name, slen);
memcpy (&((char*)&pong[1])[slen], addr, alen);
GNUNET_assert (GNUNET_OK ==
GNUNET_CRYPTO_rsa_sign (my_private_key,
&pong->purpose,
- &oal->pong_signature));
+ &oal->pong_signature));
memcpy (&pong->signature,
&oal->pong_signature,
- sizeof (struct GNUNET_CRYPTO_RsaSignature));
+ sizeof (struct GNUNET_CRYPTO_RsaSignature));
}
else if (oal == NULL)
{
GNUNET_assert (GNUNET_OK ==
GNUNET_CRYPTO_rsa_sign (my_private_key,
&pong->purpose,
- &pong->signature));
+ &pong->signature));
}
else
{
pong->expiration = GNUNET_TIME_absolute_hton (oal->pong_sig_expires);
memcpy (&pong->signature,
&oal->pong_signature,
- sizeof (struct GNUNET_CRYPTO_RsaSignature));
+ sizeof (struct GNUNET_CRYPTO_RsaSignature));
}
}
n = find_neighbour(peer);
peer,
(const char*) pong,
ntohs (pong->header.size),
- TRANSPORT_PONG_PRIORITY,
+ TRANSPORT_PONG_PRIORITY,
HELLO_VERIFICATION_TIMEOUT,
fal->session,
fal->addr,
GNUNET_STATISTICS_update (stats,
gettext_noop ("# PONGs unicast via reliable transport"),
1,
- GNUNET_NO);
+ GNUNET_NO);
GNUNET_free (pong);
return GNUNET_OK;
}
GNUNET_STATISTICS_update (stats,
gettext_noop ("# PONGs multicast to all available addresses"),
1,
- GNUNET_NO);
+ GNUNET_NO);
rl = n->plugins;
while (rl != NULL)
{
while (fal != NULL)
{
transmit_to_peer(NULL, fal,
- TRANSPORT_PONG_PRIORITY,
+ TRANSPORT_PONG_PRIORITY,
HELLO_VERIFICATION_TIMEOUT,
- (const char *)pong,
- ntohs(pong->header.size),
- GNUNET_YES,
+ (const char *)pong,
+ ntohs(pong->header.size),
+ GNUNET_YES,
n);
fal = fal->next;
}
{
if ( (session != NULL) ||
(sender_address != NULL) )
- peer_address = add_peer_address (n,
+ peer_address = add_peer_address (n,
plugin->short_name,
session,
- sender_address,
- sender_address_len);
+ sender_address,
+ sender_address_len);
if (peer_address != NULL)
{
peer_address->distance = distance;
schedule_next_ping (peer_address);
}
/* update traffic received amount ... */
- msize = ntohs (message->size);
+ msize = ntohs (message->size);
GNUNET_STATISTICS_update (stats,
gettext_noop ("# bytes received from other peers"),
msize,
GNUNET_log (GNUNET_ERROR_TYPE_WARNING |
GNUNET_ERROR_TYPE_BULK,
_
- ("Dropping incoming message due to repeated bandwidth quota (%u b/s) violations (total of %u).\n"),
+ ("Dropping incoming message due to repeated bandwidth quota (%u b/s) violations (total of %u).\n"),
n->in_tracker.available_bytes_per_s__,
n->quota_violation_count);
GNUNET_STATISTICS_update (stats,
#if DEBUG_PING_PONG
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received message of type %u and size %u from `%4s', sending to all clients.\n",
- ntohs (message->type),
- ntohs (message->size),
+ ntohs (message->type),
+ ntohs (message->size),
GNUNET_i2s (peer));
#endif
switch (ntohs (message->type))
handle_payload_message (message, n);
break;
}
- }
+ }
ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 0);
if (ret.value > 0)
{
GNUNET_STATISTICS_update (stats,
gettext_noop ("# ms throttling suggested"),
(int64_t) ret.value,
- GNUNET_NO);
+ GNUNET_NO);
}
return ret;
}
_("Rejecting control connection from peer `%s', which is not me!\n"),
GNUNET_i2s (&start->self));
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
+ return;
}
c = GNUNET_malloc (sizeof (struct TransportClient));
c->next = clients;
/* tell new client about all existing connections */
cim.header.size = htons (sizeof (struct ConnectInfoMessage));
cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
- n = neighbours;
+ n = neighbours;
while (n != NULL)
{
if (GNUNET_YES == n->received_pong)
GNUNET_STATISTICS_update (stats,
gettext_noop ("# HELLOs received from clients"),
1,
- GNUNET_NO);
+ GNUNET_NO);
ret = process_hello (NULL, message);
GNUNET_SERVER_receive_done (client, ret);
}
* Closure for 'transmit_client_message'; followed by
* 'msize' bytes of the actual message.
*/
-struct TransmitClientMessageContext
+struct TransmitClientMessageContext
{
/**
* Client on whom's behalf we are sending.
* Timeout for the transmission.
*/
struct GNUNET_TIME_Absolute timeout;
-
+
/**
* Message priority.
*/
/**
* Size of the message in bytes.
- */
+ */
uint16_t msize;
};
if (n != NULL)
{
- transmit_to_peer (tc, NULL, tcmc->priority,
+ transmit_to_peer (tc, NULL, tcmc->priority,
GNUNET_TIME_absolute_get_remaining (tcmc->timeout),
(char *)&tcmc[1],
tcmc->msize, GNUNET_NO, n);
GNUNET_STATISTICS_update (stats,
gettext_noop ("# payload received for other peers"),
size,
- GNUNET_NO);
+ GNUNET_NO);
obm = (const struct OutboundMessage *) message;
obmm = (const struct GNUNET_MessageHeader *) &obm[1];
msize = size - sizeof (struct OutboundMessage);
const struct QuotaSetMessage *qsm =
(const struct QuotaSetMessage *) message;
struct NeighbourList *n;
-
+
GNUNET_STATISTICS_update (stats,
gettext_noop ("# SET QUOTA messages received"),
1,
- GNUNET_NO);
+ GNUNET_NO);
n = find_neighbour (&qsm->peer);
if (n == NULL)
{
GNUNET_STATISTICS_update (stats,
gettext_noop ("# SET QUOTA messages ignored (no such peer)"),
1,
- GNUNET_NO);
+ GNUNET_NO);
return;
}
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received `%s' request (new quota %u, old quota %u) from client for peer `%4s'\n",
- "SET_QUOTA",
+ "SET_QUOTA",
(unsigned int) ntohl (qsm->quota.value__),
(unsigned int) n->in_tracker.available_bytes_per_s__,
GNUNET_i2s (&qsm->peer));
#endif
GNUNET_BANDWIDTH_tracker_update_quota (&n->in_tracker,
qsm->quota);
- if (0 == ntohl (qsm->quota.value__))
+ if (0 == ntohl (qsm->quota.value__))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Disconnecting peer `%4s', %s\n", GNUNET_i2s(&n->id),
/**
* Take the given address and append it to the set of results sent back to
* the client.
- *
+ *
* @param cls the transmission context used ('struct GNUNET_SERVER_TransmitContext*')
* @param address the resolved name, NULL to indicate the last response
*/
tc = GNUNET_SERVER_transmit_context_create (client);
lsPlugin->api->address_pretty_printer (lsPlugin->api->cls,
nameTransport,
- address, addressLen,
+ address, addressLen,
numeric,
rtimeout,
&transmit_address_to_client, tc);
* Start the specified transport (load the plugin).
*/
static void
-start_transport (struct GNUNET_SERVER_Handle *server,
+start_transport (struct GNUNET_SERVER_Handle *server,
const char *name)
{
struct TransportPlugin *plug;
if (bc->th != NULL)
{
GNUNET_CONNECTION_notify_transmit_ready_cancel (bc->th);
- bc->th = NULL;
+ bc->th = NULL;
}
if (bc->task == GNUNET_SCHEDULER_NO_TASK)
bc->task = GNUNET_SCHEDULER_add_now (sched,
plugins = plug->next;
if (plug->address_update_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel (plug->env.sched,
+ GNUNET_SCHEDULER_cancel (plug->env.sched,
plug->address_update_task);
plug->address_update_task = GNUNET_SCHEDULER_NO_TASK;
}
if (peerinfo == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Could not access PEERINFO service. Exiting.\n"));
+ _("Could not access PEERINFO service. Exiting.\n"));
GNUNET_SCHEDULER_shutdown (s);
if (stats != NULL)
{
/**
* @file src/transport/gnunet-wlan.c
* @brief wlan layer two server; must run as root (SUID will do)
- * This code will work under GNU/Linux only.
+ * This code will work under GNU/Linux only.
* @author David Brodski
*
* This program serves as the mediator between the wlan interface and
- * gnunet
+ * gnunet
*/
-
+
#include "gnunet-transport-wlan-helper.h"
#include <pcap/pcap.h>
/* The private key MHD uses as an \0 terminated string */
char * key;
-
+
char * crypto_init;
};
plugin->bind4_address = NULL;
}
}
-
+
/* Get crypto init string from config */
if (GNUNET_CONFIGURATION_have_value (env->cfg,
"transport-https", "CRYPTO_INIT"))
*/
struct LocalAddrList
{
-
+
/**
* This is a doubly linked list.
*/
* List of our IP addresses.
*/
struct LocalAddrList *lal_head;
-
+
/**
* Tail of our IP address list.
- */
+ */
struct LocalAddrList *lal_tail;
/**
/**
* Function called for a quick conversion of the binary address to
- * a numeric address. Note that the caller must not free the
+ * a numeric address. Note that the caller must not free the
* address and that the next call to this function is allowed
* to override the address again.
*
* @param cls closure ('struct Plugin*')
* @param addr binary address
* @param addrlen length of the address
- * @return string representing the same address
+ * @return string representing the same address
*/
-static const char*
+static const char*
tcp_address_to_string (void *cls,
const void *addr,
size_t addrlen)
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes currently in TCP buffers"),
pm->message_size,
- GNUNET_NO);
+ GNUNET_NO);
GNUNET_CONTAINER_DLL_insert (ret->pending_messages_head,
ret->pending_messages_tail,
pm);
/* do this call before callbacks (so that if callbacks destroy
session, they have a chance to cancel actions done by this
call) */
- process_pending_messages (session);
+ process_pending_messages (session);
pid = session->target;
/* no do callbacks and do not use session again since
the callbacks may abort the session */
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes currently in TCP buffers"),
- (int64_t) ret,
- GNUNET_NO);
+ GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes discarded by TCP (timeout)"),
ret,
- GNUNET_NO);
+ GNUNET_NO);
return 0;
}
/* copy all pending messages that would fit */
cbuf = buf;
hd = NULL;
tl = NULL;
- while (NULL != (pos = session->pending_messages_head))
+ while (NULL != (pos = session->pending_messages_head))
{
- if (ret + pos->message_size > size)
+ if (ret + pos->message_size > size)
break;
GNUNET_CONTAINER_DLL_remove (session->pending_messages_head,
session->pending_messages_tail,
/* schedule 'continuation' before callbacks so that callbacks that
cancel everything don't cause us to use a session that no longer
exists... */
- process_pending_messages (session);
+ process_pending_messages (session);
session->last_activity = GNUNET_TIME_absolute_get ();
pid = session->target;
/* we'll now call callbacks that may cancel the session; hence
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes currently in TCP buffers"),
- (int64_t) ret,
- GNUNET_NO);
+ GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes transmitted via TCP"),
ret,
- GNUNET_NO);
+ GNUNET_NO);
return ret;
}
(session->connect_addr != NULL) ?
tcp_address_to_string (session->plugin,
session->connect_addr,
- session->connect_alen) : "*",
+ session->connect_alen) : "*",
session);
#endif
/* remove from session list */
GNUNET_STATISTICS_update (session->plugin->env->stats,
gettext_noop ("# bytes currently in TCP buffers"),
- (int64_t) pm->message_size,
- GNUNET_NO);
+ GNUNET_NO);
GNUNET_STATISTICS_update (session->plugin->env->stats,
gettext_noop ("# bytes discarded by TCP (disconnect)"),
pm->message_size,
- GNUNET_NO);
+ GNUNET_NO);
GNUNET_CONTAINER_DLL_remove (session->pending_messages_head,
session->pending_messages_tail,
pm);
GNUNET_SCHEDULER_cancel (session->plugin->env->sched,
session->receive_delay_task);
if (session->client != NULL)
- GNUNET_SERVER_receive_done (session->client,
+ GNUNET_SERVER_receive_done (session->client,
GNUNET_SYSERR);
}
- if (session->client != NULL)
+ if (session->client != NULL)
GNUNET_SERVER_client_drop (session->client);
GNUNET_STATISTICS_update (session->plugin->env->stats,
gettext_noop ("# TCP sessions active"),
-1,
- GNUNET_NO);
+ GNUNET_NO);
GNUNET_free_non_null (session->connect_addr);
GNUNET_free (session);
}
/**
* Given two otherwise equivalent sessions, pick the better one.
- *
+ *
* @param s1 one session (also default)
* @param s2 other session
* @return "better" session (more active)
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes TCP was asked to transmit"),
msgbuf_size,
- GNUNET_NO);
+ GNUNET_NO);
/* FIXME: we could do this cheaper with a hash table
where we could restrict the iteration to entries that match
the target peer... */
{
cand_session = NULL;
next = plugin->sessions;
- while (NULL != (session = next))
+ while (NULL != (session = next))
{
next = session->next;
GNUNET_assert (session->client != NULL);
if (0 != memcmp (target,
- &session->target,
+ &session->target,
sizeof (struct GNUNET_PeerIdentity)))
continue;
if ( ( (GNUNET_SYSERR == force_address) &&
(session->expecting_welcome == GNUNET_NO) ) ||
- (GNUNET_NO == force_address) )
+ (GNUNET_NO == force_address) )
{
cand_session = select_better_session (cand_session,
session);
GNUNET_break (0);
break;
}
- if (session->inbound == GNUNET_YES)
+ if (session->inbound == GNUNET_YES)
continue;
if (addrlen != session->connect_alen)
continue;
addrlen))
continue;
cand_session = select_better_session (cand_session,
- session);
+ session);
}
session = cand_session;
}
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes discarded by TCP (no address and no connection)"),
msgbuf_size,
- GNUNET_NO);
+ GNUNET_NO);
return -1;
}
if (session == NULL)
is_natd = GNUNET_YES;
memcpy (&a6.sin6_addr,
&t6->ipv6_addr,
- sizeof (struct in6_addr));
+ sizeof (struct in6_addr));
sb = &a6;
sbs = sizeof (a6);
}
pm = GNUNET_malloc (sizeof (struct PendingMessage) + msgbuf_size);
/* FIXME: the memset of this malloc can be up to 2% of our total runtime */
pm->msg = (const char*) &pm[1];
- memcpy (&pm[1], msg, msgbuf_size);
- /* FIXME: this memcpy can be up to 7% of our total run-time
+ memcpy (&pm[1], msg, msgbuf_size);
+ /* FIXME: this memcpy can be up to 7% of our total run-time
(for transport service) */
pm->message_size = msgbuf_size;
pm->timeout = GNUNET_TIME_relative_to_absolute (timeout);
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes discarded by TCP (failed to connect)"),
msgbuf_size,
- GNUNET_NO);
+ GNUNET_NO);
return -1;
}
#if DEBUG_TCP
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes currently in TCP buffers"),
msgbuf_size,
- GNUNET_NO);
+ GNUNET_NO);
/* create new message entry */
pm = GNUNET_malloc (sizeof (struct PendingMessage) + msgbuf_size);
pm->msg = (const char*) &pm[1];
a6.sin6_port = t6->t6_port;
memcpy (&a6.sin6_addr,
&t6->ipv6_addr,
- sizeof (struct in6_addr));
+ sizeof (struct in6_addr));
port = ntohs (t6->t6_port);
sb = &a6;
sbs = sizeof (a6);
}
-/**
+/**
* Function that will be called to check if a binary address for this
* plugin is well-formed and corresponds to an address for THIS peer
* (as per our configuration). Naturally, if absolutely necessary,
* and transport, GNUNET_SYSERR if not
*/
static int
-tcp_plugin_check_address (void *cls,
- const void *addr,
+tcp_plugin_check_address (void *cls,
+ const void *addr,
size_t addrlen)
{
struct Plugin *plugin = cls;
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- if (GNUNET_OK !=
+ if (GNUNET_OK !=
check_port (plugin, ntohs (v6->t6_port)))
return GNUNET_SYSERR;
if (GNUNET_OK !=
#if DEBUG_TCP
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received %s message from a `%4s/%p'.\n",
+ "Received %s message from a `%4s/%p'.\n",
"WELCOME",
GNUNET_i2s (&wm->clientIdentity), client);
#endif
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# TCP WELCOME messages received"),
1,
- GNUNET_NO);
+ GNUNET_NO);
session = find_session_by_client (plugin, client);
if (session == NULL)
{
session->receive_delay_task = GNUNET_SCHEDULER_NO_TASK;
delay = session->plugin->env->receive (session->plugin->env->cls,
&session->target,
- NULL, 0,
+ NULL, 0,
session,
NULL, 0);
if (delay.value == 0)
GNUNET_SERVER_receive_done (session->client, GNUNET_OK);
else
- session->receive_delay_task =
+ session->receive_delay_task =
GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched,
delay, &delayed_done, session);
}
{
/* We don't want to propagate WELCOME and NAT Probe messages up! */
GNUNET_SERVER_receive_done (client, GNUNET_OK);
- return;
- }
+ return;
+ }
session = find_session_by_client (plugin, client);
if ( (NULL == session) || (GNUNET_YES == session->expecting_welcome))
{
#if DEBUG_TCP
GNUNET_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->size),
(unsigned int) ntohs (message->type),
GNUNET_i2s (&session->target));
#endif
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes received via TCP"),
ntohs (message->size),
- GNUNET_NO);
+ GNUNET_NO);
delay = plugin->env->receive (plugin->env->cls, &session->target, message, 1,
- session,
+ session,
(GNUNET_YES == session->inbound) ? NULL : session->connect_addr,
(GNUNET_YES == session->inbound) ? 0 : session->connect_alen);
if (delay.value == 0)
GNUNET_SERVER_receive_done (client, GNUNET_OK);
else
- session->receive_delay_task =
+ session->receive_delay_task =
GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched,
delay, &delayed_done, session);
}
* @param client identification of the client
*/
static void
-disconnect_notify (void *cls,
+disconnect_notify (void *cls,
struct GNUNET_SERVER_Client *client)
{
struct Plugin *plugin = cls;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("TCP transport advertises itself as being on port %llu\n"),
aport);
- GNUNET_SERVER_disconnect_notify (plugin->server,
+ GNUNET_SERVER_disconnect_notify (plugin->server,
&disconnect_notify,
plugin);
GNUNET_CONFIGURATION_get_value_string(env->cfg, "transport-tcp", "BINDTO", &plugin->bind_address);
* @param priority how important is the message
* @param msgbuf the message to transmit
* @param msgbuf_size number of bytes in 'msgbuf'
- * @param timeout when should we time out
+ * @param timeout when should we time out
* @param session which session must be used (or NULL for "any")
* @param addr the address to use (can be NULL if the plugin
* is "on its own" (i.e. re-use existing TCP connection))
/**
* Function called for a quick conversion of the binary address to
- * a numeric address. Note that the caller must not free the
+ * a numeric address. Note that the caller must not free the
* address and that the next call to this function is allowed
* to override the address again.
*
* @param cls closure
* @param addr binary address
* @param addrlen length of the address
- * @return string representing the same address
+ * @return string representing the same address
*/
-static const char*
+static const char*
template_plugin_address_to_string (void *cls,
const void *addr,
size_t addrlen)
*/
struct LocalAddrList
{
-
+
/**
* This is a doubly linked list.
*/
struct UDP_Sock_Info
{
/**
- * The network handle
+ * The network handle
*/
struct GNUNET_NETWORK_Handle *desc;
/**
- * The port we bound to
+ * The port we bound to
*/
uint16_t port;
};
* List of our IP addresses.
*/
struct LocalAddrList *lal_head;
-
+
/**
* Tail of our IP address list.
- */
+ */
struct LocalAddrList *lal_tail;
/**
struct PeerSession *
-find_session (struct Plugin *plugin,
+find_session (struct Plugin *plugin,
const struct GNUNET_PeerIdentity *peer)
{
struct PeerSession *pos;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"UDP transmit %u-byte message to %s (%d: %s)\n",
(unsigned int) ssize,
- GNUNET_a2s (sb, sbs),
+ GNUNET_a2s (sb, sbs),
(int) sent,
(sent < 0) ? STRERROR (errno) : "ok");
if (cont != NULL)
target,
msgbuf, msgbuf_size,
priority, timeout,
- peer_session->connect_addr, peer_session->connect_alen,
+ peer_session->connect_addr, peer_session->connect_alen,
cont, cont_cls);
}
else /* Haven't gotten a response from this peer, queue message */
}
else if (other_peer_natd == GNUNET_NO) /* Other peer not behind a NAT, so we can just send the message as is */
{
- sent = udp_real_send(cls,
- (addrlen == sizeof (struct IPv4UdpAddress)) ? plugin->udp_sockv4.desc : plugin->udp_sockv6.desc,
+ sent = udp_real_send(cls,
+ (addrlen == sizeof (struct IPv4UdpAddress)) ? plugin->udp_sockv4.desc : plugin->udp_sockv6.desc,
target,
msgbuf, msgbuf_size,
- priority, timeout, addr, addrlen,
+ priority, timeout, addr, addrlen,
cont, cont_cls);
}
else /* Other peer is NAT'd, but we don't want to play with them (or can't!) */
GNUNET_break (0);
return GNUNET_OK;
}
-
+
GNUNET_log (GNUNET_ERROR_TYPE_INFO |
GNUNET_ERROR_TYPE_BULK,
_("Found address `%s' (%s)\n"),
GNUNET_a2s (addr, addrlen), name);
-
+
if (addr_nat != NULL)
{
plugin->env->notify_address (plugin->env->cls,
_("Sending a probe to port %d\n"), ntohs(probe->addr.u_port));
#endif
probe->count++;
- udp_real_send(plugin,
- plugin->udp_sockv4.desc,
+ udp_real_send(plugin,
+ plugin->udp_sockv4.desc,
NULL,
- (char *)&message, ntohs(message.header.size), 0,
- GNUNET_TIME_relative_get_unit(),
+ (char *)&message, ntohs(message.header.size), 0,
+ GNUNET_TIME_relative_get_unit(),
&probe->addr, sizeof(struct IPv4UdpAddress),
&udp_probe_continuation, probe);
}
if (fromlen == sizeof(struct IPv4UdpAddress))
{
memset(&addr_buf, 0, sizeof(addr_buf));
- if (NULL == inet_ntop (AF_INET,
+ if (NULL == inet_ntop (AF_INET,
&((struct IPv4UdpAddress *) sender_addr)->ipv4_addr, addr_buf,
INET_ADDRSTRLEN))
{
outgoing_probe_confirmation = GNUNET_malloc(sizeof(struct UDP_NAT_ProbeMessageConfirmation));
outgoing_probe_confirmation->header.size = htons(sizeof(struct UDP_NAT_ProbeMessageConfirmation));
outgoing_probe_confirmation->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_NAT_PROBE_CONFIRM);
- udp_real_send(plugin, sockinfo->desc, NULL,
- (char *)outgoing_probe_confirmation,
- ntohs(outgoing_probe_confirmation->header.size), 0,
- GNUNET_TIME_relative_get_unit(),
+ udp_real_send(plugin, sockinfo->desc, NULL,
+ (char *)outgoing_probe_confirmation,
+ ntohs(outgoing_probe_confirmation->header.size), 0,
+ GNUNET_TIME_relative_get_unit(),
sender_addr, fromlen, NULL, NULL);
if (outgoing_probe->task != GNUNET_SCHEDULER_NO_TASK)
"Sending message type %d to transport!\n",
ntohs(currhdr->type));
#endif
- plugin->env->receive (plugin->env->cls, sender, currhdr, UDP_DIRECT_DISTANCE,
+ plugin->env->receive (plugin->env->cls, sender, currhdr, UDP_DIRECT_DISTANCE,
NULL, sender_addr, fromlen);
}
plugin->internal_address);
#endif
/* Start the server process */
- plugin->server_pid = GNUNET_OS_start_process(NULL,
- plugin->server_stdout,
- "gnunet-nat-server",
- "gnunet-nat-server",
+ plugin->server_pid = GNUNET_OS_start_process(NULL,
+ plugin->server_stdout,
+ "gnunet-nat-server",
+ "gnunet-nat-server",
plugin->internal_address, NULL);
if (plugin->server_pid == GNUNET_SYSERR)
{
}
/* Close the write end of the read pipe */
GNUNET_DISK_pipe_close_end(plugin->server_stdout, GNUNET_DISK_PIPE_END_WRITE);
-
+
plugin->server_stdout_handle = GNUNET_DISK_pipe_handle(plugin->server_stdout, GNUNET_DISK_PIPE_END_READ);
plugin->server_read_task =
GNUNET_SCHEDULER_add_read_file (plugin->env->sched,
serverAddr = (struct sockaddr *) &serverAddrv6;
#if DEBUG_UDP
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Binding to IPv6 port %d\n",
+ "Binding to IPv6 port %d\n",
ntohs(serverAddrv6.sin6_port));
#endif
tries = 0;
serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */
#if DEBUG_UDP
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "IPv6 Binding failed, trying new port %d\n",
+ "IPv6 Binding failed, trying new port %d\n",
ntohs(serverAddrv6.sin6_port));
#endif
tries++;
GNUNET_NETWORK_socket_close (plugin->udp_sockv6.desc);
plugin->udp_sockv6.desc = NULL;
break;
- }
+ }
}
if (plugin->udp_sockv6.desc != NULL)
{
serverAddr = (struct sockaddr *) &serverAddrv4;
#if DEBUG_UDP
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Binding to IPv4 port %d\n",
+ "Binding to IPv4 port %d\n",
ntohs(serverAddrv4.sin_port));
#endif
tries = 0;
serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */
#if DEBUG_UDP
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "IPv4 Binding failed, trying new port %d\n",
+ "IPv4 Binding failed, trying new port %d\n",
ntohs(serverAddrv4.sin_port));
#endif
tries++;
GNUNET_NETWORK_socket_close (plugin->udp_sockv4.desc);
plugin->udp_sockv4.desc = NULL;
break;
- }
+ }
}
if (plugin->udp_sockv4.desc != NULL)
{
plugin->rs = GNUNET_NETWORK_fdset_create ();
GNUNET_NETWORK_fdset_zero (plugin->rs);
if (NULL != plugin->udp_sockv4.desc)
- GNUNET_NETWORK_fdset_set (plugin->rs,
+ GNUNET_NETWORK_fdset_set (plugin->rs,
plugin->udp_sockv4.desc);
if (NULL != plugin->udp_sockv6.desc)
- GNUNET_NETWORK_fdset_set (plugin->rs,
+ GNUNET_NETWORK_fdset_set (plugin->rs,
plugin->udp_sockv6.desc);
plugin->select_task =
if ( (plugin->only_nat_addresses == GNUNET_YES) &&
(plugin->behind_nat == GNUNET_YES) )
return GNUNET_SYSERR; /* odd case... */
- if (in_port == plugin->port)
+ if (in_port == plugin->port)
return GNUNET_OK;
return GNUNET_SYSERR;
}
*
*/
static int
-udp_check_address (void *cls,
- const void *addr,
+udp_check_address (void *cls,
+ const void *addr,
size_t addrlen)
{
struct Plugin *plugin = cls;
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- if (GNUNET_OK !=
+ if (GNUNET_OK !=
check_port (plugin, ntohs (v6->u6_port)))
return GNUNET_SYSERR;
if (GNUNET_OK !=
GNUNET_SERVICE_stop (service);
GNUNET_free_non_null(external_address);
GNUNET_free_non_null(internal_address);
- return NULL;
+ return NULL;
}
mtu = 1240;
addrlen);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Transport plugin notification for address: `%s':%u\n"),
address,
port);
addrlen);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Transport plugin notification for address: `%s':%u\n"),
address,
port);
{
GNUNET_SCHEDULER_cancel (sched, die_task);
die_task = GNUNET_SCHEDULER_add_delayed (sched,
- TIMEOUT_TRANSMIT,
+ TIMEOUT_TRANSMIT,
&end_badly, NULL);
GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
OKPP;
sched = s;
die_task = GNUNET_SCHEDULER_add_delayed (sched,
- TIMEOUT,
+ TIMEOUT,
&end_badly, NULL);
if (is_udp)
}
-static int
+static int
check_gnunet_nat_server()
{
struct stat statbuf;
return GNUNET_SYSERR;
}
GNUNET_free (p);
- if ( (0 != (statbuf.st_mode & S_ISUID)) &&
- (statbuf.st_uid == 0) )
+ if ( (0 != (statbuf.st_mode & S_ISUID)) &&
+ (statbuf.st_uid == 0) )
return GNUNET_YES;
return GNUNET_NO;
}
GNUNET_TRANSPORT_disconnect (p1.th);
GNUNET_TRANSPORT_disconnect (p2.th);
#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transports disconnected, returning success!\n");
#endif
delta = GNUNET_TIME_absolute_get_duration (start_time).value;
}
-struct TestMessage
+struct TestMessage
{
struct GNUNET_MessageHeader header;
uint32_t num;
die_task = GNUNET_SCHEDULER_add_delayed (sched,
TIMEOUT,
&end_badly,
- NULL);
+ NULL);
}
if (n == TOTAL_MSGS)
end ();
if (n < TOTAL_MSGS)
GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
&p2.id,
- s, 0, TIMEOUT,
+ s, 0, TIMEOUT,
¬ify_ready,
NULL);
if (n % 5000 == 0)
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL,
+ p->arm_pid = GNUNET_OS_start_process (NULL, NULL,
"gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE_ARM
p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL,
p,
¬ify_receive,
- ¬ify_connect,
+ ¬ify_connect,
¬ify_disconnect);
GNUNET_assert (p->th != NULL);
}
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received HELLO size %d\n",
+ "Received HELLO size %d\n",
GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message));
#endif
GNUNET_TRANSPORT_offer_hello (p2.th, message);
/**
* Closure for the callbacks.
*/
- void *cls;
+ void *cls;
/**
* Function to call for received data.
* Delay until we try to reconnect.
*/
struct GNUNET_TIME_Relative reconnect_delay;
-
+
/**
* Set once we are in the process of disconnecting from the
* service.
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Would need %llu ms before bandwidth is available for delivery to `%4s', that is too long. Signaling timeout.\n",
- duration.value,
+ duration.value,
GNUNET_i2s (&n->id));
#endif
if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task);
th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
- }
+ }
n->transmit_stage = TS_NEW;
if (NULL != th->notify)
GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL));
"Need more bandwidth (%u b/s allowed, %u b needed), delaying delivery to `%4s' by %llu ms\n",
(unsigned int) n->out_tracker.available_bytes_per_s__,
(unsigned int) th->notify_size - sizeof (struct OutboundMessage),
- GNUNET_i2s (&n->id),
+ GNUNET_i2s (&n->id),
duration.value);
#endif
retry_time = GNUNET_TIME_relative_min (retry_time,
/**
* Transmit message(s) to service.
*
- * @param cls handle to transport
+ * @param cls handle to transport
* @param size number of bytes available in buf
* @param buf where to copy the message
* @return number of bytes copied to buf
}
GNUNET_CONTAINER_DLL_remove (h->control_head,
h->control_tail,
- cm);
+ cm);
nret = cm->notify (cm->notify_cls, size, &cbuf[ret]);
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_break (0);
}
GNUNET_assert (size >= sizeof (struct OutboundMessage));
- mret = th->notify (th->notify_cls,
+ mret = th->notify (th->notify_cls,
size - sizeof (struct OutboundMessage),
&cbuf[ret + sizeof (struct OutboundMessage)]);
GNUNET_assert (mret <= size - sizeof (struct OutboundMessage));
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Message of %u bytes with timeout %llums constructed for `%4s'\n",
- (unsigned int) mret,
+ (unsigned int) mret,
(unsigned long long) GNUNET_TIME_absolute_get_remaining (th->timeout).value,
GNUNET_i2s (&n->id));
#endif
*/
static void
schedule_transmission (struct GNUNET_TRANSPORT_Handle *h)
-{
+{
size_t size;
struct GNUNET_TIME_Relative timeout;
struct GNUNET_TRANSPORT_TransmitHandle *th;
_("Could not yet schedule transmission: we are not yet connected to the transport service!\n"));
return; /* not yet connected */
}
- if (NULL != h->control_head)
+ if (NULL != h->control_head)
{
size = h->control_head->notify_size;
timeout = GNUNET_TIME_UNIT_FOREVER_REL;
size = th->notify_size;
timeout = GNUNET_TIME_absolute_get_remaining (th->timeout);
}
- h->network_handle =
+ h->network_handle =
GNUNET_CLIENT_notify_transmit_ready (h->client,
size,
timeout,
th->notify_delay_task
= GNUNET_SCHEDULER_add_delayed (h->sched,
timeout, &control_transmit_timeout, th);
- if (at_head)
+ if (at_head)
GNUNET_CONTAINER_DLL_insert (h->control_head,
h->control_tail,
th);
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting `%s' request with respect to `%4s'.\n",
- "SET_QUOTA",
+ "SET_QUOTA",
GNUNET_i2s (&sqc->target));
#endif
GNUNET_assert (size >= sizeof (struct QuotaSetMessage));
hwl->rec = rec;
hwl->rec_cls = rec_cls;
if (handle->my_hello == NULL)
- return;
+ return;
rec (rec_cls, (const struct GNUNET_MessageHeader *) handle->my_hello);
}
GNUNET_break (0);
return;
}
-#if DEBUG_TRANSPORT
+#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Offering `%s' message of `%4s' to transport for validation.\n",
"HELLO",
/**
- * Free neighbour.
- *
+ * Free neighbour.
+ *
* @param n the entry to free
*/
static void
/**
- * Mark neighbour as disconnected.
- *
+ * Mark neighbour as disconnected.
+ *
* @param n the entry to mark as disconnected
*/
static void
* @param tc scheduler context
*/
static void
-reconnect (void *cls,
+reconnect (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_TRANSPORT_Handle *h = cls;
n = next;
}
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Connecting to transport service.\n");
#endif
GNUNET_assert (h->client == NULL);
{
h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS;
}
- else
+ else
{
h->reconnect_delay = GNUNET_TIME_relative_multiply (h->reconnect_delay, 2);
h->reconnect_delay = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS,
}
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Creating entry for neighbour `%4s'.\n",
+ "Creating entry for neighbour `%4s'.\n",
GNUNET_i2s (pid));
#endif
n = GNUNET_malloc (sizeof (struct NeighbourList));
MAX_BANDWIDTH_CARRY_S);
n->next = h->neighbours;
n->h = h;
- h->neighbours = n;
+ h->neighbours = n;
return n;
}
th->notify_delay_task);
th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
}
- GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL));
+ GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL));
break;
default:
GNUNET_break (0);
GNUNET_free (h);
return;
}
- if (msg == NULL)
+ if (msg == NULL)
{
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
n->is_connected = GNUNET_YES;
if (h->nc_cb != NULL)
h->nc_cb (h->cls, &n->id,
- GNUNET_TIME_relative_ntoh (cim->latency),
+ GNUNET_TIME_relative_ntoh (cim->latency),
ntohl (cim->distance));
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT:
GNUNET_i2s (&dim->peer));
#endif
n = neighbour_find (h, &dim->peer);
- GNUNET_break (n != NULL);
+ GNUNET_break (n != NULL);
if (n != NULL)
neighbour_disconnect (n);
break;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received message of type %u from `%4s'.\n",
ntohs (imm->type), GNUNET_i2s (&im->peer));
-#endif
+#endif
n = neighbour_find (h, &im->peer);
if (n == NULL)
{
"Triggering timeout for request to transmit to `%4s' (%d)\n",
GNUNET_i2s (&n->id),
n->transmit_stage);
-#endif
+#endif
notify = th->notify;
notify_cls = th->notify_cls;
switch (n->transmit_stage)
n = neighbour_find (handle, target);
if (n == NULL)
n = neighbour_add (handle, target);
- if (n == NULL)
+ if (n == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Could not create neighbour entry for peer `%s'\n",
/**
* Context for the address lookup.
- */
+ */
struct AddressLookupCtx
{
/**
* message with the human-readable address
*/
static void
-address_response_processor (void *cls,
+address_response_processor (void *cls,
const struct GNUNET_MessageHeader *msg)
{
struct AddressLookupCtx *alucb = cls;
GNUNET_CLIENT_receive (alucb->client,
&address_response_processor, alucb,
GNUNET_TIME_absolute_get_remaining
- (alucb->timeout));
+ (alucb->timeout));
alucb->cb (alucb->cb_cls, address);
}
* @param cfg configuration to use
* @param address address to convert (binary format)
* @param addressLen number of bytes in address
- * @param numeric should (IP) addresses be displayed in numeric form
+ * @param numeric should (IP) addresses be displayed in numeric form
* (otherwise do reverse DNS lookup)
* @param nameTrans name of the transport to which the address belongs
* @param timeout how long is the lookup allowed to take at most
*/
void
GNUNET_TRANSPORT_address_lookup (struct GNUNET_SCHEDULER_Handle *sched,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- const char *address,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *address,
size_t addressLen,
int numeric,
const char *nameTrans,
aluCB->timeout = abs_timeout;
aluCB->client = client;
GNUNET_assert (GNUNET_OK ==
- GNUNET_CLIENT_transmit_and_get_response (client,
- &msg->header,
+ GNUNET_CLIENT_transmit_and_get_response (client,
+ &msg->header,
timeout,
GNUNET_YES,
&address_response_processor,
/**
* Pending handle for the current request.
- */
+ */
struct GNUNET_CLIENT_TransmitHandle *th;
/**
/**
* Closure for 'cb'.
*/
- void *cb_cls;
+ void *cb_cls;
/**
* Peer currently under consideration.
{
struct GNUNET_TRANSPORT_Blacklist *br = cls;
const struct BlacklistMessage *bm;
-
+
if ( (ntohs(msg->size) != sizeof (struct BlacklistMessage)) ||
(ntohs(msg->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY) )
{
bm = (const struct BlacklistMessage *)msg;
GNUNET_break (0 == ntohl (bm->is_allowed));
br->peer = bm->peer;
- reply (br);
+ reply (br);
}
GNUNET_TIME_UNIT_FOREVER_REL,
GNUNET_YES,
&transmit_blacklist_init,
- ret);
+ ret);
return ret;
}