Prevent large amounts of UDP probes being sent consecutively.
[tinc] / src / node.h
index 153dc11..1b33789 100644 (file)
@@ -41,7 +41,8 @@ typedef struct node_status_t {
        unsigned int udppacket: 1;              /* 1 if the most recently received packet was UDP */
        unsigned int validkey_in: 1;            /* 1 if we have sent a valid key to him */
        unsigned int has_address: 1;            /* 1 if we know an external address for this node */
-       unsigned int unused: 20;
+       unsigned int ping_sent: 1;              /* 1 if we sent a UDP probe but haven't received the reply yet */
+       unsigned int unused: 19;
 } node_status_t;
 
 typedef struct node_t {
@@ -92,6 +93,7 @@ typedef struct node_t {
 
        struct timeval udp_reply_sent;          /* Last time a (gratuitous) UDP probe reply was sent */
        struct timeval udp_ping_sent;           /* Last time a UDP probe was sent */
+       int udp_ping_rtt;                       /* Round trip time of UDP ping (in microseconds; or -1 if !status.udp_confirmed) */
        timeout_t udp_ping_timeout;             /* Ping timeout event */
 
        struct timeval mtu_ping_sent;           /* Last time a MTU probe was sent */
@@ -110,6 +112,8 @@ typedef struct node_t {
        uint64_t in_bytes;
        uint64_t out_packets;
        uint64_t out_bytes;
+
+       struct address_cache_t *address_cache;
 } node_t;
 
 extern struct node_t *myself;
@@ -118,14 +122,14 @@ extern splay_tree_t *node_tree;
 extern void init_nodes(void);
 extern void exit_nodes(void);
 extern node_t *new_node(void) __attribute__((__malloc__));
-extern void free_node(node_t *);
-extern void node_add(node_t *);
-extern void node_del(node_t *);
-extern node_t *lookup_node(char *);
-extern node_t *lookup_node_id(const node_id_t *);
-extern node_t *lookup_node_udp(const sockaddr_t *);
-extern bool dump_nodes(struct connection_t *);
-extern bool dump_traffic(struct connection_t *);
-extern void update_node_udp(node_t *, const sockaddr_t *);
+extern void free_node(node_t *n);
+extern void node_add(node_t *n);
+extern void node_del(node_t *n);
+extern node_t *lookup_node(char *name);
+extern node_t *lookup_node_id(const node_id_t *id);
+extern node_t *lookup_node_udp(const sockaddr_t *sa);
+extern bool dump_nodes(struct connection_t *c);
+extern bool dump_traffic(struct connection_t *c);
+extern void update_node_udp(node_t *n, const sockaddr_t *sa);
 
 #endif