对于ipv4地址,我可以使用matchSubnet()检查地址是否与子网匹配。
但是对于ipv6,我该怎么做呢?
发布于 2020-09-22 15:38:47
感谢DinoStray在PcapPlusPlus中实现此功能。
用一个如何使用它的例子来结束这个问题:
// 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你可以在PcapPlusPlus tests中看到更多的例子,
并在IPv6Address documentation上阅读更多内容。
发布于 2020-06-02 09:42:20
这是一个很好的观点,这个特性目前在PcapPlusPlus中还不存在。
我看到你为此开了一期GitHub:https://github.com/seladb/PcapPlusPlus/issues/444
让我们在那里跟进一下。
https://stackoverflow.com/questions/62129703
复制相似问题