1

For ipv4 address, I can use matchSubnet() checks whether the address matches a subnet.
But for ipv6, how can I do this?

seladb
  • 852
  • 1
  • 13
  • 29
DinoStray
  • 696
  • 1
  • 6
  • 20

2 Answers2

1

Thank you DinoStray for implementing this feature in PcapPlusPlus.

Just to wrap this question up with an example on how to use it:

// IPv6 address
pcpp::IPv6Address ipv6Address("2607:f0d0:1002:0051:ffff:0000:0000:0004");

// IPv6 subnet
pcpp::IPv6Address subnetIpv6Address("2607:f0d0:1002:0051::");

// Match subnet with 16 bits in a mask - subnet matches
ipv6Address.matchSubnet(subnetIpv6Address, 16);   // True

// Match subnet with 96 bits in a mask - subnet doesn't match
ipv6Address.matchSubnet(subnetIpv6Address, 96);   // False

You can see more examples in PcapPlusPlus tests,

And read more in IPv6Address documentation.

seladb
  • 852
  • 1
  • 13
  • 29
0

That's a good point, this feature doesn't currently exist in PcapPlusPlus.

I saw you opened a GitHub issue for that: https://github.com/seladb/PcapPlusPlus/issues/444

Let's follow up on it there.

seladb
  • 852
  • 1
  • 13
  • 29