2 * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
3 * James Leu (jleu@mindspring.net).
4 * Copyright (C) 2001 by various other people who didn't put their name here.
5 * Licensed under the GPL.
8 #include "linux/init.h"
9 #include "linux/netdevice.h"
10 #include "linux/etherdevice.h"
15 struct ethertap_init {
20 static void etap_init(struct net_device *dev, void *data)
22 struct uml_net_private *pri;
23 struct ethertap_data *epri;
24 struct ethertap_init *init = data;
27 epri = (struct ethertap_data *) pri->user;
28 epri->dev_name = init->dev_name;
29 epri->gate_addr = init->gate_addr;
31 epri->control_fd = -1;
34 printk("ethertap backend - %s", epri->dev_name);
35 if (epri->gate_addr != NULL)
36 printk(", IP = %s", epri->gate_addr);
40 static int etap_read(int fd, struct sk_buff **skb, struct uml_net_private *lp)
44 *skb = ether_adjust_skb(*skb, ETH_HEADER_ETHERTAP);
45 if(*skb == NULL) return(-ENOMEM);
46 len = net_recvfrom(fd, (*skb)->mac.raw,
47 (*skb)->dev->mtu + 2 * ETH_HEADER_ETHERTAP);
48 if(len <= 0) return(len);
54 static int etap_write(int fd, struct sk_buff **skb, struct uml_net_private *lp)
56 if(skb_headroom(*skb) < 2){
59 skb2 = skb_realloc_headroom(*skb, 2);
61 if (skb2 == NULL) return(-ENOMEM);
65 return(net_send(fd, (*skb)->data, (*skb)->len));
68 struct net_kern_info ethertap_kern_info = {
70 .protocol = eth_protocol,
75 int ethertap_setup(char *str, char **mac_out, void *data)
77 struct ethertap_init *init = data;
79 *init = ((struct ethertap_init)
82 if(tap_setup_common(str, "ethertap", &init->dev_name, mac_out,
85 if(init->dev_name == NULL){
86 printk("ethertap_setup : Missing tap device name\n");
93 static struct transport ethertap_transport = {
94 .list = LIST_HEAD_INIT(ethertap_transport.list),
96 .setup = ethertap_setup,
97 .user = ðertap_user_info,
98 .kern = ðertap_kern_info,
99 .private_size = sizeof(struct ethertap_data),
102 static int register_ethertap(void)
104 register_transport(ðertap_transport);
108 __initcall(register_ethertap);
111 * Overrides for Emacs so that we follow Linus's tabbing style.
112 * Emacs will notice this stuff at the end of the file and automatically
113 * adjust the settings for this buffer only. This must remain at the end
115 * ---------------------------------------------------------------------------
117 * c-file-style: "linux"