tcpiputils/dhcp/src/DHCPStateMachine.cpp
branchRCL_3
changeset 75 c1029e558ef5
parent 58 8d540f55e491
equal deleted inserted replaced
67:bb2423252ea3 75:c1029e558ef5
    38   *
    38   *
    39   */
    39   */
    40 	{
    40 	{
    41 	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPStateMachine::~CDHCPStateMachine")));
    41 	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPStateMachine::~CDHCPStateMachine")));
    42 	Cancel();
    42 	Cancel();
    43 	UnloadConfigurationFile();
       
    44 	delete iDhcpMessage;
    43 	delete iDhcpMessage;
    45 	delete iMessageSender;
    44 	delete iMessageSender;
    46 	delete iTimer;
    45 	delete iTimer;
    47 	delete iHostName;
    46 	delete iHostName;
    48 	delete iDomainName;
    47 	delete iDomainName;
    65   *	@internalTechnology
    64   *	@internalTechnology
    66   *
    65   *
    67   */
    66   */
    68 	{
    67 	{
    69 	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPStateMachine::ConstructL")));
    68 	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPStateMachine::ConstructL")));
    70 	LoadConfigurationFile();
    69 	
    71 #ifdef _DEBUG
    70 #ifdef _DEBUG
    72 	// let's set debug properties to something
    71 	// let's set debug properties to something
    73 	//  so they can be read immediately..
    72 	//  so they can be read immediately..
    74 	CDHCPStateMachine* const & iStateMachine = this;
    73 	CDHCPStateMachine* const & iStateMachine = this;
    75 	CDHCPStateMachine* const & iDhcpStateMachine = iStateMachine;
    74 	CDHCPStateMachine* const & iDhcpStateMachine = iStateMachine;
   444 		{
   443 		{
   445 		__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L("CDHCPStateMachine::RemoveConfiguredAddress,Socket Open Failed: Due to %d"),error));	
   444 		__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L("CDHCPStateMachine::RemoveConfiguredAddress,Socket Open Failed: Due to %d"),error));	
   446 		}
   445 		}
   447 	}
   446 	}
   448 
   447 
   449 void CDHCPStateMachine::ConfigureInterfaceL( const TSoInetInterfaceInfoExtnDnsSuffix& aInterfaceInfo )
   448 void CDHCPStateMachine::ConfigureInterfaceL( const TSoInet6InterfaceInfo& aInterfaceInfo )
   450 /**
   449 /**
   451   * Set the interface IP address and other params
   450   * Set the interface IP address and other params
   452   * into the TCP/IP6 stack.
   451   * into the TCP/IP6 stack.
   453   *
   452   *
   454   * What we set depends on the setup
   453   * What we set depends on the setup
   464   *
   463   *
   465   * @internalTechnology
   464   * @internalTechnology
   466   */
   465   */
   467 	{
   466 	{
   468 	
   467 	
   469 	TPckgBuf<TSoInetInterfaceInfoExtnDnsSuffix> configInfo(aInterfaceInfo);
   468 	TPckgBuf<TSoInet6InterfaceInfo> configInfo(aInterfaceInfo);
   470 	
   469 	
   471 
   470 
   472 	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPStateMachine::ConfigureInterfaceL - KSoInetConfigInterface")));
   471 	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPStateMachine::ConfigureInterfaceL - KSoInetConfigInterface")));
   473 	
   472 	
   474 	User::LeaveIfError(iSocket.SetOpt(KSoInetConfigInterface, KSolInetIfCtrl, configInfo));
   473 	User::LeaveIfError(iSocket.SetOpt(KSoInetConfigInterface, KSolInetIfCtrl, configInfo));
   711 		}
   710 		}
   712 	return EFalse;
   711 	return EFalse;
   713 	}
   712 	}
   714 
   713 
   715 
   714 
   716 /** 
   715 
   717   * @name LoadConfigurationFile
       
   718   *			Opens up the dhcp.ini file and reads the content on to a heap buffer
       
   719   * @return - ETrue if the dhcp.ini is successfully parsed to the buffer, EFalse otherwise
       
   720   *
       
   721   * @internalTechnology
       
   722   */
       
   723 TBool CDHCPStateMachine::LoadConfigurationFile()
       
   724     {
       
   725     TRAP_IGNORE(iConfig = CESockIniData::NewL(DHCP_INI_DATA));
       
   726     return (iConfig != NULL);
       
   727     }
       
   728 
       
   729 /**
       
   730   * @name UnloadConfigurationFile 
       
   731   *			Frees up memory allocated for reading dhcp.ini file
       
   732   *
       
   733   * @internalTechnology
       
   734   */
       
   735 void CDHCPStateMachine::UnloadConfigurationFile()
       
   736     {
       
   737     if (iConfig)
       
   738         {
       
   739         delete iConfig;
       
   740         iConfig = NULL;
       
   741         }
       
   742     }
       
   743 
       
   744 /**
       
   745  * @name IniRead
       
   746  *          General ini file read utility. Makes use of CESockIniData object for parsing
       
   747  *          
       
   748  * @param   aOptionName   Key name within ini file whose value need to be parsed
       
   749  * @param   aOptionValue    Buffer reference to store the parsed output
       
   750  * 
       
   751  * @return  TInt error values as approriate from the ini parsing framework
       
   752  *          
       
   753  * @internalTechnology
       
   754  */
       
   755 TInt CDHCPStateMachine::IniRead(const TDesC& aOptionName, TDes8& aOptionValue)
       
   756     {
       
   757     TPtrC iniValue;
       
   758     TBool iniParsed = iConfig->FindVar(KDhcpSection, aOptionName, iniValue);
       
   759     if (!iniParsed)
       
   760         return KErrNotFound;
       
   761 
       
   762     if(aOptionName.CompareF(KDhcpExtraOptions) == KErrNone)
       
   763         {
       
   764         TLex iniLex(iniValue);
       
   765         TChar ch;
       
   766         
       
   767         while((ch = iniLex.Get()) != 0)
       
   768             {
       
   769             while ((ch = iniLex.Peek()) != ',')
       
   770                 iniLex.Inc();
       
   771             TLex token(iniLex.MarkedToken());
       
   772             
       
   773             TUint8 opCode(0);
       
   774             token.Val(opCode,EDecimal);
       
   775 
       
   776             if ( (opCode > 0) && (opCode < KOpCodeOutOfBounds) )
       
   777                 aOptionValue.Append(opCode);
       
   778             
       
   779             iniLex.Inc();
       
   780             iniLex.Mark();
       
   781             }
       
   782         return KErrNone;
       
   783         }
       
   784     else
       
   785         return KErrNotFound;
       
   786     }
       
   787 
   716 
   788 TDhcpRnd::TDhcpRnd():iXid(0)
   717 TDhcpRnd::TDhcpRnd():iXid(0)
   789 /**
   718 /**
   790   * Constructor for this little random number 
   719   * Constructor for this little random number 
   791   * class that creates us a random transaction id
   720   * class that creates us a random transaction id