[download area] [source code] [sf project page]
a modern IPv4/IPv6 stack ported to DOS
Copyright © 2015 Mateusz Viste
picotcp4dos is a DOS adaptation of the excellent open-source picoTCP network stack produced by the "Intelligent Systems / Altran" people (www.picotcp.com). picoTCP is a modern, full-featured TCP/IP stack designed for efficiency even on highly constrained hardware platforms. picotcp4dos brings picoTCP into the realms of 16-bit, real mode DOS. It works on any 8086-compatible CPU, and only requires a working packet driver to be loaded. One could say that picotcp4dos is to picoTCP what DJGPP is to gcc.
picotcp4dos is open-source, and just as picoTCP itself, it is released under the GNU GPLv2 license. picotcp4dos is distributed as a C library that allows DOS programmers to use networking operations within their programs. It also comes with its own configuration tools: ipcfg and ping. picotcp4dos is targeted to the 16 bit Open Watcom compiler.
Any program relying on picotcp4dos requires two things:
- a working packet driver, matching the system's network card
- a %PICOTCP% environment variable pointing to picotcp's configuration file (if the file doesn't exist, then the ipcfg tool will create it)
Usage
The ipcfg and ping tools are not discussed here - see their respective manuals. Neither is the picoTCP library - see the picoTCP manual for details.
The picotcp4dos library provides a simple C API with only three functions:
int picoinit(struct pico_device *picodev, int flags)
picoinit() must be called before using any picotcp functions. It will initialize the picoTCP engine, bind it to the systen's DOS packet driver, and configure the network interface with all local configurations (IP address, netmask, gateway, DNS servers...). The IP configuration step can be skipped, if flags is set to PICOINIT_NOCONF. picoinit requires a *picodev argument that must be a pointer to a pico_device structure. It's up to you to allocate this structure (either on the stack, or via a malloc call, or any other way), but you don't need to care about its content.
picoinit() returns 0 on success, non-zero otherwise. See picoinit.h for the list of possible error codes.
void picoquit(struct pico_device *picodev)
picoquit() must be used before your program quits. If skipped, your packet driver might stop responding. picoquit() deallocates all the memory used by picoTCP and detaches itself from the system's packet driver. picoquit() does NOT free the *picodev structure.
char *picover(void)
returns a pointer to the library's version string.
Finally, when linking your program, you must take care to link it to both picotcpl.lib and picodosl.lib.
Credits
This project exists because of other people's will to share their passion. Credits go to:
• Intelligent Systems / Altran (www.picotcp.com)
For producing the picoTCP stack in the first place, their friendly contact and valuable hints they provided during my picoTCP experimentations.
• Michael Brutman (www.brutman.com)
For his extensive documentation about interaction with a DOS packet driver, esp. when dealing with its interrupt routine. This saved me hours, if not days, of wondering why my packet driver interrupt handler kept crashing.