i.e. a DNS name of "MyNetBurner" is not a FQDN while "MyNetBurner.mynetwork.com" is a FQDN, where the domain name is obviously, "mynetwork.com". This is Option 81 in the standard DNS packet structure (and is decoded/displayed as such in packet sniffers such as WireShark etc.
NetBurner Folks: It might be a good idea to include this as core NB functionality...
I added this functionality to my project and was apparently able to overcome those DDNS issues. At a minimum, this required the addition of a new parameter "pDomainName" and the associated minor changes to the project's dhcpc.cpp and dhcpinternals.h modules. Of course a practical implementation also requires web element handling functions for entering / displaying the parameter, as well as including this as a non-volatile parameter in the "save-to-user-flash" functions.
In dhcpinternals.h, add Option 81 as follows:
Code: Select all
//----- DHCP option codes -----
<snip>
#define DHCPOPT_FQDN 81 // Fully Qualified Domain Name - new parameter added - B.Click
</snip>
Code: Select all
const char *pDomainName; // for FQDN support
char FQDN[40]; //buffer for assembling a fully qualified domain name
void CreateDhcpRequestMsg( DHCPMessage &OfferMsg, DHCPMessage &NewMsg, int DhcpInterface )
{
<snip>
if ( pDHCPOfferName != NULL)
{
int nlen = strlen( pDHCPOfferName );
NewMsg.SetOptions( opt++, 12 ); //this is the "host name" DHCP option (not FQDN though)
NewMsg.SetOptions( opt++, nlen );
for ( i = 0; i < nlen; i++ )
{
NewMsg.SetOptions( opt++, pDHCPOfferName[i] );
}
// Adding Option 81 FQDN to the DHCP Request message. Needed for Dynamic DNS
// Note this is not needed in the initial DHCP Discover message
if ( pDomainName[0] == 0) //no domain name available
// Just repeat host name (this is what a windows box does if not on a domain)
// yes this seems redundant with Option 12 but DDNS implementations do want it
{
sprintf (FQDN, "%s", pDHCPOfferName); //FQDN = just the host name
}
else //we have a domain name entered, use it
{
sprintf (FQDN, "%s.%s", pDHCPOfferName, pDomainName); //smack together a real FQDN
}
int plen = strlen( FQDN ); //how full is the buffer??
NewMsg.SetOptions( opt++, DHCPOPT_FQDN ); // Option #81 - as now defined in dhcpinternals.h
NewMsg.SetOptions( opt++, plen + 3 ); //message length; name string plus Flag byte plus A and PTR record bytes
NewMsg.SetOptions( opt++, 0x00 ); // MSB is Reserved, LSB is Flags. Normally 0x00.
// 0x08 for "no server update"
// 0x02 for "server override"
NewMsg.SetOptions( opt++, 0x00 ); // "A" record result (reverse lookup) byte
NewMsg.SetOptions( opt++, 0x00 ); // "PTR" record result (forward lookup) byte
// we just pad the message, DHCP ACK returns the server's opinion of DNS record status
for ( i = 0; i < plen; i++ ) //write it out
{
NewMsg.SetOptions( opt++, FQDN[i] );
}
}
AddDhcpOptions(NewMsg, opt);
NewMsg.SetOptions( opt++, DHCPOPT_END );
}
DISCLAIMER: I have not extensively tested this under infinitely numerous networking environments etc. etc. so implement and test this yourself accordingly...