It is currently Tue, 19 Aug 2014 23:47:59 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
groups).

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.

Nischal.

int
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)");
        exit(1);
    }

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

    while (TRUE) {
        len = sizeof(addr);
        val = recvfrom(igmp_fd,
                       packet,
                       sizeof(packet),
                       0,
                       (struct sockaddr *)&addr,
                       &len);
        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.

  Bill



 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

9. RAW SOCKET


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