Hi,
I am trying to use raw socket interface to caputre packets on wire.
I am getting only first 96 bytes of packets. Wondering is there any
ioctl or setsocket option to set packet length.
Here is the code snippet ...
int recvSize = 8192;
if ( (sock=socket(PF_INET, SOCK_PACKET,
htons(ETH_P_IP)))<0) {
perror("socket");
exit(1);
}
/* Set the network card in promiscuos mode */
strncpy(ethreq.ifr_name,"eth0",IFNAMSIZ);
if (ioctl(sock,SIOCGIFFLAGS,ðreq)==-1) {
perror("ioctl");
close(sock);
exit(1);
}
ethreq.ifr_flags|=IFF_PROMISC;
if (ioctl(sock,SIOCSIFFLAGS,ðreq)==-1) {
perror("ioctl");
close(sock);
exit(1);
}
if(setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
&recvSize, sizeof(recvSize))<0){
perror("setsockopt");
close(sock);
exit(1);
}
while (1) {
printf("----------\n");
n = recvfrom(sock,buffer,2048,0,NULL,NULL);
printf("%d bytes read\n",n);
}
}
Thanks,
Satish
|