//---------------------------------------------------------------------------- // // Copyright (c) Intel Corporation, 2009-2014 All Rights Reserved. // // File: KVMFunctionality.cs // // Contents: Demonstrate the IKVM interface. // // //---------------------------------------------------------------------------- using System; using System.Collections.Generic; using Intel.Manageability; using Intel.Manageability.KVM; using Intel.Manageability.Exceptions; using System.Security; namespace KVMSample { public class KVMFunctionality { /// /// Get KVM capabilities /// /// The Intel AMT instance public static void DisplayCapabilities(IAMTInstance amt) { try { KVMCapabilities capabilities = amt.KVMSetup.GetCapabilities(); Console.WriteLine("KVM Capabilities:\n=================\n"); Console.WriteLine("Default port (5900): {0}", (capabilities.IsDefaultPortEnable) ? "enable" : "disable"); Console.WriteLine("Redirection port: {0}", (capabilities.IsRedirectionPortEnable) ? "enable" : "disable"); Console.WriteLine("Opt-In policy: {0}", (capabilities.OptInPolicyEnable) ? "enable" : "disable"); Console.WriteLine("Opt-In policy timeout: {0}", capabilities.OptInPolicyTimeout); Console.WriteLine("TCP Session timeout: {0}", capabilities.TcpSessionTimeout); Console.WriteLine("Default visible screen: {0}", capabilities.VisibleScreen); } catch (KVMManageabilityException ex) { Console.WriteLine("Failed to get KVM Capabilities with status: " + ex.Message); } } /// /// Set the state of the KVM ports /// /// The Intel AMT instance /// The ports to set. Default port is no longer supported. See remarks. /// /// NOTE:KVM Default port (5900) is no longer supported, starting from the following releases. /// KabyLake: 11.8.94 /// CannonLake: 12.0.93 /// CometLake: 14.1.70 /// TigerLake: 15.0.45 /// AlderLake, RaptorLake: 16.1.25 /// Attempting to configure a RFB password or enabling the port via IPS_KVMRedirectionSettingData.PUT /// will return unsupported message. /// public static void SetPortsState(IAMTInstance amt, KVMPortsState ports) { try { Console.Write("Setting port state...\t"); amt.KVMSetup.SetPortsState(ports); Console.WriteLine("Success"); } catch (KVMManageabilityException ex) { Console.WriteLine("Failed with status: " + ex.Message); } } /// /// Set the default monitor /// /// The Intel AMT instance public static void SetDefaultMonitor(IAMTInstance amt) { try { Console.Write("Setting default monitor...\t"); List screens = amt.KVMSetup.GetAvailableMonitors(); if (screens.Contains(VisibleScreen.Monitor0)) amt.KVMSetup.SetDefaultMonitor(VisibleScreen.Monitor0); Console.WriteLine("Success"); } catch (KVMManageabilityException ex) { Console.WriteLine("Failed with status: " + ex.Message); } } /// /// Set the RFB password /// /// The Intel AMT instance /// The new RFB password /// /// NOTE: KVM Default port (5900) and configuring an RFB password are no longer supported, starting from the following releases. /// KabyLake: 11.8.94 /// CannonLake: 12.0.93 /// CometLake: 14.1.70 /// TigerLake: 15.0.45 /// AlderLake, RaptorLake: 16.1.25 /// Attempting to configure a RFB password or enabling the port via IPS_KVMRedirectionSettingData.PUT /// will return unsupported message. /// public static void SetNewRFBPass(IAMTInstance amt, SecureString password) { try { Console.Write("Setting RFB Password...\t"); amt.KVMSetup.SetRFBPassword(password); Console.WriteLine("Success"); } catch (KVMManageabilityException ex) { Console.WriteLine("Failed with status: " + ex.Message); } catch (ManageabilityException ex) { Console.WriteLine("Failed with status: " + ex.Message); } } /// /// Set the opt-in timeout /// /// The Intel AMT instance /// The timeout to set public static void SetOptInTimeout(IAMTInstance amt, ushort timeout) { try { Console.Write("Setting Opt-In timeout...\t"); amt.KVMSetup.SetOptInTimeout(timeout); Console.WriteLine("Success"); } catch (KVMManageabilityException ex) { Console.WriteLine("Failed with status: " + ex.Message); } } /// /// Set the TCP session timeout /// /// The Intel AMT instance /// The timeout to set public static void SetTCPSessionTimeout(IAMTInstance amt, ushort timeout) { try { Console.Write("Setting TCP session timeout...\t"); amt.KVMSetup.SetSessionTimeout(timeout); Console.WriteLine("Success"); } catch (KVMManageabilityException ex) { Console.WriteLine("Failed with status: " + ex.Message); } } /// /// Enable the KVM interface /// /// The Intel AMT instance public static void EnableKVMInterface(IAMTInstance amt) { try { Console.Write("Enable KVM interface...\t"); if (amt.KVMSetup.GetInterfaceState()) Console.WriteLine("\nKVM Interface is already enable."); else { amt.KVMSetup.SetInterfaceState(true); Console.WriteLine("Success"); } } catch (KVMManageabilityException ex) { Console.WriteLine("Failed with status: " + ex.Message); } } } }