Ubuntu Blog – Latest informations

Just another WordPress.com site

Ubuntu 10.10 Pcap

Name Remember Me? Password
Forgot Password?  Ubuntu Linux   Help requests related specifically to Ubuntu, Kubuntu, Xubuntu, or others in the Ubuntu family
Site Navigation Linux Forums Linux Articles Product Showcase Linux Downloads Linux Hosting Free Magazines Job Board IRC Chat RSS Feeds Free Publications

Linux Forum Topics Linux Forums Linux Forums Site News Your Distro Arch LinuxDebian LinuxGentoo LinuxKnoppix LinuxMandriva LinuxMEPIS LinuxMint LinuxPCLinuxOSSlackware LinuxSuSE LinuxRed Hat / Fedora LinuxUbuntu LinuxOther Linux DistributionsEverything BSD Linux Resources Linux Tutorials, HOWTO’s & Reference Material GNU Linux Zone NewbieInstallationApplicationsHardware / PeripheralsDesktop / X-WindowsGaming / Multimedia / EntertainmentLaptops / Netbooks / MinibooksMobile DevicesWireless InternetNetworkingServersKernelProgramming / ScriptingGraphic Arts / Digital ImagingSecurityMiscellaneousWine The Community The Coffee LoungeComments / Feedback / Suggestions Reply   Thread Tools Display Modes Old3 Hours Ago  #1 (permalink) eba Just Joined!  
Join Date: Oct 2010 Posts: 1 Hi ,
I have problems with pcap.h. I have installed the libpcap … but the problems are still there.
Can anyone help me thank you
Here is my code :
Code: #define _BSD_SOURCE 1#include #include #include #include #include #include #include #include “/home/moi/headers.h”#define SNAP_LEN 1518#define NB_PAQUETS 5void callback(u_char *args, const struct _pkthdr *header,const u_char *packet){static int count = 1;const struct ethernet *ethernet; /* entete ethernet */const struct ip *ip; /* entete IP */const struct tcp *tcp; /* entete TCP */const char *payload; /* payload */int size_ethernet = 14;int size_ip;int size_tcp;int size_payload;printf(“\nNombre de paquets captures [%d]\n”, count);count++;ethernet = (struct ethernet*) (packet) ;//Parametres de l’entete IPip = (struct ip*) (packet + size_ethernet);size_ip = ip->ip_hlen*4;printf (“IP source: [%s] –> IP Destination :[%s] “,inet_ntoa(ip->ip_source),inet_ntoa(ip->ip_dest));//Parametres de l’entete TCPtcp = (struct tcp*) (packet + size_ethernet + size_ip);size_tcp = tcp->tcp_hlen*4;printf(“Port Source: [%d] –> Port Destination: [%d]\n”, ntohs(tcp-> tcp_sourceport), ntohs(tcp->tcp_destport));printf (“Drapaux : [FIN=%d] [SYN=%d] [RST=%d] [PSH=%d] [ACK=%d] [URG=%d] \n” , tcp->tcp_fin,tcp->tcp_syn, tcp->tcp_rst, tcp->tcp_psh,tcp->tcp_ack,tcp->tcp_urg);//Affichage de la partie donnee d’un paquetpayload = (u_char *) (packet + size_ethernet + size_ip + size_tcp);size_payload = ntohs(ip->ip_total_length) – (size_ip + size_tcp);printf (“Payload [%d bytes] [%s] “, size_payload, payload);}int main (){char *dev = NULL; /* interface reseau */char errbuf[PCAP_ERRBUF_SIZE]; /* buffer d’erreurs */pcap_t *descr; /* descripteur de paquets */struct bpf_program fp;//char *packet=NULL;bpf_u_int32 maskp; /* masque reseau */bpf_u_int32 netp; /* adresse ip */char filter_app[]= “tcp”; /* filtre * //* Etape 1 : detecter l’interface reseau */dev = “wlan0”; //pcap_lookupdev(errbuf);/* Etape 2 : recuperer les informations reseau */pcap_lookupnet(dev, &netp, &maskp, errbuf);/* Etape 3 : obtenir un descripteur de capture de paquets */descr = pcap_open_live(dev, SNAP_LEN, 1, 0, errbuf);/* Etape 4: compiler la configuration de capture choisie */pcap_compile(descr, &fp, filter_app, 0, maskp);/* Etape 5 : appliquer Ie filtre */pcap_setfilter(descr, &fp);/*Etape 6 : lancer la capture de paquets –> declenchement de la fonction a chaquepaquet recu */pcap_loop(descr, NB_PAQUETS,callback, NULL);/* Etape 7 : fermeture du descripteur de paquets */pcap_close(descr) ;return 0;}
and here are the problems when i compile
Code: main.c:12: warning: ‘struct _pkthdr’ declared inside parameter listmain.c: In function ‘main’:main.c:70: warning: passing argument 3 of ‘pcap_loop’ from incompatible pointer type/usr/include/pcap/pcap.h:297: note: expected ‘pcap_handler’ but argument is of type ‘void (*)(u_char *, const struct _pkthdr *, const u_char *)’/tmp/ccZcy8p7.o: In function `main’:main.c:(.text+0x225): undefined reference to `pcap_lookupnet’main.c:(.text+0x251): undefined reference to `pcap_open_live’main.c:(.text+0x281): undefined reference to `pcap_compile’main.c:(.text+0x295): undefined reference to `pcap_setfilter’main.c:(.text+0x2ba): undefined reference to `pcap_loop’main.c:(.text+0x2c6): undefined reference to `pcap_close’collect2: ld returned 1 exit status}Thank you very much for your help.
I’m waiting for you eba is offline 

Reply With Quote Reply
« Previous Thread|Next Thread »
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)   Thread Tools Show Printable Version Show Printable Version Email this Page Email this Page Display Modes Linear Mode Linear Mode Hybrid Mode Switch to Hybrid Mode Threaded Mode Switch to Threaded Mode
Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are Off Pingbacks are Off Refbacks are Off
Free Magazines Implementing Detailed User-Level Auditing of UNIX & Linux Systems
Enhance regulatory compliance and troubleshooting through detailed auditing, logging and real-time monitoring of UNIX/Linux user activity.
subscribe Linux from Scratch – Receive Your Complimentary eBook NOW!
Linux from Scratch describes the process of creating your own Linux system from scratch from an already installed Linux distribution, using nothing but the source code of software that you need.
subscribe A Complete Beginner’s Manual for Ubuntu 10.04 (Lucid Lynx)
Getting Started with Ubuntu 10.04 (Lucid Lynx) is a comprehensive beginners guide for the Ubuntu operating system; it features comprehensive guides, How Tos and information on anything you need to know after first installing Ubuntu.
subscribe The Incredible Guide to NEW Ubuntu (Karmic Koala)
There are a lot of people still stuck with Windows because it’s the �easier alternative’. Linux is both cheaper and more versatile than Microsoft’s operating system, but the learning curve has frightened off many people.
subscribe The GNU/Linux Advanced Administration
The GNU/Linux systems have reached an important level of maturity, allowing to integrate them in almost any kind of work environment, from a desktop PC to the sever facilities of a big company.
subscribe A Newbie’s Getting Started Guide to Linux
Learn the basics of the Linux operating systems. Get to know what it is all about, and familiarize yourself with the practical side. Basically, if you’re a complete Linux newbie and looking for a quick and easy guide to get you started this is it.
subscribe Run Your Own Web Server Using Linux & Apache – Free 191 Page Preview
Learn about everything you’ll need to build and maintain your Linux servers, and to deploy Web applications to them.

All times are GMT. The time now is 12:30 PM.

Advertise About Us Contact Us Write For Us Archive Top All Areas Articles Downloads Forums Linux Hosting © 2000 – – All Rights Reserved – Property of  MAS Media
Content Relevant URLs by vBSEO 3.3.1


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


This entry was posted on October 12, 2010 by and tagged , .
%d bloggers like this: