This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: How to add multicast route?
- From: Grant Edwards <grant dot b dot edwards at gmail dot com>
- To: ecos-discuss at sources dot redhat dot com
- Date: Thu, 31 Mar 2011 18:34:51 +0000 (UTC)
- Subject: [ECOS] Re: How to add multicast route?
- References: <in2gt5$tk$1@dough.gmane.org>
On 2011-03-31, Grant Edwards <grant.b.edwards@gmail.com> wrote:
> I'm trying to figure out how to add a route to tell the stack which
> interface to use for sending UDP multicast packets, and I'm stumped.
> I've searched the list, and this exact same question has been posted
> multiple times, but it's never been answered.
>
> #define AssembleIP(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d))
>
> struct sockaddr_in addr;
> struct ecos_rtentry route;
>
> memset(&route, 0, sizeof route);
> memset(&addr, 0, sizeof addr);
>
> addr.sin_family = AF_INET;
> addr.sin_len = sizeof addr;
>
> addr.sin_addr.s_addr = htonl(AssembleIP(224,0,0,0));
> memcpy(&route.rt_dst, &addr, sizeof route.rt_dst);
> memcpy(&route.rt_gateway, &addr, sizeof route.rt_gateway);
>
> addr.sin_addr.s_addr = htonl(AssembleIP(240,0,0,0));
> memcpy(&route.rt_genmask, &addr, sizeof route.rt_genmask);
>
> route.rt_dev = "eth0";
> route.rt_flags = RTF_UP;
> route.rt_metric = 0;
>
> if ((rc=ioctl(s, SIOCADDRT, &route)))
> diag_printf("Error setting multicast route (SIOCADDRT): %s\n", strerror(errno));
>
> The ioctl always fails with the error "Network is unreachable"
In case it helps, I've dumped the network tables both before and after
the failed attempt to add a route:
Routing tables
Destination Gateway Mask Flags Interface
10.0.0.0 10.0.0.0 255.0.0.0 U eth0
Interface statistics
eth0 IP: 10.0.0.102, Broadcast: 10.255.255.255, Netmask: 255.0.0.0
UP BROADCAST RUNNING MULTICAST MTU: 1500, Metric: 0
Rx - Packets: 0, Bytes: 0, Tx - Packets: 0, Bytes: 0
Error setting multicast route (SIOCADDRT): Network is unreachable
Routing tables
Destination Gateway Mask Flags Interface
10.0.0.0 10.0.0.0 255.0.0.0 U eth0
eth0 IP: 10.0.0.102, Broadcast: 10.255.255.255, Netmask: 255.0.0.0
UP BROADCAST RUNNING MULTICAST MTU: 1500, Metric: 0
Rx - Packets: 0, Bytes: 0, Tx - Packets: 0, Bytes: 0
, and
> subsequent packets sent to 224.x.x.x. fail with "No route to host".
> I've also tried setting rt_gateway to 0's (which appears to be how
> it's done on Linux).
>
> I tried setting the RTF_MULTICAST flag, but that's not supported by
> the ecos_rtentry structure (the rt_flags field isn't big enough).
> I've also tried setting the RTF_GATEWAY flag and the RTF_STATIC flags,
> and neither made any difference.
>
> How do you add a network route for multicast?
--
Grant Edwards grant.b.edwards Yow! Now that I have my
at "APPLE", I comprehend COST
gmail.com ACCOUNTING!!
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss