2 * user-mode-linux networking multicast transport
3 * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org>
4 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
6 * based on the existing uml-networking code, which is
7 * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
8 * James Leu (jleu@mindspring.net).
9 * Copyright (C) 2001 by various other people who didn't put their name here.
11 * Licensed under the GPL.
14 #include "linux/init.h"
15 #include <linux/netdevice.h>
25 static void mcast_init(struct net_device
*dev
, void *data
)
27 struct uml_net_private
*pri
;
28 struct mcast_data
*dpri
;
29 struct mcast_init
*init
= data
;
31 pri
= netdev_priv(dev
);
32 dpri
= (struct mcast_data
*) pri
->user
;
33 dpri
->addr
= init
->addr
;
34 dpri
->port
= init
->port
;
35 dpri
->ttl
= init
->ttl
;
38 printk("mcast backend multicast address: %s:%u, TTL:%u\n",
39 dpri
->addr
, dpri
->port
, dpri
->ttl
);
42 static int mcast_read(int fd
, struct sk_buff
*skb
, struct uml_net_private
*lp
)
44 return net_recvfrom(fd
, skb_mac_header(skb
),
45 skb
->dev
->mtu
+ ETH_HEADER_OTHER
);
48 static int mcast_write(int fd
, struct sk_buff
*skb
, struct uml_net_private
*lp
)
50 return mcast_user_write(fd
, skb
->data
, skb
->len
,
51 (struct mcast_data
*) &lp
->user
);
54 static const struct net_kern_info mcast_kern_info
= {
56 .protocol
= eth_protocol
,
61 static int mcast_setup(char *str
, char **mac_out
, void *data
)
63 struct mcast_init
*init
= data
;
64 char *port_str
= NULL
, *ttl_str
= NULL
, *remain
;
67 *init
= ((struct mcast_init
)
68 { .addr
= "239.192.168.1",
72 remain
= split_if_spec(str
, mac_out
, &init
->addr
, &port_str
, &ttl_str
,
75 printk(KERN_ERR
"mcast_setup - Extra garbage on "
76 "specification : '%s'\n", remain
);
80 if (port_str
!= NULL
) {
81 init
->port
= simple_strtoul(port_str
, &last
, 10);
82 if ((*last
!= '\0') || (last
== port_str
)) {
83 printk(KERN_ERR
"mcast_setup - Bad port : '%s'\n",
89 if (ttl_str
!= NULL
) {
90 init
->ttl
= simple_strtoul(ttl_str
, &last
, 10);
91 if ((*last
!= '\0') || (last
== ttl_str
)) {
92 printk(KERN_ERR
"mcast_setup - Bad ttl : '%s'\n",
98 printk(KERN_INFO
"Configured mcast device: %s:%u-%u\n", init
->addr
,
99 init
->port
, init
->ttl
);
104 static struct transport mcast_transport
= {
105 .list
= LIST_HEAD_INIT(mcast_transport
.list
),
107 .setup
= mcast_setup
,
108 .user
= &mcast_user_info
,
109 .kern
= &mcast_kern_info
,
110 .private_size
= sizeof(struct mcast_data
),
111 .setup_size
= sizeof(struct mcast_init
),
114 static int register_mcast(void)
116 register_transport(&mcast_transport
);
120 late_initcall(register_mcast
);