private void TraceTcpNatContext(NATContext context, TcpFrame frame) { if (context == null || frame == null) { return; } NATContext.StateCode state = NATContext.StateCode.TCP_RST; // 跟踪TCP协议报文状态 if (0 != (frame.Flags & TcpFlags.TCP_SYN)) { state = NATContext.StateCode.TCP_SYN; } else if (0 != (frame.Flags & TcpFlags.TCP_FIN)) { state = NATContext.StateCode.TCP_FIN; } else if (0 != (frame.Flags & TcpFlags.TCP_RST)) { state = NATContext.StateCode.TCP_RST; } else if (0 != (frame.Flags & (TcpFlags.TCP_PSH | TcpFlags.TCP_ACK))) { state = NATContext.StateCode.TCP_RECVED; } if (context.State != NATContext.StateCode.TCP_FIN && context.State != NATContext.StateCode.TCP_RST) { context.Restart().State = state; } }
private NATContext RestartContextAgingTime(NATContext context) { if (context == null) { return(context); } if (this.ProtocolType != ProtocolType.Tcp) { return(context); } if (context.State == NATContext.StateCode.TCP_RECVED || context.State == NATContext.StateCode.TCP_SYN) { return(context.Restart()); } return(context); }