Beispiel #1
0
        public Configuration ParseConfiguration()
        {
            Configuration.Builder configurationBuilder = new Configuration.Builder();

            LOG.Trace($"Reading configuration from {_filename}");
            XElement xelement = XElement.Load(_filename);

            configurationBuilder.SetComponentName(xelement.Descendants("component_name").First().Value);
            configurationBuilder.SetRouteTableQueryLocalPort(
                int.Parse(xelement.Descendants("rc_route_table_query_local_port").First().Value));
            configurationBuilder.SetLocalTopologyLocalPort(
                int.Parse(xelement.Descendants("rc_local_topology_local_port").First().Value));
            configurationBuilder.SetNetworkTopologyLocalPort(
                int.Parse(xelement.Descendants("rc_network_topology_local_port").First().Value));

            foreach (XElement element in xelement.Descendants("row"))
            {
                Configuration.RouteTableRow.RouteTableRowBuilder routeTableRowBuilder =
                    new Configuration.RouteTableRow.RouteTableRowBuilder();
                routeTableRowBuilder.SetSrc(element.Descendants("src").First().Value);
                routeTableRowBuilder.SetDst(element.Descendants("dst").First().Value);
                routeTableRowBuilder.SetGateway(element.Descendants("gateway").First().Value);

                LOG.Trace(
                    $"src: {element.Descendants("src").First().Value} " +
                    $"dst: {element.Descendants("dst").First().Value} " +
                    $"gateway: {element.Descendants("gateway").First().Value}");
                configurationBuilder.AddRouteTableRow(routeTableRowBuilder.Build());
            }

            return(configurationBuilder.Build());
        }
Beispiel #2
0
        public Configuration ParseConfiguration()
        {
            Configuration.Builder configurationBuilder = new Configuration.Builder();

            LOG.Debug($"Reading configuration from {_filename}");
            XElement xelement = XElement.Load(_filename);

            configurationBuilder.SetConnectionControllerType(xelement.Descendants("cc_type").First().Value);
            configurationBuilder.SetConnectionRequestLocalPort(
                int.Parse(xelement.Descendants("cc_connection_request_listener_local_port").First().Value));
            configurationBuilder.SetPeerCoordinationLocalPort(
                int.Parse(xelement.Descendants("cc_peer_coordination_listener_local_port").First().Value));
            configurationBuilder.SetServerAddress(IPAddress.Parse(xelement.Descendants("server_address").First().Value));
            configurationBuilder.SetRcRouteTableQueryRemotePort(int.Parse(xelement.Descendants("rc_route_table_query_remote_port").First().Value));
            configurationBuilder.SetComponentName(xelement.Descendants("component_name").First().Value);


            foreach (XElement element in xelement.Descendants("cc_name"))
            {
                LOG.Trace($"CC: PortPattern: {element.FirstAttribute.Value} CcName: {element.Value}");
                configurationBuilder.AddCcName(element.FirstAttribute.Value, element.Value);
            }

            switch (xelement.Descendants("cc_type").First().Value)
            {
            case "node":
                foreach (XElement element in xelement.Descendants("cc_peer_coordination_remote_port"))
                {
                    LOG.Trace($"CC: CcName: {element.FirstAttribute.Value} CcPeerCoordinationRemotePort: {element.Value}");
                    configurationBuilder.AddCcPeerCoordinationRemotePort(element.FirstAttribute.Value, int.Parse(element.Value));
                }

                foreach (XElement element in xelement.Descendants("lrm_remote_port"))
                {
                    LOG.Trace($"CC: LrmRemotePortAlias: {element.FirstAttribute.Value} Port: {element.Value}");
                    configurationBuilder.AddLrmRemotePort(element.FirstAttribute.Value, int.Parse(element.Value));
                }
                configurationBuilder.SetNnFibInsertRemotePort(int.Parse(xelement.Descendants("nn_fib_insert_remote_port").First().Value));
                break;

            case "domain":
                configurationBuilder.SetPeerCoordinationRemotePort(
                    int.Parse(xelement.Descendants("cc_peer_coordination_remote_port").First().Value));

                foreach (XElement element in xelement.Descendants("cc_connection_request_remote_port"))
                {
                    LOG.Trace($"CC: CcName: {element.FirstAttribute.Value} CcConnectionRequestRemotePort: {element.Value}");
                    configurationBuilder.AddCcConnectionRequestRemotePort(element.FirstAttribute.Value, int.Parse(element.Value));
                }

                break;

            case "subnetwork":
                foreach (XElement element in xelement.Descendants("cc_connection_request_remote_port"))
                {
                    LOG.Trace($"CC: CcName: {element.FirstAttribute.Value} CcConnectionRequestRemotePort: {element.Value}");
                    configurationBuilder.AddCcConnectionRequestRemotePort(element.FirstAttribute.Value, int.Parse(element.Value));
                }

                foreach (XElement element in xelement.Descendants("cc_peer_coordination_remote_port"))
                {
                    LOG.Trace($"CC: CcName: {element.FirstAttribute.Value} CcPeerCoordinationRemotePort: {element.Value}");
                    configurationBuilder.AddCcPeerCoordinationRemotePort(element.FirstAttribute.Value, int.Parse(element.Value));
                }

                foreach (XElement element in xelement.Descendants("lrm_remote_port"))
                {
                    LOG.Trace($"CC: LrmRemotePortAlias: {element.FirstAttribute.Value} Port: {element.Value}");
                    configurationBuilder.AddLrmRemotePort(element.FirstAttribute.Value, int.Parse(element.Value));
                }

                break;
            }

            return(configurationBuilder.Build());
        }