Re: libpcap in Cocoa
Re: libpcap in Cocoa
- Subject: Re: libpcap in Cocoa
- From: Ivan Myrvold <email@hidden>
- Date: Mon, 20 Aug 2001 22:54:46 +0200
Yes, that got it through the compile and link cycle without errors.
Thank you for holding my hand through this! I have now learned new
things about PB that I didn't know was there.
Ivan
On mandag, august 20, 2001, at 10:30 , Todd Heberlein wrote:
On 8/20/01 4:16 AM, "Ivan Myrvold" <email@hidden> wrote:
Here is the complete messages from the compile:
Here is a fragment of what I get from my compiler when compiling
MyController.m
CompileC
/Users/heberlei/Development/Tests/PktReader/build/intermediates/PktReader.
bu
ild/Objects/ppc/MyController.o
...
"-I/usr/local/pcap/include"
...
And here is what I get when I link:
/usr/bin/cc -o
...
"-L/usr/local/pcap/lib"
...
"-arch" "ppc" "-lpcap" "-prebind" "-framework" "Cocoa"
The critical things being the -I/usr/local/pcap/include,
-L/usr/local/pcap/lib, and -lpcap.
I set those by doing the following:
O In the main window I click the "Targets" vertical tab
O In the "Targets" sub-pane that comes up (slides in), I click my app's
name
O In the main window area I click on the "Build Settings" tab.
O I scroll down to the bottom where the "Build Settings" table is, and
I add
the following items in the appropriate Value field:
- HEADER_SEARCH_PATHS /usr/local/pcap/include
- LIBRARY_SEARCH_PATHS /usr/local/pcap/lib
- OTHER_LDFLAGS -lpcap
That is pretty much it.
You should probably get rid of your local copy (the one in your
development
directory) of pcap.h, so you are sure your compiler is picking the one
in
the /usr/local/pcap/include directory (or wherever you like to put it).
Then change the import from quotes to brackets:
#import <pcap.h>
To open a data file of tcpdump packets (generated with tcpdump -w
filename),
use something like
p_tap = pcap_open_offline([filename cString], ebuf);
This might be an easier test than opening live packets. It is usually
nice
to be able to repeat experiments with a test file to make sure you have
the
bugs out.
I believe in old versions of pcap you didn't need to explicitly call
pcap_lookupdev(). If you passed NULL in for the device in
pcap_open_live()
it would automatically call pcap_lookupdev(). This usually worked fine
if
your computer only had one network interface. However... I haven't
tested a
recent version yet for this behavior.
Todd