Ejemplo n.º 1
0
 /// <summary>
 /// True iff the two IPv4 layers have the same TypeOfService, Identification, Fragmentation, Ttl, Protocol, HeaderChecksum, Source, Destination and Options.
 /// </summary>
 public bool Equals(IpV6Layer other)
 {
     return(other != null &&
            TrafficClass == other.TrafficClass && FlowLabel == other.FlowLabel &&
            NextHeader == other.NextHeader && HopLimit == other.HopLimit &&
            Source == other.Source && CurrentDestination == other.CurrentDestination &&
            ExtensionHeaders.SequenceEqual(other.ExtensionHeaders));
 }
Ejemplo n.º 2
0
        protected override bool Execute(ConfigFile config)
        {
            var cppHeaderGenerator = new CppHeaderGenerator(SharpGenLogger, OutputPath);

            var configsWithHeaders    = new HashSet <ConfigFile>(ConfigFile.IdComparer);
            var configsWithExtensions = new HashSet <ConfigFile>(ConfigFile.IdComparer);

            foreach (var cfg in config.ConfigFilesLoaded)
            {
                if (HeaderFiles.Any(item => item.GetMetadata("ConfigId") == cfg.Id))
                {
                    configsWithHeaders.Add(cfg);
                }

                if (ExtensionHeaders.Any(item => item.GetMetadata("ConfigId") == cfg.Id))
                {
                    configsWithExtensions.Add(cfg);
                }
            }

            var cppHeaderGenerationResult = cppHeaderGenerator.GenerateCppHeaders(config, configsWithHeaders, configsWithExtensions);

            var consumerConfig = new ConfigFile
            {
                Id            = "CppConsumerConfig",
                IncludeProlog = { cppHeaderGenerationResult.Prologue }
            };

            consumerConfig.Write(CppConsumerConfigCache.ItemSpec);

            var updatedConfigFiles = new List <ITaskItem>();

            foreach (var cfg in configsWithHeaders)
            {
                if (cppHeaderGenerationResult.UpdatedConfigs.Contains(cfg) && cfg.AbsoluteFilePath != null)
                {
                    var item = new TaskItem(cfg.AbsoluteFilePath);
                    item.SetMetadata("Id", cfg.Id);
                    updatedConfigFiles.Add(item);
                }
            }

            UpdatedConfigs = updatedConfigFiles.ToArray();

            return(!SharpGenLogger.HasErrors);
        }
Ejemplo n.º 3
0
        protected override bool Execute(ConfigFile config)
        {
            var updatedConfigs        = new HashSet <ConfigFile>(ConfigFile.IdComparer);
            var configsWithExtensions = new HashSet <ConfigFile>(ConfigFile.IdComparer);

            foreach (var cfg in config.ConfigFilesLoaded)
            {
                if (UpdatedConfigs.Any(updated => updated.GetMetadata("Id") == cfg.Id))
                {
                    updatedConfigs.Add(cfg);
                }

                if (ExtensionHeaders.Any(updated => updated.GetMetadata("ConfigId") == cfg.Id))
                {
                    configsWithExtensions.Add(cfg);
                }
            }

            var resolver = new IncludeDirectoryResolver(SharpGenLogger);

            resolver.Configure(config);

            var castXml = new CastXmlRunner(SharpGenLogger, resolver, CastXmlExecutablePath, CastXmlArguments)
            {
                OutputPath = OutputPath
            };

            var macroManager = new MacroManager(castXml);

            var cppExtensionGenerator = new CppExtensionHeaderGenerator(macroManager);

            var module = cppExtensionGenerator.GenerateExtensionHeaders(config, OutputPath, configsWithExtensions, updatedConfigs);

            ReferencedHeaders = macroManager.IncludedFiles.Select(file => new TaskItem(file)).ToArray <ITaskItem>();

            if (SharpGenLogger.HasErrors)
            {
                return(false);
            }

            module.Write(PartialCppModuleCache.ItemSpec);

            return(!SharpGenLogger.HasErrors);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Returns a hash code for the layer.
 /// The hash code is a XOR of the TrafficClass and HopLimit combined and the hash codes of the FlowLabel, Source, CurrentDestination, NextHeader, HeaderChecksum, ExtensionHeaders.
 /// </summary>
 public override int GetHashCode()
 {
     return(base.GetHashCode() ^
            Sequence.GetHashCode(BitSequence.Merge(TrafficClass, HopLimit),
                                 FlowLabel, Source, CurrentDestination, NextHeader) ^ ExtensionHeaders.GetHashCode());
 }