2 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
6 #include <linux/netdevice.h>
7 #include <linux/init.h>
8 #include <linux/skbuff.h>
18 static void tuntap_init(struct net_device *dev, void *data)
20 struct uml_net_private *pri;
21 struct tuntap_data *tpri;
22 struct tuntap_init *init = data;
25 tpri = (struct tuntap_data *) pri->user;
26 tpri->dev_name = init->dev_name;
27 tpri->fixed_config = (init->dev_name != NULL);
28 tpri->gate_addr = init->gate_addr;
32 printk("TUN/TAP backend - ");
33 if (tpri->gate_addr != NULL)
34 printk("IP = %s", tpri->gate_addr);
38 static int tuntap_read(int fd, struct sk_buff **skb,
39 struct uml_net_private *lp)
41 *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
44 return net_read(fd, skb_mac_header(*skb),
45 (*skb)->dev->mtu + ETH_HEADER_OTHER);
48 static int tuntap_write(int fd, struct sk_buff **skb,
49 struct uml_net_private *lp)
51 return net_write(fd, (*skb)->data, (*skb)->len);
54 const struct net_kern_info tuntap_kern_info = {
56 .protocol = eth_protocol,
58 .write = tuntap_write,
61 int tuntap_setup(char *str, char **mac_out, void *data)
63 struct tuntap_init *init = data;
65 *init = ((struct tuntap_init)
68 if (tap_setup_common(str, "tuntap", &init->dev_name, mac_out,
75 static struct transport tuntap_transport = {
76 .list = LIST_HEAD_INIT(tuntap_transport.list),
78 .setup = tuntap_setup,
79 .user = &tuntap_user_info,
80 .kern = &tuntap_kern_info,
81 .private_size = sizeof(struct tuntap_data),
82 .setup_size = sizeof(struct tuntap_init),
85 static int register_tuntap(void)
87 register_transport(&tuntap_transport);
91 late_initcall(register_tuntap);