tcpiputils/dhcp/src/DHCPStateMachine.cpp
branchRCL_3
changeset 53 7e41d162e158
parent 40 d566d76acea1
child 57 abbed5a4b42a
--- a/tcpiputils/dhcp/src/DHCPStateMachine.cpp	Thu Jul 15 20:25:02 2010 +0300
+++ b/tcpiputils/dhcp/src/DHCPStateMachine.cpp	Thu Aug 19 11:25:30 2010 +0300
@@ -40,6 +40,7 @@
 	{
 	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPStateMachine::~CDHCPStateMachine")));
 	Cancel();
+	UnloadConfigurationFile();
 	delete iDhcpMessage;
 	delete iMessageSender;
 	delete iTimer;
@@ -66,7 +67,7 @@
   */
 	{
 	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPStateMachine::ConstructL")));
-	
+	LoadConfigurationFile();
 #ifdef _DEBUG
 	// let's set debug properties to something
 	//  so they can be read immediately..
@@ -445,7 +446,7 @@
 		}
 	}
 
-void CDHCPStateMachine::ConfigureInterfaceL( const TSoInet6InterfaceInfo& aInterfaceInfo )
+void CDHCPStateMachine::ConfigureInterfaceL( const TSoInetInterfaceInfoExtnDnsSuffix& aInterfaceInfo )
 /**
   * Set the interface IP address and other params
   * into the TCP/IP6 stack.
@@ -465,7 +466,7 @@
   */
 	{
 	
-	TPckgBuf<TSoInet6InterfaceInfo> configInfo(aInterfaceInfo);
+	TPckgBuf<TSoInetInterfaceInfoExtnDnsSuffix> configInfo(aInterfaceInfo);
 	
 
 	__CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPStateMachine::ConfigureInterfaceL - KSoInetConfigInterface")));
@@ -712,7 +713,77 @@
 	}
 
 
+/** 
+  * @name LoadConfigurationFile
+  *			Opens up the dhcp.ini file and reads the content on to a heap buffer
+  * @return - ETrue if the dhcp.ini is successfully parsed to the buffer, EFalse otherwise
+  *
+  * @internalTechnology
+  */
+TBool CDHCPStateMachine::LoadConfigurationFile()
+    {
+    TRAP_IGNORE(iConfig = CESockIniData::NewL(DHCP_INI_DATA));
+    return (iConfig != NULL);
+    }
 
+/**
+  * @name UnloadConfigurationFile 
+  *			Frees up memory allocated for reading dhcp.ini file
+  *
+  * @internalTechnology
+  */
+void CDHCPStateMachine::UnloadConfigurationFile()
+    {
+    if (iConfig)
+        {
+        delete iConfig;
+        iConfig = NULL;
+        }
+    }
+
+/**
+ * @name IniRead
+ *          General ini file read utility. Makes use of CESockIniData object for parsing
+ *          
+ * @param   aOptionName   Key name within ini file whose value need to be parsed
+ * @param   aOptionValue    Buffer reference to store the parsed output
+ * 
+ * @return  TInt error values as approriate from the ini parsing framework
+ *          
+ * @internalTechnology
+ */
+TInt CDHCPStateMachine::IniRead(const TDesC& aOptionName, TDes8& aOptionValue)
+    {
+    TPtrC iniValue;
+    TBool iniParsed = iConfig->FindVar(KDhcpSection, aOptionName, iniValue);
+    if (!iniParsed)
+        return KErrNotFound;
+
+    if(aOptionName.CompareF(KDhcpExtraOptions) == KErrNone)
+        {
+        TLex iniLex(iniValue);
+        TChar ch;
+        
+        while((ch = iniLex.Get()) != 0)
+            {
+            while ((ch = iniLex.Peek()) != ',')
+                iniLex.Inc();
+            TLex token(iniLex.MarkedToken());
+            
+            TUint8 opCode(0);
+            token.Val(opCode,EDecimal);
+
+            if ( (opCode > 0) && (opCode < KOpCodeOutOfBounds) )
+                aOptionValue.Append(opCode);
+            
+            iniLex.Inc();
+            iniLex.Mark();
+            }
+        return KErrNone;
+        }
+    else
+        return KErrNotFound;
+    }
 
 TDhcpRnd::TDhcpRnd():iXid(0)
 /**