diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/um/drivers/mcast_kern.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/um/drivers/mcast_kern.c')
-rw-r--r-- | arch/um/drivers/mcast_kern.c | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/arch/um/drivers/mcast_kern.c b/arch/um/drivers/mcast_kern.c new file mode 100644 index 000000000000..faf714e87b5b --- /dev/null +++ b/arch/um/drivers/mcast_kern.c | |||
@@ -0,0 +1,143 @@ | |||
1 | /* | ||
2 | * user-mode-linux networking multicast transport | ||
3 | * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org> | ||
4 | * | ||
5 | * based on the existing uml-networking code, which is | ||
6 | * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and | ||
7 | * James Leu (jleu@mindspring.net). | ||
8 | * Copyright (C) 2001 by various other people who didn't put their name here. | ||
9 | * | ||
10 | * Licensed under the GPL. | ||
11 | */ | ||
12 | |||
13 | #include "linux/kernel.h" | ||
14 | #include "linux/init.h" | ||
15 | #include "linux/netdevice.h" | ||
16 | #include "linux/etherdevice.h" | ||
17 | #include "linux/in.h" | ||
18 | #include "linux/inet.h" | ||
19 | #include "net_kern.h" | ||
20 | #include "net_user.h" | ||
21 | #include "mcast.h" | ||
22 | |||
23 | struct mcast_init { | ||
24 | char *addr; | ||
25 | int port; | ||
26 | int ttl; | ||
27 | }; | ||
28 | |||
29 | void mcast_init(struct net_device *dev, void *data) | ||
30 | { | ||
31 | struct uml_net_private *pri; | ||
32 | struct mcast_data *dpri; | ||
33 | struct mcast_init *init = data; | ||
34 | |||
35 | pri = dev->priv; | ||
36 | dpri = (struct mcast_data *) pri->user; | ||
37 | dpri->addr = init->addr; | ||
38 | dpri->port = init->port; | ||
39 | dpri->ttl = init->ttl; | ||
40 | dpri->dev = dev; | ||
41 | |||
42 | printk("mcast backend "); | ||
43 | printk("multicast adddress: %s:%u, TTL:%u ", | ||
44 | dpri->addr, dpri->port, dpri->ttl); | ||
45 | |||
46 | printk("\n"); | ||
47 | } | ||
48 | |||
49 | static int mcast_read(int fd, struct sk_buff **skb, struct uml_net_private *lp) | ||
50 | { | ||
51 | *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER); | ||
52 | if(*skb == NULL) return(-ENOMEM); | ||
53 | return(net_recvfrom(fd, (*skb)->mac.raw, | ||
54 | (*skb)->dev->mtu + ETH_HEADER_OTHER)); | ||
55 | } | ||
56 | |||
57 | static int mcast_write(int fd, struct sk_buff **skb, | ||
58 | struct uml_net_private *lp) | ||
59 | { | ||
60 | return mcast_user_write(fd, (*skb)->data, (*skb)->len, | ||
61 | (struct mcast_data *) &lp->user); | ||
62 | } | ||
63 | |||
64 | static struct net_kern_info mcast_kern_info = { | ||
65 | .init = mcast_init, | ||
66 | .protocol = eth_protocol, | ||
67 | .read = mcast_read, | ||
68 | .write = mcast_write, | ||
69 | }; | ||
70 | |||
71 | int mcast_setup(char *str, char **mac_out, void *data) | ||
72 | { | ||
73 | struct mcast_init *init = data; | ||
74 | char *port_str = NULL, *ttl_str = NULL, *remain; | ||
75 | char *last; | ||
76 | int n; | ||
77 | |||
78 | *init = ((struct mcast_init) | ||
79 | { .addr = "239.192.168.1", | ||
80 | .port = 1102, | ||
81 | .ttl = 1 }); | ||
82 | |||
83 | remain = split_if_spec(str, mac_out, &init->addr, &port_str, &ttl_str, | ||
84 | NULL); | ||
85 | if(remain != NULL){ | ||
86 | printk(KERN_ERR "mcast_setup - Extra garbage on " | ||
87 | "specification : '%s'\n", remain); | ||
88 | return(0); | ||
89 | } | ||
90 | |||
91 | if(port_str != NULL){ | ||
92 | n = simple_strtoul(port_str, &last, 10); | ||
93 | if((*last != '\0') || (last == port_str)){ | ||
94 | printk(KERN_ERR "mcast_setup - Bad port : '%s'\n", | ||
95 | port_str); | ||
96 | return(0); | ||
97 | } | ||
98 | init->port = htons(n); | ||
99 | } | ||
100 | |||
101 | if(ttl_str != NULL){ | ||
102 | init->ttl = simple_strtoul(ttl_str, &last, 10); | ||
103 | if((*last != '\0') || (last == ttl_str)){ | ||
104 | printk(KERN_ERR "mcast_setup - Bad ttl : '%s'\n", | ||
105 | ttl_str); | ||
106 | return(0); | ||
107 | } | ||
108 | } | ||
109 | |||
110 | printk(KERN_INFO "Configured mcast device: %s:%u-%u\n", init->addr, | ||
111 | init->port, init->ttl); | ||
112 | |||
113 | return(1); | ||
114 | } | ||
115 | |||
116 | static struct transport mcast_transport = { | ||
117 | .list = LIST_HEAD_INIT(mcast_transport.list), | ||
118 | .name = "mcast", | ||
119 | .setup = mcast_setup, | ||
120 | .user = &mcast_user_info, | ||
121 | .kern = &mcast_kern_info, | ||
122 | .private_size = sizeof(struct mcast_data), | ||
123 | .setup_size = sizeof(struct mcast_init), | ||
124 | }; | ||
125 | |||
126 | static int register_mcast(void) | ||
127 | { | ||
128 | register_transport(&mcast_transport); | ||
129 | return(1); | ||
130 | } | ||
131 | |||
132 | __initcall(register_mcast); | ||
133 | |||
134 | /* | ||
135 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
136 | * Emacs will notice this stuff at the end of the file and automatically | ||
137 | * adjust the settings for this buffer only. This must remain at the end | ||
138 | * of the file. | ||
139 | * --------------------------------------------------------------------------- | ||
140 | * Local variables: | ||
141 | * c-file-style: "linux" | ||
142 | * End: | ||
143 | */ | ||