Enable and fix many extra warnings supported by GCC and Clang.
[tinc] / src / protocol.c
index 7de75b9..3539ca7 100644 (file)
@@ -1,7 +1,7 @@
 /*
     protocol.c -- handle the meta-protocol, basic functions
     Copyright (C) 1999-2005 Ivo Timmermans,
-                  2000-2013 Guus Sliepen <guus@tinc-vpn.org>
+                  2000-2022 Guus Sliepen <guus@tinc-vpn.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
 #include "conf.h"
 #include "connection.h"
+#include "crypto.h"
 #include "logger.h"
 #include "meta.h"
 #include "protocol.h"
+#include "utils.h"
 #include "xalloc.h"
 
 bool tunnelserver = false;
@@ -47,7 +49,7 @@ static bool (*request_handlers[])(connection_t *, const char *) = {
 
 /* Request names */
 
-static char (*request_name[]) = {
+static const char (*request_name[]) = {
        "ID", "METAKEY", "CHALLENGE", "CHAL_REPLY", "ACK",
        "STATUS", "ERROR", "TERMREQ",
        "PING", "PONG",
@@ -191,7 +193,7 @@ static void age_past_requests(void *data) {
 
        if(left)
                timeout_set(&past_request_timeout, &(struct timeval) {
-               10, rand() % 100000
+               10, jitter()
        });
 }
 
@@ -209,7 +211,7 @@ bool seen_request(const char *request) {
                new->firstseen = now.tv_sec;
                splay_insert(&past_request_tree, new);
                timeout_add(&past_request_timeout, age_past_requests, NULL, &(struct timeval) {
-                       10, rand() % 100000
+                       10, jitter()
                });
                return false;
        }