aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Richardson <mcr@sandelman.ca>2023-07-26 15:16:13 -0400
committerMichael Richardson <mcr@sandelman.ca>2023-07-26 15:16:13 -0400
commitf4f6feec8497ab25ac2f4f62da32d18d2ed464fb (patch)
tree6d1bee5cef49cda5020c187e5859da08997e7db6
parentb1b1895e55cf2406a7d4f66333a45d7379d43844 (diff)
removed DOS pcap driver, and Makefile aspects that configured it
-rw-r--r--INSTALL.md4
-rw-r--r--Makefile.in11
-rw-r--r--pcap-dos.c1550
-rw-r--r--pcap-dos.h225
4 files changed, 1 insertions, 1789 deletions
diff --git a/INSTALL.md b/INSTALL.md
index 10836eba..f3986b4e 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -245,7 +245,6 @@ in `/usr/include/sys/dlpi.h`, and find the corresponding value.
llc.h - 802.2 LLC SAP definitions
missing/* - replacements for missing library functions
mkdep - construct Makefile dependency list
- msdos/* - drivers for MS-DOS capture support
nametoaddr.c - hostname to address routines
nametoaddr.h - hostname to address prototypes
nlpid.h - OSI network layer protocol identifier definitions
@@ -281,8 +280,7 @@ in `/usr/include/sys/dlpi.h`, and find the corresponding value.
pcap-dbus.c - D-Bus capture support
pcap-dbus.h - D-Bus capture support
pcap-dlpi.c - Data Link Provider Interface support
- pcap-dos.c - MS-DOS capture support
- pcap-dos.h - headers for MS-DOS capture support
+ pcap-dos.c - removed in 2023, after libpcap 1.9
pcap-dpdk.c - DPDK device support
pcap-dpdk.h - DPDK device support
pcap-enet.c - enet support
diff --git a/Makefile.in b/Makefile.in
index da00e79f..b5025c33 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -296,15 +296,6 @@ EXTRA_DIST = \
missing/strtok_r.c \
missing/win_asprintf.c \
mkdep \
- msdos/bin2c.c \
- msdos/makefile \
- msdos/makefile.dj \
- msdos/makefile.wc \
- msdos/pkt_rx0.asm \
- msdos/pkt_rx1.s \
- msdos/pktdrvr.c \
- msdos/pktdrvr.h \
- msdos/readme.dos \
nomkdep \
org.tcpdump.chmod_bpf.plist \
pcap-airpcap.c \
@@ -321,8 +312,6 @@ EXTRA_DIST = \
pcap-dbus.h \
pcap-dll.rc \
pcap-dlpi.c \
- pcap-dos.c \
- pcap-dos.h \
pcap-dpdk.c \
pcap-dpdk.h \
pcap-enet.c \
diff --git a/pcap-dos.c b/pcap-dos.c
deleted file mode 100644
index 5093c5f0..00000000
--- a/pcap-dos.c
+++ /dev/null
@@ -1,1550 +0,0 @@
-/*
- * This file is part of DOS-libpcap
- * Ported to DOS/DOSX by G. Vanem <gvanem@yahoo.no>
- *
- * pcap-dos.c: Interface to PKTDRVR, NDIS2 and 32-bit pmode
- * network drivers.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <float.h>
-#include <fcntl.h>
-#include <limits.h> /* for INT_MAX */
-#include <io.h>
-
-#if defined(USE_32BIT_DRIVERS)
- #include "msdos/pm_drvr/pmdrvr.h"
- #include "msdos/pm_drvr/pci.h"
- #include "msdos/pm_drvr/bios32.h"
- #include "msdos/pm_drvr/module.h"
- #include "msdos/pm_drvr/3c501.h"
- #include "msdos/pm_drvr/3c503.h"
- #include "msdos/pm_drvr/3c509.h"
- #include "msdos/pm_drvr/3c59x.h"
- #include "msdos/pm_drvr/3c515.h"
- #include "msdos/pm_drvr/3c90x.h"
- #include "msdos/pm_drvr/3c575_cb.h"
- #include "msdos/pm_drvr/ne.h"
- #include "msdos/pm_drvr/wd.h"
- #include "msdos/pm_drvr/accton.h"
- #include "msdos/pm_drvr/cs89x0.h"
- #include "msdos/pm_drvr/rtl8139.h"
- #include "msdos/pm_drvr/ne2k-pci.h"
-#endif
-
-#include "pcap.h"
-#include "pcap-dos.h"
-#include "pcap-int.h"
-#include "msdos/pktdrvr.h"
-
-#ifdef USE_NDIS2
-#include "msdos/ndis2.h"
-#endif
-
-#include <arpa/inet.h>
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/if_ether.h>
-#include <net/if_packe.h>
-#include <tcp.h>
-
-#if defined(USE_32BIT_DRIVERS)
- #define FLUSHK() do { _printk_safe = 1; _printk_flush(); } while (0)
- #define NDIS_NEXT_DEV &rtl8139_dev
-
- static char *rx_pool = NULL;
- static void init_32bit (void);
-
- static int pktq_init (struct rx_ringbuf *q, int size, int num, char *pool);
- static int pktq_check (struct rx_ringbuf *q);
- static int pktq_inc_out (struct rx_ringbuf *q);
- static int pktq_in_index (struct rx_ringbuf *q) LOCKED_FUNC;
- static void pktq_clear (struct rx_ringbuf *q) LOCKED_FUNC;
-
- static struct rx_elem *pktq_in_elem (struct rx_ringbuf *q) LOCKED_FUNC;
- static struct rx_elem *pktq_out_elem (struct rx_ringbuf *q);
-
-#else
- #define FLUSHK() ((void)0)
- #define NDIS_NEXT_DEV NULL
-#endif
-
-/*
- * Internal variables/functions in Watt-32
- */
-extern WORD _pktdevclass;
-extern BOOL _eth_is_init;
-extern int _w32_dynamic_host;
-extern int _watt_do_exit;
-extern int _watt_is_init;
-extern int _w32__bootp_on, _w32__dhcp_on, _w32__rarp_on, _w32__do_mask_req;
-extern void (*_w32_usr_post_init) (void);
-extern void (*_w32_print_hook)();
-
-extern void dbug_write (const char *); /* Watt-32 lib, pcdbug.c */
-extern int pkt_get_mtu (void);
-
-static int ref_count = 0;
-
-static u_long mac_count = 0;
-static u_long filter_count = 0;
-
-static volatile BOOL exc_occurred = 0;
-
-static struct device *handle_to_device [20];
-
-static int pcap_activate_dos (pcap_t *p);
-static int pcap_read_dos (pcap_t *p, int cnt, pcap_handler callback,
- u_char *data);
-static void pcap_cleanup_dos (pcap_t *p);
-static int pcap_stats_dos (pcap_t *p, struct pcap_stat *ps);
-static int pcap_sendpacket_dos (pcap_t *p, const void *buf, size_t len);
-static int pcap_setfilter_dos (pcap_t *p, struct bpf_program *fp);
-
-static int ndis_probe (struct device *dev);
-static int pkt_probe (struct device *dev);
-
-static void close_driver (void);
-static int init_watt32 (struct pcap *pcap, const char *dev_name, char *err_buf);
-static int first_init (const char *name, char *ebuf, int promisc);
-
-static void watt32_recv_hook (u_char *dummy, const struct pcap_pkthdr *pcap,
- const u_char *buf);
-
-/*
- * These are the device we always support
- */
-static struct device ndis_dev = {
- "ndis",
- "NDIS2 LanManager",
- 0,
- 0,0,0,0,0,0,
- NDIS_NEXT_DEV, /* NULL or a 32-bit device */
- ndis_probe
- };
-
-static struct device pkt_dev = {
- "pkt",
- "Packet-Driver",
- 0,
- 0,0,0,0,0,0,
- &ndis_dev,
- pkt_probe
- };
-
-static struct device *get_device (int fd)
-{
- if (fd <= 0 || fd >= sizeof(handle_to_device)/sizeof(handle_to_device[0]))
- return (NULL);
- return handle_to_device [fd-1];
-}
-
-/*
- * Private data for capturing on MS-DOS.
- */
-struct pcap_dos {
- void (*wait_proc)(void); /* call proc while waiting */
- struct pcap_stat stat;
-};
-
-pcap_t *pcap_create_interface (const char *device _U_, char *ebuf)
-{
- pcap_t *p;
-
- p = PCAP_CREATE_COMMON(ebuf, struct pcap_dos);
- if (p == NULL)
- return (NULL);
-
- p->activate_op = pcap_activate_dos;
- return (p);
-}
-
-/*
- * Open MAC-driver with name 'device_name' for live capture of
- * network packets.
- */
-static int pcap_activate_dos (pcap_t *pcap)
-{
- if (pcap->opt.rfmon) {
- /*
- * No monitor mode on DOS.
- */
- return (PCAP_ERROR_RFMON_NOTSUP);
- }
-
- /*
- * Turn a negative snapshot value (invalid), a snapshot value of
- * 0 (unspecified), or a value bigger than the normal maximum
- * value, into the maximum allowed value.
- *
- * If some application really *needs* a bigger snapshot
- * length, we should just increase MAXIMUM_SNAPLEN.
- */
- if (pcap->snapshot <= 0 || pcap->snapshot > MAXIMUM_SNAPLEN)
- pcap->snapshot = MAXIMUM_SNAPLEN;
-
- if (pcap->snapshot < ETH_MIN+8)
- pcap->snapshot = ETH_MIN+8;
-
- if (pcap->snapshot > ETH_MAX) /* silently accept and truncate large MTUs */
- pcap->snapshot = ETH_MAX;
-
- pcap->linktype = DLT_EN10MB; /* !! */
- pcap->cleanup_op = pcap_cleanup_dos;
- pcap->read_op = pcap_read_dos;
- pcap->stats_op = pcap_stats_dos;
- pcap->inject_op = pcap_sendpacket_dos;
- pcap->setfilter_op = pcap_setfilter_dos;
- pcap->setdirection_op = NULL; /* Not implemented.*/
- pcap->fd = ++ref_count;
-
- pcap->bufsize = ETH_MAX+100; /* add some margin */
- pcap->buffer = calloc (pcap->bufsize, 1);
-
- if (pcap->fd == 1) /* first time we're called */
- {
- if (!init_watt32(pcap, pcap->opt.device, pcap->errbuf) ||
- !first_init(pcap->opt.device, pcap->errbuf, pcap->opt.promisc))
- {
- /* XXX - free pcap->buffer? */
- return (PCAP_ERROR);
- }
- atexit (close_driver);
- }
- else if (stricmp(active_dev->name,pcap->opt.device))
- {
- snprintf (pcap->errbuf, PCAP_ERRBUF_SIZE,
- "Cannot use different devices simultaneously "
- "(`%s' vs. `%s')", active_dev->name, pcap->opt.device);
- /* XXX - free pcap->buffer? */
- return (PCAP_ERROR);
- }
- handle_to_device [pcap->fd-1] = active_dev;
- return (0);
-}
-
-/*
- * Poll the receiver queue and call the pcap callback-handler
- * with the packet.
- */
-static int
-pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data)
-{
- struct pcap_dos *pd = p->priv;
- struct pcap_pkthdr pcap;
- struct timeval now, expiry = { 0,0 };
- int rx_len = 0;
-
- if (p->opt.timeout > 0)
- {
- gettimeofday2 (&now, NULL);
- expiry.tv_usec = now.tv_usec + 1000UL * p->opt.timeout;
- expiry.tv_sec = now.tv_sec;
- while (expiry.tv_usec >= 1000000L)
- {
- expiry.tv_usec -= 1000000L;
- expiry.tv_sec++;
- }
- }
-
- while (!exc_occurred)
- {
- volatile struct device *dev; /* might be reset by sig_handler */
-
- dev = get_device (p->fd);
- if (!dev)
- break;
-
- PCAP_ASSERT (dev->copy_rx_buf || dev->peek_rx_buf);
- FLUSHK();
-
- /* If driver has a zero-copy receive facility, peek at the queue,
- * filter it, do the callback and release the buffer.
- */
- if (dev->peek_rx_buf)
- {
- PCAP_ASSERT (dev->release_rx_buf);
- rx_len = (*dev->peek_rx_buf) (&p->buffer);
- }
- else
- {
- rx_len = (*dev->copy_rx_buf) (p->buffer, p->snapshot);
- }
-
- if (rx_len > 0) /* got a packet */
- {
- mac_count++;
-
- FLUSHK();
-
- pcap.caplen = min (rx_len, p->snapshot);
- pcap.len = rx_len;
-
- if (callback &&
- (!p->fcode.bf_insns || pcap_filter(p->fcode.bf_insns, p->buffer, pcap.len, pcap.caplen)))
- {
- filter_count++;
-
- /* Fix-me!! Should be time of arrival. Not time of
- * capture.
- */
- gettimeofday2 (&pcap.ts, NULL);
- (*callback) (data, &pcap, p->buffer);
- }
-
- if (dev->release_rx_buf)
- (*dev->release_rx_buf) (p->buffer);
-
- if (pcap_pkt_debug > 0)
- {
- if (callback == watt32_recv_hook)
- dbug_write ("pcap_recv_hook\n");
- else dbug_write ("pcap_read_op\n");
- }
- FLUSHK();
- return (1);
- }
-
- /* Has "pcap_breakloop()" been called?
- */
- if (p->break_loop) {
- /*
- * Yes - clear the flag that indicates that it
- * has, and return -2 to indicate that we were
- * told to break out of the loop.
- */
- p->break_loop = 0;
- return (-2);
- }
-
- /* If not to wait for a packet or pcap_cleanup_dos() called from
- * e.g. SIGINT handler, exit loop now.
- */
- if (p->opt.timeout <= 0 || (volatile int)p->fd <= 0)
- break;
-
- gettimeofday2 (&now, NULL);
-
- if (timercmp(&now, &expiry, >))
- break;
-
-#ifndef DJGPP
- kbhit(); /* a real CPU hog */
-#endif
-
- if (pd->wait_proc)
- (*pd->wait_proc)(); /* call yield func */
- }
-
- if (rx_len < 0) /* receive error */
- {
- pd->stat.ps_drop++;
-#ifdef USE_32BIT_DRIVERS
- if (pcap_pkt_debug > 1)
- printk ("pkt-err %s\n", pktInfo.error);
-#endif
- return (-1);
- }
- return (0);
-}
-
-static int
-pcap_read_dos (pcap_t *p, int cnt, pcap_handler callback, u_char *data)
-{
- int rc, num = 0;
-
- /*
- * This can conceivably process more than INT_MAX packets,
- * which would overflow the packet count, causing it either
- * to look like a negative number, and thus cause us to
- * return a value that looks like an error, or overflow
- * back into positive territory, and thus cause us to
- * return a too-low count.
- *
- * Therefore, if the packet count is unlimited, we clip
- * it at INT_MAX; this routine is not expected to
- * process packets indefinitely, so that's not an issue.
- */
- if (PACKET_COUNT_IS_UNLIMITED(cnt))
- cnt = INT_MAX;
-
- while (num <= cnt)
- {
- if (p->fd <= 0)
- return (-1);
- rc = pcap_read_one (p, callback, data);
- if (rc > 0)
- num++;
- if (rc < 0)
- break;
- _w32_os_yield(); /* allow SIGINT generation, yield to Win95/NT */
- }
- return (num);
-}
-
-/*
- * Return network statistics
- */
-static int pcap_stats_dos (pcap_t *p, struct pcap_stat *ps)
-{
- struct net_device_stats *stats;
- struct pcap_dos *pd;
- struct device *dev = p ? get_device(p->fd) : NULL;
-
- if (!dev)
- {
- strcpy (p->errbuf, "illegal pcap handle");
- return (-1);
- }
-
- if (!dev->get_stats || (stats = (*dev->get_stats)(dev)) == NULL)
- {
- strcpy (p->errbuf, "device statistics not available");
- return (-1);
- }
-
- FLUSHK();
-
- pd = p->priv;
- pd->stat.ps_recv = stats->rx_packets;
- pd->stat.ps_drop += stats->rx_missed_errors;
- pd->stat.ps_ifdrop = stats->rx_dropped + /* queue full */
- stats->rx_errors; /* HW errors */
- if (ps)
- *ps = pd->stat;
-
- return (0);
-}
-
-/*
- * Return detailed network/device statistics.
- * May be called after 'dev->close' is called.
- */
-int pcap_stats_ex (pcap_t *p, struct pcap_stat_ex *se)
-{
- struct device *dev = p ? get_device (p->fd) : NULL;
-
- if (!dev || !dev->get_stats)
- {
- pcap_strlcpy (p->errbuf, "detailed device statistics not available",
- PCAP_ERRBUF_SIZE);
- return (-1);
- }
-
- if (!strnicmp(dev->name,"pkt",3))
- {
- pcap_strlcpy (p->errbuf, "pktdrvr doesn't have detailed statistics",
- PCAP_ERRBUF_SIZE);
- return (-1);
- }
- memcpy (se, (*dev->get_stats)(dev), sizeof(*se));
- return (0);
-}
-
-/*
- * Simply store the filter-code for the pcap_read_dos() callback
- * Some day the filter-code could be handed down to the active
- * device (pkt_rx1.s or 32-bit device interrupt handler).
- */
-static int pcap_setfilter_dos (pcap_t *p, struct bpf_program *fp)
-{
- if (!p)
- return (-1);
- p->fcode = *fp;
- return (0);
-}
-
-/*
- * Return # of packets received in pcap_read_dos()
- */
-u_long pcap_mac_packets (void)
-{
- return (mac_count);
-}
-
-/*
- * Return # of packets passed through filter in pcap_read_dos()
- */
-u_long pcap_filter_packets (void)
-{
- return (filter_count);
-}
-
-/*
- * Close pcap device. Not called for offline captures.
- */
-static void pcap_cleanup_dos (pcap_t *p)
-{
- struct pcap_dos *pd;
-
- if (!exc_occurred)
- {
- pd = p->priv;
- if (pcap_stats(p,NULL) < 0)
- pd->stat.ps_drop = 0;
- if (!get_device(p->fd))
- return;
-
- handle_to_device [p->fd-1] = NULL;
- p->fd = 0;
- if (ref_count > 0)
- ref_count--;
- if (ref_count > 0)
- return;
- }
- close_driver();
- /* XXX - call pcap_cleanup_live_common? */
-}
-
-/*
- * Return the name of the 1st network interface,
- * or NULL if none can be found.
- */
-char *pcap_lookupdev (char *ebuf)
-{
- struct device *dev;
-
-#ifdef USE_32BIT_DRIVERS
- init_32bit();
-#endif
-
- for (dev = (struct device*)dev_base; dev; dev = dev->next)
- {
- PCAP_ASSERT (dev->probe);
-
- if ((*dev->probe)(dev))
- {
- FLUSHK();
- probed_dev = (struct device*) dev; /* remember last probed device */
- return (char*) dev->name;
- }
- }
-
- if (ebuf)
- strcpy (ebuf, "No driver found");
- return (NULL);
-}
-
-/*
- * Gets localnet & netmask from Watt-32.
- */
-int pcap_lookupnet (const char *device, bpf_u_int32 *localnet,
- bpf_u_int32 *netmask, char *errbuf)
-{
- DWORD mask, net;
-
- if (!_watt_is_init)
- {
- strcpy (errbuf, "pcap_open_offline() or pcap_activate() must be "
- "called first");
- return (-1);
- }
-
- mask = _w32_sin_mask;
- net = my_ip_addr & mask;
- if (net == 0)
- {
- if (IN_CLASSA(*netmask))
- net = IN_CLASSA_NET;
- else if (IN_CLASSB(*netmask))
- net = IN_CLASSB_NET;
- else if (IN_CLASSC(*netmask))
- net = IN_CLASSC_NET;
- else
- {
- snprintf (errbuf, PCAP_ERRBUF_SIZE, "inet class for 0x%lx unknown", mask);
- return (-1);
- }
- }
- *localnet = htonl (net);
- *netmask = htonl (mask);
-
- ARGSUSED (device);
- return (0);
-}
-
-/*
- * Get a list of all interfaces that are present and that we probe okay.
- * Returns -1 on error, 0 otherwise.
- * The list may be NULL empty if no interfaces were up and could be opened.
- */
-int pcap_platform_finddevs (pcap_if_list_t *devlistp, char *errbuf)
-{
- struct device *dev;
- pcap_if_t *curdev;
-#if 0 /* Pkt drivers should have no addresses */
- struct sockaddr_in sa_ll_1, sa_ll_2;
- struct sockaddr *addr, *netmask, *broadaddr, *dstaddr;
-#endif
- int ret = 0;
- int found = 0;
-
- for (dev = (struct device*)dev_base; dev; dev = dev->next)
- {
- PCAP_ASSERT (dev->probe);
-
- if (!(*dev->probe)(dev))
- continue;
-
- PCAP_ASSERT (dev->close); /* set by probe routine */
- FLUSHK();
- (*dev->close) (dev);
-
- /*
- * XXX - find out whether it's up or running? Does that apply here?
- * Can we find out if anything's plugged into the adapter, if it's
- * a wired device, and set PCAP_IF_CONNECTION_STATUS_CONNECTED
- * or PCAP_IF_CONNECTION_STATUS_DISCONNECTED?
- */
- if ((curdev = pcap_add_dev(devlistp, dev->name, 0,
- dev->long_name, errbuf)) == NULL)
- {
- ret = -1;
- break;
- }
- found = 1;
-#if 0 /* Pkt drivers should have no addresses */
- memset (&sa_ll_1, 0, sizeof(sa_ll_1));
- memset (&sa_ll_2, 0, sizeof(sa_ll_2));
- sa_ll_1.sin_family = AF_INET;
- sa_ll_2.sin_family = AF_INET;
-
- addr = (struct sockaddr*) &sa_ll_1;
- netmask = (struct sockaddr*) &sa_ll_1;
- dstaddr = (struct sockaddr*) &sa_ll_1;
- broadaddr = (struct sockaddr*) &sa_ll_2;
- memset (&sa_ll_2.sin_addr, 0xFF, sizeof(sa_ll_2.sin_addr));
-
- if (pcap_add_addr_to_dev(curdev, addr, sizeof(*addr),
- netmask, sizeof(*netmask),
- broadaddr, sizeof(*broadaddr),
- dstaddr, sizeof(*dstaddr), errbuf) < 0)
- {
- ret = -1;
- break;
- }
-#endif
- }
-
- if (ret == 0 && !found)
- strcpy (errbuf, "No drivers found");
-
- return (ret);
-}
-
-/*
- * pcap_assert() is mainly used for debugging
- */
-void pcap_assert (const char *what, const char *file, unsigned line)
-{
- FLUSHK();
- fprintf (stderr, "%s (%u): Assertion \"%s\" failed\n",
- file, line, what);
- close_driver();
- _exit (-1);
-}
-
-/*
- * For pcap_offline_read(): wait and yield between printing packets
- * to simulate the pace packets where actually recorded.
- */
-void pcap_set_wait (pcap_t *p, void (*yield)(void), int wait)
-{
- if (p)
- {
- struct pcap_dos *pd = p->priv;
-
- pd->wait_proc = yield;
- p->opt.timeout = wait;
- }
-}
-
-/*
- * Initialize a named network device.
- */
-static struct device *
-open_driver (const char *dev_name, char *ebuf, int promisc)
-{
- struct device *dev;
-
- for (dev = (struct device*)dev_base; dev; dev = dev->next)
- {
- PCAP_ASSERT (dev->name);
-
- if (strcmp (dev_name,dev->name))
- continue;
-
- if (!probed_dev) /* user didn't call pcap_lookupdev() first */
- {
- PCAP_ASSERT (dev->probe);
-
- if (!(*dev->probe)(dev)) /* call the xx_probe() function */
- {
- snprintf (ebuf, PCAP_ERRBUF_SIZE, "failed to detect device `%s'", dev_name);
- return (NULL);
- }
- probed_dev = dev; /* device is probed okay and may be used */
- }
- else if (dev != probed_dev)
- {
- goto not_probed;
- }
-
- FLUSHK();
-
- /* Select what traffic to receive
- */
- if (promisc)
- dev->flags |= (IFF_ALLMULTI | IFF_PROMISC);
- else dev->flags &= ~(IFF_ALLMULTI | IFF_PROMISC);
-
- PCAP_ASSERT (dev->open);
-
- if (!(*dev->open)(dev))
- {
- snprintf (ebuf, PCAP_ERRBUF_SIZE, "failed to activate device `%s'", dev_name);
- if (pktInfo.error && !strncmp(dev->name,"pkt",3))
- {
- strcat (ebuf, ": ");
- strcat (ebuf, pktInfo.error);
- }
- return (NULL);
- }
-
- /* Some devices need this to operate in promiscuous mode
- */
- if (promisc && dev->set_multicast_list)
- (*dev->set_multicast_list) (dev);
-
- active_dev = dev; /* remember our active device */
- break;
- }
-
- /* 'dev_name' not matched in 'dev_base' list.
- */
- if (!dev)
- {
- snprintf (ebuf, PCAP_ERRBUF_SIZE, "device `%s' not supported", dev_name);
- return (NULL);
- }
-
-not_probed:
- if (!probed_dev)
- {
- snprintf (ebuf, PCAP_ERRBUF_SIZE, "device `%s' not probed", dev_name);
- return (NULL);
- }
- return (dev);
-}
-
-/*
- * Deinitialize MAC driver.
- * Set receive mode back to default mode.
- */
-static void close_driver (void)
-{
- /* !!todo: loop over all 'handle_to_device[]' ? */
- struct device *dev = active_dev;
-
- if (dev && dev->close)
- {
- (*dev->close) (dev);
- FLUSHK();
- }
-
- active_dev = NULL;
-
-#ifdef USE_32BIT_DRIVERS
- if (rx_pool)
- {
- k_free (rx_pool);
- rx_pool = NULL;
- }
- if (dev)
- pcibios_exit();
-#endif
-}
-
-
-#ifdef __DJGPP__
-static void setup_signals (void (*handler)(int))
-{
- signal (SIGSEGV,handler);
- signal (SIGILL, handler);
- signal (SIGFPE, handler);
-}
-
-static void exc_handler (int sig)
-{
-#ifdef USE_32BIT_DRIVERS
- if (active_dev->irq > 0) /* excludes IRQ 0 */
- {
- disable_irq (active_dev->irq);
- irq_eoi_cmd (active_dev->irq);
- _printk_safe = 1;
- }
-#endif
-
- switch (sig)
- {
- case SIGSEGV:
- fputs ("Catching SIGSEGV.\n", stderr);
- break;
- case SIGILL:
- fputs ("Catching SIGILL.\n", stderr);
- break;
- case SIGFPE:
- _fpreset();
- fputs ("Catching SIGFPE.\n", stderr);
- break;
- default:
- fprintf (stderr, "Catching signal %d.\n", sig);
- }
- exc_occurred = 1;
- close_driver();
-}
-#endif /* __DJGPP__ */
-
-
-/*
- * Open the pcap device for the first client calling pcap_activate()
- */
-static int first_init (const char *name, char *ebuf, int promisc)
-{
- struct device *dev;
-
-#ifdef USE_32BIT_DRIVERS
- rx_pool = k_calloc (RECEIVE_BUF_SIZE, RECEIVE_QUEUE_SIZE);
- if (!rx_pool)
- {
- strcpy (ebuf, "Not enough memory (Rx pool)");
- return (0);
- }
-#endif
-
-#ifdef __DJGPP__
- setup_signals (exc_handler);
-#endif
-
-#ifdef USE_32BIT_DRIVERS
- init_32bit();
-#endif
-
- dev = open_driver (name, ebuf, promisc);
- if (!dev)
- {
-#ifdef USE_32BIT_DRIVERS
- k_free (rx_pool);
- rx_pool = NULL;
-#endif
-
-#ifdef __DJGPP__
- setup_signals (SIG_DFL);
-#endif
- return (0);
- }
-
-#ifdef USE_32BIT_DRIVERS
- /*
- * If driver is NOT a 16-bit "pkt/ndis" driver (having a 'copy_rx_buf'
- * set in it's probe handler), initialize near-memory ring-buffer for
- * the 32-bit device.
- */
- if (dev->copy_rx_buf == NULL)
- {
- dev->get_rx_buf = get_rxbuf;
- dev->peek_rx_buf = peek_rxbuf;
- dev->release_rx_buf = release_rxbuf;
- pktq_init (&dev->queue, RECEIVE_BUF_SIZE, RECEIVE_QUEUE_SIZE, rx_pool);
- }
-#endif
- return (1);
-}
-
-#ifdef USE_32BIT_DRIVERS
-static void init_32bit (void)
-{
- static int init_pci = 0;
-
- if (!_printk_file)
- _printk_init (64*1024, NULL); /* calls atexit(printk_exit) */
-
- if (!init_pci)
- (void)pci_init(); /* init BIOS32+PCI interface */
- init_pci = 1;
-}
-#endif
-
-
-/*
- * Hook functions for using Watt-32 together with pcap
- */
-static char rxbuf [ETH_MAX+100]; /* rx-buffer with some margin */
-static WORD etype;
-static pcap_t pcap_save;
-
-static void watt32_recv_hook (u_char *dummy, const struct pcap_pkthdr *pcap,
- const u_char *buf)
-{
- /* Fix me: assumes Ethernet II only */
- struct ether_header *ep = (struct ether_header*) buf;
-
- memcpy (rxbuf, buf, pcap->caplen);
- etype = ep->ether_type;
- ARGSUSED (dummy);
-}
-
-#if (WATTCP_VER >= 0x0224)
-/*
- * This function is used by Watt-32 to poll for a packet.
- * i.e. it's set to bypass _eth_arrived()
- */
-static void *pcap_recv_hook (WORD *type)
-{
- int len = pcap_read_dos (&pcap_save, 1, watt32_recv_hook, NULL);
-
- if (len < 0)
- return (NULL);
-
- *type = etype;
- return (void*) &rxbuf;
-}
-
-/*
- * This function is called by Watt-32 (via _eth_xmit_hook).
- * If dbug_init() was called, we should trace packets sent.
- */
-static int pcap_xmit_hook (const void *buf, unsigned len)
-{
- int rc = 0;
-
- if (pcap_pkt_debug > 0)
- dbug_write ("pcap_xmit_hook: ");
-
- if (active_dev && active_dev->xmit)
- if ((*active_dev->xmit) (active_dev, buf, len) > 0)
- rc = len;
-
- if (pcap_pkt_debug > 0)
- dbug_write (rc ? "ok\n" : "fail\n");
- return (rc);
-}
-#endif
-
-static int pcap_sendpacket_dos (pcap_t *p, const void *buf, size_t len)
-{
- struct device *dev = p ? get_device(p->fd) : NULL;
-
- if (!dev || !dev->xmit)
- return (-1);
- return (*dev->xmit) (dev, buf, len);
-}
-
-/*
- * This function is called by Watt-32 in tcp_post_init().
- * We should prevent Watt-32 from using BOOTP/DHCP/RARP etc.
- */
-static void (*prev_post_hook) (void);
-
-static void pcap_init_hook (void)
-{
- _w32__bootp_on = _w32__dhcp_on = _w32__rarp_on = 0;
- _w32__do_mask_req = 0;
- _w32_dynamic_host = 0;
- if (prev_post_hook)
- (*prev_post_hook)();
-}
-
-/*
- * Suppress PRINT message from Watt-32's sock_init()
- */
-static void null_print (void) {}
-
-/*
- * To use features of Watt-32 (netdb functions and socket etc.)
- * we must call sock_init(). But we set various hooks to prevent
- * using normal PKTDRVR functions in pcpkt.c. This should hopefully
- * make Watt-32 and pcap co-operate.
- */
-static int init_watt32 (struct pcap *pcap, const char *dev_name, char *err_buf)
-{
- char *env;
- int rc, MTU, has_ip_addr;
- int using_pktdrv = 1;
-
- /* If user called sock_init() first, we need to reinit in
- * order to open debug/trace-file properly
- */
- if (_watt_is_init)
- sock_exit();
-
- env = getenv ("PCAP_TRACE");
- if (env && atoi(env) > 0 &&
- pcap_pkt_debug < 0) /* if not already set */
- {
- dbug_init();
- pcap_pkt_debug = atoi (env);
- }
-
- _watt_do_exit = 0; /* prevent sock_init() calling exit() */
- prev_post_hook = _w32_usr_post_init;
- _w32_usr_post_init = pcap_init_hook;
- _w32_print_hook = null_print;
-
- if (dev_name && strncmp(dev_name,"pkt",3))
- using_pktdrv = FALSE;
-
- rc = sock_init();
- has_ip_addr = (rc != 8); /* IP-address assignment failed */
-
- /* if pcap is using a 32-bit driver w/o a pktdrvr loaded, we
- * just pretend Watt-32 is initialized okay.
- *
- * !! fix-me: The Watt-32 config isn't done if no pktdrvr
- * was found. In that case my_ip_addr + sin_mask
- * have default values. Should be taken from another
- * ini-file/environment in any case (ref. tcpdump.ini)
- */
- _watt_is_init = 1;
-
- if (!using_pktdrv || !has_ip_addr) /* for now .... */
- {
- static const char myip[] = "192.168.0.1";
- static const char mask[] = "255.255.255.0";
-
- printf ("Just guessing, using IP %s and netmask %s\n", myip, mask);
- my_ip_addr = aton (myip);
- _w32_sin_mask = aton (mask);
- }
- else if (rc && using_pktdrv)
- {
- snprintf (err_buf, PCAP_ERRBUF_SIZE, "sock_init() failed, code %d", rc);
- return (0);
- }
-
- /* Set recv-hook for peeking in _eth_arrived().
- */
-#if (WATTCP_VER >= 0x0224)
- _eth_recv_hook = pcap_recv_hook;
- _eth_xmit_hook = pcap_xmit_hook;
-#endif
-
- /* Free the pkt-drvr handle allocated in pkt_init().
- * The above hooks should thus use the handle reopened in open_driver()
- */
- if (using_pktdrv)
- {
- _eth_release();
-/* _eth_is_init = 1; */ /* hack to get Rx/Tx-hooks in Watt-32 working */
- }
-
- memcpy (&pcap_save, pcap, sizeof(pcap_save));
- MTU = pkt_get_mtu();
- pcap_save.fcode.bf_insns = NULL;
- pcap_save.linktype = _eth_get_hwtype (NULL, NULL);
- pcap_save.snapshot = MTU > 0 ? MTU : ETH_MAX; /* assume 1514 */
-
- /* prevent use of resolve() and resolve_ip()
- */
- last_nameserver = 0;
- return (1);
-}
-
-int EISA_bus = 0; /* Where is natural place for this? */
-
-/*
- * Application config hooks to set various driver parameters.
- */
-
-static const struct config_table debug_tab[] = {
- { "PKT.DEBUG", ARG_ATOI, &pcap_pkt_debug },
- { "PKT.VECTOR", ARG_ATOX_W, NULL },
- { "NDIS.DEBUG", ARG_ATOI, NULL },
-#ifdef USE_32BIT_DRIVERS
- { "3C503.DEBUG", ARG_ATOI, &ei_debug },
- { "3C503.IO_BASE", ARG_ATOX_W, &el2_dev.base_addr },
- { "3C503.MEMORY", ARG_ATOX_W, &el2_dev.mem_start },
- { "3C503.IRQ", ARG_ATOI, &el2_dev.irq },
- { "3C505.DEBUG", ARG_ATOI, NULL },
- { "3C505.BASE", ARG_ATOX_W, NULL },
- { "3C507.DEBUG", ARG_ATOI, NULL },
- { "3C509.DEBUG", ARG_ATOI, &el3_debug },
- { "3C509.ILOOP", ARG_ATOI, &el3_max_loop },
- { "3C529.DEBUG", ARG_ATOI, NULL },
- { "3C575.DEBUG", ARG_ATOI, &debug_3c575 },
- { "3C59X.DEBUG", ARG_ATOI, &vortex_debug },
- { "3C59X.IFACE0", ARG_ATOI, &vortex_options[0] },
- { "3C59X.IFACE1", ARG_ATOI, &vortex_options[1] },
- { "3C59X.IFACE2", ARG_ATOI, &vortex_options[2] },
- { "3C59X.IFACE3", ARG_ATOI, &vortex_options[3] },
- { "3C90X.DEBUG", ARG_ATOX_W, &tc90xbc_debug },
- { "ACCT.DEBUG", ARG_ATOI, &ethpk_debug },
- { "CS89.DEBUG", ARG_ATOI, &cs89_debug },
- { "RTL8139.DEBUG", ARG_ATOI, &rtl8139_debug },
- /* { "RTL8139.FDUPLEX", ARG_ATOI, &rtl8139_options }, */
- { "SMC.DEBUG", ARG_ATOI, &ei_debug },
- /* { "E100.DEBUG", ARG_ATOI, &e100_debug }, */
- { "PCI.DEBUG", ARG_ATOI, &pci_debug },
- { "BIOS32.DEBUG", ARG_ATOI, &bios32_debug },
- { "IRQ.DEBUG", ARG_ATOI, &irq_debug },
- { "TIMER.IRQ", ARG_ATOI, &timer_irq },
-#endif
- { NULL }
- };
-
-/*
- * pcap_config_hook() is an extension to application's config
- * handling. Uses Watt-32's config-table function.
- */
-int pcap_config_hook (const char *keyword, const char *value)
-{
- return parse_config_table (debug_tab, NULL, keyword, value);
-}
-
-/*
- * Linked list of supported devices
- */
-struct device *active_dev = NULL; /* the device we have opened */
-struct device *probed_dev = NULL; /* the device we have probed */
-const struct device *dev_base = &pkt_dev; /* list of network devices */
-
-/*
- * PKTDRVR device functions
- */
-int pcap_pkt_debug = -1;
-
-static void pkt_close (struct device *dev)
-{
- BOOL okay = PktExitDriver();
-
- if (pcap_pkt_debug > 1)
- fprintf (stderr, "pkt_close(): %d\n", okay);
-
- if (dev->priv)
- free (dev->priv);
- dev->priv = NULL;
-}
-
-static int pkt_open (struct device *dev)
-{
- PKT_RX_MODE mode;
-
- if (dev->flags & IFF_PROMISC)
- mode = PDRX_ALL_PACKETS;
- else mode = PDRX_BROADCAST;
-
- if (!PktInitDriver(mode))
- return (0);
-
- PktResetStatistics (pktInfo.handle);
- PktQueueBusy (FALSE);
- return (1);
-}
-
-static int pkt_xmit (struct device *dev, const void *buf, int len)
-{
- struct net_device_stats *stats = (struct net_device_stats*) dev->priv;
-
- if (pcap_pkt_debug > 0)
- dbug_write ("pcap_xmit\n");
-
- if (!PktTransmit(buf,len))
- {
- stats->tx_errors++;
- return (0);
- }
- return (len);
-}
-
-static void *pkt_stats (struct device *dev)
-{
- struct net_device_stats *stats = (struct net_device_stats*) dev->priv;
-
- if (!stats || !PktSessStatistics(pktInfo.handle))
- return (NULL);
-
- stats->rx_packets = pktStat.inPackets;
- stats->rx_errors = pktStat.lost;
- stats->rx_missed_errors = PktRxDropped();
- return (stats);
-}
-
-static int pkt_probe (struct device *dev)
-{
- if (!PktSearchDriver())
- return (0);
-
- dev->open = pkt_open;
- dev->xmit = pkt_xmit;
- dev->close = pkt_close;
- dev->get_stats = pkt_stats;
- dev->copy_rx_buf = PktReceive; /* farmem peek and copy routine */
- dev->get_rx_buf = NULL;
- dev->peek_rx_buf = NULL;
- dev->release_rx_buf = NULL;
- dev->priv = calloc (sizeof(struct net_device_stats), 1);
- if (!dev->priv)
- return (0);
- return (1);
-}
-
-/*
- * NDIS device functions
- */
-static void ndis_close (struct device *dev)
-{
-#ifdef USE_NDIS2
- NdisShutdown();
-#endif
- ARGSUSED (dev);
-}
-
-static int ndis_open (struct device *dev)
-{
- int promisc = (dev->flags & IFF_PROMISC);
-
-#ifdef USE_NDIS2
- if (!NdisInit(promisc))
- return (0);
- return (1);
-#else
- ARGSUSED (promisc);
- return (0);
-#endif
-}
-
-static void *ndis_stats (struct device *dev)
-{
- static struct net_device_stats stats;
-
- /* to-do */
- ARGSUSED (dev);
- return (&stats);
-}
-
-static int ndis_probe (struct device *dev)
-{
-#ifdef USE_NDIS2
- if (!NdisOpen())
- return (0);
-#endif
-
- dev->open = ndis_open;
- dev->xmit = NULL;
- dev->close = ndis_close;
- dev->get_stats = ndis_stats;
- dev->copy_rx_buf = NULL; /* to-do */
- dev->get_rx_buf = NULL; /* upcall is from rmode driver */
- dev->peek_rx_buf = NULL;
- dev->release_rx_buf = NULL;
- return (0);
-}
-
-/*
- * Search & probe for supported 32-bit (pmode) pcap devices
- */
-#if defined(USE_32BIT_DRIVERS)
-
-struct device el2_dev LOCKED_VAR = {
- "3c503",
- "EtherLink II",
- 0,
- 0,0,0,0,0,0,
- NULL,
- el2_probe
- };
-
-struct device el3_dev LOCKED_VAR = {
- "3c509",
- "EtherLink III",
- 0,
- 0,0,0,0,0,0,
- &el2_dev,
- el3_probe
- };
-
-struct device tc515_dev LOCKED_VAR = {
- "3c515",
- "EtherLink PCI",
- 0,
- 0,0,0,0,0,0,
- &el3_dev,
- tc515_probe
- };
-
-struct device tc59_dev LOCKED_VAR = {
- "3c59x",
- "EtherLink PCI",
- 0,
- 0,0,0,0,0,0,
- &tc515_dev,
- tc59x_probe
- };
-
-struct device tc90xbc_dev LOCKED_VAR = {
- "3c90x",
- "EtherLink 90X",
- 0,
- 0,0,0,0,0,0,
- &tc59_dev,
- tc90xbc_probe
- };
-
-struct device wd_dev LOCKED_VAR = {
- "wd",
- "Western Digital",
- 0,
- 0,0,0,0,0,0,
- &tc90xbc_dev,
- wd_probe
- };
-
-struct device ne_dev LOCKED_VAR = {
- "ne",
- "NEx000",
- 0,
- 0,0,0,0,0,0,
- &wd_dev,
- ne_probe
- };
-
-struct device acct_dev LOCKED_VAR = {
- "acct",
- "Accton EtherPocket",
- 0,
- 0,0,0,0,0,0,
- &ne_dev,
- ethpk_probe
- };
-
-struct device cs89_dev LOCKED_VAR = {
- "cs89",
- "Crystal Semiconductor",
- 0,
- 0,0,0,0,0,0,
- &acct_dev,
- cs89x0_probe
- };
-
-struct device rtl8139_dev LOCKED_VAR = {
- "rtl8139",
- "RealTek PCI",
- 0,
- 0,0,0,0,0,0,
- &cs89_dev,
- rtl8139_probe /* dev->probe routine */
- };
-
-/*
- * Dequeue routine is called by polling.
- * NOTE: the queue-element is not copied, only a pointer is
- * returned at '*buf'
- */
-int peek_rxbuf (BYTE **buf)
-{
- struct rx_elem *tail, *head;
-
- PCAP_ASSERT (pktq_check (&active_dev->queue));
-
- DISABLE();
- tail = pktq_out_elem (&active_dev->queue);
- head = pktq_in_elem (&active_dev->queue);
- ENABLE();
-
- if (head != tail)
- {
- PCAP_ASSERT (tail->size < active_dev->queue.elem_size-4-2);
-
- *buf = &tail->data[0];
- return (tail->size);
- }
- *buf = NULL;
- return (0);
-}
-
-/*
- * Release buffer we peeked at above.
- */
-int release_rxbuf (BYTE *buf)
-{
-#ifndef NDEBUG
- struct rx_elem *tail = pktq_out_elem (&active_dev->queue);
-
- PCAP_ASSERT (&tail->data[0] == buf);
-#else
- ARGSUSED (buf);
-#endif
- pktq_inc_out (&active_dev->queue);
- return (1);
-}
-
-/*
- * get_rxbuf() routine (in locked code) is called from IRQ handler
- * to request a buffer. Interrupts are disabled and we have a 32kB stack.
- */
-BYTE *get_rxbuf (int len)
-{
- int idx;
-
- if (len < ETH_MIN || len > ETH_MAX)
- return (NULL);
-
- idx = pktq_in_index (&active_dev->queue);
-
-#ifdef DEBUG
- {
- static int fan_idx LOCKED_VAR = 0;
- writew ("-\\|/"[fan_idx++] | (15 << 8), /* white on black colour */
- 0xB8000 + 2*79); /* upper-right corner, 80-col colour screen */
- fan_idx &= 3;
- }
-/* writew (idx + '0' + 0x0F00, 0xB8000 + 2*78); */
-#endif
-
- if (idx != active_dev->queue.out_index)
- {
- struct rx_elem *head = pktq_in_elem (&active_dev->queue);
-
- head->size = len;
- active_dev->queue.in_index = idx;
- return (&head->data[0]);
- }
-
- /* !!to-do: drop 25% of the oldest element
- */
- pktq_clear (&active_dev->queue);
- return (NULL);
-}
-
-/*
- * Simple ring-buffer queue handler for reception of packets
- * from network driver.
- */
-#define PKTQ_MARKER 0xDEADBEEF
-
-static int pktq_check (struct rx_ringbuf *q)
-{
-#ifndef NDEBUG
- int i;
- char *buf;
-#endif
-
- if (!q || !q->num_elem || !q->buf_start)
- return (0);
-
-#ifndef NDEBUG
- buf = q->buf_start;
-
- for (i = 0; i < q->num_elem; i++)
- {
- buf += q->elem_size;
- if (*(DWORD*)(buf - sizeof(DWORD)) != PKTQ_MARKER)
- return (0);
- }
-#endif
- return (1);
-}
-
-static int pktq_init (struct rx_ringbuf *q, int size, int num, char *pool)
-{
- int i;
-
- q->elem_size = size;
- q->num_elem = num;
- q->buf_start = pool;
- q->in_index = 0;
- q->out_index = 0;
-
- PCAP_ASSERT (size >= sizeof(struct rx_elem) + sizeof(DWORD));
- PCAP_ASSERT (num);
- PCAP_ASSERT (pool);
-
- for (i = 0; i < num; i++)
- {
-#if 0
- struct rx_elem *elem = (struct rx_elem*) pool;
-
- /* assert dword aligned elements
- */
- PCAP_ASSERT (((unsigned)(&elem->data[0]) & 3) == 0);
-#endif
- pool += size;
- *(DWORD*) (pool - sizeof(DWORD)) = PKTQ_MARKER;
- }
- return (1);
-}
-
-/*
- * Increment the queue 'out_index' (tail).
- * Check for wraps.
- */
-static int pktq_inc_out (struct rx_ringbuf *q)
-{
- q->out_index++;
- if (q->out_index >= q->num_elem)
- q->out_index = 0;
- return (q->out_index);
-}
-
-/*
- * Return the queue's next 'in_index' (head).
- * Check for wraps.
- */
-static int pktq_in_index (struct rx_ringbuf *q)
-{
- volatile int index = q->in_index + 1;
-
- if (index >= q->num_elem)
- index = 0;
- return (index);
-}
-
-/*
- * Return the queue's head-buffer.
- */
-static struct rx_elem *pktq_in_elem (struct rx_ringbuf *q)
-{
- return (struct rx_elem*) (q->buf_start + (q->elem_size * q->in_index));
-}
-
-/*
- * Return the queue's tail-buffer.
- */
-static struct rx_elem *pktq_out_elem (struct rx_ringbuf *q)
-{
- return (struct rx_elem*) (q->buf_start + (q->elem_size * q->out_index));
-}
-
-/*
- * Clear the queue ring-buffer by setting head=tail.
- */
-static void pktq_clear (struct rx_ringbuf *q)
-{
- q->in_index = q->out_index;
-}
-
-/*
- * Symbols that must be linkable for "gcc -O0"
- */
-#undef __IOPORT_H
-#undef __DMA_H
-
-#define extern
-#define __inline__
-
-#include "msdos/pm_drvr/ioport.h"
-#include "msdos/pm_drvr/dma.h"
-
-#endif /* USE_32BIT_DRIVERS */
-
-/*
- * Libpcap version string.
- */
-const char *
-pcap_lib_version(void)
-{
- return ("DOS-" PCAP_VERSION_STRING);
-}
diff --git a/pcap-dos.h b/pcap-dos.h
deleted file mode 100644
index bf47fb51..00000000
--- a/pcap-dos.h
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Internal details for libpcap on DOS.
- * 32-bit targets: djgpp, Pharlap or DOS4GW.
- */
-
-#ifndef __PCAP_DOS_H
-#define __PCAP_DOS_H
-
-#ifdef __DJGPP__
-#include <pc.h> /* simple non-conio kbhit */
-#else
-#include <conio.h>
-#endif
-
-typedef int BOOL;
-typedef unsigned char BYTE;
-typedef unsigned short WORD;
-typedef unsigned long DWORD;
-typedef BYTE ETHER[6];
-
-#define ETH_ALEN sizeof(ETHER) /* Ether address length */
-#define ETH_HLEN (2*ETH_ALEN+2) /* Ether header length */
-#define ETH_MTU 1500
-#define ETH_MIN 60
-#define ETH_MAX (ETH_MTU+ETH_HLEN)
-
-#ifndef TRUE
- #define TRUE 1
- #define FALSE 0
-#endif
-
-#define PHARLAP 1
-#define DJGPP 2
-#define DOS4GW 4
-
-#ifdef __DJGPP__
- #undef DOSX
- #define DOSX DJGPP
-#endif
-
-#ifdef __WATCOMC__
- #undef DOSX
- #define DOSX DOS4GW
-#endif
-
-#ifdef __HIGHC__
- #include <pharlap.h>
- #undef DOSX
- #define DOSX PHARLAP
- #define inline
-#else
- typedef unsigned int UINT;
-#endif
-
-
-#if defined(__GNUC__) || defined(__HIGHC__)
- typedef unsigned long long uint64;
- typedef unsigned long long QWORD;
-#endif
-
-#if defined(__WATCOMC__)
- typedef unsigned __int64 uint64;
- typedef unsigned __int64 QWORD;
-#endif
-
-#define ARGSUSED(x) (void) x
-
-#if defined (__SMALL__) || defined(__LARGE__)
- #define DOSX 0
-
-#elif !defined(DOSX)
- #error DOSX not defined; 1 = PharLap, 2 = djgpp, 4 = DOS4GW
-#endif
-
-#ifdef __HIGHC__
-#define min(a,b) _min(a,b)
-#define max(a,b) _max(a,b)
-#endif
-
-#ifndef min
-#define min(a,b) ((a) < (b) ? (a) : (b))
-#endif
-
-#ifndef max
-#define max(a,b) ((a) < (b) ? (b) : (a))
-#endif
-
-#if !defined(_U_) && defined(__GNUC__)
-#define _U_ __attribute__((unused))
-#endif
-
-#ifndef _U_
-#define _U_
-#endif
-
-#if defined(USE_32BIT_DRIVERS)
- #include "msdos/pm_drvr/lock.h"
-
- #ifndef RECEIVE_QUEUE_SIZE
- #define RECEIVE_QUEUE_SIZE 60
- #endif
-
- #ifndef RECEIVE_BUF_SIZE
- #define RECEIVE_BUF_SIZE (ETH_MAX+20)
- #endif
-
- extern struct device el2_dev LOCKED_VAR; /* 3Com EtherLink II */
- extern struct device el3_dev LOCKED_VAR; /* EtherLink III */
- extern struct device tc59_dev LOCKED_VAR; /* 3Com Vortex Card (?) */
- extern struct device tc515_dev LOCKED_VAR;
- extern struct device tc90x_dev LOCKED_VAR;
- extern struct device tc90bcx_dev LOCKED_VAR;
- extern struct device wd_dev LOCKED_VAR;
- extern struct device ne_dev LOCKED_VAR;
- extern struct device acct_dev LOCKED_VAR;
- extern struct device cs89_dev LOCKED_VAR;
- extern struct device rtl8139_dev LOCKED_VAR;
-
- struct rx_ringbuf {
- volatile int in_index; /* queue index head */
- int out_index; /* queue index tail */
- int elem_size; /* size of each element */
- int num_elem; /* number of elements */
- char *buf_start; /* start of buffer pool */
- };
-
- struct rx_elem {
- DWORD size; /* size copied to this element */
- BYTE data[ETH_MAX+10]; /* add some margin. data[0] should be */
- }; /* dword aligned */
-
- extern BYTE *get_rxbuf (int len) LOCKED_FUNC;
- extern int peek_rxbuf (BYTE **buf);
- extern int release_rxbuf (BYTE *buf);
-
-#else
- #define LOCKED_VAR
- #define LOCKED_FUNC
-
- struct device {
- const char *name;
- const char *long_name;
- DWORD base_addr; /* device I/O address */
- int irq; /* device IRQ number */
- int dma; /* DMA channel */
- DWORD mem_start; /* shared mem start */
- DWORD mem_end; /* shared mem end */
- DWORD rmem_start; /* shmem "recv" start */
- DWORD rmem_end; /* shared "recv" end */
-
- struct device *next; /* next device in list */
-
- /* interface service routines */
- int (*probe)(struct device *dev);
- int (*open) (struct device *dev);
- void (*close)(struct device *dev);
- int (*xmit) (struct device *dev, const void *buf, int len);
- void *(*get_stats)(struct device *dev);
- void (*set_multicast_list)(struct device *dev);
-
- /* driver-to-pcap receive buffer routines */
- int (*copy_rx_buf) (BYTE *buf, int max); /* rx-copy (pktdrvr only) */
- BYTE *(*get_rx_buf) (int len); /* rx-buf fetch/enqueue */
- int (*peek_rx_buf) (BYTE **buf); /* rx-non-copy at queue */
- int (*release_rx_buf) (BYTE *buf); /* release after peek */
-
- WORD flags; /* Low-level status flags. */
- void *priv; /* private data */
- };
-
- /*
- * Network device statistics
- */
- typedef struct net_device_stats {
- DWORD rx_packets; /* total packets received */
- DWORD tx_packets; /* total packets transmitted */
- DWORD rx_bytes; /* total bytes received */
- DWORD tx_bytes; /* total bytes transmitted */
- DWORD rx_errors; /* bad packets received */
- DWORD tx_errors; /* packet transmit problems */
- DWORD rx_dropped; /* no space in Rx buffers */
- DWORD tx_dropped; /* no space available for Tx */
- DWORD multicast; /* multicast packets received */
-
- /* detailed rx_errors: */
- DWORD rx_length_errors;
- DWORD rx_over_errors; /* recv'r overrun error */
- DWORD rx_osize_errors; /* recv'r over-size error */
- DWORD rx_crc_errors; /* recv'd pkt with crc error */
- DWORD rx_frame_errors; /* recv'd frame alignment error */
- DWORD rx_fifo_errors; /* recv'r fifo overrun */
- DWORD rx_missed_errors; /* recv'r missed packet */
-
- /* detailed tx_errors */
- DWORD tx_aborted_errors;
- DWORD tx_carrier_errors;
- DWORD tx_fifo_errors;
- DWORD tx_heartbeat_errors;
- DWORD tx_window_errors;
- DWORD tx_collisions;
- DWORD tx_jabbers;
- } NET_STATS;
-#endif
-
-extern struct device *active_dev LOCKED_VAR;
-extern const struct device *dev_base LOCKED_VAR;
-extern struct device *probed_dev;
-
-extern int pcap_pkt_debug;
-
-extern void _w32_os_yield (void); /* Watt-32's misc.c */
-
-#ifdef NDEBUG
- #define PCAP_ASSERT(x) ((void)0)
-
-#else
- void pcap_assert (const char *what, const char *file, unsigned line);
-
- #define PCAP_ASSERT(x) do { \
- if (!(x)) \
- pcap_assert (#x, __FILE__, __LINE__); \
- } while (0)
-#endif
-
-#endif /* __PCAP_DOS_H */