Importance of PortNumber and Flags in both Send/Receive handlers in LWF RRS feed

  • Question

  • What is the significance of the port number, flags in send and receive handlers in Light Weight Filter Driver, When I receive data on send call, I will be making modifications to Ethernet Header, It might also include changing the port number, Should I use this new port number while sending data (as if Filter Driver initiated) on NdisFSendNetBufferLists. Same is the case with Receive Handler.

    Suppose I have Buffer (Payload), which I wanted to put it in a NBL format, I can use allocations and queries, In addition to these Should I also set Media specifc info, or Flags, Is there any other field do we need to set before calling NdisFSendNetBufferLists.

    Appreciate your help.

    Friday, February 3, 2017 11:54 AM


  • In most cases, you should just ignore the NDIS_PORT_NUMBER.  The NDIS_PORT_NUMBER does not correspond to any protocol's port number.  (E.g., it does not correspond to TCP's destination port number.)  The port number is a generic tool for different driver frameworks to use.  Most commonly, the Native WLAN stack uses it to distinguish between station & WFD MACs.  But unless your filter driver specifically cares about one of these silos, you can ignore the NDIS_PORT_NUMBER.

    Just copy the port number & don't modify it on the way through.  If you originate new NBLs or OIDs or status indications, use NDIS_DEFAULT_PORT_NUMBER.

    You can also ignore most of the flags on the datapath handlers.  The only flag that you must take into consideration is NDIS_RECEIVE_FLAGS_RESOURCES.  If this flag is present on the receive handler, then the receive path is synchronous.

    It's a common bug to copy the Flags from your send handler into your send-complete handler.  The Flags are not compatible between send and send-complete.  Likewise for receive and receive-return.

    Generally you can ignore the media specific info.  If you're programming a native WLAN NIC, the documentation for that technology will tell you how to handle this.  Otherwise, just ignore it.

    Friday, February 17, 2017 8:29 PM