How to get subnet mask in native C++ from metro app? RRS feed

  • Question

  • Does anyone know how to retrieve subnet mask for a NIC using WinRT C++ APIs in metro app?  I have a metro application that needs to determine if an incoming packet is from local subnet or from other network/internet.  I went over all the Windows.Networking.* classes, but couldn't find any class that provides such functionality.


    Monday, April 2, 2012 5:57 PM

All replies

  • Hello,

    The IP Helper feature does not support in Metro App. Therefore, we cannot use GetAdaptersInfo to get the subnet mask.

    Please check the Networking section in this document.

    Best regards,

    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, April 3, 2012 3:10 AM
  • Do you have a use case scenario where this information would be useful in a Metro style app you can share?

    David Lamb

    Wednesday, April 4, 2012 3:25 PM
  • I am trying to develop a metro app.  Part of its functionality is to advertise and/or discover services on local subnet.  The functionality is similar to what mDNS does.  If it gets a message from same subnet, the response is sent out via multicast.  However, if the message is from somewhere other than the same subnet, the response is sent via unicast.  So, I have to know if the message is from local subnet using the NIC's subnet mask.  There are other usages as well.  For example, messages from internet are treated differently than from trusted local network.

    Can MSFT add this feature to the metro app?  Thanks.


    Wednesday, April 4, 2012 11:34 PM
  • If MSFT doesn't want to expose the lower-level functionality (NIC's subnet mask) in metro app, can you provide a high-level API for checking if an IP (v4 and v6) address is a local subnet address?  Thanks.
    Thursday, April 5, 2012 6:00 PM
    • Proposed as answer by Jacob Gladish Monday, May 6, 2013 1:42 AM
    Tuesday, August 21, 2012 9:12 PM
  • I am facing the exact same issue - I need to get network mask. Is there any update/new API introduced since then?
    Saturday, May 4, 2013 1:24 AM
  • I do, I am the author of FalconUDP: https://github.com/markmnl/FalconUDP, a library used by .NET games.

    The subnet mask is needed calculate the broadcast addresses to use for discovery. e.g. if local assigned IP: in class C subnet: broadcast address is:

    Wednesday, May 6, 2015 5:46 AM