Exemple #1
0
        protected DhcpOption(DhcpOptionCode code, Stream s)
        {
            _code = code;

            int len = s.ReadByte();

            if (len < 0)
            {
                throw new EndOfStreamException();
            }

            _value = s.ReadBytes(len);
        }
Exemple #2
0
 public void AddOption(DhcpOptionCode opCode, byte[] data)
 {
     _bytes.Add((byte)opCode);
     _bytes.Add((byte)data.Length);
     _bytes.AddRange(data);
 }
Exemple #3
0
 public void AddOption(DhcpOptionCode opCode, byte data)
 {
     AddOption(opCode, new[] { data });
 }
Exemple #4
0
 public void AddOption(DhcpOptionCode opCode, IPAddress data)
 {
     AddOption(opCode, data.GetAddressBytes());
 }
Exemple #5
0
 public void AddOption(DhcpOptionCode opCode, DhcpMessageType messageType)
 {
     AddOption(opCode, (byte)messageType);
 }
Exemple #6
0
        public void AddOption(DhcpOptionCode opCode, int data, bool isReversed)
        {
            var bytes = BitConverter.GetBytes(data);

            AddOption(opCode, isReversed ? bytes.ReverseArray() : bytes);
        }
 public DhcpOption(DhcpOptionCode code, byte[] value)
 {
     this.Code = code;
     this.Value = value;
 }
Exemple #8
0
        public static DhcpOption Parse(Stream s)
        {
            int code = s.ReadByte();

            if (code < 0)
            {
                throw new EndOfStreamException();
            }

            DhcpOptionCode optionCode = (DhcpOptionCode)code;

            switch (optionCode)
            {
            case DhcpOptionCode.SubnetMask:
                return(new SubnetMaskOption(s));

            case DhcpOptionCode.Router:
                return(new RouterOption(s));

            case DhcpOptionCode.DomainNameServer:
                return(new DomainNameServerOption(s));

            case DhcpOptionCode.HostName:
                return(new HostNameOption(s));

            case DhcpOptionCode.DomainName:
                return(new DomainNameOption(s));

            case DhcpOptionCode.BroadcastAddress:
                return(new BroadcastAddressOption(s));

            case DhcpOptionCode.VendorSpecificInformation:
                return(new VendorSpecificInformationOption(s));

            case DhcpOptionCode.NetBiosOverTcpIpNameServer:
                return(new NetBiosNameServerOption(s));

            case DhcpOptionCode.RequestedIpAddress:
                return(new RequestedIpAddressOption(s));

            case DhcpOptionCode.IpAddressLeaseTime:
                return(new IpAddressLeaseTimeOption(s));

            case DhcpOptionCode.OptionOverload:
                return(new OptionOverloadOption(s));

            case DhcpOptionCode.DhcpMessageType:
                return(new DhcpMessageTypeOption(s));

            case DhcpOptionCode.ServerIdentifier:
                return(new ServerIdentifierOption(s));

            case DhcpOptionCode.ParameterRequestList:
                return(new ParameterRequestListOption(s));

            case DhcpOptionCode.MaximumDhcpMessageSize:
                return(new MaximumDhcpMessageSizeOption(s));

            case DhcpOptionCode.RenewalTimeValue:
                return(new RenewalTimeValueOption(s));

            case DhcpOptionCode.RebindingTimeValue:
                return(new RebindingTimeValueOption(s));

            case DhcpOptionCode.VendorClassIdentifier:
                return(new VendorClassIdentifierOption(s));

            case DhcpOptionCode.ClientIdentifier:
                return(new ClientIdentifierOption(s));

            case DhcpOptionCode.ClientFullyQualifiedDomainName:
                return(new ClientFullyQualifiedDomainNameOption(s));

            case DhcpOptionCode.ClasslessStaticRoute:
                return(new ClasslessStaticRouteOption(s));

            case DhcpOptionCode.Pad:
            case DhcpOptionCode.End:
                return(new DhcpOption(optionCode));

            default:
                //unknown option
                return(new DhcpOption(optionCode, s));
            }
        }
Exemple #9
0
 protected DhcpOption(DhcpOptionCode code)
 {
     _code = code;
 }