diff --git a/nse_dnet.cc b/nse_dnet.cc index 253b79f01..9a57f4562 100644 --- a/nse_dnet.cc +++ b/nse_dnet.cc @@ -277,16 +277,26 @@ static int ip_send (lua_State *L) else nexthop = &route.nexthop; - if (!getNextHopMAC(route.ii.devfullname, route.ii.mac, &hdr.src, nexthop, dstmac)) - return luaL_error(L, "failed to determine next hop MAC address"); - /* Use cached ethernet device, and use udata's eth and interface to keep * track of if we're reusing the same device from the previous packet, and * close the cached device if not. */ memset(ð, 0, sizeof(eth)); - memcpy(eth.srcmac, route.ii.mac, sizeof(eth.srcmac)); - memcpy(eth.dstmac, dstmac, sizeof(eth.dstmac)); + +#ifdef WIN32 + // Only determine mac addr info if it's not the Npcap Loopback Adapter. + // Npcap loopback doesn't have a MAC address and isn't an ethernet device, + // so getNextHopMAC crashes. + if (!(g_has_npcap_loopback && route.ii.device_type == devt_loopback)) { +#endif + if (!getNextHopMAC(route.ii.devfullname, route.ii.mac, &hdr.src, nexthop, dstmac)) + return luaL_error(L, "failed to determine next hop MAC address"); + + memcpy(eth.srcmac, route.ii.mac, sizeof(eth.srcmac)); + memcpy(eth.dstmac, dstmac, sizeof(eth.dstmac)); +#ifdef WIN32 + } // end if not Npcap loopback +#endif /* close any current ethernet associated with this userdata */ lua_getfield(L, 1, "ethernet_close");