コード例 #1
0
ファイル: MiscParsingTests.cs プロジェクト: jnm2/corefx
        public static void RawHexIntParsing()
        {
            int val = StringParsingHelpers.ParseRawHexFileAsInt(FileUtil.TestFile("rawhexint"));

            Assert.Equal(10, val);
        }
コード例 #2
0
        public void ActiveTcpConnectionsParsing()
        {
            string tcpFile  = GetTestFilePath();
            string tcp6File = GetTestFilePath();

            if (BitConverter.IsLittleEndian)
            {
                FileUtil.NormalizeLineEndings("NetworkFiles/tcp", tcpFile);
                FileUtil.NormalizeLineEndings("NetworkFiles/tcp6", tcp6File);
            }
            else
            {
                FileUtil.NormalizeLineEndings("NetworkFiles/tcp-be", tcpFile);
                FileUtil.NormalizeLineEndings("NetworkFiles/tcp6-be", tcp6File);
            }

            TcpConnectionInformation[] infos = StringParsingHelpers.ParseActiveTcpConnectionsFromFiles(tcpFile, tcp6File);
            Assert.Equal(11, infos.Length);

            ValidateInfo(
                infos[0],
                new IPEndPoint(IPAddress.Parse("1.255.255.255"), 0x01BD),
                new IPEndPoint(0L, 0),
                TcpState.Established);

            ValidateInfo(
                infos[1],
                new IPEndPoint(IPAddress.Parse("120.86.52.18"), 0x008B),
                new IPEndPoint(0L, 0),
                TcpState.SynSent);

            ValidateInfo(
                infos[2],
                new IPEndPoint(IPAddress.Parse("127.0.1.1"), 0x0035),
                new IPEndPoint(0L, 0),
                TcpState.SynReceived);

            ValidateInfo(
                infos[3],
                new IPEndPoint(IPAddress.Parse("127.0.0.1"), 0x0277),
                new IPEndPoint(0L, 0),
                TcpState.FinWait1);

            ValidateInfo(infos[4],
                         new IPEndPoint(IPAddress.Parse("127.0.0.1"), 0x0277),
                         new IPEndPoint(IPAddress.Parse("1.0.0.0"), 0),
                         TcpState.SynReceived);

            ValidateInfo(
                infos[5],
                new IPEndPoint(IPAddress.Parse("::"), 0x01BD),
                new IPEndPoint(IPAddress.Parse("::"), 0x0000),
                TcpState.FinWait2);

            ValidateInfo(
                infos[6],
                new IPEndPoint(IPAddress.Parse("::"), 0x008B),
                new IPEndPoint(IPAddress.Parse("::"), 0x0000),
                TcpState.TimeWait);

            ValidateInfo(
                infos[7],
                new IPEndPoint(IPAddress.Parse("::1"), 0x0277),
                new IPEndPoint(IPAddress.Parse("::"), 0x0000),
                TcpState.Closing);

            ValidateInfo(
                infos[8],
                new IPEndPoint(IPAddress.Parse("::1"), 0xA696),
                new IPEndPoint(IPAddress.Parse("::1"), 0x0277),
                TcpState.CloseWait);

            ValidateInfo(
                infos[9],
                new IPEndPoint(IPAddress.Parse("::1"), 0xA69B),
                new IPEndPoint(IPAddress.Parse("::1"), 0x0277),
                TcpState.LastAck);

            ValidateInfo(
                infos[10],
                new IPEndPoint(IPAddress.Parse("::1"), 124),
                new IPEndPoint(IPAddress.Parse("fe80::215:5dff:fe00:402"), 123),
                TcpState.Established);
        }