Exemplo n.º 1
0
        public void パケット解釈_str1()
        {
            //exercise
            var sut = new PacketDns(TestUtil.HexStream2Bytes(Str1));

            //verify
            Assert.That(sut.GetId(), Is.EqualTo((short)0x0002));
            Assert.That(sut.GetCount(RrKind.QD), Is.EqualTo(1));
            Assert.That(sut.GetCount(RrKind.AN), Is.EqualTo(5));
            Assert.That(sut.GetCount(RrKind.NS), Is.EqualTo(4));
            Assert.That(sut.GetCount(RrKind.AR), Is.EqualTo(7));
            Assert.That(sut.GetRcode(), Is.EqualTo((short)0));
            Assert.That(sut.GetAa(), Is.EqualTo(false));
            Assert.That(sut.GetRd(), Is.EqualTo(true));
            Assert.That(sut.GetDnsType(), Is.EqualTo(DnsType.Mx));
            Assert.That(sut.GetRequestName(), Is.EqualTo("gmail.com."));
            Assert.That(sut.GetRr(RrKind.QD, 0).ToString(), Is.EqualTo((new RrQuery("gmail.com.", DnsType.Mx)).ToString()));
            Assert.That(sut.GetRr(RrKind.AN, 0).ToString(), Is.EqualTo((new RrMx("gmail.com.", 3427, 10, "alt1.gmail-smtp-in.l.google.com.")).ToString()));
            Assert.That(sut.GetRr(RrKind.AN, 1).ToString(), Is.EqualTo((new RrMx("gmail.com.", 3427, 20, "alt2.gmail-smtp-in.l.google.com.")).ToString()));
            Assert.That(sut.GetRr(RrKind.AN, 2).ToString(), Is.EqualTo((new RrMx("gmail.com.", 3427, 30, "alt3.gmail-smtp-in.l.google.com.")).ToString()));
            Assert.That(sut.GetRr(RrKind.AN, 3).ToString(), Is.EqualTo((new RrMx("gmail.com.", 3427, 40, "alt4.gmail-smtp-in.l.google.com.")).ToString()));
            Assert.That(sut.GetRr(RrKind.AN, 4).ToString(), Is.EqualTo((new RrMx("gmail.com.", 3427, 5, "gmail-smtp-in.l.google.com.")).ToString()));
            Assert.That(sut.GetRr(RrKind.NS, 0).ToString(), Is.EqualTo((new RrNs("gmail.com.", 54413, "ns4.google.com.")).ToString()));
            Assert.That(sut.GetRr(RrKind.NS, 1).ToString(), Is.EqualTo((new RrNs("gmail.com.", 54413, "ns2.google.com.")).ToString()));
            Assert.That(sut.GetRr(RrKind.NS, 2).ToString(), Is.EqualTo((new RrNs("gmail.com.", 54413, "ns1.google.com.")).ToString()));
            Assert.That(sut.GetRr(RrKind.NS, 3).ToString(), Is.EqualTo((new RrNs("gmail.com.", 54413, "ns3.google.com.")).ToString()));
            Assert.That(sut.GetRr(RrKind.AR, 0).ToString(), Is.EqualTo((new RrA("gmail-smtp-in.l.google.com.", 295, new Ip("74.125.25.27"))).ToString()));
            Assert.That(sut.GetRr(RrKind.AR, 1).ToString(), Is.EqualTo((new RrA("alt2.gmail-smtp-in.l.google.com.", 60, new Ip("74.125.140.27"))).ToString()));
            Assert.That(sut.GetRr(RrKind.AR, 2).ToString(), Is.EqualTo((new RrA("alt4.gmail-smtp-in.l.google.com.", 149, new Ip("74.125.131.27"))).ToString()));
            Assert.That(sut.GetRr(RrKind.AR, 3).ToString(), Is.EqualTo((new RrA("ns1.google.com.", 54584, new Ip("216.239.32.10"))).ToString()));
            Assert.That(sut.GetRr(RrKind.AR, 4).ToString(), Is.EqualTo((new RrA("ns2.google.com.", 54578, new Ip("216.239.34.10"))).ToString()));
            Assert.That(sut.GetRr(RrKind.AR, 5).ToString(), Is.EqualTo((new RrA("ns3.google.com.", 54641, new Ip("216.239.36.10"))).ToString()));
            Assert.That(sut.GetRr(RrKind.AR, 6).ToString(), Is.EqualTo((new RrA("ns4.google.com.", 54520, new Ip("216.239.38.10"))).ToString()));
        }
Exemplo n.º 2
0
        public void パケット解釈_str0()
        {
            //exercise
            var sut = new PacketDns(TestUtil.HexStream2Bytes(Str0));

            //verify
            Assert.That(sut.GetId(), Is.EqualTo((short)0x0003));
            Assert.That(sut.GetCount(RrKind.QD), Is.EqualTo(1));
            Assert.That(sut.GetCount(RrKind.AN), Is.EqualTo(0));
            Assert.That(sut.GetCount(RrKind.NS), Is.EqualTo(4));
            Assert.That(sut.GetCount(RrKind.AR), Is.EqualTo(4));
            Assert.That(sut.GetRcode(), Is.EqualTo((short)0));
            Assert.That(sut.GetAa(), Is.EqualTo(false));
            Assert.That(sut.GetRd(), Is.EqualTo(true));
            Assert.That(sut.GetDnsType(), Is.EqualTo(DnsType.Aaaa));
            Assert.That(sut.GetRequestName(), Is.EqualTo("www.google.com."));
            Assert.That(sut.GetRr(RrKind.QD, 0).ToString(), Is.EqualTo((new RrQuery("www.google.com.", DnsType.Aaaa)).ToString()));
            Assert.That(sut.GetRr(RrKind.NS, 0).ToString(), Is.EqualTo((new RrNs("google.com.", 83400, "ns4.google.com.")).ToString()));
            Assert.That(sut.GetRr(RrKind.NS, 1).ToString(), Is.EqualTo((new RrNs("google.com.", 83400, "ns2.google.com.")).ToString()));
            Assert.That(sut.GetRr(RrKind.NS, 2).ToString(), Is.EqualTo((new RrNs("google.com.", 83400, "ns3.google.com.")).ToString()));
            Assert.That(sut.GetRr(RrKind.NS, 3).ToString(), Is.EqualTo((new RrNs("google.com.", 83400, "ns1.google.com.")).ToString()));
            Assert.That(sut.GetRr(RrKind.AR, 0).ToString(), Is.EqualTo((new RrA("ns1.google.com.", 83465, new Ip("216.239.32.10"))).ToString()));
            Assert.That(sut.GetRr(RrKind.AR, 1).ToString(), Is.EqualTo((new RrA("ns2.google.com.", 83563, new Ip("216.239.34.10"))).ToString()));
            Assert.That(sut.GetRr(RrKind.AR, 2).ToString(), Is.EqualTo((new RrA("ns3.google.com.", 83465, new Ip("216.239.36.10"))).ToString()));
            Assert.That(sut.GetRr(RrKind.AR, 3).ToString(), Is.EqualTo((new RrA("ns4.google.com.", 83465, new Ip("216.239.38.10"))).ToString()));
        }
Exemplo n.º 3
0
        public void パケット解釈_str2()
        {
            //exercise
            var sut = new PacketDns(TestUtil.HexStream2Bytes(Str2));

            //verify
            Assert.That(sut.GetId(), Is.EqualTo((short)0x0004));
            Assert.That(sut.GetCount(RrKind.QD), Is.EqualTo(1));
            Assert.That(sut.GetCount(RrKind.AN), Is.EqualTo(1));
            Assert.That(sut.GetCount(RrKind.NS), Is.EqualTo(2));
            Assert.That(sut.GetCount(RrKind.AR), Is.EqualTo(2));
            Assert.That(sut.GetRcode(), Is.EqualTo((short)0));
            Assert.That(sut.GetAa(), Is.EqualTo(false));
            Assert.That(sut.GetRd(), Is.EqualTo(true));
            Assert.That(sut.GetDnsType(), Is.EqualTo(DnsType.Soa));
            Assert.That(sut.GetRequestName(), Is.EqualTo("nifty.com."));
            Assert.That(sut.GetRr(RrKind.QD, 0).ToString(), Is.EqualTo((new RrQuery("nifty.com.", DnsType.Soa)).ToString()));
            Assert.That(sut.GetRr(RrKind.AN, 0).ToString(), Is.EqualTo((new RrSoa("nifty.com.", 0x616, "ons0.nifty.ad.jp", "hostmaster.nifty.ad.jp", 0x0bfe4128, 0xe10, 0x384, 0x36ee80, 0x384)).ToString()));
            Assert.That(sut.GetRr(RrKind.NS, 0).ToString(), Is.EqualTo((new RrNs("nifty.com.", 0x6d2, "ons0.nifty.ad.jp.")).ToString()));
            Assert.That(sut.GetRr(RrKind.NS, 1).ToString(), Is.EqualTo((new RrNs("nifty.com.", 0x6d2, "ons1.nifty.ad.jp.")).ToString()));
            Assert.That(sut.GetRr(RrKind.AR, 0).ToString(), Is.EqualTo((new RrA("ons0.nifty.ad.jp.", 0x712, new Ip("202.248.37.77"))).ToString()));
            Assert.That(sut.GetRr(RrKind.AR, 1).ToString(), Is.EqualTo((new RrA("ons1.nifty.ad.jp.", 0x6da, new Ip("202.248.20.156"))).ToString()));
        }