mirror of
https://github.com/LIV2/WinUAE.git
synced 2025-12-06 00:12:52 +00:00
uaenet.device slirp support fix.
This commit is contained in:
parent
30a637b8d4
commit
80bb5a41e4
@ -264,7 +264,7 @@ static int mcfilter (const uae_u8 *data)
|
||||
return 1; // just allow everything
|
||||
}
|
||||
|
||||
static void gotfunc (struct s2devstruct *dev, const uae_u8 *databuf, int len)
|
||||
static void gotfunc (void *devv, const uae_u8 *databuf, int len)
|
||||
{
|
||||
int i;
|
||||
int size, insize, first;
|
||||
@ -274,6 +274,7 @@ static void gotfunc (struct s2devstruct *dev, const uae_u8 *databuf, int len)
|
||||
uae_u32 crc32;
|
||||
uae_u8 tmp[MAX_PACKET_SIZE], *data;
|
||||
const uae_u8 *dstmac, *srcmac;
|
||||
struct s2devstruct *dev = (struct s2devstruct*)devv;
|
||||
|
||||
if (log_a2065 > 1 && log_receive) {
|
||||
dstmac = databuf;
|
||||
@ -422,8 +423,10 @@ static void gotfunc (struct s2devstruct *dev, const uae_u8 *databuf, int len)
|
||||
rethink_a2065 ();
|
||||
}
|
||||
|
||||
static int getfunc (struct s2devstruct *dev, uae_u8 *d, int *len)
|
||||
static int getfunc (void *devv, uae_u8 *d, int *len)
|
||||
{
|
||||
struct s2devstruct *dev = (struct s2devstruct*)devv;
|
||||
|
||||
if (transmitlen <= 0)
|
||||
return 0;
|
||||
if (transmitlen > *len) {
|
||||
@ -523,7 +526,7 @@ static void do_transmit (void)
|
||||
(d[12] << 8) | d[13], outsize);
|
||||
}
|
||||
}
|
||||
ethernet_trigger (sysdata);
|
||||
ethernet_trigger (td, sysdata);
|
||||
}
|
||||
csr[0] |= CSR0_TINT;
|
||||
rethink_a2065 ();
|
||||
|
||||
17
ethernet.cpp
17
ethernet.cpp
@ -14,6 +14,7 @@ struct ethernet_data
|
||||
{
|
||||
ethernet_gotfunc *gotfunc;
|
||||
ethernet_getfunc *getfunc;
|
||||
void *userdata;
|
||||
};
|
||||
|
||||
#define SLIRP_PORT_OFFSET 0
|
||||
@ -52,13 +53,13 @@ void slirp_output (const uint8 *pkt, int pkt_len)
|
||||
if (!slirp_data)
|
||||
return;
|
||||
uae_sem_wait (&slirp_sem1);
|
||||
slirp_data->gotfunc (NULL, pkt, pkt_len);
|
||||
slirp_data->gotfunc (slirp_data->userdata, pkt, pkt_len);
|
||||
uae_sem_post (&slirp_sem1);
|
||||
}
|
||||
|
||||
void ethernet_trigger (void *vsd)
|
||||
void ethernet_trigger (struct netdriverdata *ndd, void *vsd)
|
||||
{
|
||||
switch (netmode)
|
||||
switch (ndd->type)
|
||||
{
|
||||
case UAENET_SLIRP:
|
||||
case UAENET_SLIRP_INBOUND:
|
||||
@ -69,7 +70,7 @@ void ethernet_trigger (void *vsd)
|
||||
int len = sizeof pkt;
|
||||
int v;
|
||||
uae_sem_wait (&slirp_sem1);
|
||||
v = slirp_data->getfunc(NULL, pkt, &len);
|
||||
v = slirp_data->getfunc(ed->userdata, pkt, &len);
|
||||
uae_sem_post (&slirp_sem1);
|
||||
if (v) {
|
||||
uae_sem_wait (&slirp_sem2);
|
||||
@ -97,6 +98,7 @@ int ethernet_open (struct netdriverdata *ndd, void *vsd, void *user, ethernet_go
|
||||
struct ethernet_data *ed = (struct ethernet_data*)vsd;
|
||||
ed->gotfunc = gotfunc;
|
||||
ed->getfunc = getfunc;
|
||||
ed->userdata = user;
|
||||
slirp_data = ed;
|
||||
uae_sem_init (&slirp_sem1, 0, 1);
|
||||
uae_sem_init (&slirp_sem2, 0, 1);
|
||||
@ -133,12 +135,17 @@ int ethernet_open (struct netdriverdata *ndd, void *vsd, void *user, ethernet_go
|
||||
slirp_redir (0, port + SLIRP_PORT_OFFSET, a, port);
|
||||
}
|
||||
}
|
||||
netmode = ndd->type;
|
||||
slirp_start ();
|
||||
}
|
||||
return 1;
|
||||
#ifdef WITH_UAENET_PCAP
|
||||
case UAENET_PCAP:
|
||||
return uaenet_open (vsd, ndd, user, gotfunc, getfunc, promiscuous);
|
||||
if (uaenet_open (vsd, ndd, user, gotfunc, getfunc, promiscuous)) {
|
||||
netmode = ndd->type;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -17,8 +17,8 @@ struct netdriverdata
|
||||
};
|
||||
|
||||
|
||||
typedef void (ethernet_gotfunc)(struct s2devstruct *dev, const uae_u8 *data, int len);
|
||||
typedef int (ethernet_getfunc)(struct s2devstruct *dev, uae_u8 *d, int *len);
|
||||
typedef void (ethernet_gotfunc)(void *dev, const uae_u8 *data, int len);
|
||||
typedef int (ethernet_getfunc)(void *dev, uae_u8 *d, int *len);
|
||||
|
||||
extern bool ethernet_enumerate (struct netdriverdata **, const TCHAR *name);
|
||||
extern void ethernet_enumerate_free (void);
|
||||
@ -30,7 +30,7 @@ extern int ethernet_open (struct netdriverdata *ndd, void*, void*, ethernet_gotf
|
||||
extern void ethernet_close (struct netdriverdata *ndd, void*);
|
||||
extern void ethernet_gotdata (struct s2devstruct *dev, const uae_u8 *data, int len);
|
||||
extern int ethernet_getdata (struct s2devstruct *dev, uae_u8 *d, int *len);
|
||||
extern void ethernet_trigger (void*);
|
||||
extern void ethernet_trigger (struct netdriverdata *ndd, void*);
|
||||
|
||||
extern bool slirp_start (void);
|
||||
extern void slirp_end (void);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
|
||||
#include "ethernet.h"
|
||||
|
||||
typedef void (uaenet_gotfunc)(struct s2devstruct *dev, const uae_u8 *data, int len);
|
||||
typedef int (uaenet_getfunc)(struct s2devstruct *dev, uae_u8 *d, int *len);
|
||||
typedef void (uaenet_gotfunc)(void *dev, const uae_u8 *data, int len);
|
||||
typedef int (uaenet_getfunc)(void *dev, uae_u8 *d, int *len);
|
||||
|
||||
extern struct netdriverdata *uaenet_enumerate (const TCHAR *name);
|
||||
extern void uaenet_enumerate_free (void);
|
||||
|
||||
13
sana2.cpp
13
sana2.cpp
@ -32,8 +32,8 @@
|
||||
#endif
|
||||
#include "execio.h"
|
||||
|
||||
void uaenet_gotdata (struct s2devstruct *dev, const uae_u8 *data, int len);
|
||||
int uaenet_getdata (struct s2devstruct *dev, uae_u8 *d, int *len);
|
||||
static void uaenet_gotdata (void *dev, const uae_u8 *data, int len);
|
||||
static int uaenet_getdata (void *dev, uae_u8 *d, int *len);
|
||||
|
||||
#define SANA2NAME _T("uaenet.device")
|
||||
|
||||
@ -801,11 +801,12 @@ static int handleread (TrapContext *ctx, struct priv_s2devstruct *pdev, uaecptr
|
||||
return 1;
|
||||
}
|
||||
|
||||
void uaenet_gotdata (struct s2devstruct *dev, const uae_u8 *d, int len)
|
||||
static void uaenet_gotdata (void *devv, const uae_u8 *d, int len)
|
||||
{
|
||||
uae_u16 type;
|
||||
struct mcast *mc;
|
||||
struct s2packet *s2p;
|
||||
struct s2devstruct *dev = (struct s2devstruct*)devv;
|
||||
|
||||
if (!dev->online)
|
||||
return;
|
||||
@ -888,10 +889,11 @@ static struct s2packet *createwritepacket (TrapContext *ctx, uaecptr request)
|
||||
return s2p;
|
||||
}
|
||||
|
||||
int uaenet_getdata (struct s2devstruct *dev, uae_u8 *d, int *len)
|
||||
static int uaenet_getdata (void *devv, uae_u8 *d, int *len)
|
||||
{
|
||||
int gotit;
|
||||
struct asyncreq *ar;
|
||||
struct s2devstruct *dev = (struct s2devstruct*)devv;
|
||||
|
||||
uae_sem_wait (&async_sem);
|
||||
ar = dev->ar;
|
||||
@ -1363,8 +1365,9 @@ static void *dev_thread (void *devs)
|
||||
uae_ReplyMsg (request);
|
||||
rem_async_packet (dev, request);
|
||||
} else {
|
||||
struct priv_s2devstruct *pdev = getps2devstruct (request);
|
||||
add_async_request (dev, request);
|
||||
ethernet_trigger (dev->sysdata);
|
||||
ethernet_trigger (pdev->td, dev->sysdata);
|
||||
}
|
||||
uae_sem_post (&change_sem);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user