Blame msdos/readme.dos

Packit 209cc3
libpcap for DOS
Packit 209cc3
---------------
Packit 209cc3
Packit 209cc3
This file contains some notes on building and using libpcap for MS-DOS.
Packit 209cc3
Look in `README' and `pcap.man' for usage and details. These targets are
Packit 209cc3
supported:
Packit 209cc3
Packit 209cc3
 - Borland C 4.0+ small or large model.
Packit 209cc3
 - Metaware HighC 3.1+ with PharLap DOS-extender
Packit 209cc3
 - GNU C 2.7+ with djgpp 2.01+ DOS extender
Packit 209cc3
 - Watcom C 11.x with DOS4GW extender
Packit 209cc3
Packit 209cc3
Note: the files in the libpcap.zip contains short truncated filenames.
Packit 209cc3
  So for djgpp to work with these, disable the use of long file names by
Packit 209cc3
  setting "LFN=n" in the environment. On the other hand, if you get libpcap
Packit 209cc3
  from Github or the official libpcap.tar.gz, some filenames are beyond 8+3.
Packit 209cc3
  In this case set "LFN=y".
Packit 209cc3
Packit 209cc3
Files specific to DOS are pcap-dos.[ch] and the assembly and C files in
Packit 209cc3
the MSDOS sub-directory. Remember to built the libpcap library from the top
Packit 209cc3
install directory. And not from the MSDOS sub-directory.
Packit 209cc3
Packit 209cc3
Note for djgpp users:
Packit 209cc3
  If you got the libpcap from the official site www.tcpdump, then that
Packit 209cc3
  distribution does NOT contain any sources for building 32-bit drivers.
Packit 209cc3
  Instead get the full version at
Packit 209cc3
     http://www.watt-32.net/pcap/libpcap.zip
Packit 209cc3
Packit 209cc3
  and set "USE_32BIT_DRIVERS = 1" in msdos\common.dj.
Packit 209cc3
Packit 209cc3
Packit 209cc3
Packit 209cc3
Requirements
Packit 209cc3
------------
Packit 209cc3
Packit 209cc3
DOS-libpcap currently only works reliably with a real-mode Ethernet packet-
Packit 209cc3
driver. This driver must be installed prior to using any program (e.g.
Packit 209cc3
tcpdump) compiled with libpcap. Work is underway to implement protected-
Packit 209cc3
mode drivers for 32-bit targets (djgpp only). The 3Com 3c509 driver is
Packit 209cc3
working almost perfectly. Due to lack of LAN-cards, I've not had the
Packit 209cc3
opportunity to test other drivers. These 32-bit drivers are modified
Packit 209cc3
Linux drivers.
Packit 209cc3
Packit 209cc3
Packit 209cc3
Required packages
Packit 209cc3
-----------------
Packit 209cc3
Packit 209cc3
The following packages and tools must be present for all targets.
Packit 209cc3
Packit 209cc3
1. Watt-32 tcp/ip library. This library is *not* used to send or
Packit 209cc3
   receive network data. It's mostly used to access the 'hosts'
Packit 209cc3
   file and other <netdb.h> features. Get 'watt32s*.zip' at:
Packit 209cc3
Packit 209cc3
     http://www.watt-32.net
Packit 209cc3
Packit 209cc3
2. Exception handler and disassember library (libexc.a) is needed if
Packit 209cc3
   "USE_EXCEPT = 1" in common.dj. Available at:
Packit 209cc3
Packit 209cc3
     http://www.watt-32.net/misc/exc_dx07.zip
Packit 209cc3
Packit 209cc3
3. Flex & Bison is used to generate parser for the filter handler
Packit 209cc3
   pcap_compile:
Packit 209cc3
     ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/flx254b.zip
Packit 209cc3
     ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/bsn241b.zip
Packit 209cc3
Packit 209cc3
4. NASM assembler v 0.98 or later is required when building djgpp and
Packit 209cc3
   Watcom targets:
Packit 209cc3
     http://www.nasm.us/
Packit 209cc3
Packit 209cc3
5. sed (Stream Editor) is required for doing `make depend'.
Packit 209cc3
   It's available at:
Packit 209cc3
     ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/sed422b.zip
Packit 209cc3
Packit 209cc3
   A touch tool to update the time-stamp of a file. E.g.:
Packit 209cc3
     ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/grep29b.zip
Packit 209cc3
Packit 209cc3
6. For djgpp rm.exe and cp.exe are required. These should already be
Packit 209cc3
   part of your djgpp installation. Also required (experimental at the
Packit 209cc3
   time) for djgpp is DLX 2.91 or later. This tool is for the generation
Packit 209cc3
   of dynamically loadable modules.
Packit 209cc3
Packit 209cc3
Packit 209cc3
Compiling libpcap
Packit 209cc3
-----------------
Packit 209cc3
Packit 209cc3
Follow these steps in building libpcap:
Packit 209cc3
Packit 209cc3
1. Make sure you've installed Watt-32 properly (see it's `INSTALL' file).
Packit 209cc3
   During that installation a environment variable `WATT_ROOT' is set.
Packit 209cc3
   This variable is used for building libpcap also (`WATT_INC' is
Packit 209cc3
   deducted from `WATT_ROOT'). djgpp users should also define environment
Packit 209cc3
   variables `C_INCLUDE_PATH' and `LIBRARY_PATH' to point to the include
Packit 209cc3
   directory and library directory respectively.  E.g. put this in your
Packit 209cc3
   AUTOEXEC.BAT:
Packit 209cc3
     set C_INCLUDE_PATH=c:/net/watt/inc
Packit 209cc3
     set LIBRARY_PATH=c:/net/watt/lib
Packit 209cc3
Packit 209cc3
2. Revise the msdos/common.dj file for your djgpp/gcc installation;
Packit 209cc3
   - change the value of `GCCLIB' to match location of libgcc.a.
Packit 209cc3
   - set `USE_32BIT_DRIVERS = 1' to build 32-bit driver objects.
Packit 209cc3
Packit 209cc3
Packit 209cc3
3. Build pcap by using appropriate makefile. For djgpp, use:
Packit 209cc3
     `make -f msdos/makefile.dj'  (i.e. GNU `make')
Packit 209cc3
Packit 209cc3
   For a Watcom target say:
Packit 209cc3
     `wmake -f msdos\makefile.wc'
Packit 209cc3
Packit 209cc3
   For a Borland target say:
Packit 209cc3
     `maker -f msdos\Makefile pcap_bc.lib'  (Borland's `maker.exe')
Packit 209cc3
Packit 209cc3
   And for a HighC/Pharlap target say:
Packit 209cc3
     `maker -f msdos\Makefile pcap_hc.lib'  (Borland's `maker.exe')
Packit 209cc3
Packit 209cc3
   You might like to change some `CFLAGS' -- only `DEBUG' define currently
Packit 209cc3
   have any effect. It shows a rotating "fan" in upper right corner of
Packit 209cc3
   screen.  Remove `DEBUG' if you don't like it. You could add
Packit 209cc3
   `-fomit-frame-pointer' to `CFLAGS' to speed up the generated code.
Packit 209cc3
   But note, this makes debugging and crash-traceback difficult. Only
Packit 209cc3
   add it if you're fully confident your application is 100% stable.
Packit 209cc3
Packit 209cc3
   Note: Code in `USE_NDIS2' does not work at the moment.
Packit 209cc3
Packit 209cc3
4. The resulting library is put in current directory. There's some
Packit 209cc3
   test-program for `libpcap': `filtertest.exe', `findalldevstest.exe',
Packit 209cc3
     `nonblocktest.exe' and `opentest.exe'.
Packit 209cc3
Packit 209cc3
   But linking the library with `tcpdump' is the ultimate test. DOS/djgpp
Packit 209cc3
   should now hopefully be a supported target. Get the sources at:
Packit 209cc3
     https://www.tcpdump.org/
Packit 209cc3
   or
Packit 209cc3
     https://github.com/the-tcpdump-group/tcpdump/
Packit 209cc3
Packit 209cc3
   (click on the 'Download ZIP' on the right side of that page.)
Packit 209cc3
Packit 209cc3
Packit 209cc3
Extensions to libpcap
Packit 209cc3
---------------------
Packit 209cc3
Packit 209cc3
I've included some extra functions to DOS-libpcap:
Packit 209cc3
Packit 209cc3
  `pcap_config_hook (const char *keyword, const char *value)' :
Packit 209cc3
Packit 209cc3
    Allows an application to set values of internal libpcap variables.
Packit 209cc3
    `keyword' and an associated `value' should be present in the `debug_tab[]'
Packit 209cc3
    array in pcap-dos.c (currently only used to set debug-levels and parameters
Packit 209cc3
    for the 32-bit network drivers.) Thus an application using DOS-libpcap can
Packit 209cc3
    override the default value during it's configure process (see tcpdump's
Packit 209cc3
    msdos/config.c file for an extended example).
Packit 209cc3
Packit 209cc3
  `pcap_set_wait (pcap_t *, void (*)(void), int)' :
Packit 209cc3
Packit 209cc3
    Only effective when reading offline traffic from dump-files.
Packit 209cc3
    Function `pcap_offline_read()' will wait (and optionally yield)
Packit 209cc3
    before printing next packet. This will simulate the pace the packets
Packit 209cc3
    where actually recorded.
Packit 209cc3
Packit 209cc3
Packit 209cc3
Packit 209cc3
Happy sniffing !
Packit 209cc3
Packit 209cc3
Packit 209cc3
Gisle Vanem <gvanem@yahoo.no>
Packit 209cc3
Packit 209cc3
October 1999, 2004, 2006, 2013
Packit 209cc3