You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returncty.UnknownVal(cty.String), function.NewArgErrorf(i+1, "must extend prefix by at least one bit")
159
+
}
160
+
// For portability with 32-bit systems where the subnet number
161
+
// will be a 32-bit int, we only allow extension of 32 bits in
162
+
// one call even if we're running on a 64-bit machine.
163
+
// (Of course, this is significant only for IPv6.)
164
+
iflength>32 {
165
+
returncty.UnknownVal(cty.String), function.NewArgErrorf(i+1, "may not extend prefix by more than 32 bits")
166
+
}
167
+
length+=startPrefixLen
168
+
iflength> (len(network.IP) *8) {
169
+
protocol:="IP"
170
+
switchlen(network.IP) *8 {
171
+
case32:
172
+
protocol="IPv4"
173
+
case128:
174
+
protocol="IPv6"
175
+
}
176
+
returncty.UnknownVal(cty.String), function.NewArgErrorf(i+1, "would extend prefix to %d bits, which is too long for an %s address", length, protocol)
177
+
}
178
+
179
+
next, rollover:=cidr.NextSubnet(current, length)
180
+
ifrollover||!network.Contains(next.IP) {
181
+
// If we run out of suffix bits in the base CIDR prefix then
182
+
// NextSubnet will start incrementing the prefix bits, which
183
+
// we don't allow because it would then allocate addresses
184
+
// outside of the caller's given prefix.
185
+
returncty.UnknownVal(cty.String), function.NewArgErrorf(i+1, "not enough remaining address space for a subnet with a prefix of %d bits after %s", length, current.String())
186
+
}
187
+
188
+
current=next
189
+
retVals[i] =cty.StringVal(current.String())
190
+
}
191
+
192
+
returncty.ListVal(retVals), nil
193
+
},
194
+
})
195
+
116
196
// CidrHost calculates a full host IP address within a given IP network address prefix.
0 commit comments