[avahi] Is it possible to get an A record from an Avahi server via IPv6?

jeremyf jfriesne at gmail.com
Tue Jul 31 19:45:50 PDT 2012


Hi all,

I've got a Linux server running avahi, and a client that manually sends out a simple, hand-rolled mDNS query packet over IPv6 (to ff02::fb) and parses the UDP packets it gets back to discover who is out there.  This all works fine for my purposes, since most of the server software I use speaks IPv6.

My problem is that there is a particular piece of server software running on the server that is only listening for incoming IPv4 connections -- if I try to connect to that server's port via IPv6, I get "connection refused".

My first response to this problem would be to fix the server to also listen on IPv6, but unfortunately in this case I'm not allowed to do that.

My next impulse was to check the mDNS reply packets my client receives, to see if they contain an 'A' record that would tell me the server's IPv4 address.  Then my client could make an IPv4 connection to that address.  However, the mDNS reply packets I receive don't contain any 'A' records, only an 'AAAA' record.

So my question is, is there any special flag or something I can put in my mDNS query packet that would convince the Avahi server to include an 'A' record in its response?  Or am I out of luck, and the only solution is to send mDNS query packets via both IPv4 and IPv6?

Thanks,
Jeremy

ps Here is my client's code that composes the mDNS query packet, in case it is relevant:

void ComposeMDNSPingPacket()
{
     memset(_pingBuf, 0, sizeof(_pingBuf));   // sizeof(_pingBuf)==256
     uint8 * b = _pingBuf;
     b += 2;  // leave transaction ID at zero
     b += 2;  // leave flags at zero
     *b++ = 0x00; *b++ = 0x01;  // set number-of-queries to one
     b += 2;  // leave number-of-answer-RRs at zero
     b += 2;  // leave number-of-authority-RRs at zero
     b += 2;  // leave number-of-additional-RRs at zero
     AddRRLabel(b, "_msli");
     AddRRLabel(b, "_tcp");
     AddRRLabel(b, "local");
     AddRRLabel(b, "");  // An empty string terminates the sequence
     *b++ = 0x00; *b++ = 0x0c;  // DNS Query type
     *b++ = 0x00; *b++ = 0x01;  // Class:  IN
     _pingBufSize = (b-_pingBuf);
}

void AddRRLabel(uint8 * & b, const char * lab)
{
  int sl = strlen(lab);
  *b++ = (char) sl;
  strcpy((char *)b, lab);
  b += sl;
}





More information about the avahi mailing list