private NetStatus OnRequestTimeout(Dispatcher.CallbackArgs args) { DateTime now = ((TimeoutArgument !)args).now; int i = 0; while (i != pendingRequests.Count) { PendingRequest request = (PendingRequest !)pendingRequests[i]; if (request.expiry < now) { DebugPrint("Expiring request"); request.callback(request.address, EthernetAddress.Zero, request.cookie); pendingRequests.RemoveAt(i); continue; } i++; } if (pendingRequests.Count > 0) { DateTime nextPoll = now + PollPeriod; Core.Instance().TheDispatcher.AddCallback( new Dispatcher.Callback(OnRequestTimeout), new TimeoutArgument(nextPoll), (ulong)nextPoll.Ticks ); } return(NetStatus.Code.RT_OK); }
internal NetStatus OnConnectTimeout(Dispatcher.CallbackArgs args) { // We failed to become established in time. Bail out. TcpSessionEventsSource.EventLog.LogTimeout( Uid, currentState.StateEnum, TcpTimeoutType.Connect); Terminate(null, TcpError.Timeout); return(NetStatus.Code.PROTOCOL_OK); }
// make the arp table entries older... // currently arg is null public NetStatus OnAgingTimer(Dispatcher.CallbackArgs arg) { arpTable.AgeTable(); DateTime then = DateTime.UtcNow + ArpTable.AgePeriod; Core.Instance().TheDispatcher.AddCallback( new Dispatcher.Callback(OnAgingTimer), null, (ulong)then.Ticks ); return(NetStatus.Code.RT_OK); }
private NetStatus OnPersistTimeout(Dispatcher.CallbackArgs timeoutArg) { // // NOTE: This is a hack. A proper TCP stack is supposed to // transmit a packet consisting of just one byte when probing the // remote host to see if it has reopened its receive window. // However, we prepacketize data, so we don't have that option. // Instead, we probe using full packets. // TcpSessionEventsSource.EventLog.LogTimeout( Uid, currentState.StateEnum, TcpTimeoutType.Persist); TcpSegment seg = null; if (retransmitQ.Count > 0) { // Use the oldest unacknowledged packet to probe seg = (TcpSegment)retransmitQ[0]; } else { // Nothing in the retransmit queue; probe using the next // normal packet. This will transition the packet to the // retransmission queue. seg = GetNextPacket(true /*ignore window*/); } if (seg != null) { seg.Mux = BoundMux; NetStatus err = Protocol.OnProtocolSend(seg); assert err == NetStatus.Code.PROTOCOL_OK; } if (currentState != TCPFSM.CLOSED) { // rearm StartPersistTimer(); } return(NetStatus.Code.PROTOCOL_OK); }