dect
/
libpcap
Archived
13
0
Fork 0

From Gisle Vanem and me: fix some typoes of mine in the conversion to

the new pcap_create/pcap_activate model, use pcap->opt.source rather
than pcap->md.device in the activate routine (pcap->md.device isn't
set), don't free the pcap_t if the activate routine fails, fix the
error return code paths not to set handle_to_device, fix references to
pcap_close_dos() to refer to pcap_cleanup_dos() as we renamed the
routine.
This commit is contained in:
guy 2008-04-19 17:49:21 +00:00
parent 3fdd4aeaf4
commit ddfa7ac185
1 changed files with 11 additions and 15 deletions

View File

@ -5,7 +5,7 @@
* pcap-dos.c: Interface to PKTDRVR, NDIS2 and 32-bit pmode * pcap-dos.c: Interface to PKTDRVR, NDIS2 and 32-bit pmode
* network drivers. * network drivers.
* *
* @(#) $Header: /tcpdump/master/libpcap/pcap-dos.c,v 1.5 2008-04-14 20:40:58 guy Exp $ (LBL) * @(#) $Header: /tcpdump/master/libpcap/pcap-dos.c,v 1.6 2008-04-19 17:49:21 guy Exp $ (LBL)
*/ */
#include <stdio.h> #include <stdio.h>
@ -97,10 +97,10 @@ static volatile BOOL exc_occured = 0;
static struct device *handle_to_device [20]; static struct device *handle_to_device [20];
static void pcap_activate_dos (pcap_t *p); static int pcap_activate_dos (pcap_t *p);
static int pcap_read_dos (pcap_t *p, int cnt, pcap_handler callback, static int pcap_read_dos (pcap_t *p, int cnt, pcap_handler callback,
u_char *data); u_char *data);
static void pcap_close_dos (pcap_t *p); static void pcap_cleanup_dos (pcap_t *p);
static int pcap_stats_dos (pcap_t *p, struct pcap_stat *ps); 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_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 pcap_setfilter_dos (pcap_t *p, struct bpf_program *fp);
@ -161,9 +161,7 @@ pcap_t *pcap_create (const char *device, char *ebuf)
*/ */
static int pcap_activate_dos (pcap_t *pcap) static int pcap_activate_dos (pcap_t *pcap)
{ {
int err = 0; if (pcap->opt.rfmon) {
if (p->opt.rfmon) {
/* /*
* No monitor mode on DOS. * No monitor mode on DOS.
*/ */
@ -187,24 +185,22 @@ static int pcap_activate_dos (pcap_t *pcap)
if (pcap->fd == 1) /* first time we're called */ if (pcap->fd == 1) /* first time we're called */
{ {
if (!init_watt32(pcap, pcap->md.device, pcap->errbuf) || if (!init_watt32(pcap, pcap->opt.source, pcap->errbuf) ||
!first_init(pcap->md.device, pcap->errbuf, pcap->opt.promisc)) !first_init(pcap->opt.source, pcap->errbuf, pcap->opt.promisc))
{ {
free (pcap);
return (PCAP_ERROR); return (PCAP_ERROR);
} }
atexit (close_driver); atexit (close_driver);
} }
else if (stricmp(active_dev->name,pcap->md.device)) else if (stricmp(active_dev->name,pcap->opt.source))
{ {
snprintf (pcap->errbuf, PCAP_ERRBUF_SIZE, snprintf (pcap->errbuf, PCAP_ERRBUF_SIZE,
"Cannot use different devices simultaneously " "Cannot use different devices simultaneously "
"(`%s' vs. `%s')", active_dev->name, pcap->md.device); "(`%s' vs. `%s')", active_dev->name, pcap->opt.source);
free (pcap); return (PCAP_ERROR);
err = PCAP_ERROR;
} }
handle_to_device [pcap->fd-1] = active_dev; handle_to_device [pcap->fd-1] = active_dev;
return (err); return (0);
} }
/* /*
@ -743,7 +739,7 @@ static void exc_handler (int sig)
fprintf (stderr, "Catching signal %d.\n", sig); fprintf (stderr, "Catching signal %d.\n", sig);
} }
exc_occured = 1; exc_occured = 1;
pcap_close_dos (NULL); pcap_cleanup_dos (NULL);
} }
#endif /* __DJGPP__ */ #endif /* __DJGPP__ */