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/kernel.h"
9 #include "linux/init.h"
10 #include "linux/netdevice.h"
11 #include "linux/etherdevice.h"
21 static void daemon_init(struct net_device
*dev
, void *data
)
23 struct uml_net_private
*pri
;
24 struct daemon_data
*dpri
;
25 struct daemon_init
*init
= data
;
28 dpri
= (struct daemon_data
*) pri
->user
;
29 dpri
->sock_type
= init
->sock_type
;
30 dpri
->ctl_sock
= init
->ctl_sock
;
34 /* We will free this pointer. If it contains crap we're burned. */
35 dpri
->ctl_addr
= NULL
;
36 dpri
->data_addr
= NULL
;
37 dpri
->local_addr
= NULL
;
39 printk("daemon backend (uml_switch version %d) - %s:%s",
40 SWITCH_VERSION
, dpri
->sock_type
, dpri
->ctl_sock
);
44 static int daemon_read(int fd
, struct sk_buff
**skb
,
45 struct uml_net_private
*lp
)
47 *skb
= ether_adjust_skb(*skb
, ETH_HEADER_OTHER
);
48 if(*skb
== NULL
) return(-ENOMEM
);
49 return(net_recvfrom(fd
, skb_mac_header(*skb
),
50 (*skb
)->dev
->mtu
+ ETH_HEADER_OTHER
));
53 static int daemon_write(int fd
, struct sk_buff
**skb
,
54 struct uml_net_private
*lp
)
56 return(daemon_user_write(fd
, (*skb
)->data
, (*skb
)->len
,
57 (struct daemon_data
*) &lp
->user
));
60 static const struct net_kern_info daemon_kern_info
= {
62 .protocol
= eth_protocol
,
64 .write
= daemon_write
,
67 static int daemon_setup(char *str
, char **mac_out
, void *data
)
69 struct daemon_init
*init
= data
;
72 *init
= ((struct daemon_init
)
73 { .sock_type
= "unix",
74 .ctl_sock
= "/tmp/uml.ctl" });
76 remain
= split_if_spec(str
, mac_out
, &init
->sock_type
, &init
->ctl_sock
,
79 printk(KERN_WARNING
"daemon_setup : Ignoring data socket "
85 static struct transport daemon_transport
= {
86 .list
= LIST_HEAD_INIT(daemon_transport
.list
),
88 .setup
= daemon_setup
,
89 .user
= &daemon_user_info
,
90 .kern
= &daemon_kern_info
,
91 .private_size
= sizeof(struct daemon_data
),
92 .setup_size
= sizeof(struct daemon_init
),
95 static int register_daemon(void)
97 register_transport(&daemon_transport
);
101 late_initcall(register_daemon
);