From: David Lamparter <equinox@diac24.net>
To: netdev@oss.sgi.com
Subject: user space multicast routing interface
Date: Sun, 25 Jan 2004 18:37:13 +0100 [thread overview]
Message-ID: <4013FEC9.1070900@diac24.net> (raw)
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));
}
}
next reply other threads:[~2004-01-25 17:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-25 17:37 David Lamparter [this message]
2004-01-25 19:35 ` user space multicast routing interface jamal
-- strict thread matches above, loose matches on Subject: below --
2004-01-25 21:35 David Stevens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4013FEC9.1070900@diac24.net \
--to=equinox@diac24.net \
--cc=netdev@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).