~mdw
/
tripe
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
server: Add a peer without sending key-exchange packets.
[tripe]
/
server
/
admin.c
diff --git
a/server/admin.c
b/server/admin.c
index
4dbaf33
..
73c7107
100644
(file)
--- a/
server/admin.c
+++ b/
server/admin.c
@@
-1,13
+1,11
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id$
- *
* Admin interface for configuration
*
* (c) 2001 Straylight/Edgeware
*/
* Admin interface for configuration
*
* (c) 2001 Straylight/Edgeware
*/
-/*----- Licensing notice --------------------------------------------------*
+/*----- Licensing notice --------------------------------------------------*
*
* This file is part of Trivial IP Encryption (TrIPE).
*
*
* This file is part of Trivial IP Encryption (TrIPE).
*
@@
-15,12
+13,12
@@
* 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.
* 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 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.
* 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.
@@
-385,7
+383,7
@@
static void a_rawalert(unsigned f_and, unsigned f_eq, const char *status,
{
admin *a, *aa;
dstr d = DSTR_INIT;
{
admin *a, *aa;
dstr d = DSTR_INIT;
-
+
if (!(flags & F_INIT))
return;
dstr_puts(&d, status);
if (!(flags & F_INIT))
return;
dstr_puts(&d, status);
@@
-567,10
+565,10
@@
static long a_parsetime(const char *p)
case 'h': t *= 60;
case 'm': t *= 60;
case 's': if (q[1] != 0)
case 'h': t *= 60;
case 'm': t *= 60;
case 's': if (q[1] != 0)
- default:
t = -1;
+ default: t = -1;
case 0: break;
}
case 0: break;
}
- return (t);
+ return (t);
}
/* --- @a_findpeer@ --- *
}
/* --- @a_findpeer@ --- *
@@
-986,7
+984,7
@@
static void a_resolved(struct hostent *h, void *v)
sel_rmtimer(&r->t);
xfree(r->addr);
a_bgrelease(&r->bg);
sel_rmtimer(&r->t);
xfree(r->addr);
a_bgrelease(&r->bg);
-}
+}
/* --- @a_restimer@ --- *
*
/* --- @a_restimer@ --- *
*
@@
-1059,21
+1057,25
@@
static void a_resolve(admin *a, admin_resop *r, const char *tag,
r->addr = 0;
r->func = func;
if (mystrieq(av[i], "inet")) i++;
r->addr = 0;
r->func = func;
if (mystrieq(av[i], "inet")) i++;
- if (ac - i != 2) {
- a_fail(a, "bad-addr-syntax", "[inet] ADDRESS
PORT
", A_END);
+ if (ac - i !=
1 && ac - i !=
2) {
+ a_fail(a, "bad-addr-syntax", "[inet] ADDRESS
[PORT]
", A_END);
goto fail;
}
r->sa.sin.sin_family = AF_INET;
r->sasz = sizeof(r->sa.sin);
r->addr = xstrdup(av[i]);
goto fail;
}
r->sa.sin.sin_family = AF_INET;
r->sasz = sizeof(r->sa.sin);
r->addr = xstrdup(av[i]);
- pt = strtoul(av[i + 1], &p, 0);
- if (*p) {
- struct servent *s = getservbyname(av[i + 1], "udp");
- if (!s) {
- a_fail(a, "unknown-service", "%s", av[i + 1], A_END);
- goto fail;
+ if (!av[i + i])
+ pt = TRIPE_PORT;
+ else {
+ pt = strtoul(av[i + 1], &p, 0);
+ if (*p) {
+ struct servent *s = getservbyname(av[i + 1], "udp");
+ if (!s) {
+ a_fail(a, "unknown-service", "%s", av[i + 1], A_END);
+ goto fail;
+ }
+ pt = ntohs(s->s_port);
}
}
- pt = ntohs(s->s_port);
}
if (pt == 0 || pt >= 65536) {
a_fail(a, "invalid-port", "%lu", pt, A_END);
}
if (pt == 0 || pt >= 65536) {
a_fail(a, "invalid-port", "%lu", pt, A_END);
@@
-1093,7
+1095,7
@@
static void a_resolve(admin *a, admin_resop *r, const char *tag,
a->seq, BGTAG(r), r->addr); )
/* --- If the name is numeric, do it the easy way --- */
a->seq, BGTAG(r), r->addr); )
/* --- If the name is numeric, do it the easy way --- */
-
+
if (inet_aton(av[i], &r->sa.sin.sin_addr)) {
T( trace(T_ADMIN, "admin: resop %s done the easy way", BGTAG(r)); )
func(r, ARES_OK);
if (inet_aton(av[i], &r->sa.sin.sin_addr)) {
T( trace(T_ADMIN, "admin: resop %s done the easy way", BGTAG(r)); )
func(r, ARES_OK);
@@
-1208,6
+1210,7
@@
static void acmd_add(admin *a, unsigned ac, char *av[])
add->peer.name = 0;
add->peer.t_ka = 0;
add->peer.tops = tun_default;
add->peer.name = 0;
add->peer.t_ka = 0;
add->peer.tops = tun_default;
+ add->peer.kxf = 0;
/* --- Parse options --- */
/* --- Parse options --- */
@@
-1227,11
+1230,12
@@
static void acmd_add(admin *a, unsigned ac, char *av[])
}
})
OPTTIME("-keepalive", t, { add->peer.t_ka = t; })
}
})
OPTTIME("-keepalive", t, { add->peer.t_ka = t; })
+ OPT("-cork", { add->peer.kxf |= KXF_CORK; })
});
/* --- Make sure someone's not got there already --- */
});
/* --- Make sure someone's not got there already --- */
- if (!
*av
)
+ if (!
av[0] || !av[1]
)
goto bad_syntax;
if (p_find(*av)) {
a_fail(a, "peer-exists", "%s", *av, A_END);
goto bad_syntax;
if (p_find(*av)) {
a_fail(a, "peer-exists", "%s", *av, A_END);
@@
-1349,7
+1353,7
@@
static void a_ping(admin *a, unsigned ac, char *av[],
a_bgrelease(&pg->bg);
}
return;
a_bgrelease(&pg->bg);
}
return;
-
+
bad_syntax:
a_fail(a, "bad-syntax", "%s", cmd, "[OPTIONS] PEER", cmd, A_END);
fail:
bad_syntax:
a_fail(a, "bad-syntax", "%s", cmd, "[OPTIONS] PEER", cmd, A_END);
fail:
@@
-1565,7
+1569,7
@@
static int traceish(admin *a, unsigned ac, char *av[],
}
a_fail(a, "bad-%s-option", what, "%c", *p, A_END);
return (0);
}
a_fail(a, "bad-%s-option", what, "%c", *p, A_END);
return (0);
-
tropt_ok:;
+ tropt_ok:;
break;
}
p++;
break;
}
p++;
@@
-1609,7
+1613,7
@@
static void acmd_daemon(admin *a, unsigned ac, char *av[])
a_notify("DAEMON", A_END);
if (a_stdin)
a_destroy(a_stdin);
a_notify("DAEMON", A_END);
if (a_stdin)
a_destroy(a_stdin);
- if (
u_daemon
())
+ if (
daemonize
())
a_fail(a, "daemon-error", "?ERRNO", A_END);
else {
flags |= F_DAEMON;
a_fail(a, "daemon-error", "?ERRNO", A_END);
else {
flags |= F_DAEMON;
@@
-1669,7
+1673,7
@@
static void acmd_setifname(admin *a, unsigned ac, char *av[])
a_notify("NEWIFNAME", "?PEER", p, "%s", p_ifname(p), "%s", av[1], A_END);
p_setifname(p, av[1]);
a_ok(a);
a_notify("NEWIFNAME", "?PEER", p, "%s", p_ifname(p), "%s", av[1], A_END);
p_setifname(p, av[1]);
a_ok(a);
- }
+ }
}
static void acmd_getchal(admin *a, unsigned ac, char *av[])
}
static void acmd_getchal(admin *a, unsigned ac, char *av[])
@@
-1779,7
+1783,7
@@
static void acmd_stats(admin *a, unsigned ac, char *av[])
"ip-bytes-in=%lu", st->sz_ipin,
A_END);
a_info(a,
"ip-bytes-in=%lu", st->sz_ipin,
A_END);
a_info(a,
- "ip-packets-out=%lu", st->n_ipout,
+ "ip-packets-out=%lu", st->n_ipout,
"ip-bytes-out=%lu", st->sz_ipout,
A_END);
a_info(a, "rejected-packets=%lu", st->n_reject, A_END);
"ip-bytes-out=%lu", st->sz_ipout,
A_END);
a_info(a, "rejected-packets=%lu", st->n_reject, A_END);
@@
-1882,7
+1886,7
@@
static const acmd acmdtab[] = {
{ "tunnels", 0, 0, 0, acmd_tunnels },
{ "version", 0, 0, 0, acmd_version },
{ "warn", "MESSAGE ...", 1, 0xffff, acmd_warn },
{ "tunnels", 0, 0, 0, acmd_tunnels },
{ "version", 0, 0, 0, acmd_version },
{ "warn", "MESSAGE ...", 1, 0xffff, acmd_warn },
- { "watch", "[OPTIONS]", 0, 1, acmd_watch },
+ { "watch", "[OPTIONS]", 0, 1, acmd_watch },
{ 0, 0, 0, 0, 0 }
};
{ 0, 0, 0, 0, 0 }
};
@@
-1893,7
+1897,7
@@
static void acmd_help(admin *a, unsigned ac, char *av[])
for (c = acmdtab; c->name; c++) {
if (c->help)
a_info(a, "%s", c->name, "*%s", c->help, A_END);
for (c = acmdtab; c->name; c++) {
if (c->help)
a_info(a, "%s", c->name, "*%s", c->help, A_END);
- else
+ else
a_info(a, "%s", c->name, A_END);
}
a_ok(a);
a_info(a, "%s", c->name, A_END);
}
a_ok(a);
@@
-2040,7
+2044,7
@@
static void a_line(char *p, size_t len, void *vp)
if (c->argmin > ac || ac > c->argmax) {
if (!c->help)
a_fail(a, "bad-syntax", "%s", c->name, "", A_END);
if (c->argmin > ac || ac > c->argmax) {
if (!c->help)
a_fail(a, "bad-syntax", "%s", c->name, "", A_END);
- else
+ else
a_fail(a, "bad-syntax", "%s", c->name, "%s", c->help, A_END);
} else
c->func(a, ac, av + 1);
a_fail(a, "bad-syntax", "%s", c->name, "%s", c->help, A_END);
} else
c->func(a, ac, av + 1);