예제 #1
0
        private void HandleMessage(string message)
        {
            AddLog($"Message received from MS: {message}", LogType.Information);

            // first word in message is the action type
            var action = message.Split(null)[0];
            var data   = message.Replace($"{action} ", "");

            switch (action)
            {
            case ManagementActions.SHOW_LESS_ROUTING_LOGS:
                Window.ShowDetailedRoutingLogs = false;
                break;

            case ManagementActions.SHOW_MORE_ROUTING_LOGS:
                Window.ShowDetailedRoutingLogs = true;
                break;

            case ManagementActions.SHOW_LESS_TTL_LOGS:
                Window.ShowDetailedTTLLogs = false;
                break;

            case ManagementActions.SHOW_MORE_TTL_LOGS:
                Window.ShowDetailedTTLLogs = true;
                break;

            case ManagementActions.ADD_FTN_ENTRY:
            case ManagementActions.REMOVE_FTN_ENTRY:
                var ftnArgs = new ForwardingTableEventArgs(action, new FtnTableRow(data));
                OnModifyForwardingTable(ftnArgs);
                break;

            case ManagementActions.ADD_ILM_ENTRY:
            case ManagementActions.REMOVE_ILM_ENTRY:
                var ilmArgs = new ForwardingTableEventArgs(action, new IlmTableRow(data));
                OnModifyForwardingTable(ilmArgs);
                break;

            case ManagementActions.ADD_MPLS_FIB_ENTRY:
            case ManagementActions.REMOVE_MPLS_FIB_ENTRY:
                var mplsFibArgs = new ForwardingTableEventArgs(action, new MplsFibTableRow(data));
                OnModifyForwardingTable(mplsFibArgs);
                break;

            case ManagementActions.ADD_NHLFE_ENTRY:
            case ManagementActions.REMOVE_NHLFE_ENTRY:
                var nhlfeArgs = new ForwardingTableEventArgs(action, new NHLFETableRow(data));
                OnModifyForwardingTable(nhlfeArgs);
                break;

            case ManagementActions.ADD_IP_FIB_ENTRY:
            case ManagementActions.REMOVE_IP_FIB_ENTRY:
                var ipFibArgs = new ForwardingTableEventArgs(action, new IpFibTableRow(data));
                OnModifyForwardingTable(ipFibArgs);
                break;
            }
        }
        private void HandleModifyForwardingTable(object sender, ForwardingTableEventArgs e)
        {
            switch (e.Action)
            {
            case ManagementActions.ADD_FTN_ENTRY:
                AddLog($"Adding new FTN entry: {(FtnTableRow)e.Row}", LogType.Information);
                ftnTable.Rows.Add((FtnTableRow)e.Row);
                break;

            case ManagementActions.REMOVE_FTN_ENTRY:
                AddLog($"Removing FTN entry: {(FtnTableRow)e.Row}", LogType.Information);
                ftnTable.Rows.Remove((FtnTableRow)e.Row);
                break;

            case ManagementActions.ADD_ILM_ENTRY:
                AddLog($"Adding new ILM entry: {(IlmTableRow)e.Row}", LogType.Information);
                ilmTable.Rows.Add((IlmTableRow)e.Row);
                break;

            case ManagementActions.REMOVE_ILM_ENTRY:
                AddLog($"Removing ILM entry: {(IlmTableRow)e.Row}", LogType.Information);
                ilmTable.Rows.Remove((IlmTableRow)e.Row);
                break;

            case ManagementActions.ADD_MPLS_FIB_ENTRY:
                AddLog($"Adding new MPLS-FIB entry: {(MplsFibTableRow)e.Row}", LogType.Information);
                mplsFibTable.Rows.Add((MplsFibTableRow)e.Row);
                break;

            case ManagementActions.REMOVE_MPLS_FIB_ENTRY:
                AddLog($"Removing MPLS-FIB entry: {(MplsFibTableRow)e.Row}", LogType.Information);
                mplsFibTable.Rows.Remove((MplsFibTableRow)e.Row);
                break;

            case ManagementActions.ADD_NHLFE_ENTRY:
                AddLog($"Adding new NHLFE entry: {(NHLFETableRow)e.Row}", LogType.Information);
                nhlfeTable.Rows.Add((NHLFETableRow)e.Row);
                break;

            case ManagementActions.REMOVE_NHLFE_ENTRY:
                AddLog($"Removing NHLFE entry: {(NHLFETableRow)e.Row}", LogType.Information);
                nhlfeTable.Rows.Remove((NHLFETableRow)e.Row);
                break;

            case ManagementActions.ADD_IP_FIB_ENTRY:
                AddLog($"Adding new IP-FIB entry: {(IpFibTableRow)e.Row}", LogType.Information);
                ipFibTable.Rows.Add((IpFibTableRow)e.Row);
                break;

            case ManagementActions.REMOVE_IP_FIB_ENTRY:
                AddLog($"Removing IP-FIB entry: {(IpFibTableRow)e.Row}", LogType.Information);
                ipFibTable.Rows.Remove((IpFibTableRow)e.Row);
                break;
            }
        }
예제 #3
0
 protected virtual void OnModifyForwardingTable(ForwardingTableEventArgs e)
 {
     ModfifyForwardingTable?.Invoke(this, e);
 }