netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* user space multicast routing interface
@ 2004-01-25 17:37 David Lamparter
  2004-01-25 19:35 ` jamal
  0 siblings, 1 reply; 3+ messages in thread
From: David Lamparter @ 2004-01-25 17:37 UTC (permalink / raw)
  To: netdev

Hi,

[...skip down if you don't like long "sorry for mailing" mails ;)]

first of all, please excuse me mailing to netdev for a not directly
kernel related Linux networking question - i didn't find any other place
where i could ask...

I recently started playing around with multicast routing for educational
purposes; multicast client software was easy to write, ran well and
there were lots of docs about setsockopts etc.

Continuing on my way, I'm trying to write a simple IGMP querier now, but
even getting started turns out to be pretty difficult here, almost no
docs exist (well, the FreeBSD manpage...). I tried everything coming to
my mind, but i wasn't even able to get to receiving all IGMP packets on
an interface.

[...stop skipping here]

so, 2 questions:
* what sockopts are neccessary to get all IGMP packets (all multicast
groups) on a raw socket? (MRT_INIT / MRT_ADD_VIF should do it, but it
doesn't work)
* is it possible to bind VIFs to interface indices? in ipmr.c / struct
vifctl there is no ifindex parameter (real interface, not vif)

as you can see from the 2nd question, i at least tried reading the
kernel source (2.6.1), but i don't know the stack so its difficult to
understand...

David Lamparter



Appended: testing code for IGMP

no error messages on 2.6.1, interface has
<BROADCAST,MULTICAST,ALLMULTI,UP> flags while code is running, vif shows
up under /proc/net/ip_mr_vif:
Interface      BytesIn  PktsIn  BytesOut PktsOut Flags Local    Remote
  1 eth0              0       0         0       0 08000 160216AC 00000000

<cut includes for space issues>

#define E(x) if (x) printf ("error doing %s: %d [%s]\n", \
         #x, errno, strerror (errno));
int main(int argc, char **argv)
{
         int mrouter_s4; int p = 1; struct vifctl vc;

         mrouter_s4 = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP);
         E(setsockopt(mrouter_s4, IPPROTO_IP, MRT_INIT,
                 (void *)&p, sizeof(p)));

         memset(&vc, 0, sizeof(vc));
         vc.vifc_vifi = vc.vifc_threshold = 1;
         vc.vifc_rate_limit = 4096;
         vc.vifc_lcl_addr.s_addr = inet_addr(argv[1]);
         E(setsockopt(mrouter_s4, IPPROTO_IP, MRT_ADD_VIF,
                 (void *)&vc, sizeof(vc)));

         while(1) {
                 char buf[4096]; struct sockaddr_in sender;
                 socklen_t sendsize = sizeof(sender);
                 int size = recvfrom(mrouter_s4, buf, 4096, 0,
                         (struct sockaddr *) &sender, &sendsize);
                 printf ("got %d from %s\n", size,
                         inet_ntoa(sender.sin_addr));
         }
}

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: user space multicast routing interface
@ 2004-01-25 21:35 David Stevens
  0 siblings, 0 replies; 3+ messages in thread
From: David Stevens @ 2004-01-25 21:35 UTC (permalink / raw)
  To: David Lamparter; +Cc: netdev

[-- Attachment #1: Type: text/plain, Size: 3133 bytes --]





For an IGMPv3 querier, which doesn't have to be a multicast router,
all you really need to do is create a raw socket with proto IPPROTO_IGMP
and join the "all multicast routers group" (224.0.0.22) on the interface
you
care about. Send the query to 224.0.0.1 and do a recvfrom() for the
response.

                        +-DLS


David Lamparter <equinox@diac24.net>@oss.sgi.com on 01/25/2004 09:37:13 AM

Sent by:    netdev-bounce@oss.sgi.com


To:    netdev@oss.sgi.com
cc:
Subject:    user space multicast routing interface



Hi,

[...skip down if you don't like long "sorry for mailing" mails ;)]

first of all, please excuse me mailing to netdev for a not directly
kernel related Linux networking question - i didn't find any other place
where i could ask...

I recently started playing around with multicast routing for educational
purposes; multicast client software was easy to write, ran well and
there were lots of docs about setsockopts etc.

Continuing on my way, I'm trying to write a simple IGMP querier now, but
even getting started turns out to be pretty difficult here, almost no
docs exist (well, the FreeBSD manpage...). I tried everything coming to
my mind, but i wasn't even able to get to receiving all IGMP packets on
an interface.

[...stop skipping here]

so, 2 questions:
* what sockopts are neccessary to get all IGMP packets (all multicast
groups) on a raw socket? (MRT_INIT / MRT_ADD_VIF should do it, but it
doesn't work)
* is it possible to bind VIFs to interface indices? in ipmr.c / struct
vifctl there is no ifindex parameter (real interface, not vif)

as you can see from the 2nd question, i at least tried reading the
kernel source (2.6.1), but i don't know the stack so its difficult to
understand...

David Lamparter



Appended: testing code for IGMP

no error messages on 2.6.1, interface has
<BROADCAST,MULTICAST,ALLMULTI,UP> flags while code is running, vif shows
up under /proc/net/ip_mr_vif:
Interface      BytesIn  PktsIn  BytesOut PktsOut Flags Local    Remote
  1 eth0              0       0         0       0 08000 160216AC 00000000

<cut includes for space issues>

#define E(x) if (x) printf ("error doing %s: %d [%s]\n", \
         #x, errno, strerror (errno));
int main(int argc, char **argv)
{
         int mrouter_s4; int p = 1; struct vifctl vc;

         mrouter_s4 = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP);
         E(setsockopt(mrouter_s4, IPPROTO_IP, MRT_INIT,
                 (void *)&p, sizeof(p)));

         memset(&vc, 0, sizeof(vc));
         vc.vifc_vifi = vc.vifc_threshold = 1;
         vc.vifc_rate_limit = 4096;
         vc.vifc_lcl_addr.s_addr = inet_addr(argv[1]);
         E(setsockopt(mrouter_s4, IPPROTO_IP, MRT_ADD_VIF,
                 (void *)&vc, sizeof(vc)));

         while(1) {
                 char buf[4096]; struct sockaddr_in sender;
                 socklen_t sendsize = sizeof(sender);
                 int size = recvfrom(mrouter_s4, buf, 4096, 0,
                         (struct sockaddr *) &sender, &sendsize);
                 printf ("got %d from %s\n", size,
                         inet_ntoa(sender.sin_addr));
         }
}






[-- Attachment #2: Type: text/html, Size: 3869 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-01-25 21:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-25 17:37 user space multicast routing interface David Lamparter
2004-01-25 19:35 ` jamal
  -- strict thread matches above, loose matches on Subject: below --
2004-01-25 21:35 David Stevens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).