参考link: https://blog.csdn.net/han156/article/details/77817031
通过ip/mask获取起止ipfunc getIpSegRange(userSegIp, offset uint8) (int, int) {
var ipSegMax uint8 = 255
netSegIp := ipSegMax << offset
segMinIp := netSegIp & userSegIp
segMaxIp := userSegIp&(255< 8 {
segIp, _ := strconv.Atoi(ipSegs[0])
return segIp, segIp
}
ipSeg, _ := strconv.Atoi(ipSegs[0])
return getIpSegRange(uint8(ipSeg), uint8(8-maskLen))
}
func getIpSeg2Range(ipSegs []string, maskLen int) (int, int) {
if maskLen > 16 {
segIp, _ := strconv.Atoi(ipSegs[1])
return segIp, segIp
}
ipSeg, _ := str
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)