Results 1 to 2 of 2

Thread: Compile problem

  1. #1
    Join Date
    Mar 2008

    Default Compile problem


    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 :

    #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");
    		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));
    	system ("pause");

    Solution : gcc file.c -o file -lpcap

    If you have ideas. I take it.

  2. #2
    Just burned his ISO luckyr13's Avatar
    Join Date
    Jan 2008

    Default mmm

    If u can tell me what are the compile problems (what kind of warnings do u have?) that u have maybe i could help a little more ... actually u post after your code:

    Solution : gcc file.c -o file -lpcap
    This means that you already find a solution? what do you want the programs do? ... i suggest the next links anyway... maybe could help:

Posting Permissions

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