diff --git a/src/osd/modules/netdev/pcap.c b/src/osd/modules/netdev/pcap.c index 29e642490bb..3e48aebb057 100644 --- a/src/osd/modules/netdev/pcap.c +++ b/src/osd/modules/netdev/pcap.c @@ -189,7 +189,14 @@ void netdev_pcap::set_mac(const char *mac) int netdev_pcap::send(UINT8 *buf, int len) { - if(!m_p) return 0; + int ret; + if(!m_p) { + printf("send invoked, but no pcap context\n"); + return 0; + } + ret = pcap_sendpacket_dl(m_p, buf, len); + printf("sent packet length %d, returned %d\n", len, ret); + return ret ? len : 0; return (!pcap_sendpacket_dl(m_p, buf, len))?len:0; } @@ -219,6 +226,7 @@ int netdev_pcap::recv_dev(UINT8 **buf) netdev_pcap::~netdev_pcap() { if(m_p) pcap_close_dl(m_p); + m_p = NULL; } static CREATE_NETDEV(create_pcap) @@ -279,7 +287,11 @@ int pcap_module::init() while(devs) { - add_netdev(devs->name, devs->description, create_pcap); + if(devs->description) { + add_netdev(devs->name, devs->description, create_pcap); + } else { + add_netdev(devs->name, devs->name, create_pcap); + } devs = devs->next; } return 0; diff --git a/src/osd/osdnet.c b/src/osd/osdnet.c index 68e0b12be9e..f62156b7149 100644 --- a/src/osd/osdnet.c +++ b/src/osd/osdnet.c @@ -39,11 +39,15 @@ class osd_netdev *open_netdev(int id, class device_network_interface *ifdev, int osd_netdev::osd_netdev(class device_network_interface *ifdev, int rate) { m_dev = ifdev; - ifdev->device().machine().scheduler().timer_pulse(attotime::from_hz(rate), timer_expired_delegate(FUNC(osd_netdev::recv), this)); + m_stop = false; + m_timer = ifdev->device().machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(osd_netdev::recv), this)); + m_timer->adjust(attotime::from_hz(rate), 0, attotime::from_hz(rate)); } osd_netdev::~osd_netdev() { + m_stop = true; + m_timer->reset(); } int osd_netdev::send(UINT8 *buf, int len) @@ -56,7 +60,7 @@ void osd_netdev::recv(void *ptr, int param) UINT8 *buf; int len; //const char atalkmac[] = { 0x09, 0x00, 0x07, 0xff, 0xff, 0xff }; - while((len = recv_dev(&buf))) + while((!m_stop) && (len = recv_dev(&buf))) { #if 0 if(buf[0] & 1) diff --git a/src/osd/osdnet.h b/src/osd/osdnet.h index 305570d42c4..0ea37834f9d 100644 --- a/src/osd/osdnet.h +++ b/src/osd/osdnet.h @@ -36,6 +36,8 @@ private: void recv(void *ptr, int param); class device_network_interface *m_dev; + emu_timer *m_timer; + bool m_stop; }; class osd_netdev *open_netdev(int id, class device_network_interface *ifdev, int rate);