Exemple #1
0
        /// <summary>
        /// Configure a IP configuration on the given network device.
        /// <remarks>Multiple IP Configurations can be made, like *nix environments</remarks>
        /// </summary>
        /// <param name="nic"><see cref="NetworkDevice"/> that will have the assigned configuration</param>
        /// <param name="config"><see cref="Config"/> instance that defines the IP Address, Subnet
        /// Mask and Default Gateway for the device</param>
        /// <exception cref="ArgumentException">
        /// <list type="bullet">
        /// <item>Thrown if configuration with the given config.IPAddress.Hash already exists.</item>
        /// <item>Thrown on fatal error (contact support).</item>
        /// </list>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown on fatal error (contact support).</exception>
        /// <exception cref="Sys.IO.IOException">Thrown on IO error.</exception>
        /// <exception cref="OverflowException">Thrown on fatal error (contact support).</exception>
        public static void ConfigIP(NetworkDevice nic, IPConfig config)
        {
            if (NetworkConfiguration.ConfigsContainsDevice(nic))
            {
                RemoveIPConfig(nic);
                SetConfigIP(nic, config);
            }
            else
            {
                SetConfigIP(nic, config);
            }

            NetworkConfiguration.SetCurrentConfig(nic, config);
        }