2 * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
3 * James Leu (jleu@mindspring.net).
4 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
5 * Copyright (C) 2001 by various other people who didn't put their name here.
6 * Licensed under the GPL.
9 #include <linux/init.h>
10 #include <linux/netdevice.h>
14 struct ethertap_init
{
19 static void etap_init(struct net_device
*dev
, void *data
)
21 struct uml_net_private
*pri
;
22 struct ethertap_data
*epri
;
23 struct ethertap_init
*init
= data
;
25 pri
= netdev_priv(dev
);
26 epri
= (struct ethertap_data
*) pri
->user
;
27 epri
->dev_name
= init
->dev_name
;
28 epri
->gate_addr
= init
->gate_addr
;
30 epri
->control_fd
= -1;
33 printk(KERN_INFO
"ethertap backend - %s", epri
->dev_name
);
34 if (epri
->gate_addr
!= NULL
)
35 printk(KERN_CONT
", IP = %s", epri
->gate_addr
);
36 printk(KERN_CONT
"\n");
39 static int etap_read(int fd
, struct sk_buff
*skb
, struct uml_net_private
*lp
)
43 len
= net_recvfrom(fd
, skb_mac_header(skb
),
44 skb
->dev
->mtu
+ 2 + ETH_HEADER_ETHERTAP
);
53 static int etap_write(int fd
, struct sk_buff
*skb
, struct uml_net_private
*lp
)
56 return net_send(fd
, skb
->data
, skb
->len
);
59 const struct net_kern_info ethertap_kern_info
= {
61 .protocol
= eth_protocol
,
66 int ethertap_setup(char *str
, char **mac_out
, void *data
)
68 struct ethertap_init
*init
= data
;
70 *init
= ((struct ethertap_init
)
73 if (tap_setup_common(str
, "ethertap", &init
->dev_name
, mac_out
,
76 if (init
->dev_name
== NULL
) {
77 printk(KERN_ERR
"ethertap_setup : Missing tap device name\n");
84 static struct transport ethertap_transport
= {
85 .list
= LIST_HEAD_INIT(ethertap_transport
.list
),
87 .setup
= ethertap_setup
,
88 .user
= ðertap_user_info
,
89 .kern
= ðertap_kern_info
,
90 .private_size
= sizeof(struct ethertap_data
),
91 .setup_size
= sizeof(struct ethertap_init
),
94 static int register_ethertap(void)
96 register_transport(ðertap_transport
);
100 late_initcall(register_ethertap
);