Raw socket captures only first 96 bytes of packet

Discussion in 'Linux Networking' started by satishamara, Aug 8, 2005.

  1. satishamara

    satishamara Guest

    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,&ethreq)==-1) {
    perror("ioctl");
    close(sock);
    exit(1);
    }
    ethreq.ifr_flags|=IFF_PROMISC;
    if (ioctl(sock,SIOCSIFFLAGS,&ethreq)==-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
     
    satishamara, Aug 8, 2005
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.