Exemplo n.º 1
0
        public void IPv4SubnetMask_FromByteArray(Byte[] input, Boolean parsable)
        {
            if (parsable == false)
            {
                Assert.ThrowsAny <Exception>(() => IPv4SubnetMask.FromByteArray(input));
                return;
            }

            IPv4SubnetMask mask = IPv4SubnetMask.FromByteArray(input);

            Byte[] actual = mask.GetBytes();
            Assert.Equal(input, actual);
        }
Exemplo n.º 2
0
        public static DHCPv4PacketRouteListOption FromByteArray(Byte[] data, Int32 offset)
        {
            if (data == null || data.Length < offset + 10)
            {
                throw new ArgumentException(nameof(data));
            }

            Byte  length      = data[offset + 1];
            Int32 routeAmount = length / 8;

            Int32 index = offset + 2;

            IPv4Route[] routes = new IPv4Route[routeAmount];

            for (int i = 0; i < routeAmount; i++, index += 8)
            {
                IPv4Address    network = IPv4Address.FromByteArray(data, index);
                IPv4SubnetMask mask    = IPv4SubnetMask.FromByteArray(data, index + 4);
                routes[i] = new IPv4Route(network, mask);
            }

            return(new DHCPv4PacketRouteListOption(data[offset], routes));
        }