mirror of
https://github.com/holub/mame
synced 2025-07-12 21:19:14 +03:00
* dp8390: improve address filtering * osd: remove mac address filter from osd (fixes #13586)
This commit is contained in:
parent
4b2084a6c3
commit
9058810fe2
@ -709,8 +709,6 @@ void am7990_device_base::initialize()
|
||||
|
||||
m_mode = init_block[0];
|
||||
|
||||
set_promisc(m_mode & MODE_PROM);
|
||||
|
||||
put_u16le(&m_physical_addr[0], init_block[1]);
|
||||
put_u16le(&m_physical_addr[2], init_block[2]);
|
||||
put_u16le(&m_physical_addr[4], init_block[3]);
|
||||
|
@ -126,12 +126,23 @@ void dp8390_device::recv(uint8_t *buf, int len) {
|
||||
high16 = (m_regs.dcr & 4)?m_regs.rsar<<16:0;
|
||||
if(buf[0] & 1) {
|
||||
if(!memcmp((const char *)buf, "\xff\xff\xff\xff\xff\xff", 6)) {
|
||||
// broadcast
|
||||
if(!(m_regs.rcr & 4)) return;
|
||||
} else if (memcmp((const char *)buf, "\x09\x00\x07\xff\xff\xff", 6) != 0) { // not AppleTalk broadcast
|
||||
return; // multicast
|
||||
} else {
|
||||
// multicast
|
||||
if(!(m_regs.rcr & 8)) return;
|
||||
unsigned const crc = util::crc32_creator::simple(buf, 6) >> 26;
|
||||
if(!BIT(m_regs.mar[crc >> 3], crc & 7)) return;
|
||||
}
|
||||
m_regs.rsr = 0x20;
|
||||
} else m_regs.rsr = 0;
|
||||
} else if(m_regs.rcr & 0x10) {
|
||||
// promiscuous
|
||||
m_regs.rsr = 0;
|
||||
} else {
|
||||
// physical
|
||||
if(memcmp(m_regs.par, buf, 6)) return;
|
||||
m_regs.rsr = 0;
|
||||
}
|
||||
len &= 0xffff;
|
||||
|
||||
for(i = 0; i < len; i++) {
|
||||
@ -403,7 +414,6 @@ void dp8390_device::cs_write(offs_t offset, uint8_t data) {
|
||||
break;
|
||||
case 0x0c:
|
||||
m_regs.rcr = data;
|
||||
set_promisc((data & 0x10)?true:false);
|
||||
break;
|
||||
case 0x0d:
|
||||
m_regs.tcr = data;
|
||||
|
@ -65,8 +65,6 @@ void mb8795_device::device_reset()
|
||||
|
||||
txlen = rxlen = txcount = 0;
|
||||
|
||||
set_promisc(true);
|
||||
|
||||
start_send();
|
||||
}
|
||||
|
||||
|
@ -179,8 +179,6 @@ void smc91c9x_device::device_reset()
|
||||
|
||||
m_reg[B3_ERCV] = 0x331f; m_regmask[B3_ERCV] = 0x009f;
|
||||
|
||||
set_promisc(false);
|
||||
|
||||
update_ethernet_irq();
|
||||
|
||||
// Reset MMU
|
||||
@ -935,11 +933,6 @@ void smc91c9x_device::write(offs_t offset, u16 data, u16 mem_mask)
|
||||
m_reg[B0_EPH_STATUS] |= LINK_OK;
|
||||
}
|
||||
|
||||
if ((old_reg ^ new_reg) & PRMS)
|
||||
{
|
||||
set_promisc(new_reg & PRMS);
|
||||
}
|
||||
|
||||
if (VERBOSE & LOG_GENERAL)
|
||||
{
|
||||
if (data & SOFT_RST) LOG(" SOFT RST\n");
|
||||
@ -972,8 +965,6 @@ void smc91c9x_device::write(offs_t offset, u16 data, u16 mem_mask)
|
||||
case B1_IA4_5:
|
||||
if ( ACCESSING_BITS_8_15 )
|
||||
{
|
||||
set_promisc(m_reg[B0_RCR] & PRMS);
|
||||
|
||||
u8 mac[6];
|
||||
put_u16le(&mac[0], m_reg[B1_IA0_1]);
|
||||
put_u16le(&mac[2], m_reg[B1_IA2_3]);
|
||||
|
@ -133,18 +133,9 @@ TIMER_CALLBACK_MEMBER(device_network_interface::recv_complete)
|
||||
start_net_device();
|
||||
}
|
||||
|
||||
void device_network_interface::set_promisc(bool promisc)
|
||||
{
|
||||
m_promisc = promisc;
|
||||
if (m_dev)
|
||||
m_dev->set_promisc(promisc);
|
||||
}
|
||||
|
||||
void device_network_interface::set_mac(const u8 *mac)
|
||||
{
|
||||
std::copy_n(mac, std::size(m_mac), std::begin(m_mac));
|
||||
if (m_dev)
|
||||
m_dev->set_mac(&m_mac[0]);
|
||||
}
|
||||
|
||||
void device_network_interface::set_interface(int id)
|
||||
|
@ -18,7 +18,6 @@ public:
|
||||
void interface_post_load() override ATTR_COLD;
|
||||
|
||||
void set_interface(int id) ATTR_COLD;
|
||||
void set_promisc(bool promisc);
|
||||
void set_mac(const u8 *mac);
|
||||
void set_loopback(bool loopback);
|
||||
|
||||
|
@ -453,10 +453,6 @@ void news_r4k_state::machine_common(machine_config &config)
|
||||
m_sonic->out_int_cb().set(m_sonic3, FUNC(cxd8452aq_device::irq_w));
|
||||
m_sonic->set_bus(m_sonic3, 1);
|
||||
|
||||
// Use promiscuous mode to force network driver to accept all packets, since SONIC has its own filter (CAM table)
|
||||
// Not sure if needing to use this means something else isn't set up correctly.
|
||||
m_sonic->set_promisc(true);
|
||||
|
||||
// Unlike 68k and R3000 NEWS machines, the keyboard and mouse seem to share an interrupt
|
||||
// See https://github.com/NetBSD/src/blob/trunk/sys/arch/newsmips/apbus/ms_ap.c#L103
|
||||
// where the mouse interrupt handler is initialized using the Keyboard interrupt.
|
||||
|
@ -16,7 +16,6 @@
|
||||
namespace osd {
|
||||
|
||||
network_handler::network_handler() noexcept
|
||||
: m_promisc(false)
|
||||
{
|
||||
std::fill(std::begin(m_mac), std::end(m_mac), 0);
|
||||
}
|
||||
|
@ -33,12 +33,10 @@ public:
|
||||
virtual void recv_cb(u8 *buf, int len) = 0;
|
||||
|
||||
std::array<u8, 6> const &get_mac() noexcept { return m_mac; }
|
||||
bool get_promisc() noexcept { return m_promisc; }
|
||||
|
||||
protected:
|
||||
~network_handler() = default;
|
||||
|
||||
bool m_promisc;
|
||||
std::array<u8, 6> m_mac;
|
||||
};
|
||||
|
||||
|
@ -121,7 +121,6 @@ public:
|
||||
~netdev_pcap();
|
||||
|
||||
virtual int send(uint8_t *buf, int len) override;
|
||||
virtual void set_mac(const uint8_t *mac) override;
|
||||
|
||||
protected:
|
||||
virtual int recv_dev(uint8_t **buf) override;
|
||||
@ -182,7 +181,6 @@ netdev_pcap::netdev_pcap(const char *name, network_handler &ifdev)
|
||||
m_p = nullptr;
|
||||
return;
|
||||
}
|
||||
netdev_pcap::set_mac(&get_mac()[0]);
|
||||
|
||||
#ifdef SDLMAME_MACOSX
|
||||
m_ctx.head = 0;
|
||||
@ -192,23 +190,6 @@ netdev_pcap::netdev_pcap(const char *name, network_handler &ifdev)
|
||||
#endif
|
||||
}
|
||||
|
||||
void netdev_pcap::set_mac(const uint8_t *mac)
|
||||
{
|
||||
struct bpf_program fp;
|
||||
if(!m_p) return;
|
||||
#ifdef SDLMAME_MACOSX
|
||||
auto filter = util::string_format("not ether src %02X:%02X:%02X:%02X:%02X:%02X and (ether dst %02X:%02X:%02X:%02X:%02X:%02X or ether multicast or ether broadcast or ether dst 09:00:07:ff:ff:ff)", (unsigned char)mac[0], (unsigned char)mac[1], (unsigned char)mac[2],(unsigned char)mac[3], (unsigned char)mac[4], (unsigned char)mac[5], (unsigned char)mac[0], (unsigned char)mac[1], (unsigned char)mac[2],(unsigned char)mac[3], (unsigned char)mac[4], (unsigned char)mac[5]);
|
||||
#else
|
||||
auto filter = util::string_format("ether dst %02X:%02X:%02X:%02X:%02X:%02X or ether multicast or ether broadcast", (unsigned char)mac[0], (unsigned char)mac[1], (unsigned char)mac[2],(unsigned char)mac[3], (unsigned char)mac[4], (unsigned char)mac[5]);
|
||||
#endif
|
||||
if ((*module->pcap_compile_dl)(m_p, &fp, filter.c_str(), 1, 0) == -1) {
|
||||
osd_printf_error("Error with pcap_compile\n");
|
||||
}
|
||||
if ((*module->pcap_setfilter_dl)(m_p, &fp) == -1) {
|
||||
osd_printf_error("Error with pcap_setfilter\n");
|
||||
}
|
||||
}
|
||||
|
||||
int netdev_pcap::send(uint8_t *buf, int len)
|
||||
{
|
||||
int ret;
|
||||
|
@ -67,7 +67,6 @@ public:
|
||||
~netdev_tap();
|
||||
|
||||
int send(uint8_t *buf, int len) override;
|
||||
void set_mac(const uint8_t *mac) override;
|
||||
|
||||
protected:
|
||||
int recv_dev(uint8_t **buf) override;
|
||||
@ -81,7 +80,6 @@ private:
|
||||
int m_fd = -1;
|
||||
char m_ifname[10];
|
||||
#endif
|
||||
char m_mac[6];
|
||||
uint8_t m_buf[2048];
|
||||
};
|
||||
|
||||
@ -144,11 +142,6 @@ netdev_tap::~netdev_tap()
|
||||
#endif
|
||||
}
|
||||
|
||||
void netdev_tap::set_mac(const uint8_t *mac)
|
||||
{
|
||||
memcpy(m_mac, mac, 6);
|
||||
}
|
||||
|
||||
static u32 finalise_frame(u8 buf[], u32 length)
|
||||
{
|
||||
/*
|
||||
@ -335,13 +328,9 @@ int netdev_tap::send(uint8_t *buf, int len)
|
||||
|
||||
int netdev_tap::recv_dev(uint8_t **buf)
|
||||
{
|
||||
int len;
|
||||
if(m_fd == -1) return 0;
|
||||
// exit if we didn't receive anything, got an error, got a broadcast or multicast packet,
|
||||
// are in promiscuous mode or got a packet with our mac.
|
||||
do {
|
||||
len = read(m_fd, m_buf, sizeof(m_buf));
|
||||
} while((len > 0) && memcmp(&get_mac()[0], m_buf, 6) && !get_promisc() && !(m_buf[0] & 1));
|
||||
|
||||
int len = read(m_fd, m_buf, sizeof(m_buf));
|
||||
|
||||
if (len > 0)
|
||||
len = finalise_frame(m_buf, len);
|
||||
|
@ -62,21 +62,8 @@ void osd_network_device::poll()
|
||||
{
|
||||
uint8_t *buf;
|
||||
int len;
|
||||
//const char atalkmac[] = { 0x09, 0x00, 0x07, 0xff, 0xff, 0xff };
|
||||
while(!m_stopped && (len = recv_dev(&buf)))
|
||||
{
|
||||
#if 0
|
||||
if(buf[0] & 1)
|
||||
{
|
||||
if(memcmp("\xff\xff\xff\xff\xff\xff", buf, 6) && memcmp(atalkmac, buf, 6) && !m_dev.mcast_chk(buf, len)) continue;
|
||||
}
|
||||
else {
|
||||
//const unsigned char *ourmac = (const unsigned char *)get_mac();
|
||||
//printf("our mac: %.2X:%.2X:%.2X:%.2X:%.2X:%.2X dst mac: %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", ourmac[0], ourmac[1], ourmac[2], ourmac[3], ourmac[4], ourmac[5], buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
|
||||
if(memcmp(get_mac(), buf, 6) && !get_promisc()) continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_dev.recv_cb(buf, len);
|
||||
}
|
||||
}
|
||||
@ -90,21 +77,3 @@ int osd_network_device::recv_dev(uint8_t **buf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void osd_network_device::set_mac(const uint8_t *mac)
|
||||
{
|
||||
}
|
||||
|
||||
void osd_network_device::set_promisc(bool promisc)
|
||||
{
|
||||
}
|
||||
|
||||
bool osd_network_device::get_promisc()
|
||||
{
|
||||
return m_dev.get_promisc();
|
||||
}
|
||||
|
||||
const std::array<uint8_t, 6> &osd_network_device::get_mac()
|
||||
{
|
||||
return m_dev.get_mac();
|
||||
}
|
||||
|
@ -44,11 +44,6 @@ public:
|
||||
void poll();
|
||||
|
||||
virtual int send(uint8_t *buf, int len);
|
||||
virtual void set_mac(const uint8_t *mac);
|
||||
virtual void set_promisc(bool promisc);
|
||||
|
||||
const std::array<uint8_t, 6> &get_mac();
|
||||
bool get_promisc();
|
||||
|
||||
protected:
|
||||
virtual int recv_dev(uint8_t **buf);
|
||||
|
Loading…
Reference in New Issue
Block a user