X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=ipif%2Fforwarder.c;h=793ad24e787b3d50be3732668d809a2dd56d679d;hb=92bbf44b78dc7ad8a9372a27571e0cb9b7cf5ad3;hp=6179eaa0b94fc6e53f4753f274599c676960c562;hpb=31dcbf98f0d9c0dde01dd20848acc6ee47c83b27;p=userv-utils.git diff --git a/ipif/forwarder.c b/ipif/forwarder.c index 6179eaa..793ad24 100644 --- a/ipif/forwarder.c +++ b/ipif/forwarder.c @@ -6,7 +6,7 @@ * udptunnel-forwarder * * - * + * * [] * | [ ...] * | [ ...] @@ -75,7 +75,7 @@ static struct utsname uname_result; static const char *opt_chars; static int public_local_fd, private_in_fd, private_out_fd; -static int mtu2, keepalive, timeout; +static int mtu2, keepalive, timeout, reannounce; static int public_remote_specd; static struct sockaddr_in public_remote; static int encdec_keys_fd, encdec_keys_write, crypto_debug; @@ -178,6 +178,8 @@ static const struct mechanism *find_mech(const char *name) { static void inbound(void) { static int any_recvd; + static time_t nextreann; + static unsigned long npackets, nbytes; struct sockaddr_in this_saddr; int r, i, different, this_saddrlen; @@ -219,6 +221,8 @@ static void inbound(void) { cdebugbuf(i, "decode", &buf_in, 3,0); } + npackets++; + nbytes += buf_in.size; alarm(timeout); different= (!public_remote_specd || @@ -245,8 +249,22 @@ static void inbound(void) { diag("tunnel open"); + } else if (reannounce && now() >= nextreann) { + + fprintf(stderr, "%s: tunnel still open: received %lu packets, %lu bytes\n", + programid, npackets, nbytes); + + } else { + + goto no_set_reann; /* only reset this if we don't print a message. */ + } + if (reannounce) + nextreann= now() + reannounce; + +no_set_reann: + any_recvd= 1; if (!buf_in.size || *buf_in.start != 0300) { @@ -345,6 +363,7 @@ int main(int argc, const char *const *const argv_in) { mtu2= getarg_ulong() * 2; keepalive= getarg_ulong(); timeout= getarg_ulong(); + reannounce= getarg_ulong(); arg= getarg_string(); if (*arg) {