Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the Interface class using the specified
        /// parameters.
        /// </summary>
        /// <param name="nic">The network interface card (NIC) this interface
        /// represents.</param>
        /// <param name="name">A unique name (such as eth0) for identifing the
        /// interface.</param>
        /// <param name="cidrIpAddress">The IPv4 address to associate with this
        /// interface in CIDR notation.</param>
        /// <param name="gateway">The IPv4 address of the default gateway to
        /// configure this interface with.</param>
        /// <exception cref="ArgumentNullException">Thrown if any of the arguments
        /// is null.</exception>
        public Interface(Nic nic, string name, string cidrIpAddress,
                         string gateway = null)
        {
            var t = IpAddress.ParseCIDRNotation(cidrIpAddress);

            Init(nic, name, t.Item1, t.Item2, gateway != null ?
                 new IpAddress(gateway) : null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the Route class.
        /// </summary>
        /// <param name="cidrNetworkId">The network id of the destination network in
        /// CIDR notation.</param>
        /// <param name="gateway">The gateway through which the destination network
        /// can be reached.</param>
        /// <param name="interface">The local interface through which the gateway
        /// can be reached.</param>
        /// <param name="metric">The metric of using the route.</param>
        public Route(string cidrNetworkId, string gateway,
                     Interface @interface, int metric)
        {
            var tuple = IpAddress.ParseCIDRNotation(cidrNetworkId);

            Init(tuple.Item1, tuple.Item2, gateway != null ? new IpAddress(gateway)
                                        : null, @interface, metric);
        }