~mdw
/
tripe
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
server/: Build a proper interface for handling tunnel classes.
[tripe]
/
server
/
tripe.c
diff --git
a/server/tripe.c
b/server/tripe.c
index
fb1d337
..
637400a
100644
(file)
--- a/
server/tripe.c
+++ b/
server/tripe.c
@@
-163,6
+163,21
@@
int lp_run(void)
return (0);
}
return (0);
}
+/*----- Tunnel table ------------------------------------------------------*/
+
+static const tunnel_ops *tunnels[] = {
+#ifdef TUN_LINUX
+ &tun_linux,
+#endif
+#ifdef TUN_BSD
+ &tun_bsd,
+#endif
+#ifdef TUN_UNET
+ &tun_unet,
+#endif
+ &tun_slip,
+};
+
/*----- Main code ---------------------------------------------------------*/
/* --- @main@ --- *
/*----- Main code ---------------------------------------------------------*/
/* --- @main@ --- *
@@
-229,6
+244,7
@@
int main(int argc, char *argv[])
const char *p;
const char *bindhost = 0, *bindsvc = STR(TRIPE_PORT);
struct addrinfo aihint = { 0 }, *ailist;
const char *p;
const char *bindhost = 0, *bindsvc = STR(TRIPE_PORT);
struct addrinfo aihint = { 0 }, *ailist;
+ const tunnel_ops *dflt = 0;
unsigned f = 0;
int i;
int err;
unsigned f = 0;
int i;
int err;
@@
-247,7
+263,6
@@
int main(int argc, char *argv[])
dir = p;
if ((p = getenv("TRIPESOCK")) != 0)
csock = p;
dir = p;
if ((p = getenv("TRIPESOCK")) != 0)
csock = p;
- tun_default = tunnels[0];
aihint.ai_family = AF_UNSPEC;
for (;;) {
aihint.ai_family = AF_UNSPEC;
for (;;) {
@@
-323,13
+338,11
@@
int main(int argc, char *argv[])
break;
case 'n': {
int i;
break;
case 'n': {
int i;
- for (i = 0;; i++) {
- if (!tunnels[i])
- die(EXIT_FAILURE, "unknown tunnel `%s'", optarg);
+ for (i = 0; i < N(tunnels); i++)
if (mystrieq(optarg, tunnels[i]->name))
if (mystrieq(optarg, tunnels[i]->name))
- break;
- }
-
tun_default = tunnels[i]
;
+ { dflt = tunnels[i]; goto found_tun; }
+ die(EXIT_FAILURE, "unknown tunnel `%s'", optarg);
+
found_tun:
;
} break;
case 'd':
dir = optarg;
} break;
case 'd':
dir = optarg;
@@
-359,7
+372,7
@@
int main(int argc, char *argv[])
#endif
case '0': {
int i;
#endif
case '0': {
int i;
- for (i = 0;
tunnels[i]
; i++)
+ for (i = 0;
i < N(tunnels)
; i++)
puts(tunnels[i]->name);
exit(0);
} break;
puts(tunnels[i]->name);
exit(0);
} break;
@@
-406,8
+419,9
@@
int main(int argc, char *argv[])
}
p_init();
}
p_init();
- for (i = 0; tunnels[i]; i++)
- tunnels[i]->init();
+ for (i = 0; i < N(tunnels); i++)
+ p_addtun(tunnels[i]);
+ if (dflt) p_setdflttun(dflt);
p_bind(ailist); freeaddrinfo(ailist);
for (i = 0; tunnels[i]; i++) {
p_bind(ailist); freeaddrinfo(ailist);
for (i = 0; tunnels[i]; i++) {