X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet_packet.c;h=d372ced633f7c5d5069974c1293d399b56b9ef32;hb=e32d4f3db3f1ed3eebe2e11d57512b60a6c02fa6;hp=24ebdff84bee65c01a9b101944763adee8c47e05;hpb=b2701c7c54b11cda71461c5dbbc985476bf5b221;p=tinc diff --git a/src/net_packet.c b/src/net_packet.c index 24ebdff8..d372ced6 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -55,10 +55,6 @@ #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. */ @@ -743,7 +739,7 @@ static void choose_udp_address(const node_t *n, const sockaddr_t **sa, size_t *s 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) { @@ -755,7 +751,7 @@ static void choose_udp_address(const node_t *n, const sockaddr_t **sa, size_t *s if(candidate) { *sa = &candidate->address; - *sock = rand() % listen_sockets; + *sock = prng(listen_sockets); } adapt_socket(*sa, sock); @@ -767,7 +763,7 @@ static void choose_local_address(const node_t *n, const sockaddr_t **sa, size_t /* 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) { @@ -779,7 +775,7 @@ static void choose_local_address(const node_t *n, const sockaddr_t **sa, size_t if(candidate && candidate->local_address.sa.sa_family) { *sa = &candidate->local_address; - *sock = rand() % listen_sockets; + *sock = prng(listen_sockets); adapt_socket(*sa, sock); } }