问题描述
我正在寻找与 Net_IPv4 和 Net_IPv6 ,但是为Java编写的.它需要能够执行以下操作:
I am looking for a package that is similar to Net_IPv4 and Net_IPv6 but written for Java. It needs to be able to do the following:
- 验证地址是否有效(例如127.0.0.1有效,而127.0.0.257无效)
- 返回子网中是否包含地址(例如127.0.0.11位于127.0.0.0/28中)
- 返回给定子网的广播地址(例如127.0.0.0/28为127.0.0.15)
如果还可以,那就太棒了
It would be awesome if it could also:
- 按顺序返回子网的地址列表
- 对地址列表进行排序
我可能会编写一个程序包来完成所有这些工作,但是如果有人已经遇到麻烦并且很可能已经做得更好,那么我将全力以赴.有人知道这样的一个或多个软件包可以完成所有这些工作吗?我们正在扩展到IPv6,因此,如果可能,它需要同时适用于IPv4和IPv6.
I could probably write a package to do all this, but if someone has already gone through the trouble and most likely has done a better job, I'm all about using that. Anyone know of such a package or packages that could do all this? We are expanding into IPv6, so it needs to work for both IPv4 and IPv6 if possible.
感谢您的帮助.
推荐答案
仅适用于IPv4,但 SubnetUtils 类,它是 Commons Net 具有您要寻找的功能.基于此,您可以编写一个IPv6版本并将其贡献回项目! :)
It's only for IPv4, but the SubnetUtils class that is part of Commons Net has the functionality you are looking for. Based on that you could code up an IPv6 version and contribute it back to the project! :)
这篇关于IPv4/IPv6网络计算和Java验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!