Next implements the Datum interface.
(_ *EvalContext)
| 1646 | |
| 1647 | // Next implements the Datum interface. |
| 1648 | func (d *DIPAddr) Next(_ *EvalContext) (Datum, bool) { |
| 1649 | // We will do one of a few things to get the Next IP address: |
| 1650 | // - Increment IP address if we won't overflow the IP. |
| 1651 | // - Increment mask and set the IP to min in family if we will overflow. |
| 1652 | // - Jump up from IPv4 to IPv6 if we will overflow both IP and mask. |
| 1653 | if d.Family == ipaddr.IPv4family && d.Addr.Equal(dIPv4max) { |
| 1654 | if d.Mask == 32 { |
| 1655 | // Jump up IP family. |
| 1656 | return dMinIPv6Addr, true |
| 1657 | } |
| 1658 | // Increase mask size, wrap IPv4 IP address. |
| 1659 | return NewDIPAddr(DIPAddr{ipaddr.IPAddr{Family: ipaddr.IPv4family, Addr: dIPv4min, Mask: d.Mask + 1}}), true |
| 1660 | } else if d.Family == ipaddr.IPv6family && d.Addr.Equal(dIPv6max) { |
| 1661 | // Increase mask size, wrap IPv6 IP address. |
| 1662 | return NewDIPAddr(DIPAddr{ipaddr.IPAddr{Family: ipaddr.IPv6family, Addr: dIPv6min, Mask: d.Mask + 1}}), true |
| 1663 | } |
| 1664 | // Increment IP address. |
| 1665 | return NewDIPAddr(DIPAddr{ipaddr.IPAddr{Family: d.Family, Addr: d.Addr.Add(1), Mask: d.Mask}}), true |
| 1666 | } |
| 1667 | |
| 1668 | // IsMax implements the Datum interface. |
| 1669 | func (d *DIPAddr) IsMax(_ *EvalContext) bool { |
nothing calls this directly
no test coverage detected