Beispiel #1
0
        IEnumerable <byte> EncodePrefixes(IEnumerable <Prefix> prefixes)
        {
            var outStream = new MemoryStream();
            var parser    = new PrefixParser();

            prefixes.ToList().ForEach(prefix => parser.Encode(outStream, prefix));
            var encodedPrefixes = outStream.GetBuffer().Take(Convert.ToInt32(outStream.Position)).ToArray();

            return(EncodeNumber(Convert.ToUInt32(encodedPrefixes.Length), 2).Concat(encodedPrefixes));
        }
Beispiel #2
0
        IEnumerable <Prefix> ParsePrefixes(Stream dataStream, uint withdrawnRoutesLength)
        {
            var prefixes   = new List <Prefix>();
            var parser     = new PrefixParser();
            var stopLength = dataStream.Position + withdrawnRoutesLength;

            while (dataStream.Position < stopLength)
            {
                var prefix = parser.Decode(dataStream);

                prefixes.Add(prefix);
            }

            return(prefixes);
        }