Exemplo n.º 1
0
        private static void AnnounceService(Socket sock, String service)
        {
            IPEndPoint   remoteEp = new IPEndPoint(IPAddress.Parse(mdnsIP), mdnsPort);
            mDNSPacket   dnsPkt   = new mDNSPacket();
            mDNSHeader   mdnsHdr  = new mDNSHeader();
            mDNSAnswerRR mdnsAnRR = new mDNSAnswerRR(service, Type.AAAA, (Class.IN | Class.CF), 4500, 16);

            Byte[] rdata = new Byte[16];

            mdnsAnRR.RDATA = rdata;

            mdnsHdr.AA      = true;
            mdnsHdr.TC      = false;
            mdnsHdr.RD      = false;
            mdnsHdr.RA      = false;
            mdnsHdr.RCODE   = RespCode.NoError;
            mdnsHdr.OPCODE  = OpCode.QUERY;
            mdnsHdr.QR      = true;
            mdnsHdr.qdcount = 0;
            mdnsHdr.an_rrs  = 1;
            mdnsHdr.ns_rrs  = 0;
            mdnsHdr.ar_rrs  = 0;

            dnsPkt.Header   = mdnsHdr;
            dnsPkt.AnswerRR = mdnsAnRR;

            dnsPkt.print();

            Console.WriteLine("Announcing Service: " + service);
            sock.SendTo(dnsPkt.data, remoteEp);
        }
Exemplo n.º 2
0
        static void PrintTestPacket()
        {
            mDNSPacket       dnsPkt   = new mDNSPacket();
            mDNSHeader       mdnsHdr  = new mDNSHeader();
            mDNSAnswerRR     mdnsAnRR = new mDNSAnswerRR("_services._dns-sd._udp.local.", Type.TXT, Class.IN, 4500, 16);
            mDNSAdditionalRR mdnsArRR = new mDNSAdditionalRR("_services._dns-sd._udp.local.", Type.TXT, Class.IN, 4500, 16);

            Byte[] rdata = new Byte[16];

            mdnsAnRR.RDATA = rdata;
            mdnsArRR.RDATA = rdata;

            mdnsHdr.AA      = true;
            mdnsHdr.TC      = false;
            mdnsHdr.RD      = false;
            mdnsHdr.RA      = false;
            mdnsHdr.RCODE   = RespCode.NoError;
            mdnsHdr.QR      = true;
            mdnsHdr.qdcount = 0;
            mdnsHdr.an_rrs  = 3;
            mdnsHdr.ns_rrs  = 0;
            mdnsHdr.ar_rrs  = 4;

            dnsPkt.Header       = mdnsHdr;
            dnsPkt.AnswerRR     = mdnsAnRR;
            dnsPkt.AnswerRR     = mdnsAnRR;
            dnsPkt.AnswerRR     = mdnsAnRR;
            dnsPkt.AdditionalRR = mdnsArRR;
            dnsPkt.AdditionalRR = mdnsArRR;
            dnsPkt.AdditionalRR = mdnsArRR;
            dnsPkt.AdditionalRR = mdnsArRR;

            dnsPkt.print();
        }