watching broadcast behavior by tcpdump in Linux
===

I have a c sample code to receive broatcast packets in RedHat Enterprise Linux5.5 ,
the following is the key source :

    struct ip_mreq {
        struct in_addr imr_multiaddr;    /* IP multicast address of group */
        struct in_addr imr_interface;    /* local IP address of interface */
    } mreq; 

    serv_addr.sin_addr.s_addr = inet_addr("225.0.100.100");
    portno = 10000 ;
    serv_addr.sin_port = htons(portno);
    mreq.imr_multiaddr = serv_addr.sin_addr; 
    mreq.imr_interface.s_addr = INADDR_ANY ;
    //mreq.imr_interface.s_addr = inet_addr("192.168.165.212");
    setsockopt(newsockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
    setsockopt(newsockfd, SOL_SOCKET, SO_REUSEADDR, &set, sizeof(set));


The routing table is :

[root@linux01 ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.172.165.0   *               255.255.255.0   U     0      0        0 eth0

128.110.10.0    *               255.255.255.0   U     0      0        0 eth2

225.0.0.0       192.172.165.212 255.255.0.0     UG    0      0        0 eth0

169.254.0.0     *               255.255.0.0     U     0      0        0 eth0

default         128.110.10.254  0.0.0.0         UG    0      0        0 eth2



I  use tcpdump -i eth0 -nn   to watch  if  join broadcast group succefully , 

    mreq.imr_interface.s_addr = INADDR_ANY ;
    //mreq.imr_interface.s_addr = inet_addr("192.168.165.212");
will showes :

16:14:24.322672 IP 192.172.165.212 > 225.0.100.100: igmp v2 report 225.0.100.100

    mreq.imr_interface.s_addr = INADDR_ANY ;
    //mreq.imr_interface.s_addr = inet_addr("192.168.165.212");

this won't have igmp v2 report messages !!

My question is :  Why INADDR_ANY works , but not inet_addr("192.168.165.212");

Anything I missed ?


eth0 inet addr:192.172.165.212  Bcast:192.172.165.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth2 inet addr:128.110.10.69  Bcast:128.110.10.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1





