X-Git-Url: https://git.distorted.org.uk/~mdw/userv-utils/blobdiff_plain/9d4e63db418172c744c7bc98a7bc21c1c876f1ef..09966b4959fa31ea3f6746b6b6583907744484e1:/ipif/forwarder.c diff --git a/ipif/forwarder.c b/ipif/forwarder.c index a9e43e0..015afbd 100644 --- a/ipif/forwarder.c +++ b/ipif/forwarder.c @@ -2,10 +2,11 @@ * Encrypting tunnel for userv-ipif tunnels, actual implementation * * usage: - * udptunnel-forwarder + * udptunnel-forwarder + * + * * * [] - * * [ ...] * [ ...] * '' @@ -14,7 +15,9 @@ * whereever we get a good packet from first, in which case port * should not be specified. * - * is '' to mean read, anything else to mean write. + * is zero or more of + * w means generate and write encdec keys, rather than reading them + * D means do crypto debug (use with care!) * * Every must be numeric. There is very little argument checking. * @@ -47,11 +50,12 @@ static size_t buffer_size; +static const char *opt_chars; static int public_local_fd, private_in_fd, private_out_fd; static int mtu2, keepalive, timeout; static int public_remote_specd; static struct sockaddr_in public_remote; -static int encdec_keys_fd, encdec_keys_write; +static int encdec_keys_fd, encdec_keys_write, crypto_debug; static int n_mechs; static const struct mechanism *mechs[MAXMECHS]; @@ -64,6 +68,46 @@ static size_t accum_used, accum_avail; static time_t nextsendka; +static void cdebug(int mechno /*or -1*/, const char *msg) { + if (!crypto_debug) return; + printf("%s: CRYPTO: %-20s encrypt setup\n", + programid, + mechno >= 0 ? mechs[i]->name : "", + msg); +} + +static void cdebughex(int mechno /*or -1*/, const char *msg, + size_t skipbefore, const void *ptr, size_t sz, size_t skipafter) { + const unsigned char *p; + + if (!crypto_debug) return; + printf("%s: CRYPTO: %-20s %s", + programid, + mechno >= 0 ? mechs[i]->name : "", + msg); + for (i=0; iencsetup(&md_in[i], &maxprefix, &maxsuffix); - for (i=0; idecsetup(&md_out[i]); + for (i=0; iencsetup(&md_in[i], &maxprefix, &maxsuffix); + } + for (i=0; idecsetup(&md_out[i]); + } if (maxprefix<1) maxprefix= 1; if (maxsuffix<1) maxsuffix= 1;