For each TSR option in an mDNS message, the mDNS registrar first determines the owner name of the TSR option by assigning
an index to each non-question resource record in the mDNS message. The 'RR Index' value of each TSR option is then matched to the
index of a resource record, and the owner name for that resource record is applied to the TSR option. The time on the TSR
option is then computed by taking the current local clock time and subtracting from it the 'Time Offset' value in
the TSR option.¶
If there is a TSR option in an mDNS message for which there is no matching resource record in the mDNS message, the mDNS
registrar MUST ignore that TSR option. The mDNS registrar MUST NOT use the 'RR Index' value in the TSR option to search across the
mDNS packet since such an index can easily be out of bounds.¶
Now, for each record in the mDNS message, the mDNS registrar first determines whether the record is an OPT record, is in
the question section, or is a known answer (QD bit = 0 and it's a record in the answer section). For all such records, no
special processing is done for TSRs, since no TSR should exist in the mDNS message.¶
For each remaining resource record in the mDNS message, the mDNS registrar MUST check to see if there is a TSR option in
the mDNS message for that owner name. If there is not, the mDNS registrar MUST check to see if there is TSR data with that
owner name locally. If there is not, the record is processed normally.¶
If there is local TSR data for the record's owner name, the mDNS registrar checks to see if there are any resource records
in the local registration database (that is, not just in the cache) on that name. If there are, the record is treated as a
conflict. This conflict exists even if the locally registered records are all shared records. In cases where there are
records on the name in the cache, those records are all discarded, because they are in conflict with the new data.¶
In the case that there is TSR data for the record in the mDNS packet, and no local TSR data, this always means that any
data is in conflict. How that conflict is addressed depends on the data. First, note that resource records in the answer
section of an mDNS Query (QR bit in the header is 0) are "known answers" and therefore are not relevant when adding data
to the mDNSResponder cache. Such records can never have TSR options associated with them. However, resource records in
the authority and additional sections of a query do need to be processed (but in the case of authority records, are not
added to the cache).¶
In cases where the TSR data for a particular name is present both locally and in the mDNS message, the mDNS responder
MUST compare the key checksums. If they are different, then the records are always in conflict, and are handled according
to the context of the conflict, as described in Section 9 of [RFC6762].¶
In cases where the key checksums match, the mDNS registrar MUST compare the times. When the TSR time from the mDNS Message
is more recent than the local TSR time, local data in the cache is flushed and registered data is removed and reported
to the registrant that registered it as stale.¶
When the TSR times are the same, any resource records on that name in the answer section and additional section are added
to the cache.¶
When the local TSR time is more recent, the data in the message is not added to the cache, and no action is taken with
respect to any locally-registered data.¶