readme.dos 6.0 KB

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