From 3c6bb3c118a83da504c775f69f58346d2d3c4ae5 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 5 Mar 2016 12:27:08 +0200 Subject: [PATCH] S2_READORPHAN should never filter multicasts. --- sana2.cpp | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/sana2.cpp b/sana2.cpp index 2867e33e..f39db1b6 100644 --- a/sana2.cpp +++ b/sana2.cpp @@ -370,7 +370,6 @@ static int initint (TrapContext *ctx) trap_put_long(ctx, p + 54, p + 92 + 4096); // SPReg tmp1 = here (); - write_log(_T("uaenet worker: %08x\n"), tmp1); dl(0x2c780004); // move.l 4.w,a6 dw(0x203c); // move.l #$100,d0 dl(0x00000100); @@ -812,7 +811,7 @@ static struct s2packet *createreadpacket (struct s2devstruct *dev, const uae_u8 return s2p; } -static int handleread (TrapContext *ctx, struct priv_s2devstruct *pdev, uae_u8 *request, uaecptr arequest, uae_u8 *d, int len, int cmd) +static int handleread (TrapContext *ctx, struct priv_s2devstruct *pdev, struct s2devstruct *dev, uae_u8 *request, uaecptr arequest, uae_u8 *d, int len, int cmd) { uae_u8 flags = get_byte_host(request + 30); uaecptr data = get_long_host(request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4); @@ -826,6 +825,20 @@ static int handleread (TrapContext *ctx, struct priv_s2devstruct *pdev, uae_u8 * memcpy(dstaddr, d, ADDR_SIZE); memcpy(srcaddr, d + ADDR_SIZE, ADDR_SIZE); + /* drop if CMD_READ and multicast with unknown address */ + if (cmd == CMD_READ && ismulticast(dstaddr)) { + uae_u64 mac64 = addrto64(dstaddr); + /* multicast */ + struct mcast *mc = dev->mc; + while (mc) { + if (mac64 >= mc->start && mac64 <= mc->end) + break; + mc = mc->next; + } + if (!mc) + return 0; + } + put_long_host(request + 32 + 4, type); if (pdev->tracks[type]) { pdev->bytesreceived += len; @@ -846,8 +859,11 @@ static int handleread (TrapContext *ctx, struct priv_s2devstruct *pdev, uae_u8 * } put_long_host(request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2, len); - if (pdev->packetfilter && cmd == CMD_READ && packetfilter (ctx, pdev->packetfilter, arequest, data2) == 0) - return 0; + if (cmd == CMD_READ) { + if (pdev->packetfilter && packetfilter (ctx, pdev->packetfilter, arequest, data2) == 0) + return 0; + } + if (!copytobuff (ctx, data2, data, len, pdev->copytobuff)) { put_long_host(request + 32, S2WERR_BUFF_ERROR); put_byte_host(request + 31, S2ERR_NO_RESOURCES); @@ -858,7 +874,6 @@ static int handleread (TrapContext *ctx, struct priv_s2devstruct *pdev, uae_u8 * 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; @@ -873,19 +888,6 @@ static void uaenet_gotdata (void *devv, const uae_u8 *d, int len) /* drop if not promiscuous and dst != broadcast and dst != me */ if (!dev->promiscuous && !isbroadcast (d) && memcmp (d, dev->td->mac, ADDR_SIZE)) return; - /* drop if multicast with unknown address */ - if (ismulticast (d)) { - uae_u64 mac64 = addrto64 (d); - /* multicast */ - mc = dev->mc; - while (mc) { - if (mac64 >= mc->start && mac64 <= mc->end) - break; - mc = mc->next; - } - if (!mc) - return; - } type = (d[12] << 8) | d[13]; s2p = createreadpacket (dev, d, len); @@ -1526,7 +1528,7 @@ static int uaenet_int_handler2(TrapContext *ctx) if (packettype == type || (packettype <= 1500 && type <= 1500)) { struct priv_s2devstruct *pdev = getps2devstruct(ctx, arequest); if (pdev && pdev->tmp == 0) { - if (handleread (ctx, pdev, request, arequest, p->data, p->len, command)) { + if (handleread (ctx, pdev, dev, request, arequest, p->data, p->len, command)) { if (log_net) write_log (_T("-> %p Accepted, CMD_READ, REQ=%08X LEN=%d\n"), p, arequest, p->len); ar->ready = 1; @@ -1563,7 +1565,7 @@ static int uaenet_int_handler2(TrapContext *ctx) if (pdev && pdev->tmp <= 0) { if (log_net) write_log (_T("-> %p Accepted, S2_READORPHAN, REQ=%08X LEN=%d\n"), p, arequest, p->len); - handleread (ctx, pdev, request, arequest, p->data, p->len, command); + handleread (ctx, pdev, dev, request, arequest, p->data, p->len, command); ar->ready = 1; uae_sem_wait(&pipe_sem); trap_set_background(ctx); -- 2.47.3