It is currently Sun, 26 Feb 2017 00:55:30 GMT

Author Message
 Raw sockets with IGMP

I am trying to use raw sockets to receive all IGMP packets coming in on
any interface on my sun workstation. I am running sunos 4.1.4 with multicast
extensions. Normally you would have join a group to get multicast traffic
directed to that group. However in this case I need to get IGMP packets sent
to any multicast address (there does not seem to be any way to join all

The code i have follows. I am just trying to open a raw socket with
the protocol set to IGMP. I assumed that the kernel would give me any packets
that it received with the protocol set to IGMP. However this program does not
get anything. I can see IGMP packets coming in using tcpdump. Also I have set
the promisc and allmulti flags on all the interfaces. Do i need to do any
ioctls to get this to work. Thanks for your ideas/suggetions.


main(int argc, char *argv[])
    char packet[BUFSIZE];
    int val, igmp_fd;
    int len;
    char *ptr;
    struct sockaddr_in addr;
    unsigned char loop;
    unsigned char mrt;

    /* Create a igmp socket */
    if ((igmp_fd = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP)) < 0)
        perror("socket(AF_INET, SOCK_RAW)");

     * Set non-blocking I/O on the descriptor
    if (fcntl(igmp_fd, F_SETFL, FNDELAY) < 0)
        perror("fcntl(F_SETFL, O_NONBLOCK)");

    while (TRUE) {
        len = sizeof(addr);
        val = recvfrom(igmp_fd,
                       (struct sockaddr *)&addr,
        if (val > 0) {
            printf("received %d bytes from %s\n",
                   len, inet_ntoa(addr.sin_addr));

 Sun, 09 May 1999 03:00:00 GMT   
 Raw sockets with IGMP

The only way to do this is to become a multicast router.  You have to

int one = 1;
setsockopt(s, IPPROTO_IP, MRT_INIT, &one, sizeof(one));

and then do a

setsockopt(s, IPPROTO_IP, MRT_ADD_VIF, &vif, sizeof(vif));

for each interface on which you want to hear all IGMP.

You will then have to handle the kernel's requests to install multicast
cache entries for all multicast traffic.  This is probably more than you
want to deal with, unless you're writing a multicast router.


 Fri, 14 May 1999 03:00:00 GMT   
   [ 2 post ] 

Similar Threads

1. raw IP and raw ICMP socket???

2. Information of the RAW socket interface for Berkely sockets

3. Raw socket link indication

4. raw sockets & security in Linux

5. Getting/setting eth frame interface for raw socket

6. raw sockets and UDP broadcast : a strange phenomenon

7. wpa_supplicant only works with a non_blocking raw socket

8. raw socket question


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software