Exemplo n.º 1
0
 private void PushLabel(Package package, NhlfeEntry nhlfeEntry)
 {
     if (nhlfeEntry.outLabel == null)
     {
         Logs.ShowLog(LogType.ERROR, $"Invalid NHLFE entry for router {routerName}. outLabel null.");
         return;
     }
     else if (nhlfeEntry.outPort == null)
     {
         if (nhlfeEntry.nextId == null)
         {
             Logs.ShowLog(LogType.ERROR, $"Invalid NHLFE entry for router {routerName}. outPort and nextId null.");
             return;
         }
         package.labels.Add((int)nhlfeEntry.outLabel);
         var nextNhlfeEntry = nhlfeTable.entries[(int)nhlfeEntry.nextId];
         PushLabel(package, nextNhlfeEntry);
     }
     else if (nhlfeEntry.nextId == null)
     {
         package.labels.Add((int)nhlfeEntry.outLabel);
         package.incomingPort = (int)nhlfeEntry.outPort;
         // send to cloud
     }
     else
     {
         Logs.ShowLog(LogType.ERROR, $"Invalid NHLFE entry for router {routerName}. All 3 values not null.");
         return;
     }
 }
Exemplo n.º 2
0
        private void PopLabel(Package package, NhlfeEntry nhlfeEntry)
        {
            if (nhlfeEntry.outLabel != null && nhlfeEntry.outPort != null && nhlfeEntry.nextId != null)
            {
                Logs.ShowLog(LogType.ERROR, $"Invalid NHLFE entry for router {routerName}. outLabel, outPort or nextId  NOT null.");
                return;
            }
            if (package.labels.Any())
            {
                poppedLabel = package.labels[package.labels.Count - 1];
                package.labels.RemoveAt(package.labels.Count - 1);
                if (package.labels.Any())
                {
                    IlmEntry ilmEntry;
                    ilmEntry = ilmTable.entries[$"{package.labels.Last()}, {package.incomingPort}, {poppedLabel}"];
                    var newNhlfeEntry = nhlfeTable.entries[ilmEntry.id];
                    switch (newNhlfeEntry.operation)
                    {
                    case "PUSH":
                        PushLabel(package, newNhlfeEntry);
                        break;

                    case "POP":
                        PopLabel(package, newNhlfeEntry);
                        break;

                    case "SWAP":
                        SwapLabel(package, newNhlfeEntry);
                        break;
                    }
                }
                else
                {
                    var mplsEntry = mplsFibTable.entries[package.destPort];
                    if (mplsEntry.fec == 0)
                    {
                        var ipFibEntry = ipFibTable.entries[package.destAddress];
                        package.incomingPort = ipFibEntry.outPort;
                        // send package to cloud
                    }
                }
            }
            else
            {
                Logs.ShowLog(LogType.ERROR, "No label to pop found.");
            }
        }
Exemplo n.º 3
0
 private void SwapLabel(Package package, NhlfeEntry nhlfeEntry)
 {
     package.labels[package.labels.Count - 1] = (int)nhlfeEntry.outLabel;
     package.incomingPort = (int)nhlfeEntry.outPort;
     // send package to cloud
 }