Page 1 of 1

PPP code is missing DNS setting

Posted: Sun Jan 15, 2012 10:48 pm
by v8dave
Hi all,

I am still having issues with trying to get PPP working with my 2 modems. I decided to have a look at the code from RC2.5 and I noticed that this includes my changes except for the setting on DNS. Only the IP gets configured. DNS primary and secondary are never configured and always zero. I used the following code to set these.

Code: Select all

void IPCP_Class::TestOption( PBYTE option_start, DWORD maskv )
{
   /* We are very limited */

   switch ( option_start[0] )
   {
   case IPCP_OPT_IPADDR:
       {
          PDWORD pdw = ( PDWORD )( option_start + 2 );
          if ( *pdw == 0 )
          {
             options_nak_mask |= maskv;
             *pdw = m_pPPP->ActualThatInterfaceAddress;
          }
          else
          {
             if ( ( m_pPPP->ActualThatInterfaceAddress != 0 ) && ( *pdw != m_pPPP->ActualThatInterfaceAddress ) )
             {
                *pdw = m_pPPP->ActualThatInterfaceAddress;
                options_nak_mask |= maskv;
             }
             else
             {
                m_pPPP->ActualThatInterfaceAddress = *pdw;
                options_ok_mask |= maskv;
             }
          }
       }

       return;

   case IPCP_OPT_PRIMARY_DNS:
	   {
		   PDWORD pdw = ( PDWORD )( option_start + 2 );
		   if ( *pdw == 0 )
		   {
			   options_nak_mask |= maskv;
		   }
		   else
		   {
			   m_pPPP->primaryDnsIpAddress = *pdw;
			   options_ok_mask |= maskv;
		   }
	   }
	   return;

   case IPCP_OPT_SECONDARY_DNS:
	   {
		   PDWORD pdw = ( PDWORD )( option_start + 2 );
		   if ( *pdw == 0 )
		   {
			   options_nak_mask |= maskv;
		   }
		   else
		   {
			   m_pPPP->secondaryDnsIpAddress = *pdw;
			   options_ok_mask |= maskv;
		   }
	   }
	   return;

   case IPCP_OPT_COMPRESS:
       {
          PDWORD pdw = ( PDWORD )( option_start + 2 );
          if ( ( *pdw & 0xFFFF00FF ) == 0x002D0000 )
          {
             if ( ( ( *pdw & 0x0000FF00 ) >> 8 ) == 0x0F )
             {
                options_ok_mask |= maskv;
             }
             else if ( ( ( ( *pdw & 0x0000FF00 ) >> 8 ) < 0x0F ) && ( ( ( *pdw & 0x0000FF00 ) >> 8 ) > 0x01 ) )
             {
                NumStatesTX = ( ( *pdw & 0x0000FF00 ) >> 8 ) + 1;
                sl_compress_init( comp );
                options_ok_mask |= maskv;
             }
             else if ( ( ( ( *pdw & 0x0000FF00 ) >> 8 ) < 0x02 ) && ( ( ( *pdw & 0x0000FF00 ) >> 8 ) > 0x0F ) )
             {
                *pdw = 0x002D0f00;
                options_nak_mask |= maskv;
             }
          }
          else
          {
             *pdw = 0x002D0f00;
             options_nak_mask |= maskv;
          }
       }
    return;

     default:
    /*Unknown or unused option */
       {
          options_rej_mask |= maskv;
          return;
       }
   }
}
I also noticed that the defines for DNS options are in decimal and need to be in hexadecimal to work.

Code: Select all

#define IPCP_OPT_DNS (81)
#define IPCP_OPT_DNS2 (83)
Interestingly, they are not used in the code.

I have them defined as follows:

Code: Select all

#define IPCP_OPT_PRIMARY_DNS (0x81)
#define IPCP_OPT_SECONDARY_DNS (0x83)

Re: PPP code is missing DNS setting

Posted: Mon Jan 16, 2012 12:52 am
by v8dave
I got it working. Looking at the debug output I saw that the ISP was rejecting the secondary DNS entry.

I decided to disable this in the request and hey presto the ISP connected first time.


The PPP code needs a bit of work as the primary DNS is not actually set in the recent release.

I'll tidy up my code changes to PPP and send this to Netburner shortly as it may help others who are having the same issues.

Dave...