sysprog21 / vwifi

A virtual wireless device driver for Linux
MIT License
203 stars 39 forks source link

Filtering out certain wifi networks: blocked/allowed-list #48

Closed naddika closed 9 months ago

naddika commented 1 year ago

Can it tweaked such that it'll only allow discovering a certain list of WiFi networks? That is, the user (admin) upon installation will provide a list of whitelisted networks via config or somehow statically. When the driver runs, it'll only show those to the client application ignoring all the rest.

If so, where's the place for this in the code?

Also, what does it mean "virtual" Wifi driver?

rickywu0421 commented 1 year ago

Can it tweaked such that it'll only allow discovering a certain list of WiFi networks?

Currently, vwifi doesn't have the ability to filter out other wireless interfaces. But it's feasible to do this in vwifi with little modifications. For configuration, we need to figure out some other ways since static configuration seems not possible for a kernel module. Maybe we can write a simple user program for this, and communicate with vwifi via Netlink.

Also, what does it mean "virtual" Wifi driver?

It means vwifi doesn't work with a real wireless network card, and vwifi itself behaves like both a cfg80211 driver and a cfg80211 hardware.

naddika commented 1 year ago

Currently, vwifi doesn't have the ability to filter out other wireless interfaces.

I didn't it say that had it. I said if "it could be" tweaked accordingly -- by myself

I didn't ask about interfaces, I did about networks.

Also, I asked, where was that place in the code, so I could rewrite it? @rickywu0421

rickywu0421 commented 11 months ago

I didn't it say that had it. I said if "it could be" tweaked accordingly -- by myself

I didn't ask about interfaces, I did about networks.

I apologize for my misunderstanding.

Also, I asked, where was that place in the code, so I could rewrite it? @rickywu0421

The code is in the owl_ndo_start_xmit() function (line 599), and you can filter out packet here:

/* TX by interface of AP mode */
    else if (vif->wdev.iftype == NL80211_IFTYPE_AP) {
        /* Check if the packet is broadcasting */
        if (is_broadcast_ether_addr(eth_hdr->h_dest)) {
            list_for_each_entry (dest_vif, &vif->bss_list, bss_list) {
                /* Don't send broadcast packet back to the source interface.
                 */
                if (ether_addr_equal(eth_hdr->h_source,
                                     dest_vif->ndev->dev_addr))
                    continue;

                if (__owl_ndo_start_xmit(vif, dest_vif, skb))
                    count++;
            }
        }
        /* The packet is unicasting */
        else {
            list_for_each_entry (dest_vif, &vif->bss_list, bss_list) {
                if (ether_addr_equal(eth_hdr->h_dest,
                                     dest_vif->ndev->dev_addr)) {
                    if (__owl_ndo_start_xmit(vif, dest_vif, skb))
                        count++;
                    break;
                }
            }
        }
    }