2 * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
6 #include "linux/stddef.h"
7 #include "linux/netdevice.h"
8 #include "linux/etherdevice.h"
9 #include "linux/skbuff.h"
10 #include "linux/init.h"
11 #include "asm/errno.h"
21 static void tuntap_init(struct net_device *dev, void *data)
23 struct uml_net_private *pri;
24 struct tuntap_data *tpri;
25 struct tuntap_init *init = data;
28 tpri = (struct tuntap_data *) pri->user;
29 tpri->dev_name = init->dev_name;
30 tpri->fixed_config = (init->dev_name != NULL);
31 tpri->gate_addr = init->gate_addr;
35 printk("TUN/TAP backend - ");
36 if (tpri->gate_addr != NULL)
37 printk("IP = %s", tpri->gate_addr);
41 static int tuntap_read(int fd, struct sk_buff **skb,
42 struct uml_net_private *lp)
44 *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
45 if(*skb == NULL) return(-ENOMEM);
46 return(net_read(fd, (*skb)->mac.raw,
47 (*skb)->dev->mtu + ETH_HEADER_OTHER));
50 static int tuntap_write(int fd, struct sk_buff **skb,
51 struct uml_net_private *lp)
53 return(net_write(fd, (*skb)->data, (*skb)->len));
56 const struct net_kern_info tuntap_kern_info = {
58 .protocol = eth_protocol,
60 .write = tuntap_write,
63 int tuntap_setup(char *str, char **mac_out, void *data)
65 struct tuntap_init *init = data;
67 *init = ((struct tuntap_init)
70 if(tap_setup_common(str, "tuntap", &init->dev_name, mac_out,
77 static struct transport tuntap_transport = {
78 .list = LIST_HEAD_INIT(tuntap_transport.list),
80 .setup = tuntap_setup,
81 .user = &tuntap_user_info,
82 .kern = &tuntap_kern_info,
83 .private_size = sizeof(struct tuntap_data),
84 .setup_size = sizeof(struct tuntap_init),
87 static int register_tuntap(void)
89 register_transport(&tuntap_transport);
93 __initcall(register_tuntap);