Merge branch 'from-linus' into upstream
[linux-2.6] / arch / um / drivers / slip_kern.c
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"
11
12 struct slip_init {
13         char *gate_addr;
14 };
15
16 void slip_init(struct net_device *dev, void *data)
17 {
18         struct uml_net_private *private;
19         struct slip_data *spri;
20         struct slip_init *init = data;
21
22         private = dev->priv;
23         spri = (struct slip_data *) private->user;
24
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;
30
31         slip_proto_init(&spri->slip);
32
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);
43 }
44
45 static unsigned short slip_protocol(struct sk_buff *skbuff)
46 {
47         return(htons(ETH_P_IP));
48 }
49
50 static int slip_read(int fd, struct sk_buff **skb, 
51                        struct uml_net_private *lp)
52 {
53         return(slip_user_read(fd, (*skb)->mac.raw, (*skb)->dev->mtu, 
54                               (struct slip_data *) &lp->user));
55 }
56
57 static int slip_write(int fd, struct sk_buff **skb,
58                       struct uml_net_private *lp)
59 {
60         return(slip_user_write(fd, (*skb)->data, (*skb)->len, 
61                                (struct slip_data *) &lp->user));
62 }
63
64 struct net_kern_info slip_kern_info = {
65         .init                   = slip_init,
66         .protocol               = slip_protocol,
67         .read                   = slip_read,
68         .write                  = slip_write,
69 };
70
71 static int slip_setup(char *str, char **mac_out, void *data)
72 {
73         struct slip_init *init = data;
74
75         *init = ((struct slip_init)
76                 { .gate_addr            = NULL });
77
78         if(str[0] != '\0') 
79                 init->gate_addr = str;
80         return(1);
81 }
82
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),
91 };
92
93 static int register_slip(void)
94 {
95         register_transport(&slip_transport);
96         return 0;
97 }
98
99 __initcall(register_slip);