Reputation: 278
I am attempting to retrieve the ip of the sender of a multicast packet as well as the destination address/interface to which the multicast packet was sent.
When receiving a multicast packet via recvfrom(SOCKET s, char *buf, int len, int flags, sockaddr *from, int *fromlen)
returns the senders IP via the from parameter, however no information is provided as to the address which the packet is being sent to.
In order to overcome this shortcoming of recvfrom()
I have attempted to use WSARecvMsg()
which supposedly provides all the information required. Answers to other questions all seem very confident that all the information required can be acquired using (at least the *nix) recvmsg method.
When receiving a packet with WSARecvMsg()
and examining the IN_PKTINFO
structure, it contains the following:
typedef struct in_pktinfo {
IN_ADDR ipi_addr;
ULONG ipi_ifindex;
} IN_PKTINFO, *PIN_PKTINFO
And from the documentation the member ipi_addr
is the destination address and ipi_ifindex
is the interface on which it was received.
From the above it seems as if WSARecvMsg()
can only provide the other half (i.e. the destination) but not the senders information.
Am I missing something? Or is there another way to get the information I want, preferably without having to resort to raw sockets?
Upvotes: 1
Views: 183