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