SOCK_RAW problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hallo,
I write a small program in order to catch all packet
at the physical layer (see below). I have the problem
that i cannot see the contain of packet that i caugth.
The printf() function returns the same Hex data.

Can someone tell me how can i catch all the all packet
and how can i examine the contain of the packet i've
caugth ?

include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <linux/if_packet.h>
#include <linux/if_ether.h>
#include <features.h>
#include <netinet/in.h>
#include <sys/ioctl.h>


int main(int argc, char **argv)
{
   int sockfd;
   char buffer[1024];
   struct sockaddr_in from;
   int length, recv_ret;

   if ((sockfd = socket(PF_PACKET, SOCK_DGRAM,        
         htons(ETH_P_ALL))) < 0)
   {
      perror("socket");
      exit(-1);
   }

   while ((recv_ret = recvfrom(sockfd, (void *)buffer,
   sizeof(buffer), 0, (struct sockaddr *)0, 0)) >= 0) 
   {
      if (recv_ret == 0)
      printf("The last packet \n");

      printf("recv_ret = %d\n", recv_ret) ;
      printf("%x\n", (char *)buffer);
   }
   if (recv_ret < 0) {
   perror("recvfrom");
   exit(-1);
   }
	
   return 0;
}


__________________________________________________________________
Do You Yahoo!?
Gesendet von Yahoo! Mail - http://mail.yahoo.de
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux