Examples of DnsQuestion


Examples of javax.jmdns.impl.DNSQuestion

            {
                if (count++ < 3 && !info.hasData())
                {
                    long now = System.currentTimeMillis();
                    DNSOutgoing out = new DNSOutgoing(DNSConstants.FLAGS_QR_QUERY);
                    out.addQuestion(new DNSQuestion(info.getQualifiedName(), DNSConstants.TYPE_SRV, DNSConstants.CLASS_IN));
                    out.addQuestion(new DNSQuestion(info.getQualifiedName(), DNSConstants.TYPE_TXT, DNSConstants.CLASS_IN));
                    if (info.getServer() != null)
                    {
                        out.addQuestion(new DNSQuestion(info.getServer(), DNSConstants.TYPE_A, DNSConstants.CLASS_IN));
                    }
                    out.addAnswer((DNSRecord) this.jmDNSImpl.getCache().get(info.getQualifiedName(), DNSConstants.TYPE_SRV, DNSConstants.CLASS_IN), now);
                    out.addAnswer((DNSRecord) this.jmDNSImpl.getCache().get(info.getQualifiedName(), DNSConstants.TYPE_TXT, DNSConstants.CLASS_IN), now);
                    if (info.getServer() != null)
                    {
View Full Code Here

Examples of javax.jmdns.impl.DNSQuestion

                    for (Iterator iterator = in.getQuestions().iterator(); iterator.hasNext();)
                    {
                        DNSEntry entry = (DNSEntry) iterator.next();
                        if (entry instanceof DNSQuestion)
                        {
                            DNSQuestion q = (DNSQuestion) entry;

                            // for unicast responses the question must be included
                            if (isUnicast)
                            {
                                //out.addQuestion(q);
                                questions.add(q);
                            }

                            int type = q.getType();
                            if (type == DNSConstants.TYPE_ANY || type == DNSConstants.TYPE_SRV)
                            { // I ama not sure of why there is a special case here [PJYF Oct 15 2004]
                                if (this.jmDNSImpl.getLocalHost().getName().equalsIgnoreCase(q.getName()))
                                {
                                    // type = DNSConstants.TYPE_A;
                                    DNSRecord answer = this.jmDNSImpl.getLocalHost().getDNS4AddressRecord();
                                    if (answer != null)
                                    {
                                        answers.add(answer);
                                    }
                                    answer = this.jmDNSImpl.getLocalHost().getDNS6AddressRecord();
                                    if (answer != null)
                                    {
                                        answers.add(answer);
                                    }
                                    type = DNSConstants.TYPE_IGNORE;
                                }
                                else
                                {
                                    if (this.jmDNSImpl.getServiceTypes().containsKey(q.getName().toLowerCase()))
                                    {
                                        type = DNSConstants.TYPE_PTR;
                                    }
                                }
                            }

                            switch (type)
                            {
                                case DNSConstants.TYPE_A:
                                    {
                                        // Answer a query for a domain name
                                        //out = addAnswer( in, addr, port, out, host );
                                        DNSRecord answer = this.jmDNSImpl.getLocalHost().getDNS4AddressRecord();
                                        if (answer != null)
                                        {
                                            answers.add(answer);
                                        }
                                        break;
                                    }
                                case DNSConstants.TYPE_AAAA:
                                    {
                                        // Answer a query for a domain name
                                        DNSRecord answer = this.jmDNSImpl.getLocalHost().getDNS6AddressRecord();
                                        if (answer != null)
                                        {
                                            answers.add(answer);
                                        }
                                        break;
                                    }
                                case DNSConstants.TYPE_PTR:
                                    {
                                        // Answer a query for services of a given type

                                        // find matching services
                                        for (Iterator serviceIterator = this.jmDNSImpl.getServices().values().iterator(); serviceIterator.hasNext();)
                                        {
                                            ServiceInfoImpl info = (ServiceInfoImpl) serviceIterator.next();
                                            if (info.getState() == DNSState.ANNOUNCED)
                                            {
                                                if (q.getName().equalsIgnoreCase(info.getType()))
                                                {
                                                    DNSRecord answer = this.jmDNSImpl.getLocalHost().getDNS4AddressRecord();
                                                    if (answer != null)
                                                    {
                                                        answers.add(answer);
                                                    }
                                                    answer = this.jmDNSImpl.getLocalHost().getDNS6AddressRecord();
                                                    if (answer != null)
                                                    {
                                                        answers.add(answer);
                                                    }
                                                    answers.add(new DNSRecord.Pointer(info.getType(), DNSConstants.TYPE_PTR, DNSConstants.CLASS_IN, DNSConstants.DNS_TTL, info.getQualifiedName()));
                                                    answers.add(new DNSRecord.Service(info.getQualifiedName(), DNSConstants.TYPE_SRV, DNSConstants.CLASS_IN | DNSConstants.CLASS_UNIQUE, DNSConstants.DNS_TTL,
                                                            info.getPriority(), info.getWeight(), info.getPort(), this.jmDNSImpl.getLocalHost().getName()));
                                                    answers.add(new DNSRecord.Text(info.getQualifiedName(), DNSConstants.TYPE_TXT, DNSConstants.CLASS_IN | DNSConstants.CLASS_UNIQUE, DNSConstants.DNS_TTL,
                                                            info.getText()));
                                                }
                                            }
                                        }
                                        if (q.getName().equalsIgnoreCase("_services._mdns._udp.local."))
                                        {
                                            for (Iterator serviceTypeIterator = this.jmDNSImpl.getServiceTypes().values().iterator(); serviceTypeIterator.hasNext();)
                                            {
                                                answers.add(new DNSRecord.Pointer("_services._mdns._udp.local.", DNSConstants.TYPE_PTR, DNSConstants.CLASS_IN, DNSConstants.DNS_TTL, (String) serviceTypeIterator.next()));
                                            }
                                        }
                                        break;
                                    }
                                case DNSConstants.TYPE_SRV:
                                case DNSConstants.TYPE_ANY:
                                case DNSConstants.TYPE_TXT:
                                    {
                                        ServiceInfoImpl info = (ServiceInfoImpl) this.jmDNSImpl.getServices().get(q.getName().toLowerCase());
                                        if (info != null && info.getState() == DNSState.ANNOUNCED)
                                        {
                                            DNSRecord answer = this.jmDNSImpl.getLocalHost().getDNS4AddressRecord();
                                            if (answer != null)
                                            {
View Full Code Here

Examples of javax.jmdns.impl.DNSQuestion

    public Canceler(JmDNSImpl jmDNSImpl, ServiceInfoImpl info, Object lock) {
        this.jmDNSImpl = jmDNSImpl;
        this.infos = new ServiceInfoImpl[] { info };
        this.lock = lock;
        this.jmDNSImpl.addListener(info, new DNSQuestion(info.getQualifiedName(), DNSConstants.TYPE_ANY, DNSConstants.CLASS_IN));
    }
View Full Code Here

Examples of javax.jmdns.impl.DNSQuestion

            if (this.jmDNSImpl.getState() == DNSState.ANNOUNCED || ANNOUNCE_OVERRIDE) {
                if (count++ < 3) {
                    logger.finer("run() JmDNS querying service");
                    long now = System.currentTimeMillis();
                    DNSOutgoing out = new DNSOutgoing(DNSConstants.FLAGS_QR_QUERY);
                    out.addQuestion(new DNSQuestion(type, DNSConstants.TYPE_PTR, DNSConstants.CLASS_IN));
                    for (Iterator s = this.jmDNSImpl.getServices().values().iterator(); s.hasNext();) {
                        final ServiceInfoImpl info = (ServiceInfoImpl) s.next();
                        try {
                            out.addAnswer(new DNSRecord.Pointer(info.getType(), DNSConstants.TYPE_PTR, DNSConstants.CLASS_IN, DNSConstants.DNS_TTL, info.getQualifiedName()), now);
                        } catch (IOException ee) {
View Full Code Here

Examples of javax.jmdns.impl.DNSQuestion

    public ServiceInfoResolver(JmDNSImpl jmDNSImpl, ServiceInfoImpl info)
    {
        this.jmDNSImpl = jmDNSImpl;
        this.info = info;
        info.setDns(this.jmDNSImpl);
        this.jmDNSImpl.addListener(info, new DNSQuestion(info.getQualifiedName(), DNSConstants.TYPE_ANY, DNSConstants.CLASS_IN));
    }
View Full Code Here

Examples of javax.jmdns.impl.DNSQuestion

            {
                if (count++ < 3 && !info.hasData())
                {
                    long now = System.currentTimeMillis();
                    DNSOutgoing out = new DNSOutgoing(DNSConstants.FLAGS_QR_QUERY);
                    out.addQuestion(new DNSQuestion(info.getQualifiedName(), DNSConstants.TYPE_SRV, DNSConstants.CLASS_IN));
                    out.addQuestion(new DNSQuestion(info.getQualifiedName(), DNSConstants.TYPE_TXT, DNSConstants.CLASS_IN));
                    if (info.getServer() != null)
                    {
                        out.addQuestion(new DNSQuestion(info.getServer(), DNSConstants.TYPE_A, DNSConstants.CLASS_IN));
                    }
                    out.addAnswer((DNSRecord) this.jmDNSImpl.getCache().get(info.getQualifiedName(), DNSConstants.TYPE_SRV, DNSConstants.CLASS_IN), now);
                    out.addAnswer((DNSRecord) this.jmDNSImpl.getCache().get(info.getQualifiedName(), DNSConstants.TYPE_TXT, DNSConstants.CLASS_IN), now);
                    if (info.getServer() != null)
                    {
View Full Code Here

Examples of javax.jmdns.impl.DNSQuestion

        for (Iterator i = in.getQuestions().iterator(); i.hasNext();)
        {
            DNSEntry entry = (DNSEntry) i.next();
            if (entry instanceof DNSQuestion)
            {
                DNSQuestion q = (DNSQuestion) entry;
//                logger.finest("start() question=" + q);
                iAmTheOnlyOne &= (q.getType() == DNSConstants.TYPE_SRV
                    || q.getType() == DNSConstants.TYPE_TXT
                    || q.getType() == DNSConstants.TYPE_A
                    || q.getType() == DNSConstants.TYPE_AAAA
                    || this.jmDNSImpl.getLocalHost().getName().equalsIgnoreCase(q.getName())
                    || this.jmDNSImpl.getServices().containsKey(q.getName().toLowerCase()));
                if (!iAmTheOnlyOne)
                {
                    break;
                }
            }
View Full Code Here

Examples of javax.jmdns.impl.DNSQuestion

                    for (Iterator iterator = in.getQuestions().iterator(); iterator.hasNext();)
                    {
                        DNSEntry entry = (DNSEntry) iterator.next();
                        if (entry instanceof DNSQuestion)
                        {
                            DNSQuestion q = (DNSQuestion) entry;

                            // for unicast responses the question must be included
                            if (isUnicast)
                            {
                                //out.addQuestion(q);
                                questions.add(q);
                            }

                            int type = q.getType();
                            if (type == DNSConstants.TYPE_ANY || type == DNSConstants.TYPE_SRV)
                            { // I ama not sure of why there is a special case here [PJYF Oct 15 2004]
                                if (this.jmDNSImpl.getLocalHost().getName().equalsIgnoreCase(q.getName()))
                                {
                                    // type = DNSConstants.TYPE_A;
                                    DNSRecord answer = this.jmDNSImpl.getLocalHost().getDNS4AddressRecord();
                                    if (answer != null)
                                    {
                                        answers.add(answer);
                                    }
                                    answer = this.jmDNSImpl.getLocalHost().getDNS6AddressRecord();
                                    if (answer != null)
                                    {
                                        answers.add(answer);
                                    }
                                    type = DNSConstants.TYPE_IGNORE;
                                }
                                else
                                {
                                    if (this.jmDNSImpl.getServiceTypes().containsKey(q.getName().toLowerCase()))
                                    {
                                        type = DNSConstants.TYPE_PTR;
                                    }
                                }
                            }

                            switch (type)
                            {
                                case DNSConstants.TYPE_A:
                                    {
                                        // Answer a query for a domain name
                                        //out = addAnswer( in, addr, port, out, host );
                                        DNSRecord answer = this.jmDNSImpl.getLocalHost().getDNS4AddressRecord();
                                        if (answer != null)
                                        {
                                            answers.add(answer);
                                        }
                                        break;
                                    }
                                case DNSConstants.TYPE_AAAA:
                                    {
                                        // Answer a query for a domain name
                                        DNSRecord answer = this.jmDNSImpl.getLocalHost().getDNS6AddressRecord();
                                        if (answer != null)
                                        {
                                            answers.add(answer);
                                        }
                                        break;
                                    }
                                case DNSConstants.TYPE_PTR:
                                    {
                                        // Answer a query for services of a given type

                                        // find matching services
                                        for (Iterator serviceIterator = this.jmDNSImpl.getServices().values().iterator(); serviceIterator.hasNext();)
                                        {
                                            ServiceInfoImpl info = (ServiceInfoImpl) serviceIterator.next();
                                            if (info.getState() == DNSState.ANNOUNCED)
                                            {
                                                if (q.getName().equalsIgnoreCase(info.getType()))
                                                {
                                                    DNSRecord answer = this.jmDNSImpl.getLocalHost().getDNS4AddressRecord();
                                                    if (answer != null)
                                                    {
                                                        answers.add(answer);
                                                    }
                                                    answer = this.jmDNSImpl.getLocalHost().getDNS6AddressRecord();
                                                    if (answer != null)
                                                    {
                                                        answers.add(answer);
                                                    }
                                                    answers.add(new DNSRecord.Pointer(info.getType(), DNSConstants.TYPE_PTR, DNSConstants.CLASS_IN, DNSConstants.DNS_TTL, info.getQualifiedName()));
                                                    answers.add(new DNSRecord.Service(info.getQualifiedName(), DNSConstants.TYPE_SRV, DNSConstants.CLASS_IN | DNSConstants.CLASS_UNIQUE, DNSConstants.DNS_TTL,
                                                            info.getPriority(), info.getWeight(), info.getPort(), this.jmDNSImpl.getLocalHost().getName()));
                                                    answers.add(new DNSRecord.Text(info.getQualifiedName(), DNSConstants.TYPE_TXT, DNSConstants.CLASS_IN | DNSConstants.CLASS_UNIQUE, DNSConstants.DNS_TTL,
                                                            info.getText()));
                                                }
                                            }
                                        }
                                        if (q.getName().equalsIgnoreCase("_services" + DNSConstants.DNS_META_QUERY + "local."))
                                        {
                                            for (Iterator serviceTypeIterator = this.jmDNSImpl.getServiceTypes().values().iterator(); serviceTypeIterator.hasNext();)
                                            {
                                                answers.add(new DNSRecord.Pointer("_services" + DNSConstants.DNS_META_QUERY + "local.", DNSConstants.TYPE_PTR, DNSConstants.CLASS_IN, DNSConstants.DNS_TTL, (String) serviceTypeIterator.next()));
                                            }
                                        }
                                        break;
                                    }
                                case DNSConstants.TYPE_SRV:
                                case DNSConstants.TYPE_ANY:
                                case DNSConstants.TYPE_TXT:
                                    {
                                        ServiceInfoImpl info = (ServiceInfoImpl) this.jmDNSImpl.getServices().get(q.getName().toLowerCase());
                                        if (info != null && info.getState() == DNSState.ANNOUNCED)
                                        {
                                            DNSRecord answer = this.jmDNSImpl.getLocalHost().getDNS4AddressRecord();
                                            if (answer != null)
                                            {
View Full Code Here

Examples of javax.jmdns.impl.DNSQuestion

    public Canceler(JmDNSImpl jmDNSImpl, ServiceInfoImpl info, Object lock)
    {
        this.jmDNSImpl = jmDNSImpl;
        this.infos = new ServiceInfoImpl[]{info};
        this.lock = lock;
        this.jmDNSImpl.addListener(info, new DNSQuestion(info.getQualifiedName(), DNSConstants.TYPE_ANY, DNSConstants.CLASS_IN));
    }
View Full Code Here

Examples of javax.jmdns.impl.DNSQuestion

                if (count++ < 3)
                {
//                    logger.finer("run() JmDNS querying service");
                    long now = System.currentTimeMillis();
                    DNSOutgoing out = new DNSOutgoing(DNSConstants.FLAGS_QR_QUERY);
                    out.addQuestion(new DNSQuestion(type, DNSConstants.TYPE_PTR, DNSConstants.CLASS_IN));
                    for (Iterator s = this.jmDNSImpl.getServices().values().iterator(); s.hasNext();)
                    {
                        final ServiceInfoImpl info = (ServiceInfoImpl) s.next();
                        try
                        {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.