From ef01ebf4035063442d93ab4aadd0b56dc8ef05b8 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 7 Sep 2011 15:50:07 -0400 Subject: [PATCH] net: sync CIDRMask code, doc R=golang-dev, r CC=golang-dev https://golang.org/cl/4961069 --- src/pkg/net/ip.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pkg/net/ip.go b/src/pkg/net/ip.go index 0ad27faebb5..61dc3be909c 100644 --- a/src/pkg/net/ip.go +++ b/src/pkg/net/ip.go @@ -65,8 +65,9 @@ func IPv4Mask(a, b, c, d byte) IPMask { return p } -// CIDRMask returns an IPMask of size bits with the first n bits -// set to to 1. nil is returned if the mask is impossible. +// CIDRMask returns an IPMask consisting of `ones' 1 bits +// followed by 0s up to a total length of `bits' bits. +// For a mask of this form, CIDRMask is the inverse of IPMask.Size. func CIDRMask(ones, bits int) IPMask { if bits != 8*IPv4len && bits != 8*IPv6len { return nil