aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/daemon_kern.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/um/drivers/daemon_kern.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/um/drivers/daemon_kern.c')
-rw-r--r--arch/um/drivers/daemon_kern.c108
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
16struct daemon_init {
17 char *sock_type;
18 char *ctl_sock;
19};
20
21void 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
40static 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
49static 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
56static 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
63int 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
81static 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
91static 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 */