X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/tripe/blobdiff_plain/844abf94571ffdd3e113c518947073ff5375d748..11ad66c29764521f87f0dd399a1e592147c7af36:/server/admin.c diff --git a/server/admin.c b/server/admin.c index b25e511e..2d1658ee 100644 --- a/server/admin.c +++ b/server/admin.c @@ -9,19 +9,18 @@ * * This file is part of Trivial IP Encryption (TrIPE). * - * TrIPE is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * TrIPE is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 3 of the License, or (at your + * option) any later version. * - * TrIPE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * TrIPE is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. * * You should have received a copy of the GNU General Public License - * along with TrIPE; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with TrIPE. If not, see . */ /*----- Header files ------------------------------------------------------*/ @@ -311,6 +310,7 @@ void a_vformat(dstr *d, const char *fmt, va_list *ap) } fmt = va_arg(*ap, const char *); } + dstr_putz(d); dstr_destroy(&dd); } @@ -373,7 +373,7 @@ static void a_write(admin *a, const char *status, const char *tag, va_end(ap); } -/* --- @a_ok@, @a_info@, @a_fail@ --- * +/* --- @a_ok@, @a_fail@ --- * * * Arguments: @admin *a@ = connection * @const char *fmt@ = format string @@ -386,21 +386,32 @@ static void a_write(admin *a, const char *status, const char *tag, static void a_ok(admin *a) { a_write(a, "OK", 0, A_END); } -static void a_info(admin *a, const char *fmt, ...) +static void a_fail(admin *a, const char *fmt, ...) { va_list ap; va_start(ap, fmt); - a_vwrite(a, "INFO", 0, fmt, &ap); + a_vwrite(a, "FAIL", 0, fmt, &ap); va_end(ap); } -static void a_fail(admin *a, const char *fmt, ...) +/* --- @a_info@ --- * + * + * Arguments: @admin *a@ = connection + * @const char *fmt@ = format string + * @...@ = other arguments + * + * Returns: --- + * + * Use: Report information to an admin client. + */ + +void a_info(admin *a, const char *fmt, ...) { va_list ap; va_start(ap, fmt); - a_vwrite(a, "FAIL", 0, fmt, &ap); + a_vwrite(a, "INFO", 0, fmt, &ap); va_end(ap); } @@ -1013,7 +1024,7 @@ static void a_resolved(struct hostent *h, void *v) admin_resop *r = v; T( trace(T_ADMIN, "admin: resop %s resolved", BGTAG(r)); ) - TIMER; + QUICKRAND; if (!h) { a_bgfail(&r->bg, "resolve-error", "%s", r->addr, A_END); r->func(r, ARES_FAIL); @@ -1708,7 +1719,7 @@ static void acmd_algs(admin *a, unsigned ac, char *av[]) { peer *p; const kdata *kd; - const group *g; + const dhgrp *g; const algswitch *algs; if (!ac) @@ -1717,47 +1728,25 @@ static void acmd_algs(admin *a, unsigned ac, char *av[]) if ((p = a_findpeer(a, av[0])) == 0) return; kd = p->kx.kpriv; } - g = kd->g; + g = kd->grp; algs = &kd->algs; - a_info(a, - "kx-group=%s", g->ops->name, - "kx-group-order-bits=%lu", (unsigned long)mp_bits(g->r), - "kx-group-elt-bits=%lu", (unsigned long)g->nbits, - A_END); + g->ops->grpinfo(g, a); a_info(a, "hash=%s", algs->h->name, "mgf=%s", algs->mgf->name, "hash-sz=%lu", (unsigned long)algs->h->hashsz, A_END); a_info(a, - "bulk-transform=%s", algs->bulk->name, - "bulk-overhead=%lu", (unsigned long)algs->bulk->overhead(algs), + "bulk-transform=%s", algs->bulk->ops->name, + "bulk-overhead=%lu", + (unsigned long)algs->bulk->ops->overhead(algs->bulk), A_END); - if (algs->c) { - a_info(a, - "cipher=%s", algs->c->name, - "cipher-keysz=%lu", (unsigned long)algs->cksz, - "cipher-blksz=%lu", (unsigned long)algs->c->blksz, - A_END); - } + algs->bulk->ops->alginfo(algs->bulk, a); a_info(a, - "cipher-data-limit=%lu", (unsigned long)algs->expsz, + "cipher-data-limit=%lu", + (unsigned long)algs->bulk->ops->expsz(algs->bulk), A_END); - if (algs->m) { - a_info(a, - "mac=%s", algs->m->name, - "mac-keysz=%lu", (unsigned long)algs->mksz, - "mac-tagsz=%lu", (unsigned long)algs->tagsz, - A_END); - } - if (algs->b) { - a_info(a, - "blkc=%.*s", strlen(algs->b->name) - 4, algs->b->name, - "blkc-keysz=%lu", (unsigned long)algs->bksz, - "blkc-blksz=%lu", (unsigned long)algs->b->blksz, - A_END); - } a_ok(a); } @@ -2155,7 +2144,7 @@ static void a_line(char *p, size_t len, void *vp) char *av[16 + 1]; size_t ac; - TIMER; + QUICKRAND; if (a->f & AF_DEAD) return; if (!p) {