// Ctor allows conversion from L4Packet to Connection. public Connection(IPV4_PACKET pkt) { Type = new ConnectionType(pkt.protocol); _state = new ConnectionState(TransmissionDirection.ONE_WAY); SrcHost = new ConnectionAddress(pkt.source_address); DstHost = new ConnectionAddress(pkt.destination_address); SrcPort = pkt.source_port; DstPort = pkt.destination_port; DstGeo = new GeoData(); _packetCount = 1; _dataSize = pkt.payload_size; TimeStamp = DateTime.Now; DstASN = null; DstASNOrg = "--"; }
public int CompareTo(object obj) { // Make sure we are comparing to a valid object. if (obj == null || !(obj is GeoData)) { throw new NotSupportedException("Error: compared object is not a GeoData type!"); } // Cast objest to usable current type. GeoData geo = (obj as GeoData); // Compare numerical value based on enum. if (this.CountryISO.CompareTo(geo.CountryISO) > 0) { return(1); } else if (this.CountryISO.CompareTo(geo.CountryISO) < 0) { return(-1); } else { if (this.StateISO.CompareTo(geo.StateISO) > 0) { return(1); } else if (this.StateISO.CompareTo(geo.StateISO) < 0) { return(-1); } else { return(0); } } }