Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/agpgart
[linux-2.6] / arch / um / drivers / slip_kern.c
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"
6 #include "net_kern.h"
7 #include "net_user.h"
8 #include "kern.h"
9 #include "slip.h"
10
11 struct slip_init {
12         char *gate_addr;
13 };
14
15 void slip_init(struct net_device *dev, void *data)
16 {
17         struct uml_net_private *private;
18         struct slip_data *spri;
19         struct slip_init *init = data;
20
21         private = dev->priv;
22         spri = (struct slip_data *) private->user;
23
24         memset(spri->name, 0, sizeof(spri->name));
25         spri->addr = NULL;
26         spri->gate_addr = init->gate_addr;
27         spri->slave = -1;
28         spri->dev = dev;
29
30         slip_proto_init(&spri->slip);
31
32         dev->init = NULL;
33         dev->header_cache_update = NULL;
34         dev->hard_header_cache = NULL;
35         dev->hard_header = NULL;
36         dev->hard_header_len = 0;
37         dev->addr_len = 0;
38         dev->type = ARPHRD_SLIP;
39         dev->tx_queue_len = 256;
40         dev->flags = IFF_NOARP;
41         printk("SLIP backend - SLIP IP = %s\n", spri->gate_addr);
42 }
43
44 static unsigned short slip_protocol(struct sk_buff *skbuff)
45 {
46         return(htons(ETH_P_IP));
47 }
48
49 static int slip_read(int fd, struct sk_buff **skb, 
50                        struct uml_net_private *lp)
51 {
52         return(slip_user_read(fd, skb_mac_header(*skb), (*skb)->dev->mtu,
53                               (struct slip_data *) &lp->user));
54 }
55
56 static int slip_write(int fd, struct sk_buff **skb,
57                       struct uml_net_private *lp)
58 {
59         return(slip_user_write(fd, (*skb)->data, (*skb)->len, 
60                                (struct slip_data *) &lp->user));
61 }
62
63 const struct net_kern_info slip_kern_info = {
64         .init                   = slip_init,
65         .protocol               = slip_protocol,
66         .read                   = slip_read,
67         .write                  = slip_write,
68 };
69
70 static int slip_setup(char *str, char **mac_out, void *data)
71 {
72         struct slip_init *init = data;
73
74         *init = ((struct slip_init)
75                 { .gate_addr            = NULL });
76
77         if(str[0] != '\0') 
78                 init->gate_addr = str;
79         return(1);
80 }
81
82 static struct transport slip_transport = {
83         .list           = LIST_HEAD_INIT(slip_transport.list),
84         .name           = "slip",
85         .setup          = slip_setup,
86         .user           = &slip_user_info,
87         .kern           = &slip_kern_info,
88         .private_size   = sizeof(struct slip_data),
89         .setup_size     = sizeof(struct slip_init),
90 };
91
92 static int register_slip(void)
93 {
94         register_transport(&slip_transport);
95         return 0;
96 }
97
98 late_initcall(register_slip);