private IPv6Record MakeIPv6Record(string[] row) { IPv6Record r = new IPv6Record(); r.ip_from = row[0].PadLeft(39, '0'); r.ip_to = row[1].PadLeft(39, '0'); SetGenericIPRecordFields(r, row); return(r); }
/// <summary> /// Returns the IPv4Record containing the specified address, or null. (null should be impossible if the database is correctly formed) /// </summary> /// <param name="ipv4Address">The ipv4 address.</param> /// <returns></returns> public IPv4Record GetIPv4Record(uint ipv4Address) { if (Program.settings.resolveIPv4WithIPv6Table) { BigInteger ipno = new BigInteger((((ulong)ipv4Address) | 0xFFFF00000000)); IPv6Record v6 = GetIPv6Record(ipno); return(new IPv4Record(v6)); } lock (syncLock) { return(db.Query <IPv4Record>("SELECT * FROM IPv4Record WHERE ip_to >= ? LIMIT 1", ipv4Address).FirstOrDefault()); } }
public IPv6Record(IPRecord copyFrom) : base(copyFrom) { if (copyFrom is IPv6Record) { IPv6Record v6 = copyFrom as IPv6Record; ip_from = v6.ip_from; ip_to = v6.ip_to; } else if (copyFrom is IPv4Record) { IPv4Record v4 = copyFrom as IPv4Record; ip_from = (((ulong)v4.ip_from) | 0xFFFF00000000).ToString(); ip_to = (((ulong)v4.ip_to) | 0xFFFF00000000).ToString(); } }
public IPv4Record(IPRecord copyFrom) : base(copyFrom) { if (copyFrom is IPv4Record) { IPv4Record v4 = copyFrom as IPv4Record; ip_from = v4.ip_from; ip_to = v4.ip_to; } else if (copyFrom is IPv6Record) { IPv6Record v6 = copyFrom as IPv6Record; if (BigInteger.TryParse(v6.ip_from, out BigInteger from) && BigInteger.TryParse(v6.ip_to, out BigInteger to)) { ip_from = (uint)(from & 0xFFFFFFFF); ip_to = (uint)(to & 0xFFFFFFFF); } } }