【问题标题】:For lib pcapplusplus, why there is no matchSubnet() for ipv6 address对于lib pcapplusplus,为什么ipv6地址没有matchSubnet()
【发布时间】:2020-06-01 09:58:07
【问题描述】:

对于 ipv4 地址,我可以使用 matchSubnet() 检查地址是否与子网匹配。
但是对于 ipv6,我该怎么做呢?

【问题讨论】:

    标签: pcap libpcap pcapplusplus


    【解决方案1】:

    感谢DinoStrayPcapPlusPlus 中实现此功能。

    只是用一个关于如何使用它的例子来结束这个问题:

    // 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阅读更多内容。

    【讨论】:

      【解决方案2】:

      很好,PcapPlusPlus 中目前不存在此功能。

      我看到你为此打开了一个 GitHub 问题:https://github.com/seladb/PcapPlusPlus/issues/444

      让我们在那里跟进。

      【讨论】:

        猜你喜欢
        • 2021-12-21
        • 2012-02-03
        • 2011-06-19
        • 1970-01-01
        • 2020-12-19
        • 2021-07-30
        • 2020-02-24
        • 2017-11-11
        • 2018-10-21
        相关资源
        最近更新 更多