summaryrefslogtreecommitdiff
path: root/arch/um/drivers/mcast_kern.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-17 02:20:36 +0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-17 02:20:36 +0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/um/drivers/mcast_kern.c
downloadlinux-1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.tar.xz
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.c143
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 @@
+/*
+ * user-mode-linux networking multicast transport
+ * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org>
+ *
+ * based on the existing uml-networking code, which is
+ * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
+ * James Leu (jleu@mindspring.net).
+ * Copyright (C) 2001 by various other people who didn't put their name here.
+ *
+ * Licensed under the GPL.
+ */
+
+#include "linux/kernel.h"
+#include "linux/init.h"
+#include "linux/netdevice.h"
+#include "linux/etherdevice.h"
+#include "linux/in.h"
+#include "linux/inet.h"
+#include "net_kern.h"
+#include "net_user.h"
+#include "mcast.h"
+
+struct mcast_init {
+ char *addr;
+ int port;
+ int ttl;
+};
+
+void mcast_init(struct net_device *dev, void *data)
+{
+ struct uml_net_private *pri;
+ struct mcast_data *dpri;
+ struct mcast_init *init = data;
+
+ pri = dev->priv;
+ dpri = (struct mcast_data *) pri->user;
+ dpri->addr = init->addr;
+ dpri->port = init->port;
+ dpri->ttl = init->ttl;
+ dpri->dev = dev;
+
+ printk("mcast backend ");
+ printk("multicast adddress: %s:%u, TTL:%u ",
+ dpri->addr, dpri->port, dpri->ttl);
+
+ printk("\n");
+}
+
+static int mcast_read(int fd, struct sk_buff **skb, struct uml_net_private *lp)
+{
+ *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
+ if(*skb == NULL) return(-ENOMEM);
+ return(net_recvfrom(fd, (*skb)->mac.raw,
+ (*skb)->dev->mtu + ETH_HEADER_OTHER));
+}
+
+static int mcast_write(int fd, struct sk_buff **skb,
+ struct uml_net_private *lp)
+{
+ return mcast_user_write(fd, (*skb)->data, (*skb)->len,
+ (struct mcast_data *) &lp->user);
+}
+
+static struct net_kern_info mcast_kern_info = {
+ .init = mcast_init,
+ .protocol = eth_protocol,
+ .read = mcast_read,
+ .write = mcast_write,
+};
+
+int mcast_setup(char *str, char **mac_out, void *data)
+{
+ struct mcast_init *init = data;
+ char *port_str = NULL, *ttl_str = NULL, *remain;
+ char *last;
+ int n;
+
+ *init = ((struct mcast_init)
+ { .addr = "239.192.168.1",
+ .port = 1102,
+ .ttl = 1 });
+
+ remain = split_if_spec(str, mac_out, &init->addr, &port_str, &ttl_str,
+ NULL);
+ if(remain != NULL){
+ printk(KERN_ERR "mcast_setup - Extra garbage on "
+ "specification : '%s'\n", remain);
+ return(0);
+ }
+
+ if(port_str != NULL){
+ n = simple_strtoul(port_str, &last, 10);
+ if((*last != '\0') || (last == port_str)){
+ printk(KERN_ERR "mcast_setup - Bad port : '%s'\n",
+ port_str);
+ return(0);
+ }
+ init->port = htons(n);
+ }
+
+ if(ttl_str != NULL){
+ init->ttl = simple_strtoul(ttl_str, &last, 10);
+ if((*last != '\0') || (last == ttl_str)){
+ printk(KERN_ERR "mcast_setup - Bad ttl : '%s'\n",
+ ttl_str);
+ return(0);
+ }
+ }
+
+ printk(KERN_INFO "Configured mcast device: %s:%u-%u\n", init->addr,
+ init->port, init->ttl);
+
+ return(1);
+}
+
+static struct transport mcast_transport = {
+ .list = LIST_HEAD_INIT(mcast_transport.list),
+ .name = "mcast",
+ .setup = mcast_setup,
+ .user = &mcast_user_info,
+ .kern = &mcast_kern_info,
+ .private_size = sizeof(struct mcast_data),
+ .setup_size = sizeof(struct mcast_init),
+};
+
+static int register_mcast(void)
+{
+ register_transport(&mcast_transport);
+ return(1);
+}
+
+__initcall(register_mcast);
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only. This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-file-style: "linux"
+ * End:
+ */