예제 #1
0
 /**
  * Instantiates a new dhcp vendor info option.
  *
  * @param vendorInfoOption the vendor info option
  */
 public DhcpV6VendorInfoOption(v6VendorInfoOption vendorInfoOption) : base()
 {
     if (vendorInfoOption != null)
     {
         enterpriseNumber = vendorInfoOption.enterpriseNumber;
         List <optionDefType> optdefs = vendorInfoOption.suboptionList;
         if (optdefs != null)
         {
             foreach (optionDefType optdef in optdefs)
             {
                 DhcpOption subopt = GenericOptionFactory.GetDhcpOption(optdef);
                 AddSuboption(subopt);
             }
         }
     }
     SetCode(DhcpConstants.V6OPTION_VENDOR_OPTS);
 }
예제 #2
0
        public Dictionary <int, DhcpOption> InitDhcpOptionMap()
        {
            this.optionMap.Clear();

            v6BcmcsAddressesOption bcmcsAddressesOption = this.configOptions.v6BcmcsAddressesOption;

            if (bcmcsAddressesOption != null && bcmcsAddressesOption.ipAddress.Count > 0)
            {
                this.optionMap[bcmcsAddressesOption.code] = new DhcpV6BcmcsAddressesOption(bcmcsAddressesOption);
            }

            v6BcmcsDomainNamesOption bcmcsDomainNamesOption = this.configOptions.v6BcmcsDomainNamesOption;

            if (bcmcsDomainNamesOption != null && bcmcsDomainNamesOption.domainName.Count > 0)
            {
                this.optionMap[bcmcsDomainNamesOption.code] = new DhcpV6BcmcsDomainNamesOption(bcmcsDomainNamesOption);
            }

            v6DnsServersOption dnsServersOption = this.configOptions.v6DnsServersOption;

            if (dnsServersOption != null && dnsServersOption.ipAddress.Count > 0)
            {
                this.optionMap[dnsServersOption.code] = new DhcpV6DnsServersOption(dnsServersOption);
            }

            v6DomainSearchListOption domainSearchListOption = this.configOptions.v6DomainSearchListOption;

            if (domainSearchListOption != null && domainSearchListOption.domainName.Count > 0)
            {
                this.optionMap[domainSearchListOption.code] = new DhcpV6DomainSearchListOption(domainSearchListOption);
            }

            v6GeoconfCivicOption geoconfCivicOption = this.configOptions.v6GeoconfCivicOption;

            if (geoconfCivicOption != null && geoconfCivicOption.civicAddressElement.Count > 0)
            {
                this.optionMap[geoconfCivicOption.code] = new DhcpV6GeoconfCivicOption(geoconfCivicOption);
            }

            v6InfoRefreshTimeOption infoRefreshTimeOption = this.configOptions.v6InfoRefreshTimeOption;

            if (infoRefreshTimeOption != null && infoRefreshTimeOption.unsignedInt > 0)
            {
                this.optionMap[infoRefreshTimeOption.code] = new DhcpV6InfoRefreshTimeOption(infoRefreshTimeOption);
            }

            v6LostServerDomainNameOption lostServerDomainNameOption = this.configOptions.v6LostServerDomainNameOption;

            if (lostServerDomainNameOption != null && !String.IsNullOrEmpty(lostServerDomainNameOption.domainName))
            {
                this.optionMap[lostServerDomainNameOption.code] = new DhcpV6LostServerDomainNameOption(lostServerDomainNameOption);
            }

            v6NewPosixTimezoneOption newPosixTimezoneOption = this.configOptions.v6NewPosixTimezoneOption;

            if (newPosixTimezoneOption != null && !String.IsNullOrEmpty(newPosixTimezoneOption.@string))
            {
                this.optionMap[newPosixTimezoneOption.code] = new DhcpV6NewPosixTimezoneOption();
            }

            v6NewTzdbTimezoneOption newTzdbTimezoneOption = this.configOptions.v6NewTzdbTimezoneOption;

            if (newTzdbTimezoneOption != null && !String.IsNullOrEmpty(newTzdbTimezoneOption.@string))
            {
                this.optionMap[newTzdbTimezoneOption.code] = new DhcpV6NewTzdbTimezoneOption();
            }

            v6NisDomainNameOption nisDomainNameOption = this.configOptions.v6NisDomainNameOption;

            if (nisDomainNameOption != null && !String.IsNullOrEmpty(nisDomainNameOption.domainName))
            {
                this.optionMap[nisDomainNameOption.code] = new DhcpV6NisDomainNameOption(nisDomainNameOption);
            }

            v6NisPlusDomainNameOption nisPlusDomainNameOption = this.configOptions.v6NisPlusDomainNameOption;

            if (nisPlusDomainNameOption != null && !String.IsNullOrEmpty(nisPlusDomainNameOption.domainName))
            {
                this.optionMap[nisPlusDomainNameOption.code] = new DhcpV6NisPlusDomainNameOption(nisPlusDomainNameOption);
            }

            v6NisPlusServersOption nisPlusServersOption = this.configOptions.v6NisPlusServersOption;

            if (nisPlusServersOption != null && nisPlusServersOption.ipAddress.Count > 0)
            {
                this.optionMap[nisPlusServersOption.code] = new DhcpV6NisPlusServersOption(nisPlusServersOption);
            }

            v6NisServersOption nisServersOption = this.configOptions.v6NisServersOption;

            if (nisServersOption != null && nisServersOption.ipAddress.Count > 0)
            {
                this.optionMap[nisServersOption.code] = new DhcpV6NisServersOption(nisServersOption);
            }

            v6PanaAgentAddressesOption panaAgentAddressesOption = this.configOptions.v6PanaAgentAddressesOption;

            if (panaAgentAddressesOption != null && panaAgentAddressesOption.ipAddress.Count > 0)
            {
                this.optionMap[panaAgentAddressesOption.code] = new DhcpV6PanaAgentAddressesOption(panaAgentAddressesOption);
            }

            v6PreferenceOption preferenceOption = this.configOptions.v6PreferenceOption;

            if (preferenceOption != null && preferenceOption.unsignedByte != 0)
            {
                this.optionMap[preferenceOption.code] = new DhcpV6PreferenceOption(preferenceOption);
            }

            v6ServerUnicastOption serverUnicastOption = this.configOptions.v6ServerUnicastOption;

            if (serverUnicastOption != null && !String.IsNullOrEmpty(serverUnicastOption.ipAddress))
            {
                this.optionMap[serverUnicastOption.code] = new DhcpV6ServerUnicastOption(serverUnicastOption);
            }

            v6SipServerAddressesOption sipServerAddressesOption = this.configOptions.v6SipServerAddressesOption;

            if (sipServerAddressesOption != null && sipServerAddressesOption.ipAddress.Count > 0)
            {
                this.optionMap[sipServerAddressesOption.code] = new DhcpV6SipServerAddressesOption(sipServerAddressesOption);
            }

            v6SipServerDomainNamesOption sipServerDomainNamesOption = this.configOptions.v6SipServerDomainNamesOption;

            if (sipServerDomainNamesOption != null && sipServerDomainNamesOption.domainName.Count > 0)
            {
                this.optionMap[sipServerDomainNamesOption.code] = new DhcpV6SipServerDomainNamesOption(sipServerDomainNamesOption);
            }

            v6SntpServersOption sntpServersOption = this.configOptions.v6SntpServersOption;

            if (sntpServersOption != null && sntpServersOption.ipAddress.Count > 0)
            {
                this.optionMap[sntpServersOption.code] = new DhcpV6SntpServersOption(sntpServersOption);
            }

            v6StatusCodeOption statusCodeOption = this.configOptions.v6StatusCodeOption;

            if (statusCodeOption != null && !String.IsNullOrEmpty(statusCodeOption.message))
            {
                this.optionMap[statusCodeOption.code] = new DhcpV6StatusCodeOption(statusCodeOption);
            }


            v6VendorInfoOption vendorInfoOption = this.configOptions.v6VendorInfoOption;

            if (vendorInfoOption != null && vendorInfoOption.suboptionList.Count > 0)
            {
                this.optionMap[vendorInfoOption.code] = new DhcpV6VendorInfoOption(vendorInfoOption);
            }

            if (this.configOptions.v6OtherOptions.Count > 0)
            {
                optionMap.PutAll(GenericOptionFactory.GenericOptions(configOptions.v6OtherOptions));
            }
            return(this.optionMap);
        }
        /**
         * Inits the dhcp option map.
         *
         * @return the map< integer, dhcp option>
         */
        public Dictionary <int, DhcpOption> InitDhcpV4OptionMap()
        {
            optionMap.Clear();

            if (configOptions.v4DomainNameOption != null && !string.IsNullOrEmpty(configOptions.v4DomainNameOption.@string))
            {
                v4DomainNameOption domainNameOption = configOptions.v4DomainNameOption;
                if (domainNameOption != null)
                {
                    optionMap[(int)domainNameOption.code] = new DhcpV4DomainNameOption(domainNameOption);
                }
            }

            if (configOptions.v4DomainServersOption != null && configOptions.v4DomainServersOption.ipAddress.Count > 0)
            {
                v4DomainServersOption domainServersOption = configOptions.v4DomainServersOption;
                if (domainServersOption != null)
                {
                    optionMap[(int)domainServersOption.code] = new DhcpV4DomainServersOption(domainServersOption);
                }
            }

            if (configOptions.v4RoutersOption != null && configOptions.v4RoutersOption.ipAddress.Count > 0)
            {
                v4RoutersOption routersOption = configOptions.v4RoutersOption;
                if (routersOption != null)
                {
                    optionMap[(int)routersOption.code] = new DhcpV4RoutersOption(routersOption);
                }
            }

            if (configOptions.v4SubnetMaskOption != null && !string.IsNullOrEmpty(configOptions.v4SubnetMaskOption.ipAddress))
            {
                v4SubnetMaskOption subnetMaskOption = configOptions.v4SubnetMaskOption;
                if (subnetMaskOption != null)
                {
                    optionMap[(int)subnetMaskOption.code] = new DhcpV4SubnetMaskOption(subnetMaskOption);
                }
            }

            if (configOptions.v4TimeOffsetOption != null && configOptions.v4TimeOffsetOption.unsignedInt > 0)
            {
                v4TimeOffsetOption timeOffsetOption = configOptions.v4TimeOffsetOption;
                if (timeOffsetOption != null)
                {
                    optionMap[(int)timeOffsetOption.code] = new DhcpV4TimeOffsetOption(timeOffsetOption);
                }
            }

            if (configOptions.v4TimeServersOption != null && configOptions.v4TimeServersOption.ipAddress.Count > 0)
            {
                v4TimeServersOption timeServersOption = configOptions.v4TimeServersOption;
                if (timeServersOption != null)
                {
                    optionMap[(int)timeServersOption.code] = new DhcpV4TimeServersOption(timeServersOption);
                }
            }

            if (configOptions.v4VendorSpecificOption != null && configOptions.v4VendorSpecificOption.opaqueData != null &&
                configOptions.v4VendorSpecificOption.opaqueData.asciiValue != null && configOptions.v4VendorSpecificOption.opaqueData.hexValue != null)
            {
                v4VendorSpecificOption vendorSpecificOption = configOptions.v4VendorSpecificOption;
                if (vendorSpecificOption != null)
                {
                    optionMap[(int)vendorSpecificOption.code] = new DhcpV4VendorSpecificOption(vendorSpecificOption);
                }
            }

            if (configOptions.v4NetbiosNameServersOption != null && configOptions.v4NetbiosNameServersOption.ipAddress.Count > 0)
            {
                v4NetbiosNameServersOption netbiosNameServersOption =
                    configOptions.v4NetbiosNameServersOption;
                if (netbiosNameServersOption != null)
                {
                    optionMap[(int)netbiosNameServersOption.code] = new DhcpV4NetbiosNameServersOption(netbiosNameServersOption);
                }
            }

            if (configOptions.v4NetbiosNodeTypeOption != null && configOptions.v4NetbiosNodeTypeOption.unsignedByte > 0)
            {
                v4NetbiosNodeTypeOption netbiosNodeTypeOption =
                    configOptions.v4NetbiosNodeTypeOption;
                if (netbiosNodeTypeOption != null)
                {
                    optionMap[(int)netbiosNodeTypeOption.code] =
                        new DhcpV4NetbiosNodeTypeOption(netbiosNodeTypeOption);
                }
            }

            if (configOptions.v4TftpServerNameOption != null && !string.IsNullOrEmpty(configOptions.v4TftpServerNameOption.@string))
            {
                v4TftpServerNameOption tftpServerNameOption = configOptions.v4TftpServerNameOption;
                if (tftpServerNameOption != null)
                {
                    optionMap[(int)tftpServerNameOption.code] =
                        new DhcpV4TftpServerNameOption(tftpServerNameOption);
                }
            }

            if (configOptions.v4BootFileNameOption != null && !string.IsNullOrEmpty(configOptions.v4BootFileNameOption.@string))
            {
                v4BootFileNameOption bootFileNameOption = configOptions.v4BootFileNameOption;
                if (bootFileNameOption != null)
                {
                    optionMap[(int)bootFileNameOption.code] =
                        new DhcpV4BootFileNameOption(bootFileNameOption);
                }
            }

            if (configOptions.otherOptions != null && configOptions.otherOptions.Count > 0)
            {
                optionMap.PutAll(GenericOptionFactory.GenericOptions(configOptions.otherOptions));
            }

            return(optionMap);
        }