示例#1
0
        internal override sealed Option Read(byte[] buffer, ref int offset, int length)
        {
            int num = offset + length;

            if (offset == num)
            {
                return((Option)null);
            }
            IpV4OptionType optionType = (IpV4OptionType)buffer[offset++];

            switch (optionType)
            {
            case IpV4OptionType.EndOfOptionList:
                return((Option)IpV4Option.End);

            case IpV4OptionType.NoOperation:
                return((Option)IpV4Option.Nop);

            default:
                return(OptionComplexFactory <IpV4OptionType> .Read(optionType, buffer, ref offset, num - offset));
            }
        }
示例#2
0
        internal sealed override V4Option Read(byte[] buffer, ref int offset, int length)
        {
            int offsetEnd = offset + length;

            if (offset == offsetEnd)
            {
                return(null);
            }

            IpV4OptionType optionType = (IpV4OptionType)buffer[offset++];

            switch (optionType)
            {
            case IpV4OptionType.EndOfOptionList:
                return(End);

            case IpV4OptionType.NoOperation:
                return(Nop);

            default:
                return((V4Option)OptionComplexFactory <IpV4OptionType> .Read(optionType, buffer, ref offset, offsetEnd - offset));
            }
        }