none
Can a NDIS Light-weight Filter attach to a WAN adapter? RRS feed

  • Question

  • I am developing WinPcap and want it to see WAN packets. It is a NDIS Light-weight Filter driver, and I have added the "wan" option in my INF file, like below:

    HKR, Ndi\Interfaces,UpperRange,,"noupper"
    HKR, Ndi\Interfaces,LowerRange,,"nolower"
    
    
    ; TODO: Ensure that the list of media types below is correct.  Typically,
    ; filters include "ethernet".  Filters may also include "ppip" to include
    ; native WWAN stacks, but you must be prepared to handle the packet framing.
    ; Possible values are listed on MSDN, but common values include:
    ;     ethernet, wan, ppip, wlan
    HKR, Ndi\Interfaces, FilterMediaTypes,,"ethernet, wan, ppip, wlan, bluetooth, ndis5, vwifi, nolower"

    And in my FilterAttach function, I already let the NdisMediumWan and NdisMediumWirelessWan type adapter go, as the code below.

    _Use_decl_annotations_
    NDIS_STATUS
    NPF_AttachAdapter(
        NDIS_HANDLE                     NdisFilterHandle,
        NDIS_HANDLE                     FilterDriverContext,
        PNDIS_FILTER_ATTACH_PARAMETERS  AttachParameters
        )
    {
        POPEN_INSTANCE          Open = NULL;
        NDIS_STATUS             Status = NDIS_STATUS_SUCCESS;
        NDIS_STATUS             returnStatus;
        NDIS_FILTER_ATTRIBUTES  FilterAttributes;
        BOOLEAN               bFalse = FALSE;
    
        TRACE_ENTER();
    
        do
        {
            ASSERT(FilterDriverContext == (NDIS_HANDLE)FilterDriverObject);
            if (FilterDriverContext != (NDIS_HANDLE)FilterDriverObject)
            {
                Status = NDIS_STATUS_INVALID_PARAMETER;
                break;
            }
    
            // Verify the media type is supported.  This is a last resort; the
            // the filter should never have been bound to an unsupported miniport
            // to begin with.  If this driver is marked as a Mandatory filter (which
            // is the default for this sample; see the INF file), failing to attach 
            // here will leave the network adapter in an unusable state.
            //
            // Your setup/install code should not bind the filter to unsupported
            // media types.
            if ((AttachParameters->MiniportMediaType != NdisMedium802_3)
                    && (AttachParameters->MiniportMediaType != NdisMediumNative802_11)
                    && (AttachParameters->MiniportMediaType != NdisMediumWan) //we don't care this kind of miniports
                    && (AttachParameters->MiniportMediaType != NdisMediumWirelessWan) //we don't care this kind of miniports
                    && (AttachParameters->MiniportMediaType != NdisMediumFddi)
                    && (AttachParameters->MiniportMediaType != NdisMediumArcnet878_2)
                    && (AttachParameters->MiniportMediaType != NdisMediumAtm)
                    && (AttachParameters->MiniportMediaType != NdisMedium802_5))
            {
                IF_LOUD(DbgPrint("Unsupported media type.\n");)
    
                Status = NDIS_STATUS_INVALID_PARAMETER;
                break;
            }
    
            IF_LOUD (DbgPrint("NPF_Attach: AdapterName=%ws, MacAddress=%c-%c-%c-%c-%c-%c\n",
                AttachParameters->BaseMiniportName,
                AttachParameters->CurrentMacAddress[0], 
                AttachParameters->CurrentMacAddress[1], 
                AttachParameters->CurrentMacAddress[2], 
                AttachParameters->CurrentMacAddress[3], 
                AttachParameters->CurrentMacAddress[4], 
                AttachParameters->CurrentMacAddress[5]);
            )
    ...

    But the result turns out that the WAN adapters like below NEVER show up in FilterAttach routine. All AttachParameters->MiniportMediaType are NdisMedium802_3.

    WAN Miniport (SSTP)
    WAN Miniport (IPv6)
    WAN Miniport (IP)
    WAN Miniport (L2TP)
    WAN Miniport (PPPOE)
    WAN Miniport (PPTP)
    WAN Miniport (Network Monitor)
    WAN Miniport (IKEv2)

    So I wonder if it is possible to bind to a WAN adapter using NDIS Filter technique? Thanks!

    Wednesday, July 15, 2015 5:35 AM