public IEnumerable <IPAddress> Hosts() { var net = networkAddress.ReverseBytes(); var broad = broadcastAddress.ReverseBytes(); for (var host = net + 1; host < broad; host++) { yield return(host.ReverseBytes().ToIPAddress()); } }
public IPSegment(IPAddress ip, IPAddress mask) { this.ip = ip.ToUInt32(); this.mask = mask.ToUInt32(); networkAddress = this.ip & this.mask; broadcastAddress = networkAddress + ~this.mask; mAllHost = new List <IPAddress>(); uint net = networkAddress.ReverseBytes(); uint broad = broadcastAddress.ReverseBytes(); for (uint host = net + 1; host < broad; host++) { mAllHost.Add(host.ReverseBytes().ToIPAddress()); } }