static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)

{

    static const uint8_t bcast[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};

    static const uint8_t vlan[] = {0x81, 0x00};

    uint8_t *ptr = (uint8_t *)buf;

    int i;



    if (n->promisc)

        return 1;



    if (!memcmp(&ptr[12], vlan, sizeof(vlan))) {

        int vid = be16_to_cpup((uint16_t *)(ptr + 14)) & 0xfff;

        if (!(n->vlans[vid >> 5] & (1U << (vid & 0x1f))))

            return 0;

    }



    if (ptr[0] & 1) { // multicast

        if (!memcmp(ptr, bcast, sizeof(bcast))) {

            return 1;

        } else if (n->allmulti) {

            return 1;

        }

    } else { // unicast

        if (!memcmp(ptr, n->mac, ETH_ALEN)) {

            return 1;

        }

    }



    for (i = 0; i < n->mac_table.in_use; i++) {

        if (!memcmp(ptr, &n->mac_table.macs[i * ETH_ALEN], ETH_ALEN))

            return 1;

    }



    return 0;

}

static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)

{

    static const uint8_t bcast[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};

    static const uint8_t vlan[] = {0x81, 0x00};

    uint8_t *ptr = (uint8_t *)buf;

    int i;



    if (n->promisc)

        return 1;



    if (!memcmp(&ptr[12], vlan, sizeof(vlan))) {

        int vid = be16_to_cpup((uint16_t *)(ptr + 14)) & 0xfff;

        if (!(n->vlans[vid >> 5] & (1U << (vid & 0x1f))))

            return 0;

    }



    if (ptr[0] & 1) { 

        if (!memcmp(ptr, bcast, sizeof(bcast))) {

            return 1;

        } else if (n->allmulti) {

            return 1;

        }

    } else { 

        if (!memcmp(ptr, n->mac, ETH_ALEN)) {

            return 1;

        }

    }



    for (i = 0; i < n->mac_table.in_use; i++) {

        if (!memcmp(ptr, &n->mac_table.macs[i * ETH_ALEN], ETH_ALEN))

            return 1;

    }



    return 0;

}

        } else if (n->allmulti) {         if (!memcmp(ptr, n->mac, ETH_ALEN)) {
static int FUNC_0(VirtIONet *VAR_0, const uint8_t *VAR_1, int VAR_2)

{

    static const uint8_t VAR_3[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};

    static const uint8_t VAR_4[] = {0x81, 0x00};

    uint8_t *ptr = (uint8_t *)VAR_1;

    int VAR_5;



    if (VAR_0->promisc)

        return 1;



    if (!memcmp(&ptr[12], VAR_4, sizeof(VAR_4))) {

        int VAR_6 = be16_to_cpup((uint16_t *)(ptr + 14)) & 0xfff;

        if (!(VAR_0->vlans[VAR_6 >> 5] & (1U << (VAR_6 & 0x1f))))

            return 0;

    }



    if (ptr[0] & 1) { 

        if (!memcmp(ptr, VAR_3, sizeof(VAR_3))) {

            return 1;

        } else if (VAR_0->allmulti) {

            return 1;

        }

    } else { 

        if (!memcmp(ptr, VAR_0->mac, ETH_ALEN)) {

            return 1;

        }

    }



    for (VAR_5 = 0; VAR_5 < VAR_0->mac_table.in_use; VAR_5++) {

        if (!memcmp(ptr, &VAR_0->mac_table.macs[VAR_5 * ETH_ALEN], ETH_ALEN))

            return 1;

    }



    return 0;

}

static int FUNC_0(VirtIONet *VAR_0, const uint8_t *VAR_1, int VAR_2)
{ static const uint8_t VAR_3[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; static const uint8_t VAR_4[] = {0x81, 0x00}; uint8_t *ptr = (uint8_t *)VAR_1; int VAR_5; if (VAR_0->promisc)
return 1; if (!memcmp(&ptr[12], VAR_4, sizeof(VAR_4))) { int VAR_6 = be16_to_cpup((uint16_t *)(ptr + 14)) & 0xfff; if (!(VAR_0->vlans[VAR_6 >> 5] & (1U << (VAR_6 & 0x1f))))
return 0; } if (ptr[0] & 1) { if (!memcmp(ptr, VAR_3, sizeof(VAR_3))) { return 1; } else if (VAR_0->allmulti) { return 1; } } else { if (!memcmp(ptr, VAR_0->mac, ETH_ALEN)) { return 1; } } for (VAR_5 = 0; VAR_5 < VAR_0->mac_table.in_use; VAR_5++) { if (!memcmp(ptr, &VAR_0->mac_table.macs[VAR_5 * ETH_ALEN], ETH_ALEN))
return 1; } return 0; }