1 #include "linux/kernel.h"
2 #include "linux/stddef.h"
3 #include "linux/init.h"
4 #include "linux/netdevice.h"
5 #include "linux/if_arp.h"
12 struct arg_list_dummy_wrapper argw
; /* XXX should be simpler... */
15 void slirp_init(struct net_device
*dev
, void *data
)
17 struct uml_net_private
*private;
18 struct slirp_data
*spri
;
19 struct slirp_init
*init
= data
;
23 spri
= (struct slirp_data
*) private->user
;
25 spri
->argw
= init
->argw
;
30 slip_proto_init(&spri
->slip
);
33 dev
->hard_header_len
= 0;
34 dev
->header_cache_update
= NULL
;
35 dev
->hard_header_cache
= NULL
;
36 dev
->hard_header
= NULL
;
38 dev
->type
= ARPHRD_SLIP
;
39 dev
->tx_queue_len
= 256;
40 dev
->flags
= IFF_NOARP
;
41 printk("SLIRP backend - command line:");
42 for(i
=0;spri
->argw
.argv
[i
]!=NULL
;i
++) {
43 printk(" '%s'",spri
->argw
.argv
[i
]);
48 static unsigned short slirp_protocol(struct sk_buff
*skbuff
)
50 return(htons(ETH_P_IP
));
53 static int slirp_read(int fd
, struct sk_buff
**skb
,
54 struct uml_net_private
*lp
)
56 return(slirp_user_read(fd
, (*skb
)->mac
.raw
, (*skb
)->dev
->mtu
,
57 (struct slirp_data
*) &lp
->user
));
60 static int slirp_write(int fd
, struct sk_buff
**skb
,
61 struct uml_net_private
*lp
)
63 return(slirp_user_write(fd
, (*skb
)->data
, (*skb
)->len
,
64 (struct slirp_data
*) &lp
->user
));
67 struct net_kern_info slirp_kern_info
= {
69 .protocol
= slirp_protocol
,
74 static int slirp_setup(char *str
, char **mac_out
, void *data
)
76 struct slirp_init
*init
= data
;
79 *init
= ((struct slirp_init
)
80 { .argw
= { { "slirp", NULL
} } });
82 str
= split_if_spec(str
, mac_out
, NULL
);
84 if(str
== NULL
) { /* no command line given after MAC addr */
89 if(i
>=SLIRP_MAX_ARGS
-1) {
90 printk("slirp_setup: truncating slirp arguments\n");
93 init
->argw
.argv
[i
++] = str
;
94 while(*str
&& *str
!=',') {
95 if(*str
=='_') *str
=' ';
102 init
->argw
.argv
[i
]=NULL
;
106 static struct transport slirp_transport
= {
107 .list
= LIST_HEAD_INIT(slirp_transport
.list
),
109 .setup
= slirp_setup
,
110 .user
= &slirp_user_info
,
111 .kern
= &slirp_kern_info
,
112 .private_size
= sizeof(struct slirp_data
),
113 .setup_size
= sizeof(struct slirp_init
),
116 static int register_slirp(void)
118 register_transport(&slirp_transport
);
122 __initcall(register_slirp
);