Skip to content

Fetching of netmask on Windows almost always returns 0.0.0.0 #5398

Description

@MayaPosch

Describe the bug
When retrieving any network interface's netmask it almost always returns 0.0.0.0, which is incorrect.

To Reproduce
A call to Poco::Net::NetworkInterface::subnetMask() with as index default 0 or 1.

Expected behavior
This is expected to return a netmask, like the typical /24 netmask of 255.255.255.0, or 255.0.0.0 on loopback.

Logs

With the default 0 index parameter:

Found 3 network interfaces.
Network interface 'Software Loopback Interface 1'.
Subnet Mask: 0.0.0.0
Broadcast: 255.255.255.255
Broadcast IP address: 255.255.255.255
Sending...
Listening...
Received message with length 205
Network interface 'Realtek PCIe GbE Family Controller'.
Subnet Mask: 0.0.0.0
Broadcast: 255.255.255.255
Broadcast IP address: 255.255.255.255
Sending...
Listening...
Received message with length 205
Network interface 'VirtualBox Host-Only Ethernet Adapter'.
Subnet Mask: 0.0.0.0
Broadcast: 255.255.255.255
Broadcast IP address: 255.255.255.255

When changing the index to 1 two of the three interfaces return the right netmask:

Found 3 network interfaces.
Network interface 'Software Loopback Interface 1'.
Subnet Mask: 255.0.0.0
Broadcast: 255.255.255.255
Broadcast IP address: 127.255.255.255
Sending...
Listening...
Network interface 'Realtek PCIe GbE Family Controller'.
Subnet Mask: 0.0.0.0
Broadcast: 255.255.255.255
Broadcast IP address: 255.255.255.255
Sending...
Listening...
Network interface 'VirtualBox Host-Only Ethernet Adapter'.
Subnet Mask: 255.255.255.0
Broadcast: 255.255.255.255
Broadcast IP address: 192.168.56.255

Screenshots
If applicable, add screenshots to help explain your problem.

Please add relevant environment information:

  • OS: Windows 10.
  • Current POCO version in the MSYS2 repository, as well as a slightly older version obtained via vcpkg.
  • Tests were run within the NyanSD project's codebase, in both MSYS2 with g++ and natively in a Visual Studio 2017 & 2022 shell on two different Windows 10 systems.

Additional context
It's unclear what the meaning of the index parameter is in obtaining the netmask. Previously just the IP address from the default index was used to create a /24 broadcast address from, which works fine. This seems to imply that the IP address exists in multiple records, but the netmask is missing in some records, which is curious.

I haven't tried the same tests on another OS like Linux yet, but this can be done too if necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions