<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>I am not sure why is the order of records interesting. In general
DNS records to not have set order in which they should be
received. Unicast DNS even randomizes the first record. If you
rely on specific order of TXT records, please don't. It would be
nice to have it always processed the same way. But any application
should not rely on their order.</p>
<p>Or have I understood it wrong way?</p>
<p>Regards,<br>
Petr<br>
</p>
<div class="moz-cite-prefix">On 2/14/23 09:02, Handa Wang wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAMdKZqw-=6hFLSE71+Lpgs2bKCKzVTJxa8ybGUtvHqCktz277g@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">Hello,
<div><br>
</div>
<div>(This is the same as issue <a
href="https://github.com/lathiat/avahi/issues/436"
moz-do-not-send="true">#436</a>.)</div>
<div><br>
</div>
<div>It seems that in `avahi_entry_group_add_service_strlst` the
passed in TXT argument is reversed before passing to the
server: <a
href="https://github.com/lathiat/avahi/blob/master/avahi-client/entrygroup.c#L373"
moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/lathiat/avahi/blob/master/avahi-client/entrygroup.c#L373</a>.
In this way when we call the
`avahi_entry_group_add_service_strlst` API, we can construct
the TXT string list by calling `avahi_string_list_add` in the
normal order. <br>
<br>
On the other hand, the TXT passed into
`AvahiServiceResolverCallback` is in the reverse order, which
is different from above. When a user receives the TXT in the
callback, the user may have to reverse the TXT string list
first to get the correct order. <br>
<br>
Is this a bug or by design? <br>
<br>
Also, it seems that `avahi-browse` also doesn't reverse the
TXT string list in its callback so that it returns the TXT
record in the reversed order. This can be confirmed by
following commands:</div>
<div><br>
```<br>
$ sudo avahi-publish-service test1 _test._udp 1234 k1=v1 k2=v2<br>
```<br>
<br>
</div>
<div>```<br>
$ avahi-browse -rt _test._udp<br>
```<br>
</div>
<div><br>
</div>
<div>Regards,</div>
<div>Handa</div>
</div>
</blockquote>
<pre class="moz-signature" cols="72">--
Petr Menšík
Software Engineer, RHEL
Red Hat, <a class="moz-txt-link-freetext" href="https://www.redhat.com/">https://www.redhat.com/</a>
PGP: DFCF908DB7C87E8E529925BC4931CA5B6C9FC5CB</pre>
</body>
</html>