CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Mar 2017
    Posts
    9

    Receiving the Multicast Listener Report

    Hello.
    I'd like to receive the multicast listener report that is sent as a reply to the Multicast listener query. My code however doesn't accept anything. I'd really appreciate any help.

    Here is the wireshark screenshot. I am sending the query, getting the reply but cannot catch it with my program. At least one of them would be nice.

    Code:
    //...
    //creating the socket
    int ndpResFdLMNR = socket(AF_INET6, SOCK_RAW, IPPROTO_RAW);
    	if (ndpResFdLMNR == -1)
    	{
    		std::cerr << "Cannot create the listening socket!";
    		return FAIL_EXIT;
    	}
    
    //not sure if I have to do this but joining the ff02::c mcast group :-)
    struct ipv6_mreq mreq;
    mreq.ipv6mr_interface = if_nametoindex(interfaceName);
    inet_pton(AF_INET6, "ff02::c",&(mreq.ipv6mr_multiaddr));	
    setsockopt(ndpResFdLMNR, IPPROTO_RAW, IPV6_JOIN_GROUP, &mreq, sizeof(mreq)); //EDIT: I noticed that IPPROTO_RAW returns error here, changed to IPPROTO_IPV6 but still not working
    
    //setting the timeout
    setsockopt(ndpResFdLMNR, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
    
    //setting the reuse
    int one = 1;
    setsockopt(ndpResFdLMNR,SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
    
    //binding
    struct sockaddr_in6 sa6LMNR;
    sa6LMNR.sin6_family = AF_INET6;
    sa6LMNR.sin6_port = 0;
    sa6LMNR.sin6_flowinfo = 0;
    sa6LMNR.sin6_scope_id = 0; //EDIT2: Also tried to put if_nametoindex(interfaceName) here
    inet_pton(AF_INET6, "ff02::c",&(sa6LMNR.sin6_addr));
    bind(ndpResFdLMNR, (struct sockaddr*)&sa6LMNR, sizeof(sa6LMNR));
    
    	while (1)
    	{		
    		retVal6 = recvfrom(ndpResFdLMNR, &r, sizeof(lqPck), 0, (struct sockaddr*)&sourceRes, &len);
    		if (retVal6 < 0)
    			break;
    		addIPv6(sourceRes);
    	}
    I am sorry if I'm missing something basic but I don't know where to look anymore . Have a nice day!
    Last edited by Hitokage; March 5th, 2017 at 06:01 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured