- /* Register for poll() */
- register_for_poll(st, tun_beforepoll, tun_afterpoll, 1, st->nl.name);
-}
-
-#ifdef HAVE_LINUX_IF_H
-static list_t *tun_apply(closure_t *self, struct cloc loc, dict_t *context,
- list_t *args)
-{
- struct tun *st;
- item_t *item;
- dict_t *dict;
-
- st=safe_malloc(sizeof(*st),"tun_apply");
-
- /* First parameter must be a dict */
- item=list_elem(args,0);
- if (!item || item->type!=t_dict)
- cfgfatal(loc,"tun","parameter must be a dictionary\n");
-
- dict=item->data.dict;
-
- st->netlink_to_tunnel=
- netlink_init(&st->nl,st,loc,dict,
- "netlink-tun",tun_deliver_to_kernel);
-
- st->tun_old=False;
- st->device_path=dict_read_string(dict,"device",False,"tun-netlink",loc);
- st->interface_name=dict_read_string(dict,"interface",False,
- "tun-netlink",loc);
- st->ifconfig_path=dict_read_string(dict,"ifconfig-path",
- False,"tun-netlink",loc);
- st->route_path=dict_read_string(dict,"route-path",
- False,"tun-netlink",loc);
-
- if (!st->device_path) st->device_path="/dev/net/tun";
- if (!st->ifconfig_path) st->ifconfig_path="ifconfig";
- if (!st->route_path) st->route_path="route";
- st->buff=find_cl_if(dict,"buffer",CL_BUFFER,True,"tun-netlink",loc);
-
- add_hook(PHASE_GETRESOURCES,tun_phase_hook,st);
-
- return new_closure(&st->nl.cl);
-}
-#endif /* HAVE_LINUX_IF_H */
-
-static list_t *tun_old_apply(closure_t *self, struct cloc loc, dict_t *context,
- list_t *args)
-{
- struct tun *st;
- item_t *item;
- dict_t *dict;
-
- st=safe_malloc(sizeof(*st),"tun_old_apply");
-
- Message(M_WARNING,"the tun-old code has never been tested. Please report "
- "success or failure to steve@greenend.org.uk\n");
-
- /* First parameter must be a dict */
- item=list_elem(args,0);
- if (!item || item->type!=t_dict)
- cfgfatal(loc,"tun","parameter must be a dictionary\n");
-
- dict=item->data.dict;
-
- st->netlink_to_tunnel=
- netlink_init(&st->nl,st,loc,dict,
- "netlink-tun",tun_deliver_to_kernel);
-
- st->tun_old=True;
- st->device_path=dict_read_string(dict,"device",False,"tun-netlink",loc);
- st->interface_name=dict_read_string(dict,"interface",False,
- "tun-netlink",loc);
- st->search_for_if=dict_read_bool(dict,"interface-search",False,
- "tun-netlink",loc,st->device_path==NULL);
- st->ifconfig_path=dict_read_string(dict,"ifconfig-path",False,
- "tun-netlink",loc);
- st->route_path=dict_read_string(dict,"route-path",False,"tun-netlink",loc);
-
- if (!st->device_path) st->device_path="/dev/tun";
- if (!st->ifconfig_path) st->ifconfig_path="ifconfig";
- if (!st->route_path) st->route_path="route";
- st->buff=find_cl_if(dict,"buffer",CL_BUFFER,True,"tun-netlink",loc);
-
- /* Old TUN interface: the network interface name depends on which
- /dev/tunX file we open. If 'interface-search' is set to true, treat
- 'device' as the prefix and try numbers from 0--255. If it's set
- to false, treat 'device' as the whole name, and require than an
- appropriate interface name be specified. */
- if (st->search_for_if && st->interface_name) {
- cfgfatal(loc,"tun-old","you may not specify an interface name "
- "in interface-search mode\n");