Пример #1
0
        // 10.1.100.1/24
        public Subnet(CidrBlock address, byte mask)
        {
            (Address, Mask) = (address, mask);
            var maskBytes = CidrBlock.GetMaskBytes(Mask);

            MaskCidr = new CidrBlock(maskBytes[0], maskBytes[1], maskBytes[2], maskBytes[3]);
            var networkBeginAddress = GetNetworkBeginAddress(Address.AddressBytes, MaskCidr.AddressBytes);

            NetworkBeginAddress = new CidrBlock(networkBeginAddress[0], networkBeginAddress[1], networkBeginAddress[2], networkBeginAddress[3]);
            var networkEndAddress = GetNetworkEndAddress(Address.AddressBytes, MaskCidr.AddressBytes);

            NetworkEndAddress = new CidrBlock(networkEndAddress[0], networkEndAddress[1], networkEndAddress[2], networkEndAddress[3]);
        }
Пример #2
0
        // 10.1.100.1/255.255.255.0
        public Subnet(CidrBlock address, CidrBlock mask)
        {
            var maskByte = CidrBlock.FromMaskBytes(mask.AddressBytes);

            (Address, Mask) = (address, maskByte);
            MaskCidr        = mask;
            var networkBeginAddress = GetNetworkBeginAddress(Address.AddressBytes, MaskCidr.AddressBytes);

            NetworkBeginAddress = new CidrBlock(networkBeginAddress[0], networkBeginAddress[1], networkBeginAddress[2], networkBeginAddress[3]);
            var networkEndAddress = GetNetworkEndAddress(Address.AddressBytes, MaskCidr.AddressBytes);

            NetworkEndAddress = new CidrBlock(networkEndAddress[0], networkEndAddress[1], networkEndAddress[2], networkEndAddress[3]);
        }
Пример #3
0
        // 10.1.100.1/24
        // 10.1.100.1/255.255.255.0
        public Subnet(string subnetWithMask)
        {
            var split   = subnetWithMask.Split("/");
            var address = new CidrBlock(split[0]);
            var mask    = new CidrBlock(split[1]);

            var maskByte = CidrBlock.FromMaskBytes(mask.AddressBytes);

            (Address, Mask) = (address, maskByte);
            MaskCidr        = mask;
            var networkBeginAddress = GetNetworkBeginAddress(Address.AddressBytes, MaskCidr.AddressBytes);

            NetworkBeginAddress = new CidrBlock(networkBeginAddress[0], networkBeginAddress[1], networkBeginAddress[2], networkBeginAddress[3]);
            var networkEndAddress = GetNetworkEndAddress(Address.AddressBytes, MaskCidr.AddressBytes);

            NetworkEndAddress = new CidrBlock(networkEndAddress[0], networkEndAddress[1], networkEndAddress[2], networkEndAddress[3]);
        }
Пример #4
0
 public CidrBlock Add(CidrBlock add)
 {
     return(new CidrBlock((byte)(this.VpcCidr1 + add.VpcCidr1), (byte)(this.VpcCidr2 + add.VpcCidr2), (byte)(this.VpcCidr3 + add.VpcCidr3), (byte)(this.VpcCidr4 + add.VpcCidr4)));
 }