blob: 163ee0d5f75e4e165c312a47b02d2af8975f4be9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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
12struct slip_init {
13 char *gate_addr;
14};
15
16void 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;
Paolo 'Blaisorblade' Giarrusso854e9812006-02-01 03:06:25 -080024
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);
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33 dev->init = NULL;
Jeff Dikea3c77c62005-06-13 15:52:18 -070034 dev->header_cache_update = NULL;
35 dev->hard_header_cache = NULL;
36 dev->hard_header = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 dev->hard_header_len = 0;
Jeff Dikea3c77c62005-06-13 15:52:18 -070038 dev->addr_len = 0;
39 dev->type = ARPHRD_SLIP;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 dev->tx_queue_len = 256;
41 dev->flags = IFF_NOARP;
42 printk("SLIP backend - SLIP IP = %s\n", spri->gate_addr);
43}
44
45static unsigned short slip_protocol(struct sk_buff *skbuff)
46{
47 return(htons(ETH_P_IP));
48}
49
50static 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
57static 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
64struct net_kern_info slip_kern_info = {
65 .init = slip_init,
66 .protocol = slip_protocol,
67 .read = slip_read,
68 .write = slip_write,
69};
70
71static 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
83static 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
93static int register_slip(void)
94{
95 register_transport(&slip_transport);
Jeff Dikef4c57a72006-03-31 02:30:10 -080096 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097}
98
99__initcall(register_slip);