?
Solved

Raw socket promiscuous mode

Posted on 2003-02-26
3
Medium Priority
?
2,532 Views
Last Modified: 2007-12-19
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?
0
Comment
Question by:matt31
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
bkrahmer earned 153 total points
ID: 8026769
I don't know a lot about multicast packets, but what makes you think it isn't working properly?  MSDN states that SIO_RCVALL_MCAST will let you receive all mcast packets destined for the range of 224.0.0.0 to 239.255.255.255.  Are packets that you are seeing in this range?  Personally, I wouldn't worry about it.  If I wasn't interested in those packets, I would drop them and move on.
brian
0
 

Author Comment

by:matt31
ID: 8026876
ok thanks but it works really fine now, it was not due to my code but to an option on my network adapter card which wasn't set properly.
(FYI: in practical SIO_RCVALL_MCAST also let you receive packets destined to your own IP...)
0
 
LVL 11

Expert Comment

by:bcladd
ID: 9846901
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 (http://www.experts-exchange.com/help.jsp#hi73).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

-bcl (bcladd)
EE Cleanup Volunteer
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question