Linux 2.6.17.7
[linux/fpc-iii.git] / arch / um / drivers / slip_kern.c
blob163ee0d5f75e4e165c312a47b02d2af8975f4be9
1 #include "linux/config.h"
2 #include "linux/kernel.h"
3 #include "linux/stddef.h"
4 #include "linux/init.h"
5 #include "linux/netdevice.h"
6 #include "linux/if_arp.h"
7 #include "net_kern.h"
8 #include "net_user.h"
9 #include "kern.h"
10 #include "slip.h"
12 struct slip_init {
13 char *gate_addr;
16 void slip_init(struct net_device *dev, void *data)
18 struct uml_net_private *private;
19 struct slip_data *spri;
20 struct slip_init *init = data;
22 private = dev->priv;
23 spri = (struct slip_data *) private->user;
25 memset(spri->name, 0, sizeof(spri->name));
26 spri->addr = NULL;
27 spri->gate_addr = init->gate_addr;
28 spri->slave = -1;
29 spri->dev = dev;
31 slip_proto_init(&spri->slip);
33 dev->init = NULL;
34 dev->header_cache_update = NULL;
35 dev->hard_header_cache = NULL;
36 dev->hard_header = NULL;
37 dev->hard_header_len = 0;
38 dev->addr_len = 0;
39 dev->type = ARPHRD_SLIP;
40 dev->tx_queue_len = 256;
41 dev->flags = IFF_NOARP;
42 printk("SLIP backend - SLIP IP = %s\n", spri->gate_addr);
45 static unsigned short slip_protocol(struct sk_buff *skbuff)
47 return(htons(ETH_P_IP));
50 static int slip_read(int fd, struct sk_buff **skb,
51 struct uml_net_private *lp)
53 return(slip_user_read(fd, (*skb)->mac.raw, (*skb)->dev->mtu,
54 (struct slip_data *) &lp->user));
57 static int slip_write(int fd, struct sk_buff **skb,
58 struct uml_net_private *lp)
60 return(slip_user_write(fd, (*skb)->data, (*skb)->len,
61 (struct slip_data *) &lp->user));
64 struct net_kern_info slip_kern_info = {
65 .init = slip_init,
66 .protocol = slip_protocol,
67 .read = slip_read,
68 .write = slip_write,
71 static int slip_setup(char *str, char **mac_out, void *data)
73 struct slip_init *init = data;
75 *init = ((struct slip_init)
76 { .gate_addr = NULL });
78 if(str[0] != '\0')
79 init->gate_addr = str;
80 return(1);
83 static struct transport slip_transport = {
84 .list = LIST_HEAD_INIT(slip_transport.list),
85 .name = "slip",
86 .setup = slip_setup,
87 .user = &slip_user_info,
88 .kern = &slip_kern_info,
89 .private_size = sizeof(struct slip_data),
90 .setup_size = sizeof(struct slip_init),
93 static int register_slip(void)
95 register_transport(&slip_transport);
96 return 0;
99 __initcall(register_slip);