diff options
Diffstat (limited to 'arch/um/drivers/daemon_kern.c')
-rw-r--r-- | arch/um/drivers/daemon_kern.c | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/arch/um/drivers/daemon_kern.c b/arch/um/drivers/daemon_kern.c new file mode 100644 index 000000000000..30d285b266af --- /dev/null +++ b/arch/um/drivers/daemon_kern.c | |||
@@ -0,0 +1,108 @@ | |||
1 | /* | ||
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. | ||
6 | */ | ||
7 | |||
8 | #include "linux/kernel.h" | ||
9 | #include "linux/init.h" | ||
10 | #include "linux/netdevice.h" | ||
11 | #include "linux/etherdevice.h" | ||
12 | #include "net_kern.h" | ||
13 | #include "net_user.h" | ||
14 | #include "daemon.h" | ||
15 | |||
16 | struct daemon_init { | ||
17 | char *sock_type; | ||
18 | char *ctl_sock; | ||
19 | }; | ||
20 | |||
21 | void daemon_init(struct net_device *dev, void *data) | ||
22 | { | ||
23 | struct uml_net_private *pri; | ||
24 | struct daemon_data *dpri; | ||
25 | struct daemon_init *init = data; | ||
26 | |||
27 | pri = dev->priv; | ||
28 | dpri = (struct daemon_data *) pri->user; | ||
29 | dpri->sock_type = init->sock_type; | ||
30 | dpri->ctl_sock = init->ctl_sock; | ||
31 | dpri->fd = -1; | ||
32 | dpri->control = -1; | ||
33 | dpri->dev = dev; | ||
34 | |||
35 | printk("daemon backend (uml_switch version %d) - %s:%s", | ||
36 | SWITCH_VERSION, dpri->sock_type, dpri->ctl_sock); | ||
37 | printk("\n"); | ||
38 | } | ||
39 | |||
40 | static int daemon_read(int fd, struct sk_buff **skb, | ||
41 | struct uml_net_private *lp) | ||
42 | { | ||
43 | *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER); | ||
44 | if(*skb == NULL) return(-ENOMEM); | ||
45 | return(net_recvfrom(fd, (*skb)->mac.raw, | ||
46 | (*skb)->dev->mtu + ETH_HEADER_OTHER)); | ||
47 | } | ||
48 | |||
49 | static int daemon_write(int fd, struct sk_buff **skb, | ||
50 | struct uml_net_private *lp) | ||
51 | { | ||
52 | return(daemon_user_write(fd, (*skb)->data, (*skb)->len, | ||
53 | (struct daemon_data *) &lp->user)); | ||
54 | } | ||
55 | |||
56 | static struct net_kern_info daemon_kern_info = { | ||
57 | .init = daemon_init, | ||
58 | .protocol = eth_protocol, | ||
59 | .read = daemon_read, | ||
60 | .write = daemon_write, | ||
61 | }; | ||
62 | |||
63 | int daemon_setup(char *str, char **mac_out, void *data) | ||
64 | { | ||
65 | struct daemon_init *init = data; | ||
66 | char *remain; | ||
67 | |||
68 | *init = ((struct daemon_init) | ||
69 | { .sock_type = "unix", | ||
70 | .ctl_sock = "/tmp/uml.ctl" }); | ||
71 | |||
72 | remain = split_if_spec(str, mac_out, &init->sock_type, &init->ctl_sock, | ||
73 | NULL); | ||
74 | if(remain != NULL) | ||
75 | printk(KERN_WARNING "daemon_setup : Ignoring data socket " | ||
76 | "specification\n"); | ||
77 | |||
78 | return(1); | ||
79 | } | ||
80 | |||
81 | static struct transport daemon_transport = { | ||
82 | .list = LIST_HEAD_INIT(daemon_transport.list), | ||
83 | .name = "daemon", | ||
84 | .setup = daemon_setup, | ||
85 | .user = &daemon_user_info, | ||
86 | .kern = &daemon_kern_info, | ||
87 | .private_size = sizeof(struct daemon_data), | ||
88 | .setup_size = sizeof(struct daemon_init), | ||
89 | }; | ||
90 | |||
91 | static int register_daemon(void) | ||
92 | { | ||
93 | register_transport(&daemon_transport); | ||
94 | return(1); | ||
95 | } | ||
96 | |||
97 | __initcall(register_daemon); | ||
98 | |||
99 | /* | ||
100 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
101 | * Emacs will notice this stuff at the end of the file and automatically | ||
102 | * adjust the settings for this buffer only. This must remain at the end | ||
103 | * of the file. | ||
104 | * --------------------------------------------------------------------------- | ||
105 | * Local variables: | ||
106 | * c-file-style: "linux" | ||
107 | * End: | ||
108 | */ | ||