From 36201eba9d2a4091ce21d0c6a2c053415bf66f95 Mon Sep 17 00:00:00 2001 From: cracyc Date: Sat, 2 Mar 2013 03:29:47 +0000 Subject: [PATCH] dinetwork: remove mcast_chk and check for multicast in recv (nw) netdev_tap: do mac filtering (nw) --- src/emu/dinetwork.c | 6 ------ src/emu/dinetwork.h | 1 - src/mess/machine/3c505.c | 20 +++++++------------- src/mess/machine/3c505.h | 1 - src/mess/machine/dp8390.c | 10 +++------- src/mess/machine/dp8390.h | 1 - src/mess/machine/mb8795.c | 5 ----- src/mess/machine/mb8795.h | 1 - src/osd/sdl/netdev_tap.c | 4 +++- 9 files changed, 13 insertions(+), 36 deletions(-) diff --git a/src/emu/dinetwork.c b/src/emu/dinetwork.c index fa95739e038..2702a84bf8f 100644 --- a/src/emu/dinetwork.c +++ b/src/emu/dinetwork.c @@ -26,12 +26,6 @@ void device_network_interface::recv_cb(UINT8 *buf, int len) { } -bool device_network_interface::mcast_chk(const UINT8 *buf, int len) -{ - // reject multicast packets - return false; -} - void device_network_interface::set_promisc(bool promisc) { m_promisc = promisc; diff --git a/src/emu/dinetwork.h b/src/emu/dinetwork.h index bc1546e17c4..b239fe2ceb0 100644 --- a/src/emu/dinetwork.h +++ b/src/emu/dinetwork.h @@ -19,7 +19,6 @@ public: int send(UINT8 *buf, int len); virtual void recv_cb(UINT8 *buf, int len); - virtual bool mcast_chk(const UINT8 *buf, int len); protected: bool m_promisc; diff --git a/src/mess/machine/3c505.c b/src/mess/machine/3c505.c index 956ff1c21f9..c463bd14750 100644 --- a/src/mess/machine/3c505.c +++ b/src/mess/machine/3c505.c @@ -855,6 +855,13 @@ int threecom3c505_device::ethernet_packet_is_for_me(const UINT8 mac_address[]) return 1; } } + for (i = 0; i + ETHERNET_ADDR_SIZE < sizeof(m_multicast_list); i += ETHERNET_ADDR_SIZE) + { + if (memcmp(mac_address, m_multicast_list + i, ETHERNET_ADDR_SIZE) == 0) + { + return 1; + } + } return 0; } @@ -896,19 +903,6 @@ void threecom3c505_device::recv_cb(UINT8 *data, int length) } } -bool threecom3c505_device::mcast_chk(const UINT8 *buf, int len) { - int i; - for (i = 0; i + ETHERNET_ADDR_SIZE < sizeof(m_multicast_list); i += ETHERNET_ADDR_SIZE) - { - if (memcmp(buf, m_multicast_list + i, ETHERNET_ADDR_SIZE) == 0) - { - LOG2(("threecom3c505_device::mcast_chk: true (len=%d)", len)); - return true; - } - } - return false; -} - void threecom3c505_device::write_command_port( UINT8 data) { LOG2(("writing 3C505 command port %02x - m_status=%02x m_control=%02x m_command_index=%02x", data, m_status, m_control, m_command_index)); diff --git a/src/mess/machine/3c505.h b/src/mess/machine/3c505.h index ba9209fe525..8ef2bfc8c47 100644 --- a/src/mess/machine/3c505.h +++ b/src/mess/machine/3c505.h @@ -163,7 +163,6 @@ public: static void static_set_interface(device_t &device, const threecom3c505_interface &interface); void recv_cb(UINT8 *buf, int len); - bool mcast_chk(const UINT8 *buf, int len); // device register I/O UINT8 read_port(offs_t offset); diff --git a/src/mess/machine/dp8390.c b/src/mess/machine/dp8390.c index 6c644ddb40f..a20d42f7e38 100644 --- a/src/mess/machine/dp8390.c +++ b/src/mess/machine/dp8390.c @@ -132,7 +132,9 @@ void dp8390_device::recv(UINT8 *buf, int len) { offset = start + 4; high16 = (m_regs.dcr & 4)?m_regs.rsar<<16:0; if(buf[0] & 1) { - if(!(m_regs.rcr & 4) && !memcmp((const char *)buf, "\xff\xff\xff\xff\xff\xff", 6)) return; + if(!memcmp((const char *)buf, "\xff\xff\xff\xff\xff\xff", 6)) { + if(!(m_regs.rcr & 4)) return; + } else return; // multicast m_regs.rsr = 0x20; } else m_regs.rsr = 0; len &= 0xffff; @@ -161,12 +163,6 @@ void dp8390_device::recv_cb(UINT8 *buf, int len) { if(!LOOPBACK) recv(buf, len); } -bool dp8390_device::mcast_chk(const UINT8 *buf, int len) { - if(!(m_regs.rcr & 8)) return false; - - return false; // TODO: multicast -} - WRITE_LINE_MEMBER(dp8390_device::dp8390_cs) { m_cs = state; } diff --git a/src/mess/machine/dp8390.h b/src/mess/machine/dp8390.h index a97a3e35825..7078334b558 100644 --- a/src/mess/machine/dp8390.h +++ b/src/mess/machine/dp8390.h @@ -33,7 +33,6 @@ public: DECLARE_WRITE_LINE_MEMBER( dp8390_cs ); DECLARE_WRITE_LINE_MEMBER( dp8390_reset ); void recv_cb(UINT8 *buf, int len); - bool mcast_chk(const UINT8* buf, int len); protected: // device-level overrides diff --git a/src/mess/machine/mb8795.c b/src/mess/machine/mb8795.c index 04c95822c9a..58b4265b3d4 100644 --- a/src/mess/machine/mb8795.c +++ b/src/mess/machine/mb8795.c @@ -79,11 +79,6 @@ void mb8795_device::recv_cb(UINT8 *buf, int len) receive(); } -bool mb8795_device::mcast_chk(const UINT8 *buf, int len) -{ - return true; -} - READ8_MEMBER(mb8795_device::txstat_r) { // fprintf(stderr, "mb8795: txstat_r %02x (%08x)\n", txstat, space.device().safe_pc()); diff --git a/src/mess/machine/mb8795.h b/src/mess/machine/mb8795.h index f08dbdc1b18..40cd1d6b156 100644 --- a/src/mess/machine/mb8795.h +++ b/src/mess/machine/mb8795.h @@ -43,7 +43,6 @@ protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); virtual void recv_cb(UINT8 *buf, int len); - virtual bool mcast_chk(const UINT8* buf, int len); private: enum { TIMER_TX, TIMER_RX }; diff --git a/src/osd/sdl/netdev_tap.c b/src/osd/sdl/netdev_tap.c index 86f734cc7ed..b19cc8d9720 100644 --- a/src/osd/sdl/netdev_tap.c +++ b/src/osd/sdl/netdev_tap.c @@ -81,7 +81,9 @@ int netdev_tap::recv_dev(UINT8 **buf) { int len; if(m_fd == -1) return 0; - len = read(m_fd, m_buf, sizeof(m_buf)); + do { + len = read(m_fd, m_buf, sizeof(m_buf)); + } while(!get_promisc() && memcmp(get_mac(), m_buf, 6)); *buf = m_buf; return (len == -1)?0:len; }