Supporting Multicast in Network driver
freebsd nettest
freebsd_nettest at yahoo.co.in
Wed Jul 19 11:35:18 UTC 2006
Hi,
I would like to support MULTICAST in my network driver. I have define a function set_multi which will extract the Ethernet multicast address and update the corresponding hardware register. This function is called in the SIOCADDMULTI and SIOCDELMULTI ioctl case.
I used following user level program to test the multicast functionality of the driver. When I run the user level program, I could see that the control comes to SIOCADDMULTI ioctl and the correct Ethernet Multicast Mac address is added. After that when I try to ping the Multicast IP address from remote machine, the ping is not responding. Do I need to do any thing extra apart from update the Ethernet Multicast address?
User level program:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>
//#include <net/if.h>
#include <netinet/in.h>
//#include <sys/types.h>
#include <sys/socket.h>
int
main(int argc, char *argv[])
{
struct ip_mreq mreqn;
int s;
struct in_addr ip;
if (argc != 3) {
fprintf(stderr, "usage: %s <dev> <group>\n", argv[0]);
exit(1);
}
if((s = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
perror("socket");
exit(1);
}
memset(&mreqn, 0, sizeof(mreqn));
inet_aton(argv[1], &(mreqn.imr_interface));
/* mreqn.imr_interface = ip; */
if (inet_pton(AF_INET, argv[2], &mreqn.imr_multiaddr) <= 0) {
fprintf(stderr, "%s: \"%s\" invalid group address\n", argv[0],argv[2]);
exit(1);
}
if (setsockopt(s, 0, IP_ADD_MEMBERSHIP,&mreqn,sizeof mreqn) < 0) {
perror("IP_ADD_MEMBERSHIP");
exit(1);
}
printf("joined group %s on %s (pausing...)\n", argv[2], argv[1]);
fflush(stdout);
pause();
}
Thanks
---------------------------------
Find out what India is talking about on Yahoo! Answers India.
Send FREE SMS from New Yahoo! Messenger to Mobile: Download NOW!
More information about the freebsd-net
mailing list