Search code examples
clinuxarp

ARP message how to get IP


I need to know the IP adress of the sender of the ARP reply.I tried using recvfrom but I can't get the IP address from it.Thank you for the help.

I have some child processes that each send a ARP requst to an IP adress.The problem is that the response comes to all the children because the socket is raw so I need somehow to know for what child the response arrived.I tried

struct sockaddr_ll linkLayerAddr;
char buf[32];
int sockaddr_len=sizeof(linkLayerAddr);
memset(&linkLayerAddr,0,sizeof(linkLayerAddr));
fcntl(sock,F_SETFL,O_NONBLOCK);
nanosleep(&time1,NULL);

if(recvfrom(sock,buf,sizeof(buf),0,(struct sockaddr*)&linkLayerAddr,&sockaddr_len)==-1){

info.status=0; 
}//se primeste raspunsul
else{
info.status=1;

}

I wait 800000 nanosecond for a reply and I want to know for what IP the message came.With recvfrom i can only get the MAC adress.


Solution

  • Emile, i have already replied to the same question.

    Click here:

    Same question

    if you don't like the answer, let's discuss it, but avoid opening new question with the same identical topic