ipnetwork icon indicating copy to clipboard operation
ipnetwork copied to clipboard

CidrGuess considerations

Open maettu-this opened this issue 3 years ago • 0 comments

Hi Luc,

The behavior of Parse("192.0.43.8") of v2.2.0 is:

  • Network = 192.0.43.0
  • Cidr =24

Apparently this is class-full. Now consider Parse("192.0.43.0"):

  • Network = 192.0.43.0
  • Cidr =24

For class-full of course I would expect the same. But for class-less I would also expect this. Why? Because of the trailing "0". But of course this could result in invalid behavior when somebody expects Cidr = 32 for a trailing "0".

I don't fully see the behavior of the current code. But in case class-less always results in Cidr = 32 (for IPv4), I have a request:

Please provide a third CidrGuess, one that is "network aware". Expectation:

  • Parse("192.0.43.8") => Cidr = 32
  • Parse("192.0.43.0") => Cidr = 24
  • Parse("192.43.0.0") => Cidr = 16
  • Parse("192.0.43.255") => Cidr = 24 (wildcard mask)
  • Parse("192.43.255.255") => Cidr = 16 (wildcard mask)
  • ...

Best regards, Matthias

maettu-this avatar Sep 17 '22 12:09 maettu-this