]> The Tcpdump Group git mirrors - libpcap/blob - pcap-dos.c
Clean up the ether_hostton() stuff.
[libpcap] / pcap-dos.c
1 /*
2 * This file is part of DOS-libpcap
3 * Ported to DOS/DOSX by G. Vanem <gvanem@yahoo.no>
4 *
5 * pcap-dos.c: Interface to PKTDRVR, NDIS2 and 32-bit pmode
6 * network drivers.
7 */
8
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <signal.h>
13 #include <float.h>
14 #include <fcntl.h>
15 #include <io.h>
16
17 #if defined(USE_32BIT_DRIVERS)
18 #include "msdos/pm_drvr/pmdrvr.h"
19 #include "msdos/pm_drvr/pci.h"
20 #include "msdos/pm_drvr/bios32.h"
21 #include "msdos/pm_drvr/module.h"
22 #include "msdos/pm_drvr/3c501.h"
23 #include "msdos/pm_drvr/3c503.h"
24 #include "msdos/pm_drvr/3c509.h"
25 #include "msdos/pm_drvr/3c59x.h"
26 #include "msdos/pm_drvr/3c515.h"
27 #include "msdos/pm_drvr/3c90x.h"
28 #include "msdos/pm_drvr/3c575_cb.h"
29 #include "msdos/pm_drvr/ne.h"
30 #include "msdos/pm_drvr/wd.h"
31 #include "msdos/pm_drvr/accton.h"
32 #include "msdos/pm_drvr/cs89x0.h"
33 #include "msdos/pm_drvr/rtl8139.h"
34 #include "msdos/pm_drvr/ne2k-pci.h"
35 #endif
36
37 #include "pcap.h"
38 #include "pcap-dos.h"
39 #include "pcap-int.h"
40 #include "msdos/pktdrvr.h"
41
42 #ifdef USE_NDIS2
43 #include "msdos/ndis2.h"
44 #endif
45
46 #include <arpa/inet.h>
47 #include <net/if.h>
48 #include <net/if_arp.h>
49 #include <net/if_ether.h>
50 #include <net/if_packe.h>
51 #include <tcp.h>
52
53 #if defined(USE_32BIT_DRIVERS)
54 #define FLUSHK() do { _printk_safe = 1; _printk_flush(); } while (0)
55 #define NDIS_NEXT_DEV &rtl8139_dev
56
57 static char *rx_pool = NULL;
58 static void init_32bit (void);
59
60 static int pktq_init (struct rx_ringbuf *q, int size, int num, char *pool);
61 static int pktq_check (struct rx_ringbuf *q);
62 static int pktq_inc_out (struct rx_ringbuf *q);
63 static int pktq_in_index (struct rx_ringbuf *q) LOCKED_FUNC;
64 static void pktq_clear (struct rx_ringbuf *q) LOCKED_FUNC;
65
66 static struct rx_elem *pktq_in_elem (struct rx_ringbuf *q) LOCKED_FUNC;
67 static struct rx_elem *pktq_out_elem (struct rx_ringbuf *q);
68
69 #else
70 #define FLUSHK() ((void)0)
71 #define NDIS_NEXT_DEV NULL
72 #endif
73
74 /*
75 * Internal variables/functions in Watt-32
76 */
77 extern WORD _pktdevclass;
78 extern BOOL _eth_is_init;
79 extern int _w32_dynamic_host;
80 extern int _watt_do_exit;
81 extern int _watt_is_init;
82 extern int _w32__bootp_on, _w32__dhcp_on, _w32__rarp_on, _w32__do_mask_req;
83 extern void (*_w32_usr_post_init) (void);
84 extern void (*_w32_print_hook)();
85
86 extern void dbug_write (const char *); /* Watt-32 lib, pcdbug.c */
87 extern int pkt_get_mtu (void);
88
89 static int ref_count = 0;
90
91 static u_long mac_count = 0;
92 static u_long filter_count = 0;
93
94 static volatile BOOL exc_occured = 0;
95
96 static struct device *handle_to_device [20];
97
98 static int pcap_activate_dos (pcap_t *p);
99 static int pcap_read_dos (pcap_t *p, int cnt, pcap_handler callback,
100 u_char *data);
101 static void pcap_cleanup_dos (pcap_t *p);
102 static int pcap_stats_dos (pcap_t *p, struct pcap_stat *ps);
103 static int pcap_sendpacket_dos (pcap_t *p, const void *buf, size_t len);
104 static int pcap_setfilter_dos (pcap_t *p, struct bpf_program *fp);
105
106 static int ndis_probe (struct device *dev);
107 static int pkt_probe (struct device *dev);
108
109 static void close_driver (void);
110 static int init_watt32 (struct pcap *pcap, const char *dev_name, char *err_buf);
111 static int first_init (const char *name, char *ebuf, int promisc);
112
113 static void watt32_recv_hook (u_char *dummy, const struct pcap_pkthdr *pcap,
114 const u_char *buf);
115
116 /*
117 * These are the device we always support
118 */
119 static struct device ndis_dev = {
120 "ndis",
121 "NDIS2 LanManager",
122 0,
123 0,0,0,0,0,0,
124 NDIS_NEXT_DEV, /* NULL or a 32-bit device */
125 ndis_probe
126 };
127
128 static struct device pkt_dev = {
129 "pkt",
130 "Packet-Driver",
131 0,
132 0,0,0,0,0,0,
133 &ndis_dev,
134 pkt_probe
135 };
136
137 static struct device *get_device (int fd)
138 {
139 if (fd <= 0 || fd >= sizeof(handle_to_device)/sizeof(handle_to_device[0]))
140 return (NULL);
141 return handle_to_device [fd-1];
142 }
143
144 /*
145 * Private data for capturing on MS-DOS.
146 */
147 struct pcap_dos {
148 void (*wait_proc)(void); /* call proc while waiting */
149 struct pcap_stat stat;
150 };
151
152 pcap_t *pcap_create_interface (const char *device _U_, char *ebuf)
153 {
154 pcap_t *p;
155
156 p = pcap_create_common(ebuf, sizeof (struct pcap_dos));
157 if (p == NULL)
158 return (NULL);
159
160 p->activate_op = pcap_activate_dos;
161 return (p);
162 }
163
164 /*
165 * Open MAC-driver with name 'device_name' for live capture of
166 * network packets.
167 */
168 static int pcap_activate_dos (pcap_t *pcap)
169 {
170 if (pcap->opt.rfmon) {
171 /*
172 * No monitor mode on DOS.
173 */
174 return (PCAP_ERROR_RFMON_NOTSUP);
175 }
176
177 /*
178 * Turn a negative snapshot value (invalid), a snapshot value of
179 * 0 (unspecified), or a value bigger than the normal maximum
180 * value, into the maximum allowed value.
181 *
182 * If some application really *needs* a bigger snapshot
183 * length, we should just increase MAXIMUM_SNAPLEN.
184 */
185 if (pcap->snapshot <= 0 || pcap->snapshot > MAXIMUM_SNAPLEN)
186 pcap->snapshot = MAXIMUM_SNAPLEN;
187
188 if (pcap->snapshot < ETH_MIN+8)
189 pcap->snapshot = ETH_MIN+8;
190
191 if (pcap->snapshot > ETH_MAX) /* silently accept and truncate large MTUs */
192 pcap->snapshot = ETH_MAX;
193
194 pcap->linktype = DLT_EN10MB; /* !! */
195 pcap->cleanup_op = pcap_cleanup_dos;
196 pcap->read_op = pcap_read_dos;
197 pcap->stats_op = pcap_stats_dos;
198 pcap->inject_op = pcap_sendpacket_dos;
199 pcap->setfilter_op = pcap_setfilter_dos;
200 pcap->setdirection_op = NULL; /* Not implemented.*/
201 pcap->fd = ++ref_count;
202
203 pcap->bufsize = ETH_MAX+100; /* add some margin */
204 pcap->buffer = calloc (pcap->bufsize, 1);
205
206 if (pcap->fd == 1) /* first time we're called */
207 {
208 if (!init_watt32(pcap, pcap->opt.device, pcap->errbuf) ||
209 !first_init(pcap->opt.device, pcap->errbuf, pcap->opt.promisc))
210 {
211 /* XXX - free pcap->buffer? */
212 return (PCAP_ERROR);
213 }
214 atexit (close_driver);
215 }
216 else if (stricmp(active_dev->name,pcap->opt.device))
217 {
218 pcap_snprintf (pcap->errbuf, PCAP_ERRBUF_SIZE,
219 "Cannot use different devices simultaneously "
220 "(`%s' vs. `%s')", active_dev->name, pcap->opt.device);
221 /* XXX - free pcap->buffer? */
222 return (PCAP_ERROR);
223 }
224 handle_to_device [pcap->fd-1] = active_dev;
225 return (0);
226 }
227
228 /*
229 * Poll the receiver queue and call the pcap callback-handler
230 * with the packet.
231 */
232 static int
233 pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data)
234 {
235 struct pcap_dos *pd = p->priv;
236 struct pcap_pkthdr pcap;
237 struct timeval now, expiry = { 0,0 };
238 int rx_len = 0;
239
240 if (p->opt.timeout > 0)
241 {
242 gettimeofday2 (&now, NULL);
243 expiry.tv_usec = now.tv_usec + 1000UL * p->opt.timeout;
244 expiry.tv_sec = now.tv_sec;
245 while (expiry.tv_usec >= 1000000L)
246 {
247 expiry.tv_usec -= 1000000L;
248 expiry.tv_sec++;
249 }
250 }
251
252 while (!exc_occured)
253 {
254 volatile struct device *dev; /* might be reset by sig_handler */
255
256 dev = get_device (p->fd);
257 if (!dev)
258 break;
259
260 PCAP_ASSERT (dev->copy_rx_buf || dev->peek_rx_buf);
261 FLUSHK();
262
263 /* If driver has a zero-copy receive facility, peek at the queue,
264 * filter it, do the callback and release the buffer.
265 */
266 if (dev->peek_rx_buf)
267 {
268 PCAP_ASSERT (dev->release_rx_buf);
269 rx_len = (*dev->peek_rx_buf) (&p->buffer);
270 }
271 else
272 {
273 rx_len = (*dev->copy_rx_buf) (p->buffer, p->snapshot);
274 }
275
276 if (rx_len > 0) /* got a packet */
277 {
278 mac_count++;
279
280 FLUSHK();
281
282 pcap.caplen = min (rx_len, p->snapshot);
283 pcap.len = rx_len;
284
285 if (callback &&
286 (!p->fcode.bf_insns || bpf_filter(p->fcode.bf_insns, p->buffer, pcap.len, pcap.caplen)))
287 {
288 filter_count++;
289
290 /* Fix-me!! Should be time of arrival. Not time of
291 * capture.
292 */
293 gettimeofday2 (&pcap.ts, NULL);
294 (*callback) (data, &pcap, p->buffer);
295 }
296
297 if (dev->release_rx_buf)
298 (*dev->release_rx_buf) (p->buffer);
299
300 if (pcap_pkt_debug > 0)
301 {
302 if (callback == watt32_recv_hook)
303 dbug_write ("pcap_recv_hook\n");
304 else dbug_write ("pcap_read_op\n");
305 }
306 FLUSHK();
307 return (1);
308 }
309
310 /* Has "pcap_breakloop()" been called?
311 */
312 if (p->break_loop) {
313 /*
314 * Yes - clear the flag that indicates that it
315 * has, and return -2 to indicate that we were
316 * told to break out of the loop.
317 */
318 p->break_loop = 0;
319 return (-2);
320 }
321
322 /* If not to wait for a packet or pcap_cleanup_dos() called from
323 * e.g. SIGINT handler, exit loop now.
324 */
325 if (p->opt.timeout <= 0 || (volatile int)p->fd <= 0)
326 break;
327
328 gettimeofday2 (&now, NULL);
329
330 if (timercmp(&now, &expiry, >))
331 break;
332
333 #ifndef DJGPP
334 kbhit(); /* a real CPU hog */
335 #endif
336
337 if (pd->wait_proc)
338 (*pd->wait_proc)(); /* call yield func */
339 }
340
341 if (rx_len < 0) /* receive error */
342 {
343 pd->stat.ps_drop++;
344 #ifdef USE_32BIT_DRIVERS
345 if (pcap_pkt_debug > 1)
346 printk ("pkt-err %s\n", pktInfo.error);
347 #endif
348 return (-1);
349 }
350 return (0);
351 }
352
353 static int
354 pcap_read_dos (pcap_t *p, int cnt, pcap_handler callback, u_char *data)
355 {
356 int rc, num = 0;
357
358 while (num <= cnt || PACKET_COUNT_IS_UNLIMITED(cnt))
359 {
360 if (p->fd <= 0)
361 return (-1);
362 rc = pcap_read_one (p, callback, data);
363 if (rc > 0)
364 num++;
365 if (rc < 0)
366 break;
367 _w32_os_yield(); /* allow SIGINT generation, yield to Win95/NT */
368 }
369 return (num);
370 }
371
372 /*
373 * Return network statistics
374 */
375 static int pcap_stats_dos (pcap_t *p, struct pcap_stat *ps)
376 {
377 struct net_device_stats *stats;
378 struct pcap_dos *pd;
379 struct device *dev = p ? get_device(p->fd) : NULL;
380
381 if (!dev)
382 {
383 strcpy (p->errbuf, "illegal pcap handle");
384 return (-1);
385 }
386
387 if (!dev->get_stats || (stats = (*dev->get_stats)(dev)) == NULL)
388 {
389 strcpy (p->errbuf, "device statistics not available");
390 return (-1);
391 }
392
393 FLUSHK();
394
395 pd = p->priv;
396 pd->stat.ps_recv = stats->rx_packets;
397 pd->stat.ps_drop += stats->rx_missed_errors;
398 pd->stat.ps_ifdrop = stats->rx_dropped + /* queue full */
399 stats->rx_errors; /* HW errors */
400 if (ps)
401 *ps = pd->stat;
402
403 return (0);
404 }
405
406 /*
407 * Return detailed network/device statistics.
408 * May be called after 'dev->close' is called.
409 */
410 int pcap_stats_ex (pcap_t *p, struct pcap_stat_ex *se)
411 {
412 struct device *dev = p ? get_device (p->fd) : NULL;
413
414 if (!dev || !dev->get_stats)
415 {
416 strlcpy (p->errbuf, "detailed device statistics not available",
417 PCAP_ERRBUF_SIZE);
418 return (-1);
419 }
420
421 if (!strnicmp(dev->name,"pkt",3))
422 {
423 strlcpy (p->errbuf, "pktdrvr doesn't have detailed statistics",
424 PCAP_ERRBUF_SIZE);
425 return (-1);
426 }
427 memcpy (se, (*dev->get_stats)(dev), sizeof(*se));
428 return (0);
429 }
430
431 /*
432 * Simply store the filter-code for the pcap_read_dos() callback
433 * Some day the filter-code could be handed down to the active
434 * device (pkt_rx1.s or 32-bit device interrupt handler).
435 */
436 static int pcap_setfilter_dos (pcap_t *p, struct bpf_program *fp)
437 {
438 if (!p)
439 return (-1);
440 p->fcode = *fp;
441 return (0);
442 }
443
444 /*
445 * Return # of packets received in pcap_read_dos()
446 */
447 u_long pcap_mac_packets (void)
448 {
449 return (mac_count);
450 }
451
452 /*
453 * Return # of packets passed through filter in pcap_read_dos()
454 */
455 u_long pcap_filter_packets (void)
456 {
457 return (filter_count);
458 }
459
460 /*
461 * Close pcap device. Not called for offline captures.
462 */
463 static void pcap_cleanup_dos (pcap_t *p)
464 {
465 struct pcap_dos *pd;
466
467 if (!exc_occured)
468 {
469 pd = p->priv;
470 if (pcap_stats(p,NULL) < 0)
471 pd->stat.ps_drop = 0;
472 if (!get_device(p->fd))
473 return;
474
475 handle_to_device [p->fd-1] = NULL;
476 p->fd = 0;
477 if (ref_count > 0)
478 ref_count--;
479 if (ref_count > 0)
480 return;
481 }
482 close_driver();
483 /* XXX - call pcap_cleanup_live_common? */
484 }
485
486 /*
487 * Return the name of the 1st network interface,
488 * or NULL if none can be found.
489 */
490 char *pcap_lookupdev (char *ebuf)
491 {
492 struct device *dev;
493
494 #ifdef USE_32BIT_DRIVERS
495 init_32bit();
496 #endif
497
498 for (dev = (struct device*)dev_base; dev; dev = dev->next)
499 {
500 PCAP_ASSERT (dev->probe);
501
502 if ((*dev->probe)(dev))
503 {
504 FLUSHK();
505 probed_dev = (struct device*) dev; /* remember last probed device */
506 return (char*) dev->name;
507 }
508 }
509
510 if (ebuf)
511 strcpy (ebuf, "No driver found");
512 return (NULL);
513 }
514
515 /*
516 * Gets localnet & netmask from Watt-32.
517 */
518 int pcap_lookupnet (const char *device, bpf_u_int32 *localnet,
519 bpf_u_int32 *netmask, char *errbuf)
520 {
521 DWORD mask, net;
522
523 if (!_watt_is_init)
524 {
525 strcpy (errbuf, "pcap_open_offline() or pcap_activate() must be "
526 "called first");
527 return (-1);
528 }
529
530 mask = _w32_sin_mask;
531 net = my_ip_addr & mask;
532 if (net == 0)
533 {
534 if (IN_CLASSA(*netmask))
535 net = IN_CLASSA_NET;
536 else if (IN_CLASSB(*netmask))
537 net = IN_CLASSB_NET;
538 else if (IN_CLASSC(*netmask))
539 net = IN_CLASSC_NET;
540 else
541 {
542 pcap_snprintf (errbuf, PCAP_ERRBUF_SIZE, "inet class for 0x%lx unknown", mask);
543 return (-1);
544 }
545 }
546 *localnet = htonl (net);
547 *netmask = htonl (mask);
548
549 ARGSUSED (device);
550 return (0);
551 }
552
553 /*
554 * Get a list of all interfaces that are present and that we probe okay.
555 * Returns -1 on error, 0 otherwise.
556 * The list may be NULL epty if no interfaces were up and could be opened.
557 */
558 int pcap_platform_finddevs (pcap_if_list_t *devlistp, char *errbuf)
559 {
560 struct device *dev;
561 pcap_if_t *curdev;
562 #if 0 /* Pkt drivers should have no addresses */
563 struct sockaddr_in sa_ll_1, sa_ll_2;
564 struct sockaddr *addr, *netmask, *broadaddr, *dstaddr;
565 #endif
566 int ret = 0;
567 int found = 0;
568
569 for (dev = (struct device*)dev_base; dev; dev = dev->next)
570 {
571 PCAP_ASSERT (dev->probe);
572
573 if (!(*dev->probe)(dev))
574 continue;
575
576 PCAP_ASSERT (dev->close); /* set by probe routine */
577 FLUSHK();
578 (*dev->close) (dev);
579
580 /*
581 * XXX - find out whether it's up or running? Does that apply here?
582 */
583 if ((curdev = add_dev(devlistp, dev->name, 0,
584 dev->long_name, errbuf)) == NULL)
585 {
586 ret = -1;
587 break;
588 }
589 found = 1;
590 #if 0 /* Pkt drivers should have no addresses */
591 memset (&sa_ll_1, 0, sizeof(sa_ll_1));
592 memset (&sa_ll_2, 0, sizeof(sa_ll_2));
593 sa_ll_1.sin_family = AF_INET;
594 sa_ll_2.sin_family = AF_INET;
595
596 addr = (struct sockaddr*) &sa_ll_1;
597 netmask = (struct sockaddr*) &sa_ll_1;
598 dstaddr = (struct sockaddr*) &sa_ll_1;
599 broadaddr = (struct sockaddr*) &sa_ll_2;
600 memset (&sa_ll_2.sin_addr, 0xFF, sizeof(sa_ll_2.sin_addr));
601
602 if (add_addr_to_dev(curdev, addr, sizeof(*addr),
603 netmask, sizeof(*netmask),
604 broadaddr, sizeof(*broadaddr),
605 dstaddr, sizeof(*dstaddr), errbuf) < 0)
606 {
607 ret = -1;
608 break;
609 }
610 #endif
611 }
612
613 if (ret == 0 && !found)
614 strcpy (errbuf, "No drivers found");
615
616 return (ret);
617 }
618
619 /*
620 * pcap_assert() is mainly used for debugging
621 */
622 void pcap_assert (const char *what, const char *file, unsigned line)
623 {
624 FLUSHK();
625 fprintf (stderr, "%s (%u): Assertion \"%s\" failed\n",
626 file, line, what);
627 close_driver();
628 _exit (-1);
629 }
630
631 /*
632 * For pcap_offline_read(): wait and yield between printing packets
633 * to simulate the pace packets where actually recorded.
634 */
635 void pcap_set_wait (pcap_t *p, void (*yield)(void), int wait)
636 {
637 if (p)
638 {
639 struct pcap_dos *pd = p->priv;
640
641 pd->wait_proc = yield;
642 p->opt.timeout = wait;
643 }
644 }
645
646 /*
647 * Initialise a named network device.
648 */
649 static struct device *
650 open_driver (const char *dev_name, char *ebuf, int promisc)
651 {
652 struct device *dev;
653
654 for (dev = (struct device*)dev_base; dev; dev = dev->next)
655 {
656 PCAP_ASSERT (dev->name);
657
658 if (strcmp (dev_name,dev->name))
659 continue;
660
661 if (!probed_dev) /* user didn't call pcap_lookupdev() first */
662 {
663 PCAP_ASSERT (dev->probe);
664
665 if (!(*dev->probe)(dev)) /* call the xx_probe() function */
666 {
667 pcap_snprintf (ebuf, PCAP_ERRBUF_SIZE, "failed to detect device `%s'", dev_name);
668 return (NULL);
669 }
670 probed_dev = dev; /* device is probed okay and may be used */
671 }
672 else if (dev != probed_dev)
673 {
674 goto not_probed;
675 }
676
677 FLUSHK();
678
679 /* Select what traffic to receive
680 */
681 if (promisc)
682 dev->flags |= (IFF_ALLMULTI | IFF_PROMISC);
683 else dev->flags &= ~(IFF_ALLMULTI | IFF_PROMISC);
684
685 PCAP_ASSERT (dev->open);
686
687 if (!(*dev->open)(dev))
688 {
689 pcap_snprintf (ebuf, PCAP_ERRBUF_SIZE, "failed to activate device `%s'", dev_name);
690 if (pktInfo.error && !strncmp(dev->name,"pkt",3))
691 {
692 strcat (ebuf, ": ");
693 strcat (ebuf, pktInfo.error);
694 }
695 return (NULL);
696 }
697
698 /* Some devices need this to operate in promiscous mode
699 */
700 if (promisc && dev->set_multicast_list)
701 (*dev->set_multicast_list) (dev);
702
703 active_dev = dev; /* remember our active device */
704 break;
705 }
706
707 /* 'dev_name' not matched in 'dev_base' list.
708 */
709 if (!dev)
710 {
711 pcap_snprintf (ebuf, PCAP_ERRBUF_SIZE, "device `%s' not supported", dev_name);
712 return (NULL);
713 }
714
715 not_probed:
716 if (!probed_dev)
717 {
718 pcap_snprintf (ebuf, PCAP_ERRBUF_SIZE, "device `%s' not probed", dev_name);
719 return (NULL);
720 }
721 return (dev);
722 }
723
724 /*
725 * Deinitialise MAC driver.
726 * Set receive mode back to default mode.
727 */
728 static void close_driver (void)
729 {
730 /* !!todo: loop over all 'handle_to_device[]' ? */
731 struct device *dev = active_dev;
732
733 if (dev && dev->close)
734 {
735 (*dev->close) (dev);
736 FLUSHK();
737 }
738
739 active_dev = NULL;
740
741 #ifdef USE_32BIT_DRIVERS
742 if (rx_pool)
743 {
744 k_free (rx_pool);
745 rx_pool = NULL;
746 }
747 if (dev)
748 pcibios_exit();
749 #endif
750 }
751
752
753 #ifdef __DJGPP__
754 static void setup_signals (void (*handler)(int))
755 {
756 signal (SIGSEGV,handler);
757 signal (SIGILL, handler);
758 signal (SIGFPE, handler);
759 }
760
761 static void exc_handler (int sig)
762 {
763 #ifdef USE_32BIT_DRIVERS
764 if (active_dev->irq > 0) /* excludes IRQ 0 */
765 {
766 disable_irq (active_dev->irq);
767 irq_eoi_cmd (active_dev->irq);
768 _printk_safe = 1;
769 }
770 #endif
771
772 switch (sig)
773 {
774 case SIGSEGV:
775 fputs ("Catching SIGSEGV.\n", stderr);
776 break;
777 case SIGILL:
778 fputs ("Catching SIGILL.\n", stderr);
779 break;
780 case SIGFPE:
781 _fpreset();
782 fputs ("Catching SIGFPE.\n", stderr);
783 break;
784 default:
785 fprintf (stderr, "Catching signal %d.\n", sig);
786 }
787 exc_occured = 1;
788 close_driver();
789 }
790 #endif /* __DJGPP__ */
791
792
793 /*
794 * Open the pcap device for the first client calling pcap_activate()
795 */
796 static int first_init (const char *name, char *ebuf, int promisc)
797 {
798 struct device *dev;
799
800 #ifdef USE_32BIT_DRIVERS
801 rx_pool = k_calloc (RECEIVE_BUF_SIZE, RECEIVE_QUEUE_SIZE);
802 if (!rx_pool)
803 {
804 strcpy (ebuf, "Not enough memory (Rx pool)");
805 return (0);
806 }
807 #endif
808
809 #ifdef __DJGPP__
810 setup_signals (exc_handler);
811 #endif
812
813 #ifdef USE_32BIT_DRIVERS
814 init_32bit();
815 #endif
816
817 dev = open_driver (name, ebuf, promisc);
818 if (!dev)
819 {
820 #ifdef USE_32BIT_DRIVERS
821 k_free (rx_pool);
822 rx_pool = NULL;
823 #endif
824
825 #ifdef __DJGPP__
826 setup_signals (SIG_DFL);
827 #endif
828 return (0);
829 }
830
831 #ifdef USE_32BIT_DRIVERS
832 /*
833 * If driver is NOT a 16-bit "pkt/ndis" driver (having a 'copy_rx_buf'
834 * set in it's probe handler), initialise near-memory ring-buffer for
835 * the 32-bit device.
836 */
837 if (dev->copy_rx_buf == NULL)
838 {
839 dev->get_rx_buf = get_rxbuf;
840 dev->peek_rx_buf = peek_rxbuf;
841 dev->release_rx_buf = release_rxbuf;
842 pktq_init (&dev->queue, RECEIVE_BUF_SIZE, RECEIVE_QUEUE_SIZE, rx_pool);
843 }
844 #endif
845 return (1);
846 }
847
848 #ifdef USE_32BIT_DRIVERS
849 static void init_32bit (void)
850 {
851 static int init_pci = 0;
852
853 if (!_printk_file)
854 _printk_init (64*1024, NULL); /* calls atexit(printk_exit) */
855
856 if (!init_pci)
857 (void)pci_init(); /* init BIOS32+PCI interface */
858 init_pci = 1;
859 }
860 #endif
861
862
863 /*
864 * Hook functions for using Watt-32 together with pcap
865 */
866 static char rxbuf [ETH_MAX+100]; /* rx-buffer with some margin */
867 static WORD etype;
868 static pcap_t pcap_save;
869
870 static void watt32_recv_hook (u_char *dummy, const struct pcap_pkthdr *pcap,
871 const u_char *buf)
872 {
873 /* Fix me: assumes Ethernet II only */
874 struct ether_header *ep = (struct ether_header*) buf;
875
876 memcpy (rxbuf, buf, pcap->caplen);
877 etype = ep->ether_type;
878 ARGSUSED (dummy);
879 }
880
881 #if (WATTCP_VER >= 0x0224)
882 /*
883 * This function is used by Watt-32 to poll for a packet.
884 * i.e. it's set to bypass _eth_arrived()
885 */
886 static void *pcap_recv_hook (WORD *type)
887 {
888 int len = pcap_read_dos (&pcap_save, 1, watt32_recv_hook, NULL);
889
890 if (len < 0)
891 return (NULL);
892
893 *type = etype;
894 return (void*) &rxbuf;
895 }
896
897 /*
898 * This function is called by Watt-32 (via _eth_xmit_hook).
899 * If dbug_init() was called, we should trace packets sent.
900 */
901 static int pcap_xmit_hook (const void *buf, unsigned len)
902 {
903 int rc = 0;
904
905 if (pcap_pkt_debug > 0)
906 dbug_write ("pcap_xmit_hook: ");
907
908 if (active_dev && active_dev->xmit)
909 if ((*active_dev->xmit) (active_dev, buf, len) > 0)
910 rc = len;
911
912 if (pcap_pkt_debug > 0)
913 dbug_write (rc ? "ok\n" : "fail\n");
914 return (rc);
915 }
916 #endif
917
918 static int pcap_sendpacket_dos (pcap_t *p, const void *buf, size_t len)
919 {
920 struct device *dev = p ? get_device(p->fd) : NULL;
921
922 if (!dev || !dev->xmit)
923 return (-1);
924 return (*dev->xmit) (dev, buf, len);
925 }
926
927 /*
928 * This function is called by Watt-32 in tcp_post_init().
929 * We should prevent Watt-32 from using BOOTP/DHCP/RARP etc.
930 */
931 static void (*prev_post_hook) (void);
932
933 static void pcap_init_hook (void)
934 {
935 _w32__bootp_on = _w32__dhcp_on = _w32__rarp_on = 0;
936 _w32__do_mask_req = 0;
937 _w32_dynamic_host = 0;
938 if (prev_post_hook)
939 (*prev_post_hook)();
940 }
941
942 /*
943 * Supress PRINT message from Watt-32's sock_init()
944 */
945 static void null_print (void) {}
946
947 /*
948 * To use features of Watt-32 (netdb functions and socket etc.)
949 * we must call sock_init(). But we set various hooks to prevent
950 * using normal PKTDRVR functions in pcpkt.c. This should hopefully
951 * make Watt-32 and pcap co-operate.
952 */
953 static int init_watt32 (struct pcap *pcap, const char *dev_name, char *err_buf)
954 {
955 char *env;
956 int rc, MTU, has_ip_addr;
957 int using_pktdrv = 1;
958
959 /* If user called sock_init() first, we need to reinit in
960 * order to open debug/trace-file properly
961 */
962 if (_watt_is_init)
963 sock_exit();
964
965 env = getenv ("PCAP_TRACE");
966 if (env && atoi(env) > 0 &&
967 pcap_pkt_debug < 0) /* if not already set */
968 {
969 dbug_init();
970 pcap_pkt_debug = atoi (env);
971 }
972
973 _watt_do_exit = 0; /* prevent sock_init() calling exit() */
974 prev_post_hook = _w32_usr_post_init;
975 _w32_usr_post_init = pcap_init_hook;
976 _w32_print_hook = null_print;
977
978 if (dev_name && strncmp(dev_name,"pkt",3))
979 using_pktdrv = FALSE;
980
981 rc = sock_init();
982 has_ip_addr = (rc != 8); /* IP-address assignment failed */
983
984 /* if pcap is using a 32-bit driver w/o a pktdrvr loaded, we
985 * just pretend Watt-32 is initialised okay.
986 *
987 * !! fix-me: The Watt-32 config isn't done if no pktdrvr
988 * was found. In that case my_ip_addr + sin_mask
989 * have default values. Should be taken from another
990 * ini-file/environment in any case (ref. tcpdump.ini)
991 */
992 _watt_is_init = 1;
993
994 if (!using_pktdrv || !has_ip_addr) /* for now .... */
995 {
996 static const char myip[] = "192.168.0.1";
997 static const char mask[] = "255.255.255.0";
998
999 printf ("Just guessing, using IP %s and netmask %s\n", myip, mask);
1000 my_ip_addr = aton (myip);
1001 _w32_sin_mask = aton (mask);
1002 }
1003 else if (rc && using_pktdrv)
1004 {
1005 pcap_snprintf (err_buf, PCAP_ERRBUF_SIZE, "sock_init() failed, code %d", rc);
1006 return (0);
1007 }
1008
1009 /* Set recv-hook for peeking in _eth_arrived().
1010 */
1011 #if (WATTCP_VER >= 0x0224)
1012 _eth_recv_hook = pcap_recv_hook;
1013 _eth_xmit_hook = pcap_xmit_hook;
1014 #endif
1015
1016 /* Free the pkt-drvr handle allocated in pkt_init().
1017 * The above hooks should thus use the handle reopened in open_driver()
1018 */
1019 if (using_pktdrv)
1020 {
1021 _eth_release();
1022 /* _eth_is_init = 1; */ /* hack to get Rx/Tx-hooks in Watt-32 working */
1023 }
1024
1025 memcpy (&pcap_save, pcap, sizeof(pcap_save));
1026 MTU = pkt_get_mtu();
1027 pcap_save.fcode.bf_insns = NULL;
1028 pcap_save.linktype = _eth_get_hwtype (NULL, NULL);
1029 pcap_save.snapshot = MTU > 0 ? MTU : ETH_MAX; /* assume 1514 */
1030
1031 #if 1
1032 /* prevent use of resolve() and resolve_ip()
1033 */
1034 last_nameserver = 0;
1035 #endif
1036 return (1);
1037 }
1038
1039 int EISA_bus = 0; /* Where is natural place for this? */
1040
1041 /*
1042 * Application config hooks to set various driver parameters.
1043 */
1044
1045 static const struct config_table debug_tab[] = {
1046 { "PKT.DEBUG", ARG_ATOI, &pcap_pkt_debug },
1047 { "PKT.VECTOR", ARG_ATOX_W, NULL },
1048 { "NDIS.DEBUG", ARG_ATOI, NULL },
1049 #ifdef USE_32BIT_DRIVERS
1050 { "3C503.DEBUG", ARG_ATOI, &ei_debug },
1051 { "3C503.IO_BASE", ARG_ATOX_W, &el2_dev.base_addr },
1052 { "3C503.MEMORY", ARG_ATOX_W, &el2_dev.mem_start },
1053 { "3C503.IRQ", ARG_ATOI, &el2_dev.irq },
1054 { "3C505.DEBUG", ARG_ATOI, NULL },
1055 { "3C505.BASE", ARG_ATOX_W, NULL },
1056 { "3C507.DEBUG", ARG_ATOI, NULL },
1057 { "3C509.DEBUG", ARG_ATOI, &el3_debug },
1058 { "3C509.ILOOP", ARG_ATOI, &el3_max_loop },
1059 { "3C529.DEBUG", ARG_ATOI, NULL },
1060 { "3C575.DEBUG", ARG_ATOI, &debug_3c575 },
1061 { "3C59X.DEBUG", ARG_ATOI, &vortex_debug },
1062 { "3C59X.IFACE0", ARG_ATOI, &vortex_options[0] },
1063 { "3C59X.IFACE1", ARG_ATOI, &vortex_options[1] },
1064 { "3C59X.IFACE2", ARG_ATOI, &vortex_options[2] },
1065 { "3C59X.IFACE3", ARG_ATOI, &vortex_options[3] },
1066 { "3C90X.DEBUG", ARG_ATOX_W, &tc90xbc_debug },
1067 { "ACCT.DEBUG", ARG_ATOI, &ethpk_debug },
1068 { "CS89.DEBUG", ARG_ATOI, &cs89_debug },
1069 { "RTL8139.DEBUG", ARG_ATOI, &rtl8139_debug },
1070 /* { "RTL8139.FDUPLEX", ARG_ATOI, &rtl8139_options }, */
1071 { "SMC.DEBUG", ARG_ATOI, &ei_debug },
1072 /* { "E100.DEBUG", ARG_ATOI, &e100_debug }, */
1073 { "PCI.DEBUG", ARG_ATOI, &pci_debug },
1074 { "BIOS32.DEBUG", ARG_ATOI, &bios32_debug },
1075 { "IRQ.DEBUG", ARG_ATOI, &irq_debug },
1076 { "TIMER.IRQ", ARG_ATOI, &timer_irq },
1077 #endif
1078 { NULL }
1079 };
1080
1081 /*
1082 * pcap_config_hook() is an extension to application's config
1083 * handling. Uses Watt-32's config-table function.
1084 */
1085 int pcap_config_hook (const char *keyword, const char *value)
1086 {
1087 return parse_config_table (debug_tab, NULL, keyword, value);
1088 }
1089
1090 /*
1091 * Linked list of supported devices
1092 */
1093 struct device *active_dev = NULL; /* the device we have opened */
1094 struct device *probed_dev = NULL; /* the device we have probed */
1095 const struct device *dev_base = &pkt_dev; /* list of network devices */
1096
1097 /*
1098 * PKTDRVR device functions
1099 */
1100 int pcap_pkt_debug = -1;
1101
1102 static void pkt_close (struct device *dev)
1103 {
1104 BOOL okay = PktExitDriver();
1105
1106 if (pcap_pkt_debug > 1)
1107 fprintf (stderr, "pkt_close(): %d\n", okay);
1108
1109 if (dev->priv)
1110 free (dev->priv);
1111 dev->priv = NULL;
1112 }
1113
1114 static int pkt_open (struct device *dev)
1115 {
1116 PKT_RX_MODE mode;
1117
1118 if (dev->flags & IFF_PROMISC)
1119 mode = PDRX_ALL_PACKETS;
1120 else mode = PDRX_BROADCAST;
1121
1122 if (!PktInitDriver(mode))
1123 return (0);
1124
1125 PktResetStatistics (pktInfo.handle);
1126 PktQueueBusy (FALSE);
1127 return (1);
1128 }
1129
1130 static int pkt_xmit (struct device *dev, const void *buf, int len)
1131 {
1132 struct net_device_stats *stats = (struct net_device_stats*) dev->priv;
1133
1134 if (pcap_pkt_debug > 0)
1135 dbug_write ("pcap_xmit\n");
1136
1137 if (!PktTransmit(buf,len))
1138 {
1139 stats->tx_errors++;
1140 return (0);
1141 }
1142 return (len);
1143 }
1144
1145 static void *pkt_stats (struct device *dev)
1146 {
1147 struct net_device_stats *stats = (struct net_device_stats*) dev->priv;
1148
1149 if (!stats || !PktSessStatistics(pktInfo.handle))
1150 return (NULL);
1151
1152 stats->rx_packets = pktStat.inPackets;
1153 stats->rx_errors = pktStat.lost;
1154 stats->rx_missed_errors = PktRxDropped();
1155 return (stats);
1156 }
1157
1158 static int pkt_probe (struct device *dev)
1159 {
1160 if (!PktSearchDriver())
1161 return (0);
1162
1163 dev->open = pkt_open;
1164 dev->xmit = pkt_xmit;
1165 dev->close = pkt_close;
1166 dev->get_stats = pkt_stats;
1167 dev->copy_rx_buf = PktReceive; /* farmem peek and copy routine */
1168 dev->get_rx_buf = NULL;
1169 dev->peek_rx_buf = NULL;
1170 dev->release_rx_buf = NULL;
1171 dev->priv = calloc (sizeof(struct net_device_stats), 1);
1172 if (!dev->priv)
1173 return (0);
1174 return (1);
1175 }
1176
1177 /*
1178 * NDIS device functions
1179 */
1180 static void ndis_close (struct device *dev)
1181 {
1182 #ifdef USE_NDIS2
1183 NdisShutdown();
1184 #endif
1185 ARGSUSED (dev);
1186 }
1187
1188 static int ndis_open (struct device *dev)
1189 {
1190 int promis = (dev->flags & IFF_PROMISC);
1191
1192 #ifdef USE_NDIS2
1193 if (!NdisInit(promis))
1194 return (0);
1195 return (1);
1196 #else
1197 ARGSUSED (promis);
1198 return (0);
1199 #endif
1200 }
1201
1202 static void *ndis_stats (struct device *dev)
1203 {
1204 static struct net_device_stats stats;
1205
1206 /* to-do */
1207 ARGSUSED (dev);
1208 return (&stats);
1209 }
1210
1211 static int ndis_probe (struct device *dev)
1212 {
1213 #ifdef USE_NDIS2
1214 if (!NdisOpen())
1215 return (0);
1216 #endif
1217
1218 dev->open = ndis_open;
1219 dev->xmit = NULL;
1220 dev->close = ndis_close;
1221 dev->get_stats = ndis_stats;
1222 dev->copy_rx_buf = NULL; /* to-do */
1223 dev->get_rx_buf = NULL; /* upcall is from rmode driver */
1224 dev->peek_rx_buf = NULL;
1225 dev->release_rx_buf = NULL;
1226 return (0);
1227 }
1228
1229 /*
1230 * Search & probe for supported 32-bit (pmode) pcap devices
1231 */
1232 #if defined(USE_32BIT_DRIVERS)
1233
1234 struct device el2_dev LOCKED_VAR = {
1235 "3c503",
1236 "EtherLink II",
1237 0,
1238 0,0,0,0,0,0,
1239 NULL,
1240 el2_probe
1241 };
1242
1243 struct device el3_dev LOCKED_VAR = {
1244 "3c509",
1245 "EtherLink III",
1246 0,
1247 0,0,0,0,0,0,
1248 &el2_dev,
1249 el3_probe
1250 };
1251
1252 struct device tc515_dev LOCKED_VAR = {
1253 "3c515",
1254 "EtherLink PCI",
1255 0,
1256 0,0,0,0,0,0,
1257 &el3_dev,
1258 tc515_probe
1259 };
1260
1261 struct device tc59_dev LOCKED_VAR = {
1262 "3c59x",
1263 "EtherLink PCI",
1264 0,
1265 0,0,0,0,0,0,
1266 &tc515_dev,
1267 tc59x_probe
1268 };
1269
1270 struct device tc90xbc_dev LOCKED_VAR = {
1271 "3c90x",
1272 "EtherLink 90X",
1273 0,
1274 0,0,0,0,0,0,
1275 &tc59_dev,
1276 tc90xbc_probe
1277 };
1278
1279 struct device wd_dev LOCKED_VAR = {
1280 "wd",
1281 "Westen Digital",
1282 0,
1283 0,0,0,0,0,0,
1284 &tc90xbc_dev,
1285 wd_probe
1286 };
1287
1288 struct device ne_dev LOCKED_VAR = {
1289 "ne",
1290 "NEx000",
1291 0,
1292 0,0,0,0,0,0,
1293 &wd_dev,
1294 ne_probe
1295 };
1296
1297 struct device acct_dev LOCKED_VAR = {
1298 "acct",
1299 "Accton EtherPocket",
1300 0,
1301 0,0,0,0,0,0,
1302 &ne_dev,
1303 ethpk_probe
1304 };
1305
1306 struct device cs89_dev LOCKED_VAR = {
1307 "cs89",
1308 "Crystal Semiconductor",
1309 0,
1310 0,0,0,0,0,0,
1311 &acct_dev,
1312 cs89x0_probe
1313 };
1314
1315 struct device rtl8139_dev LOCKED_VAR = {
1316 "rtl8139",
1317 "RealTek PCI",
1318 0,
1319 0,0,0,0,0,0,
1320 &cs89_dev,
1321 rtl8139_probe /* dev->probe routine */
1322 };
1323
1324 /*
1325 * Dequeue routine is called by polling.
1326 * NOTE: the queue-element is not copied, only a pointer is
1327 * returned at '*buf'
1328 */
1329 int peek_rxbuf (BYTE **buf)
1330 {
1331 struct rx_elem *tail, *head;
1332
1333 PCAP_ASSERT (pktq_check (&active_dev->queue));
1334
1335 DISABLE();
1336 tail = pktq_out_elem (&active_dev->queue);
1337 head = pktq_in_elem (&active_dev->queue);
1338 ENABLE();
1339
1340 if (head != tail)
1341 {
1342 PCAP_ASSERT (tail->size < active_dev->queue.elem_size-4-2);
1343
1344 *buf = &tail->data[0];
1345 return (tail->size);
1346 }
1347 *buf = NULL;
1348 return (0);
1349 }
1350
1351 /*
1352 * Release buffer we peeked at above.
1353 */
1354 int release_rxbuf (BYTE *buf)
1355 {
1356 #ifndef NDEBUG
1357 struct rx_elem *tail = pktq_out_elem (&active_dev->queue);
1358
1359 PCAP_ASSERT (&tail->data[0] == buf);
1360 #else
1361 ARGSUSED (buf);
1362 #endif
1363 pktq_inc_out (&active_dev->queue);
1364 return (1);
1365 }
1366
1367 /*
1368 * get_rxbuf() routine (in locked code) is called from IRQ handler
1369 * to request a buffer. Interrupts are disabled and we have a 32kB stack.
1370 */
1371 BYTE *get_rxbuf (int len)
1372 {
1373 int idx;
1374
1375 if (len < ETH_MIN || len > ETH_MAX)
1376 return (NULL);
1377
1378 idx = pktq_in_index (&active_dev->queue);
1379
1380 #ifdef DEBUG
1381 {
1382 static int fan_idx LOCKED_VAR = 0;
1383 writew ("-\\|/"[fan_idx++] | (15 << 8), /* white on black colour */
1384 0xB8000 + 2*79); /* upper-right corner, 80-col colour screen */
1385 fan_idx &= 3;
1386 }
1387 /* writew (idx + '0' + 0x0F00, 0xB8000 + 2*78); */
1388 #endif
1389
1390 if (idx != active_dev->queue.out_index)
1391 {
1392 struct rx_elem *head = pktq_in_elem (&active_dev->queue);
1393
1394 head->size = len;
1395 active_dev->queue.in_index = idx;
1396 return (&head->data[0]);
1397 }
1398
1399 /* !!to-do: drop 25% of the oldest element
1400 */
1401 pktq_clear (&active_dev->queue);
1402 return (NULL);
1403 }
1404
1405 /*
1406 * Simple ring-buffer queue handler for reception of packets
1407 * from network driver.
1408 */
1409 #define PKTQ_MARKER 0xDEADBEEF
1410
1411 static int pktq_check (struct rx_ringbuf *q)
1412 {
1413 #ifndef NDEBUG
1414 int i;
1415 char *buf;
1416 #endif
1417
1418 if (!q || !q->num_elem || !q->buf_start)
1419 return (0);
1420
1421 #ifndef NDEBUG
1422 buf = q->buf_start;
1423
1424 for (i = 0; i < q->num_elem; i++)
1425 {
1426 buf += q->elem_size;
1427 if (*(DWORD*)(buf - sizeof(DWORD)) != PKTQ_MARKER)
1428 return (0);
1429 }
1430 #endif
1431 return (1);
1432 }
1433
1434 static int pktq_init (struct rx_ringbuf *q, int size, int num, char *pool)
1435 {
1436 int i;
1437
1438 q->elem_size = size;
1439 q->num_elem = num;
1440 q->buf_start = pool;
1441 q->in_index = 0;
1442 q->out_index = 0;
1443
1444 PCAP_ASSERT (size >= sizeof(struct rx_elem) + sizeof(DWORD));
1445 PCAP_ASSERT (num);
1446 PCAP_ASSERT (pool);
1447
1448 for (i = 0; i < num; i++)
1449 {
1450 #if 0
1451 struct rx_elem *elem = (struct rx_elem*) pool;
1452
1453 /* assert dword aligned elements
1454 */
1455 PCAP_ASSERT (((unsigned)(&elem->data[0]) & 3) == 0);
1456 #endif
1457 pool += size;
1458 *(DWORD*) (pool - sizeof(DWORD)) = PKTQ_MARKER;
1459 }
1460 return (1);
1461 }
1462
1463 /*
1464 * Increment the queue 'out_index' (tail).
1465 * Check for wraps.
1466 */
1467 static int pktq_inc_out (struct rx_ringbuf *q)
1468 {
1469 q->out_index++;
1470 if (q->out_index >= q->num_elem)
1471 q->out_index = 0;
1472 return (q->out_index);
1473 }
1474
1475 /*
1476 * Return the queue's next 'in_index' (head).
1477 * Check for wraps.
1478 */
1479 static int pktq_in_index (struct rx_ringbuf *q)
1480 {
1481 volatile int index = q->in_index + 1;
1482
1483 if (index >= q->num_elem)
1484 index = 0;
1485 return (index);
1486 }
1487
1488 /*
1489 * Return the queue's head-buffer.
1490 */
1491 static struct rx_elem *pktq_in_elem (struct rx_ringbuf *q)
1492 {
1493 return (struct rx_elem*) (q->buf_start + (q->elem_size * q->in_index));
1494 }
1495
1496 /*
1497 * Return the queue's tail-buffer.
1498 */
1499 static struct rx_elem *pktq_out_elem (struct rx_ringbuf *q)
1500 {
1501 return (struct rx_elem*) (q->buf_start + (q->elem_size * q->out_index));
1502 }
1503
1504 /*
1505 * Clear the queue ring-buffer by setting head=tail.
1506 */
1507 static void pktq_clear (struct rx_ringbuf *q)
1508 {
1509 q->in_index = q->out_index;
1510 }
1511
1512 /*
1513 * Symbols that must be linkable for "gcc -O0"
1514 */
1515 #undef __IOPORT_H
1516 #undef __DMA_H
1517
1518 #define extern
1519 #define __inline__
1520
1521 #include "msdos/pm_drvr/ioport.h"
1522 #include "msdos/pm_drvr/dma.h"
1523
1524 #endif /* USE_32BIT_DRIVERS */
1525
1526 #include "pcap_version.h"
1527
1528 /*
1529 * Libpcap version string.
1530 */
1531 const char *
1532 pcap_lib_version(void)
1533 {
1534 return ("DOS-" PCAP_VERSION_STRING);
1535 }