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
;
24 *spri
= ((struct slirp_data
)
35 dev
->hard_header_len
= 0;
36 dev
->header_cache_update
= NULL
;
37 dev
->hard_header_cache
= NULL
;
38 dev
->hard_header
= NULL
;
40 dev
->type
= ARPHRD_SLIP
;
41 dev
->tx_queue_len
= 256;
42 dev
->flags
= IFF_NOARP
;
43 printk("SLIRP backend - command line:");
44 for(i
=0;spri
->argw
.argv
[i
]!=NULL
;i
++) {
45 printk(" '%s'",spri
->argw
.argv
[i
]);
50 static unsigned short slirp_protocol(struct sk_buff
*skbuff
)
52 return(htons(ETH_P_IP
));
55 static int slirp_read(int fd
, struct sk_buff
**skb
,
56 struct uml_net_private
*lp
)
58 return(slirp_user_read(fd
, (*skb
)->mac
.raw
, (*skb
)->dev
->mtu
,
59 (struct slirp_data
*) &lp
->user
));
62 static int slirp_write(int fd
, struct sk_buff
**skb
,
63 struct uml_net_private
*lp
)
65 return(slirp_user_write(fd
, (*skb
)->data
, (*skb
)->len
,
66 (struct slirp_data
*) &lp
->user
));
69 struct net_kern_info slirp_kern_info
= {
71 .protocol
= slirp_protocol
,
76 static int slirp_setup(char *str
, char **mac_out
, void *data
)
78 struct slirp_init
*init
= data
;
81 *init
= ((struct slirp_init
)
82 { argw
: { { "slirp", NULL
} } });
84 str
= split_if_spec(str
, mac_out
, NULL
);
86 if(str
== NULL
) { /* no command line given after MAC addr */
91 if(i
>=SLIRP_MAX_ARGS
-1) {
92 printk("slirp_setup: truncating slirp arguments\n");
95 init
->argw
.argv
[i
++] = str
;
96 while(*str
&& *str
!=',') {
97 if(*str
=='_') *str
=' ';
104 init
->argw
.argv
[i
]=NULL
;
108 static struct transport slirp_transport
= {
109 .list
= LIST_HEAD_INIT(slirp_transport
.list
),
111 .setup
= slirp_setup
,
112 .user
= &slirp_user_info
,
113 .kern
= &slirp_kern_info
,
114 .private_size
= sizeof(struct slirp_data
),
115 .setup_size
= sizeof(struct slirp_init
),
118 static int register_slirp(void)
120 register_transport(&slirp_transport
);
124 __initcall(register_slirp
);
127 * Overrides for Emacs so that we follow Linus's tabbing style.
128 * Emacs will notice this stuff at the end of the file and automatically
129 * adjust the settings for this buffer only. This must remain at the end
131 * ---------------------------------------------------------------------------
133 * c-file-style: "linux"