Search in sources :

Example 1 with Service

use of javax.jmdns.impl.DNSRecord.Service in project EngineDriver by JMRI.

the class ServiceInfoImpl method answers.

/**
 * Create a series of answer that correspond with the give service info.
 *
 * @param recordClass
 *            record class of the query
 * @param unique
 * @param ttl
 * @param localHost
 * @return collection of answers
 */
public Collection<DNSRecord> answers(DNSRecordClass recordClass, boolean unique, int ttl, HostInfo localHost) {
    List<DNSRecord> list = new ArrayList<DNSRecord>();
    // [PJYF Dec 6 2011] This is bad hack as I don't know what the spec should really means in this case. i.e. what is the class of our registered services.
    if ((recordClass == DNSRecordClass.CLASS_ANY) || (recordClass == DNSRecordClass.CLASS_IN)) {
        if (this.getSubtype().length() > 0) {
            list.add(new Pointer(this.getTypeWithSubtype(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, ttl, this.getQualifiedName()));
        }
        list.add(new Pointer(this.getType(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, ttl, this.getQualifiedName()));
        list.add(new Service(this.getQualifiedName(), DNSRecordClass.CLASS_IN, unique, ttl, _priority, _weight, _port, localHost.getName()));
        list.add(new Text(this.getQualifiedName(), DNSRecordClass.CLASS_IN, unique, ttl, this.getTextBytes()));
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) Service(javax.jmdns.impl.DNSRecord.Service) Pointer(javax.jmdns.impl.DNSRecord.Pointer) Text(javax.jmdns.impl.DNSRecord.Text)

Example 2 with Service

use of javax.jmdns.impl.DNSRecord.Service in project ecf by eclipse.

the class ServiceInfoImpl method addAnswers.

public void addAnswers(DNSOutgoing out, int ttl, HostInfo localHost) throws IOException {
    out.addAnswer(new Pointer(type, DNSConstants.TYPE_PTR, DNSConstants.CLASS_IN, ttl, getQualifiedName()), 0);
    out.addAnswer(new Service(getQualifiedName(), DNSConstants.TYPE_SRV, DNSConstants.CLASS_IN | DNSConstants.CLASS_UNIQUE, ttl, priority, weight, port, localHost.getName()), 0);
    out.addAnswer(new Text(getQualifiedName(), DNSConstants.TYPE_TXT, DNSConstants.CLASS_IN | DNSConstants.CLASS_UNIQUE, ttl, getText()), 0);
}
Also used : Service(javax.jmdns.impl.DNSRecord.Service) Pointer(javax.jmdns.impl.DNSRecord.Pointer) Text(javax.jmdns.impl.DNSRecord.Text)

Example 3 with Service

use of javax.jmdns.impl.DNSRecord.Service in project JAirPort by froks.

the class ServiceInfoImpl method answers.

public Collection<DNSRecord> answers(boolean unique, int ttl, HostInfo localHost) {
    List<DNSRecord> list = new ArrayList<DNSRecord>();
    if (this.getSubtype().length() > 0) {
        list.add(new Pointer(this.getTypeWithSubtype(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, ttl, this.getQualifiedName()));
    }
    list.add(new Text(this.getQualifiedName(), DNSRecordClass.CLASS_IN, unique, ttl, textBytesToValidTextBytes(this.getTextBytes())));
    list.add(new Pointer(this.getType(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, ttl, this.getQualifiedName()));
    list.add(new Service(this.getQualifiedName(), DNSRecordClass.CLASS_IN, unique, ttl, _priority, _weight, _port, localHost.getName()));
    // }
    for (Inet4Address adr : this.getInet4Addresses()) {
        list.add(new DNSRecord.IPv4Address(removeLastDot(this.getServer()), DNSRecordClass.CLASS_IN, false, ttl, adr));
    }
    list.add(new Pointer("_services._dns-sd._udp.local", DNSRecordClass.CLASS_IN, false, ttl, "_raop._tcp.local"));
    return list;
}
Also used : Inet4Address(java.net.Inet4Address) ArrayList(java.util.ArrayList) Service(javax.jmdns.impl.DNSRecord.Service) Pointer(javax.jmdns.impl.DNSRecord.Pointer) Text(javax.jmdns.impl.DNSRecord.Text)

Aggregations

Pointer (javax.jmdns.impl.DNSRecord.Pointer)3 Service (javax.jmdns.impl.DNSRecord.Service)3 Text (javax.jmdns.impl.DNSRecord.Text)3 ArrayList (java.util.ArrayList)2 Inet4Address (java.net.Inet4Address)1