hallo,
# nm libpcap.a | grep -i datalink
and see if it is compiled in (exported[?])
it may not be in your pcap library.
:)
for example, pcap_set_datalink is not on my debian.
-alexm
14:49 28/11/2003
On Fri, 28 Nov 2003, Arthur Chen wrote:
> Hi all,
> now I have found part of the error.
> 1) my system is redhat 9.0, and I installed pcap with these steps:
> root# ./configure
> root# ./make
> root# ./make install
> with these steps, in the Makefile's item 'install:', it showed out these
> things to do
> (a) copy libpcap.a to /usr/local/lib,
> (b)copy pcap.h, pcap-named.h pcap-bpf.h to /usr/local/include
> 2) It seems the 'configure' shell is wrong,
> (a) copy libpcap.a to /usr/local/lib,----this should be copy to
> /usr/lib
> (b)copy pcap.h, pcap-named.h pcap-bpf.h to
> /usr/local/include-----this is wrong, should be copy to /usr/include
>
> 3)But after I copied them to the correct place, I still can not compile, the
> error is still be:
> "undefined reference to 'pcap_set_datalink'"
> I have noticed that under the directory /usr/lib, there are several shared
> library files called libpcap.so,
> libpcap.so.0,libpcap.so.0.6,libpcap.so.0.6.2 , they might be the key
> problem---because when I make and instal the new PCAP library, I didn't see
> that there were any of these files be createdl:
>
> ----anybody help me!
>
>
>
>
>
>
> >From: "Arthur Chen" <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: [tcpdump-workers] small program compile failed when using pcap,
> >"undefined reference to `pcap_set"
> >Date: Thu, 27 Nov 2003 23:00:02 +0000
> >
> >this small trying program can not compile, It said undefined reference to
> >`pcap_set_datalink', but this function prototype was included in pcap.h and
> >was implemented in pcap.c! Any idea?
> >
> > This is the error message:
> >
> >[root@ arthur]# gcc -lpcap -o pcap_test.o pcap_test.c
> >/tmp/ccViVFVU.o(.text+0xbb): In function `main':
> >: undefined reference to `pcap_set_datalink'
> >collect2: ld returned 1 exit status
> >[root@ arthur]#
> >
> >
> > the source file is:
> >
> >#include <stdio.h>
> >#include <pcap.h>
> >//#include <pcap_int.h>
> >extern int pcap_set_datalink(pcap_t *, int);
> > int main()
> > {
> > pcap_t *handle; /* Session handle */
> >// char *dev; /* The device to sniff on */
> > char errbuf[PCAP_ERRBUF_SIZE]; /* Error string */
> > struct bpf_program filter; /* The compiled filter */
> >// char filter_app[] = "port 23"; /* The filter expression */
> > char filter_app[] = "ether[11]=0xcb || (ether[5]=0xcb)";
> > bpf_u_int32 mask; /* Our netmask */
> > bpf_u_int32 net; /* Our IP */
> > struct pcap_pkthdr header; /* The header that pcap gives
> >us */
> > const u_char *packet; /* The actual packet */
> > /* Define the device */
> >// dev = pcap_lookupdev(errbuf);
> >char dev[]="eth0";
> >int errCode=0;
> >
> >bpf_u_int32 counter=0;
> >printf("the dev=%s\n",dev);
> >
> > /* Find the properties for the device */
> > pcap_lookupnet(dev, &net, &mask, errbuf);
> > /* Open the session in promiscuous mode */
> > handle = pcap_open_live(dev, BUFSIZ, 1, 0, errbuf);
> > //printf("The data link is %d",(pcap_datalink(handle)));
> >pcap_set_datalink(handle, DLT_PPP_ETHER);
> >
> >if (errCode)
> > printf("Set data link failed, error code=%d",errCode);
> >else
> > printf("Set data link succeeded, ");
> >
> > /* Compile and apply the filter */
> >// pcap_compile(handle, &filter, filter_app, 0, net);
> > pcap_compile(handle, &filter, filter_app, 0, net);
> > pcap_setfilter(handle, &filter);
> > /* Grab a packet */
> >
> > packet = pcap_next(handle, &header);
> > /* Print its length */
> > printf("Jacked a packet with length of [%d]\n", header.len);
> > /* And close the session */
> >for (; counter<header.len; counter++)
> > printf("%3x", *(packet+counter));
> >
> > pcap_close(handle);
> >
> > return(0);
> > }
> >
> >_________________________________________________________________
> >Help STOP SPAM with the new MSN 8 and get 2 months FREE*
> >http://join.msn.com/?page=features/junkmail
> >
> >-
> >This is the TCPDUMP workers list. It is archived at
> >http://www.tcpdump.org/lists/workers/index.html
> >To unsubscribe use
> >mailto:[EMAIL PROTECTED]
>
> _________________________________________________________________
> The new MSN 8: advanced junk mail protection and 2 months FREE*
> http://join.msn.com/?page=features/junkmail
>
> -
> This is the TCPDUMP workers list. It is archived at
> http://www.tcpdump.org/lists/workers/index.html
> To unsubscribe use mailto:[EMAIL PROTECTED]
>
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:[EMAIL PROTECTED]