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"
11 #include "linux/init.h"
16 struct ethertap_init {
21 static void etap_init(struct net_device *dev, void *data)
23 struct uml_net_private *pri;
24 struct ethertap_data *epri;
25 struct ethertap_init *init = data;
28 epri = (struct ethertap_data *) pri->user;
29 epri->dev_name = init->dev_name;
30 epri->gate_addr = init->gate_addr;
32 epri->control_fd = -1;
35 printk("ethertap backend - %s", epri->dev_name);
36 if (epri->gate_addr != NULL)
37 printk(", IP = %s", epri->gate_addr);
41 static int etap_read(int fd, struct sk_buff **skb, struct uml_net_private *lp)
45 *skb = ether_adjust_skb(*skb, ETH_HEADER_ETHERTAP);
46 if(*skb == NULL) return(-ENOMEM);
47 len = net_recvfrom(fd, (*skb)->mac.raw,
48 (*skb)->dev->mtu + 2 * ETH_HEADER_ETHERTAP);
49 if(len <= 0) return(len);
55 static int etap_write(int fd, struct sk_buff **skb, struct uml_net_private *lp)
57 if(skb_headroom(*skb) < 2){
60 skb2 = skb_realloc_headroom(*skb, 2);
62 if (skb2 == NULL) return(-ENOMEM);
66 return(net_send(fd, (*skb)->data, (*skb)->len));
69 struct net_kern_info ethertap_kern_info = {
71 .protocol = eth_protocol,
76 int ethertap_setup(char *str, char **mac_out, void *data)
78 struct ethertap_init *init = data;
80 *init = ((struct ethertap_init)
83 if(tap_setup_common(str, "ethertap", &init->dev_name, mac_out,
86 if(init->dev_name == NULL){
87 printk("ethertap_setup : Missing tap device name\n");
94 static struct transport ethertap_transport = {
95 .list = LIST_HEAD_INIT(ethertap_transport.list),
97 .setup = ethertap_setup,
98 .user = ðertap_user_info,
99 .kern = ðertap_kern_info,
100 .private_size = sizeof(struct ethertap_data),
103 static int register_ethertap(void)
105 register_transport(ðertap_transport);
109 __initcall(register_ethertap);
112 * Overrides for Emacs so that we follow Linus's tabbing style.
113 * Emacs will notice this stuff at the end of the file and automatically
114 * adjust the settings for this buffer only. This must remain at the end
116 * ---------------------------------------------------------------------------
118 * c-file-style: "linux"