matt31
asked on
Raw socket promiscuous mode
hi,
i have developped a piece of code that capture packets with raw sockets (winsock). But i want to switch reception mode between "normal" mode and promiscuous mode (using WSAIoctl with SIO_RCVALL_MCAST or SIO_RCVALL option). Is it possible to do that when the socket is already binded? i've already tried this solution:
...
DWORD dwCode = RCVALL_OFF,
dwValue = 0,
dwBytes = 0;
// put off precedent sock option
status = WSAIoctl(sockRaw_, SIO_RCVALL_MCAST, &dwCode, sizeof(dwCode), NULL, 0, &dwBytes, NULL, NULL);
if (status == SOCKET_ERROR)
TRACE("0x%x: SetPromiscuous(SIO_RCVALL_ MCAST): WSAIoctl() failed: %d", GetCurrentThreadId(), WSAGetLastError());
dwCode = RCVALL_ON;
// set new sock option
status = WSAIoctl(sockRaw_, SIO_RCVALL, &dwCode, sizeof(dwCode), &dwValue, sizeof(dwValue), &dwBytes, NULL, NULL);
if (status == SOCKET_ERROR)
TRACE("0x%x: SetPromiscuous(SIO_RCVALL) : WSAIoctl() failed: %d", GetCurrentThreadId(), WSAGetLastError());
...
It makes no error but does not work. i still receive mutlicast packets. Any suggestions??Is there an another way to do that?
i have developped a piece of code that capture packets with raw sockets (winsock). But i want to switch reception mode between "normal" mode and promiscuous mode (using WSAIoctl with SIO_RCVALL_MCAST or SIO_RCVALL option). Is it possible to do that when the socket is already binded? i've already tried this solution:
...
DWORD dwCode = RCVALL_OFF,
dwValue = 0,
dwBytes = 0;
// put off precedent sock option
status = WSAIoctl(sockRaw_, SIO_RCVALL_MCAST, &dwCode, sizeof(dwCode), NULL, 0, &dwBytes, NULL, NULL);
if (status == SOCKET_ERROR)
TRACE("0x%x: SetPromiscuous(SIO_RCVALL_
dwCode = RCVALL_ON;
// set new sock option
status = WSAIoctl(sockRaw_, SIO_RCVALL, &dwCode, sizeof(dwCode), &dwValue, sizeof(dwValue), &dwBytes, NULL, NULL);
if (status == SOCKET_ERROR)
TRACE("0x%x: SetPromiscuous(SIO_RCVALL)
...
It makes no error but does not work. i still receive mutlicast packets. Any suggestions??Is there an another way to do that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No comment has been added lately, so it's time to clean up this TA. I will
leave a recommendation in the Cleanup topic area that this question is:
Answered: Points to bkrahmer: Grade A
Please leave any comments here within the next seven days.
Experts: Silence means you don't care. Grading recommendations are made in light
of the posted grading guidlines (https://www.experts-exchange.com/help.jsp#hi73).
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
-bcl (bcladd)
EE Cleanup Volunteer
leave a recommendation in the Cleanup topic area that this question is:
Answered: Points to bkrahmer: Grade A
Please leave any comments here within the next seven days.
Experts: Silence means you don't care. Grading recommendations are made in light
of the posted grading guidlines (https://www.experts-exchange.com/help.jsp#hi73).
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
-bcl (bcladd)
EE Cleanup Volunteer
ASKER
(FYI: in practical SIO_RCVALL_MCAST also let you receive packets destined to your own IP...)