Example #1
0
        public async void Update(HierarchicalLabelSwitchedPath.HierarchicalLabelSwitchedPath HierarchicalLabelSwitchedPath)
        {
            while (this.locked)
            {
                await Task.Delay(1);
            }

            this.locked = true;

            /* Id is based on Tunnel Sender and Receiver addresses, this does not work with JunOS implementation of
             * PCRept message that sends LSPs with Remove flag set and missing Tunnel Sender and Receiver addresses = "0.0.0.0"
             *
             * var existingHierarchicalLabelSwitchedPath =
             *  HierarchicalLabelSwitchedPaths.Find(l => l.Id == HierarchicalLabelSwitchedPath.Id);
             */

            var existingHierarchicalLabelSwitchedPath =
                HierarchicalLabelSwitchedPaths.Find(l => l.SymbolicPathName == HierarchicalLabelSwitchedPath.SymbolicPathName);

            if (existingHierarchicalLabelSwitchedPath == null)
            {
                HierarchicalLabelSwitchedPaths.Add(HierarchicalLabelSwitchedPath);
            }

            // UPDATE? (can overwrite children!)

            this.locked = false;
        }
Example #2
0
        private async void ProcessSHIFTPCEPMessage(JObject data)
        {
            var symbolicPathName = (string)data["lsp"]["symbolic_path_name"];

            if (!string.IsNullOrWhiteSpace(symbolicPathName))
            {
                var ipv4_tunnel_sender_address   = (string)data["lsp"]["ipv4_tunnel_sender_address"];
                var ipv4_tunnel_endpoint_address = (string)data["lsp"]["ipv4_tunnel_endpoint_address"];

                // Gets the PCC parameter from the local node database instead of the LSP property, SHIFT PCEP listener is behind Docker Swarm's NAT(PAT).
                var    ingress_node = this.Nodes.Find(n => n.IPv4RouterIdentifier == ipv4_tunnel_sender_address);
                string pcc          = string.Empty;
                if (ingress_node != null)
                {
                    pcc = ingress_node.PCC;
                }

                if (symbolicPathName.Contains("/"))
                {
                    var hierarchicalSymbolicPathName = symbolicPathName.Split("/".ToCharArray());

                    HierarchicalLabelSwitchedPath.HierarchicalLabelSwitchedPath parent = new HierarchicalLabelSwitchedPath.HierarchicalLabelSwitchedPath(hierarchicalSymbolicPathName[0])
                    {
                        IPv4TunnelSenderAddress   = ipv4_tunnel_sender_address,
                        IPv4TunnelEndpointAddress = ipv4_tunnel_endpoint_address
                    };

                    this.Update(parent);

                    LabelSwitchedPath.LabelSwitchedPath child = new LabelSwitchedPath.LabelSwitchedPath(parent.Id)
                    {
                        PCC = pcc,
                        IPv4TunnelSenderAddress          = ipv4_tunnel_sender_address,
                        IPv4TunnelEndpointAddress        = ipv4_tunnel_endpoint_address,
                        SymbolicPathName                 = symbolicPathName,
                        TunnelIdentifier                 = (string)data["lsp"]["tunnel_id"],
                        ExtendedTunnelIdentifier         = (string)data["lsp"]["extended_tunnel_id"],
                        ExtendedTunnelIdentifierTunnelId = (string)data["lsp"]["extended_tunnel_id"],
                        LspIdentifier     = (string)data["lsp"]["lsp_id"],
                        ReservedBandwidth = (long?)data["bandwidth"],
                        Administrative    = (bool)data["lsp"]["flags"]["administrative"],
                        Delegate          = (bool)data["lsp"]["flags"]["delegate"],
                        Operational       = (bool)data["lsp"]["flags"]["operational"],
                        Remove            = (bool)data["lsp"]["flags"]["remove"],
                        Sync = (bool)data["lsp"]["flags"]["sync"]
                    };

                    if (data["rro"] != null)
                    {
                        List <string> hops = new List <string>();

                        foreach (var hop in data["rro"])
                        {
                            hops.Add((string)hop["address"]);
                        }

                        child.RecordRouteObject = hops.ToArray();
                    }

                    this.Update(child);
                }
                else
                {
                    LabelSwitchedPath.LabelSwitchedPath l = new LabelSwitchedPath.LabelSwitchedPath(null)
                    {
                        PCC = pcc,
                        IPv4TunnelSenderAddress          = ipv4_tunnel_sender_address,
                        IPv4TunnelEndpointAddress        = ipv4_tunnel_endpoint_address,
                        SymbolicPathName                 = symbolicPathName,
                        TunnelIdentifier                 = (string)data["lsp"]["tunnel_id"],
                        ExtendedTunnelIdentifier         = (string)data["lsp"]["extended_tunnel_id"],
                        ExtendedTunnelIdentifierTunnelId = (string)data["lsp"]["extended_tunnel_id"],
                        LspIdentifier     = (string)data["lsp"]["lsp_id"],
                        ReservedBandwidth = (long?)data["bandwidth"],
                        Administrative    = (bool)data["lsp"]["flags"]["administrative"],
                        Delegate          = (bool)data["lsp"]["flags"]["delegate"],
                        Operational       = (bool)data["lsp"]["flags"]["operational"],
                        Remove            = (bool)data["lsp"]["flags"]["remove"],
                        Sync = (bool)data["lsp"]["flags"]["sync"]
                    };

                    if (data["lsp"]["rro"] != null)
                    {
                        List <string> hops = new List <string>();

                        foreach (var hop in data["lsp"]["rro"])
                        {
                            hops.Add((string)hop["address"]);
                        }

                        l.RecordRouteObject = hops.ToArray();
                    }

                    this.Update(l);
                }
            }
        }
Example #3
0
 public static string ToJson(this HierarchicalLabelSwitchedPath self) => JsonConvert.SerializeObject(self, shift.yggdrasil2.Topology.MPLS.HierarchicalLabelSwitchedPath.Converter.Settings);