public TcpConnection(Packet packet) { if (packet.Ethernet == null) { throw new Exception("error creating TcpStreamAddress packet is not ethernet"); } EthernetDatagram ethernet = packet.Ethernet; //if (ip == null) if (ethernet.EtherType != PcapDotNet.Packets.Ethernet.EthernetType.IpV4) { throw new Exception("error creating TcpStreamAddress packet is not ipv4"); } IpV4Datagram ip = ethernet.IpV4; //if (tcp == null) if (ip.Protocol != IpV4Protocol.Tcp) { throw new Exception("error creating TcpStreamAddress packet is not tcp"); } TcpDatagram tcp = ip.Tcp; //_source = new TcpAddress(ip.Source, tcp.SourcePort); _source = new TcpAddress(ethernet.Source, ip.Source, tcp.SourcePort); //_destination = new TcpAddress(ip.Destination, tcp.DestinationPort); _destination = new TcpAddress(ethernet.Destination, ip.Destination, tcp.DestinationPort); SetOrder(); }
private void SetOrder() { if (_source < _destination) { _address1 = _source; _address2 = _destination; _originalOrder = true; } else { _address1 = _destination; _address2 = _source; _originalOrder = false; } }
public TcpConnection(TcpAddress source, TcpAddress destination) { _source = source; _destination = destination; SetOrder(); }