Exemple #1
0
        private bool LogSessionContractCall(
            [EventLogMethodParameter(Title = "Session", OrdinalInStruct = 0, TypeInStruct = "ushort")]
            uint sessionId,
            [EventLogMethodParameter(Title = "SessionState", OrdinalInStruct = 1, TypeInStruct = "byte")]
            TcpStateEnum sessionState,
            [EventLogMethodParameter(Title = "CallName", OrdinalInStruct = 2, TypeInStruct = "byte")]
            TcpSessionContractEntrypoints contractEntrypoint,
            uint flag)
        {
            if ((debugOptions & flag /* To Debugger */) != 0)
            {
                Core.Log("TCP: Ses{0,3} ({1}) Contract EP '{2}' called.",
                         sessionId,
                         TcpState.TcpStateNames[(uint)sessionState],
                         TcpSessionEventsSource.ContractCallNames[(uint)contractEntrypoint]);
            }

            if ((ControlFlags & flag) != 0)
            {
                ContractCallEntry contractCallEntry =
                    new ContractCallEntry(sessionId, sessionState, contractEntrypoint);

                unsafe
                {
                    return(LogEntry(ControlFlags,
                                    contractCallTypeHandle,
                                    (byte *)&contractCallEntry,
                                    sizeof(ContractCallEntry)) != 0);
                }
            }

            return(false);
        }
Exemple #2
0
        public bool LogTimeout(
            [EventLogMethodParameter(Title = "Session Id", OrdinalInStruct = 0, TypeInStruct = "ushort")]
            uint sessionId,
            [EventLogMethodParameter(Title = "Session State", OrdinalInStruct = 1, TypeInStruct = "byte")]
            TcpStateEnum sessionState,
            [EventLogMethodParameter(Title = "Timeout Type", OrdinalInStruct = 2, TypeInStruct = "byte")]
            TcpSession.TcpTimeoutType timeoutType)
        {
            if ((debugOptions & LogTimeouts /* To Debugger */) != 0)
            {
                Core.Log("TCP: Ses{0,3} ({1}) Timeout of type '{2}' occurred",
                         sessionId,
                         TcpState.TcpStateNames[(uint)sessionState],
                         TcpSession.TcpTimeoutTypeNames[(uint)timeoutType]);
            }

            if ((ControlFlags & LogTimeouts) != 0)
            {
                TimeoutEntry timeoutEntry =
                    new TimeoutEntry(sessionId, sessionState, timeoutType);

                unsafe
                {
                    return(LogEntry(ControlFlags,
                                    timeoutTypeHandle,
                                    (byte *)&timeoutEntry,
                                    sizeof(TimeoutEntry)) != 0);
                }
            }

            return(false);
        }
Exemple #3
0
        public bool LogSessionStateChange(
            [EventLogMethodParameter(Title = "Session", OrdinalInStruct = 0, TypeInStruct = "ushort")]
            uint sessionId,
            [EventLogMethodParameter(Title = "FrState", OrdinalInStruct = 1, TypeInStruct = "byte")]
            TcpStateEnum fromState,
            [EventLogMethodParameter(Title = "ToState", OrdinalInStruct = 2, TypeInStruct = "byte")]
            TcpStateEnum toState)   // BUGBUG AM: signature poor way to differentiate various entries.  Is there a way to have two two "int" loggers with different types and member labels?
        {
            if ((debugOptions & LogStateChanges /* To Debugger */) != 0)
            {
                Core.Log("TCP: Ses{0,3} ({1}) State Change to {2}.",
                         sessionId,
                         TcpState.TcpStateNames[(uint)fromState],
                         TcpState.TcpStateNames[(uint)toState]);
            }

            if ((ControlFlags & LogStateChanges) != 0)
            {
                StateChangeEntry stateChangeEntry =
                    new StateChangeEntry(sessionId, fromState, toState);

                unsafe
                {            // BUGBUG AM: Just a comment - this causes my otherwise safe compile to be changed to unsafe.  This is bad.
                    return(LogEntry(ControlFlags,
                                    stateChangeTypeHandle,
                                    (byte *)&stateChangeEntry,
                                    sizeof(StateChangeEntry)) != 0);
                }
            }

            return(false);
        }
Exemple #4
0
 public SendingPacketEntry(uint sessionId, TcpStateEnum sessionState, uint packetFlags, uint packetLength)
 {
     this.sessionId    = (ushort)sessionId;
     this.sessionState = (byte)sessionState;
     this.packetFlags  = (byte)packetFlags;
     this.packetLength = (ushort)packetLength;
 }
Exemple #5
0
 public ContractCallEntry(uint sessionId, TcpStateEnum sessionState,
                          TcpSessionContractEntrypoints callId)
 {
     this.sessionId    = (ushort)sessionId;
     this.sessionState = (byte)sessionState;
     this.callId       = (byte)callId;
 }
Exemple #6
0
        // change the state of this session
        internal void ChangeState(TcpState !newState)
        {
            lock (this.lockHolder)
            {
                assert(currentState != null);

                // Log upcoming State Change
                TcpSessionEventsSource.EventLog.LogSessionStateChange(
                    Uid,
                    currentState.StateEnum,
                    newState.StateEnum);
#if false
                TcpSessionEvents.EventLog.TcpSessionStateChangeEvent(
                    (ushort)Uid,
                    (TcpSessionEvents.TcpSessionState)currentState.StateEnum,
                    (TcpSessionEvents.TcpSessionState)newState.StateEnum);
#endif
                // Old State's Exit Processing
                currentState.OnStateLeave(this, newState);

                // Actual State Change
                oldStateEnum = currentState.StateEnum;
                currentState = newState;

                // New State's Entry Processing
                currentState.OnStateEnter(this);
            }
        }
Exemple #7
0
        public new void ReInitialize(IProtocol !protocol)
        {
            base.ReInitialize(protocol);
            sessionTCB          = new TCB();
            sessionTCB.SND.WND  = TcpFormat.TCP_MSS;
            sessionTCB.RCV.WND  = TcpFormat.TCP_MSS;
            maxAcceptedSessions = 0;
            passiveSession      = null;
            isValidForRead      = true;
            isValidForWrite     = true;

            DrainQueue(outQueue);
            DrainQueue(inQueue);
            retransmitQ.Clear();
            acceptedSessions.Clear();
            setupCompleteEvent.Reset();
            closedEvent.Reset();

            // create and initialize the init state
            this.oldStateEnum = TcpStateEnum.Undefined;
            if (!IsClosed)
            {
                ChangeState(TCPFSM.CLOSED);
            }

            DestroyConnectTimer();
            DestroyShutdownTimer();
            DestroyPersistTimer();

            retransInterval = InitialRetransInterval;
        }
Exemple #8
0
        public TcpSession(IProtocol !p)
            : base(p, TxQSize, RcvQSize)
        {
            sessionTCB           = new TCB();
            sessionTCB.SND.WND   = TcpFormat.TCP_MSS;
            sessionTCB.RCV.WND   = TcpFormat.TCP_MSS;
            retransmitQ          = new ArrayList(RetransmitQSize);
            acceptedSessions     = new ArrayList();
            maxAcceptedSessions  = 0;                   // Changed by Listen()
            acceptSessionMonitor = new object();

            setupCompleteEvent = new System.Threading.ManualResetEvent(false);
            closedEvent        = new System.Threading.ManualResetEvent(false);
            passiveSession     = null;

            // at first the session is valid (user can interact with it)
            isValidForRead  = true;
            isValidForWrite = true;

            // Assign the undifferentiated state (the parent of the
            //  specialized states) and then change the state to CLOSED.
            this.oldStateEnum = TcpStateEnum.Undefined;
            this.currentState = TcpState.InstanceOfUndefined();
            ChangeState(TCPFSM.CLOSED);
        }
Exemple #9
0
 internal bool LogSessionInfoContractCall(
     [EventLogMethodParameter(Title = "Session", OrdinalInStruct = 0, TypeInStruct = "ushort")]
     uint sessionId,
     [EventLogMethodParameter(Title = "SessionState", OrdinalInStruct = 1, TypeInStruct = "byte")]
     TcpStateEnum sessionState,
     [EventLogMethodParameter(Title = "CallId", OrdinalInStruct = 2, TypeInStruct = "byte")]
     TcpSessionContractEntrypoints contractEntrypoint)
 {
     return(this.LogSessionContractCall(sessionId, sessionState,
                                        contractEntrypoint,
                                        LogInfoContractCalls));
 }
Exemple #10
0
        public bool LogSendingPacket(
            [EventLogMethodParameter(Title = "Session Id", OrdinalInStruct = 0, TypeInStruct = "ushort")]
            uint sessionId,
            [EventLogMethodParameter(Title = "Session State", OrdinalInStruct = 1, TypeInStruct = "byte")]
            TcpStateEnum sessionState,
            [EventLogMethodParameter(Title = "Packet Flags", OrdinalInStruct = 2, TypeInStruct = "byte")]
            uint packetFlags,
            [EventLogMethodParameter(Title = "Packet Length", OrdinalInStruct = 3, TypeInStruct = "ushort")]
            uint packetLength)
        {
            if ((debugOptions & LogSendingPackets /* To Debugger */) != 0)
            {
                string flagsText = FlagsToText(packetFlags);    // TODO Move then Qualify
                Core.Log("TCP: Ses{0,3} ({1}) Packet ({2}) Len{3,4} being sent",
                         sessionId,
                         TcpState.TcpStateNames[(uint)sessionState],
                         flagsText,
                         packetLength);
            }

            if ((ControlFlags & LogSendingPackets) != 0)
            {
                SendingPacketEntry sendingPacketEntry =
                    new SendingPacketEntry(sessionId, sessionState, packetFlags, packetLength);

                unsafe
                {
                    return(LogEntry(ControlFlags,
                                    sendingPacketTypeHandle,
                                    (byte *)&sendingPacketEntry,
                                    sizeof(SendingPacketEntry)) != 0);
                }
            }

            return(false);
        }
Exemple #11
0
 public TimeoutEntry(uint sessionId, TcpStateEnum sessionState, TcpSession.TcpTimeoutType timeoutType)
 {
     this.sessionId    = (ushort)sessionId;
     this.sessionState = (byte)sessionState;
     this.timeoutType  = (byte)timeoutType;
 }
Exemple #12
0
 public StateChangeEntry(uint sessionId, TcpStateEnum fromState, TcpStateEnum toState)
 {
     this.sessionId = (ushort)sessionId;
     this.fromState = (byte)fromState;
     this.toState   = (byte)toState;
 }