This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
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:24:38 +0000 (UTC)
- Subject: [ECOS] How to add multicast route?
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", 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
at
gmail.com
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss