ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Zero Configuration Networking: Using the Java APIs, Part 2
Pages: 1, 2, 3, 4, 5, 6

Adding, Updating, and Removing Additional Records

A standard DNS-SD service is described by two DNS records: an SRV record, giving target host and port number, and a TXT record, containing zero or more key/value attributes. For almost all applications, advertising a service with these two records is all that's needed. However, there are certain applications—iChat being the prime example—that have extra requirements. For the benefit of applications like this, DNS-SD provides some additional specialized APIs to add, update, and remove additional records.



DNS-SD allows applications to add additional DNS records to an existing service registration using DNSSDRegistration's addRecord method. iChat attaches a small JPEG image to each advertised service, containing the user's icon or picture, and because this is too large to fit in a TXT record attribute, iChat attaches it as an additional record. Adding records like this is something that should not be done indiscriminately because of the cost in increased network traffic, but in the case of iChat, it is the most appropriate way to communicate a user's icon to all the other iChat clients on the local network.

Calling addRecord( ) returns a DNSRecord object, which supports two operations, update( ) and remove( ). If you need to change the data in the record (as iChat does when the user changes the icon), then you can use update( ) to provide new data to replace the old data in the record.

When adding a record, you need to specify the DNS type of the record. The original DNS types are listed in RFC 1035, and newer types are given in later RFCs. For example, the SRV record type (type 33) is specified in RFC 2782. You can also find the list of currently defined DNS types at http://www.iana.org/assignments/dns-parameters. On many systems, you can also find the defined types listed in one of the C header files, such as /usr/include/nameser.h or /usr/include/dns_sd.h. The current IANA list of DNS types is shown in Table 8-2.

Table 8-2. DNS resource record types

TYPE

Value

Meaning

Reference

A

1

A host address

RFC1035

NS

2

An authoritative name server

RFC1035

MD

3

A mail destination (OBSOLETE; use MX)

RFC1035

MF

4

A mail forwarder (OBSOLETE; use MX)

RFC1035

CNAME

5

The canonical name for an alias

RFC1035

SOA

6

Marks the start of a zone of authority

RFC1035

MB

7

A mailbox domain name (EXPERIMENTAL)

RFC1035

MG

8

A mail group member (EXPERIMENTAL)

RFC1035

MR

9

A mail rename domain name (EXPERIMENTAL)

RFC1035

NULL

10

A null RR (EXPERIMENTAL)

RFC1035

WKS

11

A well-known service description

RFC1035

PTR

12

A domain name pointer

RFC1035

HINFO

13

Host information

RFC1035

MINFO

14

Mailbox or mail list information

RFC1035

MX

15

Mail exchange

RFC1035

TXT

16

Text strings

RFC1035

RP

17

For Responsible Person

RFC1183

AFSDB

18

For AFS Data Base location

RFC1183

X25

19

For X.25 PSDN address

RFC1183

ISDN

20

For ISDN address

RFC1183

RT

21

For Route Through

RFC1183

NSAP

22

For NSAP address, NSAP style A record

RFC1706

NSAP-PTR

23

 

 

SIG

24

For security signature

RFC2535 RFC3755 RFC4034

KEY

25

For security key

RFC2535 RFC3755 RFC4034

PX

26

X.400 mail mapping information

RFC2163

GPOS

27

Geographical Position

RFC1712

AAAA

28

IP6 Address

Thomson

LOC

29

Location Information

Vixie

NXT

30

Next Domain (OBSOLETE)

RFC2535, RFC3755

EID

31

Endpoint Identifier

Patton

NIMLOC

32

Nimrod Locator

Patton

SRV

33

Server Selection

RFC2782

ATMA

34

ATM Address

Dobrowski

NAPTR

35

Naming Authority Pointer

RFC2168, RFC2915

KX

36

Key Exchanger

RFC2230

CERT

37

CERT

RFC2538

A6

38

A6

RFC2874

DNAME

39

DNAME

RFC2672

SINK

40

SINK

Eastlake

OPT

41

OPT

RFC2671

APL

42

APL

RFC3123

DS

43

Delegation Signer

RFC3658

SSHFP

44

SSH Key Fingerprint

RFC-ietf-secsh-dns-05.txt

IPSECKEY

45

IPSECKEY

RFC4025

RRSIG

46

RRSIG

RFC3755

NSEC

47

NSEC

RFC3755

DNSKEY

48

DNSKEY

RFC3755

UINFO

100

IANA-Reserved

 

UID

101

IANA-Reserved

 

GID

102

IANA-Reserved

 

UNSPEC

103

IANA-Reserved

 

TKEY

249

Transaction Key

RFC2930

TSIG

250

Transaction Signature

RFC2845

IXFR

251

Incremental transfer

RFC1995

AXFR

252

Transfer of an entire zone

RFC1035

MAILB

253

Mailbox-related RRs (MB, MG, or MR)

RFC1035

MAILA

254

Mail agent RRs (OBSOLETE; see MX)

RFC1035

ANY

255

A request for any record(s)

RFC1035

When adding or updating records, it is your responsibility to make sure that the byte array data you provide is properly formatted for the DNS record type in question. You can specify the DNS time to live (TTL), though for most applications, it's most sensible to simply pass zero and let DNS-SD use its default TTL.

Pages: 1, 2, 3, 4, 5, 6

Next Pagearrow