[PATCH] uml: use get_random_bytes() after random pool is seeded
[linux-2.6/linux-mips.git] / arch / um / os-Linux / drivers / tuntap_kern.c
blob76570a2c25c33bae1a799a61fb54078301304b29
1 /*
2 * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
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"
12 #include "net_kern.h"
13 #include "net_user.h"
14 #include "tuntap.h"
16 struct tuntap_init {
17 char *dev_name;
18 char *gate_addr;
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;
27 pri = dev->priv;
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;
32 tpri->fd = -1;
33 tpri->dev = dev;
35 printk("TUN/TAP backend - ");
36 if (tpri->gate_addr != NULL)
37 printk("IP = %s", tpri->gate_addr);
38 printk("\n");
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 = {
57 .init = tuntap_init,
58 .protocol = eth_protocol,
59 .read = tuntap_read,
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)
68 { .dev_name = NULL,
69 .gate_addr = NULL });
70 if(tap_setup_common(str, "tuntap", &init->dev_name, mac_out,
71 &init->gate_addr))
72 return(0);
74 return(1);
77 static struct transport tuntap_transport = {
78 .list = LIST_HEAD_INIT(tuntap_transport.list),
79 .name = "tuntap",
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);
90 return 0;
93 late_initcall(register_tuntap);