示例#1
0
 static DHCPMessage()
 {
     optionsTemplates = new IDHCPOption[256];
     for (int t = 1; t < 255; t++)
     {
         optionsTemplates[t] = new DHCPOptionGeneric((DHCPOption)t);
     }
     optionsTemplates[0]   = new DHCPOptionFixedLength(DHCPOption.Pad);
     optionsTemplates[255] = new DHCPOptionFixedLength(DHCPOption.End);
     optionsTemplates[(int)DHCPOption.HostName]                 = new DHCPOptionHostName();
     optionsTemplates[(int)DHCPOption.IPAddressLeaseTime]       = new DHCPOptionIPAddressLeaseTime();
     optionsTemplates[(int)DHCPOption.ServerIdentifier]         = new DHCPOptionServerIdentifier();
     optionsTemplates[(int)DHCPOption.RequestedIPAddress]       = new DHCPOptionRequestedIPAddress();
     optionsTemplates[(int)DHCPOption.OptionOverload]           = new DHCPOptionOptionOverload();
     optionsTemplates[(int)DHCPOption.TFTPServerName]           = new DHCPOptionTFTPServerName();
     optionsTemplates[(int)DHCPOption.BootFileName]             = new DHCPOptionBootFileName();
     optionsTemplates[(int)DHCPOption.MessageType]              = new DHCPOptionMessageType();
     optionsTemplates[(int)DHCPOption.Message]                  = new DHCPOptionMessage();
     optionsTemplates[(int)DHCPOption.MaximumDHCPMessageSize]   = new DHCPOptionMaximumDHCPMessageSize();
     optionsTemplates[(int)DHCPOption.ParameterRequestList]     = new DHCPOptionParameterRequestList();
     optionsTemplates[(int)DHCPOption.RenewalTimeValue]         = new DHCPOptionRenewalTimeValue();
     optionsTemplates[(int)DHCPOption.RebindingTimeValue]       = new DHCPOptionRebindingTimeValue();
     optionsTemplates[(int)DHCPOption.VendorClassIdentifier]    = new DHCPOptionVendorClassIdentifier();
     optionsTemplates[(int)DHCPOption.ClientIdentifier]         = new DHCPOptionClientIdentifier();
     optionsTemplates[(int)DHCPOption.FullyQualifiedDomainName] = new DHCPOptionFullyQualifiedDomainName();
     optionsTemplates[(int)DHCPOption.SubnetMask]               = new DHCPOptionSubnetMask();
 }
示例#2
0
        public override IDHCPOption FromStream(Stream s)
        {
            var result = new DHCPOptionGeneric(this.m_OptionType)
            {
                Data = new byte[s.Length]
            };

            s.Read(result.Data, 0, result.Data.Length);
            return(result);
        }