Find the answer to your Linux question:
Results 1 to 6 of 6
hello, we need to modify the existing libpcap library to include nanosecond resolution. We know what are the changes to be done. We just need to know how to integrate ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2010
    Posts
    7

    related to libpcap


    hello,
    we need to modify the existing libpcap library to include nanosecond resolution.
    We know what are the changes to be done. We just need to know how to integrate these changes in existing libpcap? how should we proceed?


    ---Eagerly waiting for reply.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,453
    I assume you want to contribute these changes back into the mainline library code? You will need to contact the library maintainers. Here is the web site for that: TCPDUMP/LIBPCAP public repository
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Dec 2010
    Posts
    7

    Libpcap

    Thanks for you reply.
    We browsed through the source code of libpcap and found some API's for sending packets over the network(eg: pcap_inject(), pcap_sendpacket() ...) .We tried using them but the code is not working. Could you please suggest some other API's or libraries to generate raw packets to be sent onto the network?

    We also tried using raw socket API's to send and receive raw sockets but were not
    successful.


    Eagerly waiting for the reply.....

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,453
    Quote Originally Posted by begroup View Post
    Thanks for you reply.
    We browsed through the source code of libpcap and found some API's for sending packets over the network(eg: pcap_inject(), pcap_sendpacket() ...) .We tried using them but the code is not working. Could you please suggest some other API's or libraries to generate raw packets to be sent onto the network?

    We also tried using raw socket API's to send and receive raw sockets but were not
    successful.


    Eagerly waiting for the reply.....
    Given your results, I have to think that you are doing something wrong. The libpcap is a widely used library. While like all software, it may have some issues, the fact that nothing seems to be working for you at all is indicative of a problem at your end. Please provide the code that you are using so we can see what may be the problem. Also, provide full system specs, such as operating system distribution+version, libpcap version, etc.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  5. #5
    Just Joined!
    Join Date
    Dec 2010
    Posts
    7

    libpcap

    We are using libpcap v1.1.1, ubuntu 10.04 with the kernel 2.6.29.We are using Realtek NIC 8139 here is the code using libpcap which is not working. It is giving error in inject function..


    #include<stdio.h>
    #include<stdlib.h>
    #include<pcap.h>
    #include<netinet/in.h>
    #include<arpa/inet.h>
    #include<netinet/if_ether.h>
    #include <linux/if_packet.h>
    #include <linux/if_ether.h>
    #include<string.h>
    #include<sys/types.h>


    int main()
    {
    char *dev;
    char erbuf[PCAP_ERRBUF_SIZE];
    pcap_t *descr;
    const u_char * packet;
    struct pcap_pkthdr hdr;
    struct ether_header * eptr;
    char *buffer=(char*)malloc(ETH_FRAME_LEN);
    unsigned char *etherhead=buffer;
    struct ethhdr *eh=(struct ethhdr*)etherhead;
    unsigned char *data=buffer+14;
    unsigned char src_mac[6]={//Source MAC address};
    unsigned char dest_mac[6]={//Destination MAC address};

    //Constructing ethernet frame
    memcpy(buffer,dest_mac,ETH_ALEN);
    memcpy((buffer+ETH_ALEN),src_mac,ETH_ALEN);
    eh->h_proto=0x00;

    //strcpy(data,"HELLO"); data in ethernet frame

    dev=pcap_lookupdev(erbuf);
    if(dev==NULL)
    {
    printf("\n%s\n\n",erbuf);
    exit(1);
    }
    else
    printf("\n\n%s",dev);

    descr=pcap_open_live(dev,BUFSIZ,0,-1,erbuf);

    if(descr==NULL)
    {
    printf("\nCannot open:%s",erbuf);
    exit(1);
    }

    int s=sizeof(buffer);
    printf("\nS:%lu\n",s);
    printf("\nBuffer:%.2x\n",*buffer);
    for(j=0;j<14;j++)
    {
    printf("%.2x ",buffer[j]);

    }
    int i=pcap_sendpacket(descr,buffer,s);
    if(i==-1)
    {
    printf("\nError in inject function!!!\n");
    printf("\nerror: %s",*(descr).errbuf);
    exit(1);
    }
    return 0;
    }
    eagerly waiting for your reply.....

  6. #6
    Just Joined!
    Join Date
    Oct 2011
    Posts
    1
    I am stuck at a similar problem. I am able to send a packet using pcap_inject(), but I am not getting any reply back from the server(say google.com). In my case, the packet is not a dummy packet, but a real one.
    Has anyone successfully used pcap_inject to send packets on the network and got the response back from the respective server??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •