Create a socket that receives promiscuous packets

Viewed 97

My driver is already in promiscuous mode, and I can even log the promiscuous packets within the driver where the destination MAC and IP are something other than my machines MAC and IP. Where I am stuck is creating a socket to pull the packets from the mux layer. I am using vxworks, so I do not have some of the defines from linux, such as ETH_P_ALL etc.Ive played around with my socket creation and I can receive any packet in the application layer thats destined for my machine, regardless of the source. But the application does not receive the promiscuous packets, even though my driver does. Is a socket the only way to connect the mux to my application to receive these promiscuous packets? If so, can anyone shed some light on why my socket doesn't pull the packets that aren't for my MAC/IP? Thank you in advance.

Ive tried using SOCK_RAW, IPPROTO_UDP, IPPROTO_RAW etc, but maybe I just haven't had the right combination.

    std::string newIP = "0.0.0.0";
    descriptor = socket(AF_INET, SOCK_DGRAM, 0);
    if(descriptor == -1)
    {
        reportError(errno, "Couldn't open socket", __PRETTY_FUNCTION__);
        return;
    }

    remoteAddress = makeSockaddr(remotePort);

    if(inet_aton(const_cast<char *>(newIP.c_str()), &remoteAddress.sin_addr) == -1)
    {
        reportError(errno, "Failed to translate address", __PRETTY_FUNCTION__);
        return;
    }
    other = remoteAddress;

    sockaddr_in localAddr = makeSockaddr(localPort);
    if(inet_aton(const_cast<char *>(newIP.c_str()), &localAddr.sin_addr) == -1)
    {
        reportError(errno, "Failed to translate address", __PRETTY_FUNCTION__);
        return;
    }

    if(bind(descriptor, (sockaddr *)&localAddr, sizeof(localAddr)) == -1)
    {
        reportError(errno, "Failed to bind socket", __PRETTY_FUNCTION__);
        return;
    }
0 Answers
Related