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@ --- *
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;
dir = p;
if ((p = getenv("TRIPESOCK")) != 0)
csock = p;
- tun_default = tunnels[0];
aihint.ai_family = AF_UNSPEC;
for (;;) {
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))
- 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;
#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;
}
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++) {