Ejemplo n.º 1
0
		public Controller(string[] args) {

			List<string> connections = new List<string>();
			bool is_active=false, is_tcp=false;

			phy_port_list = new List<ofp_phy_port>();
			var optionSet = new OptionSet() { };

			try {
				connections = optionSet.Parse(args);
			} catch {
				Console.WriteLine("Error: Option error");
			}

			if (connections.Count != 1 ) {
            Console.WriteLine("Error:Inapropriate address argument");
            Usage();
            Environment.Exit(0);
			}

         if ( !(connections[0].StartsWith("ptcp:") || connections[0].StartsWith("tcp") || connections[0].StartsWith("punix:") || connections[0].StartsWith("unix:"))) {
            Console.WriteLine("Error:Not a valid connection address");
            Usage();
            Environment.Exit(0);
         }
         if ( !connections[0].StartsWith("p")) {
            is_active = true;
         }
         if ( connections[0].Split(':')[0].Contains("tcp")) {
            is_tcp = true;
         }

			try { 
				socket_connection = new SocketConnection(is_active, is_tcp, connections[0].Split(':')[1]);
			} catch {
            Console.WriteLine("Error:Fail to establish socket connection");
				Environment.Exit(0);
			}

			string[] log_files = connections[0].Split('/');  
			log_file = log_files[log_files.Length-1];
			log_file += ".log";
			logger = new Logger(log_file);
			mac_learning = new MacLearning(logger);


         StreamWriter file = new StreamWriter("controller.log", false);
         file.Close();
			Write(ofp_hello(0));	
			Write(ofp_features_request(0));
		} //Controller
Ejemplo n.º 2
0
		public UnixSocketIPCClientController(string[] args, string addr) : base(args) { 
			socket_connection = new SocketConnection(false, addr); 
		}
Ejemplo n.º 3
0
		public UnixSocketIPCServerController(string[] args, string addr) : base(args) { 
			socket_connection = new SocketConnection(true, addr); 
		}