From: Peter Enderborg <pme@ufh.se>
To: linux kermel <linux-kernel@vger.kernel.org>,
linux net <linux-net@vger.kernel.org>
Subject: Usage of SIOCADDMULTI ?
Date: Tue, 28 Aug 2001 22:56:10 +0200 [thread overview]
Message-ID: <3B8C056A.A3114FE1@ufh.se> (raw)
Im trying to grab some ethernet multicasts. And the ioctl that should do
that is SIOCADDMULTI.
But I can't get it to work. And I have not found any who use that from
userlevel so
this is my guess who to do it. (I don't work but dont gives any error
message)
#include <stdio.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <errno.h>
#include <sys/un.h>
int main()
{
int i,res,sock,from_len;
struct sockaddr_in eb_addr,from_addr;
char databuf[1500];
struct ifreq req;
if((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
{
printf("%s",strerror(errno));
exit(1);
}
eb_addr.sin_family = AF_INET;
/* eb_addr.sin_family = AF_UNSPEC; */
eb_addr.sin_addr.s_addr = inet_addr("0.0.0.0");
eb_addr.sin_port = htons(4711);
for (i = 0; i < 8; ++i)
eb_addr.sin_zero[i] = 0;
if(bind(sock,(struct sockaddr*) &eb_addr, sizeof(struct sockaddr_in))
== -1)
{
printf("Unable to bind the socket\n");
exit(1);
}
strcpy(req.ifr_name,"eth0");
req.ifr_ifru.ifru_addr.sa_data[0] = 0x01;
req.ifr_ifru.ifru_addr.sa_data[1] = 0x80;
req.ifr_ifru.ifru_addr.sa_data[2] = 0xc2;
req.ifr_ifru.ifru_addr.sa_data[3] = 0x00;
req.ifr_ifru.ifru_addr.sa_data[4] = 0x00;
req.ifr_ifru.ifru_addr.sa_data[5] = 0x00;
/* req.ifr_flags = IFF_ALLMULTI; | IFF_PROMISC; */
res = ioctl(sock,SIOCADDMULTI,&req);
if(res == -1)
{
printf("%s",strerror(errno));
exit(1);
}
while (1)
{
printf("enter recvfrom\n");
res = recvfrom(sock, databuf, sizeof(databuf), 0,(struct
sockaddr*) &from_addr, &from_len);
printf("Received %d bytes\n", res );
}
return 0;
}
This on a 2.4.9 kernel on SMP P2. Im trying to grab some 802 bridge
packets and I see them
with tcpdump but that is using a other interface. (BPF or what ever) Any
ideas whats wrong ?
next reply other threads:[~2001-08-28 20:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-28 20:56 Peter Enderborg [this message]
2001-08-29 8:18 ` Usage of SIOCADDMULTI ? Terje Eggestad
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=3B8C056A.A3114FE1@ufh.se \
--to=pme@ufh.se \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-net@vger.kernel.org \
/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