#include "route.h"
#include "utils.h"
-#ifndef MAX
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
/* The minimum size of a probe is 14 bytes, but since we normally use CBC mode
encryption, we can add a few extra random bytes without increasing the
resulting packet size. */
So we pick a random edge and a random socket. */
unsigned int i = 0;
- unsigned int j = rand() % n->edge_tree.count;
+ unsigned int j = prng(n->edge_tree.count);
edge_t *candidate = NULL;
for splay_each(edge_t, e, &n->edge_tree) {
if(candidate) {
*sa = &candidate->address;
- *sock = rand() % listen_sockets;
+ *sock = prng(listen_sockets);
}
adapt_socket(*sa, sock);
/* Pick one of the edges from this node at random, then use its local address. */
unsigned int i = 0;
- unsigned int j = rand() % n->edge_tree.count;
+ unsigned int j = prng(n->edge_tree.count);
edge_t *candidate = NULL;
for splay_each(edge_t, e, &n->edge_tree) {
if(candidate && candidate->local_address.sa.sa_family) {
*sa = &candidate->local_address;
- *sock = rand() % listen_sockets;
+ *sock = prng(listen_sockets);
adapt_socket(*sa, sock);
}
}
return send_sptps_tcppacket(to->nexthop->connection, buf, sizeof(buf));
}
- char buf[len * 4 / 3 + 5];
- b64encode(data, buf, len);
+ char buf[B64_SIZE(len)];
+ b64encode_tinc(data, buf, len);
/* If this is a handshake packet, use ANS_KEY instead of REQ_KEY, for two reasons:
- We don't want intermediate nodes to switch to UDP to relay these packets;