1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#include "emu.h"
#include "osdnet.h"
typedef struct netdev_entry
{
char name[256];
create_netdev func;
struct netdev_entry *m_next;
} netdev_entry_t;
static class simple_list<netdev_entry_t> netdev_list;
void add_netdev(const char *name, create_netdev func)
{
netdev_entry_t *entry = new netdev_entry_t;
strncpy(entry->name, name, 255);
entry->name[255] = '\0';
entry->func = func;
netdev_list.append(*entry);
}
class netdev *open_netdev(const char *name, class device_network_interface *ifdev, int rate)
{
netdev_entry_t *entry = netdev_list.first();
while(entry) {
if(!strncmp(name, entry->name, 256))
return entry->func(entry->name, ifdev, rate);
entry = entry->m_next;
}
return NULL;
}
netdev::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(netdev::recv), this));
}
netdev::~netdev()
{
}
int netdev::send(UINT8 *buf, int len)
{
return 0;
}
void netdev::recv(void *ptr, int param)
{
UINT8 *buf;
int len;
while((len = recv_dev(&buf)))
{
if(buf[0] & 1)
{
if(memcmp("\xff\xff\xff\xff\xff\xff", buf, 6) && !m_dev->mcast_chk(buf, len)) continue;
}
else
if(memcmp(get_mac(), buf, 6) && !get_promisc()) continue;
m_dev->recv_cb(buf, len);
}
}
int netdev::recv_dev(UINT8 **buf)
{
return 0;
}
void netdev::set_mac(const char *mac)
{
}
void netdev::set_promisc(bool promisc)
{
}
bool netdev::get_promisc()
{
if(m_dev)
return m_dev->get_promisc();
return false;
}
const char *netdev::get_mac()
{
if(m_dev)
return m_dev->get_mac();
return "\0\0\0\0\0\0";
}
|