Hello!!
I have a problem compiling my program.
It has warnings, and it doesn't make any link for pcap_open_offline and other pcap function. I have no lib missing error or other. So I d'ont understand.
complie command : gcc file.c
Here is my code :
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <pcap.h>
#include <pcap-bpf.h>
#include <netinet/in.h>
#include <net/ethernet.h>
#include <netinet/ether.h>
#include <netinet/ip.h>
int main(int argn, char **argv)
{
pcap_t *desc;
const u_char *packet_1;
const u_char *packet_2;
struct pcap_pkthdr hdr;
char errbuf[PCAP_ERRBUF_SIZE];
struct bpf_program bp ;
char * buff =NULL;
struct ethhdr *EtherHdr_1;
struct ethhdr *EtherHdr_2;
bpf_u_int32 netmask=32;
FILE *fp=fopen("./fichier/adresses_ip_mac.htm","w");
if(fp==NULL)
printf("Ouverture de fichier impossible\n");
desc = pcap_open_offline("./fichier/fichiertest.pcap", errbuf);
if (desc == NULL)
printf("pcap_open_offline: %s\n", errbuf), exit(2);
packet_1 = pcap_next(desc,&hdr);
EtherHdr_1 = (struct etherhdr *)packet_1;
packet_2 = packet_1;
EtherHdr_2 = (struct etherhdr *)packet_2;
while (EtherHdr_1->h_source == EtherHdr_2->h_source && (packet_2=pcap_next(desc,&hdr)))
{
EtherHdr_2 = (struct etherhdr *)packet_2;
}
printf("Adresse Mac 1 :%s\n", ether_ntoa((struct ether_addr *)EtherHdr_1->h_dest));
fclose(fp);
pcap_close(desc);
system ("pause");
}
Solution : gcc file.c -o file -lpcap
If you have ideas. I take it.