networkprotocols/tcpipv4v6prt/src/iface.cpp
branchRCL_3
changeset 22 8d540f55e491
parent 21 abbed5a4b42a
child 23 425d8f4f7fa5
--- a/networkprotocols/tcpipv4v6prt/src/iface.cpp	Tue Aug 31 16:45:15 2010 +0300
+++ b/networkprotocols/tcpipv4v6prt/src/iface.cpp	Wed Sep 01 12:33:58 2010 +0100
@@ -617,7 +617,7 @@
 
     // Wrap a packet into ICMP error reply
     void IcmpSend(RMBufChain &aPacket, const TIcmpTypeCode aIcmp, const TUint32 aParameter = 0, const TInt aMC = 0);
-
+    
 private:
 #   ifdef WEAK_ES
     TUint32 IsForMe(const TIp6Addr &aAddr, const CIp6Interface *const aSrcIf,
@@ -667,9 +667,14 @@
     //
     void RemoveInterface(CIp6Interface *aIf);
     //
-    // Modify Inet Interface information (SetOption part!)
-    //
-    TInt InetInterfaceOption(TUint aName, const TSoInet6InterfaceInfo &aInfo);
+    // Modify Inet Interface information (SetOption part!) for TSoInet6InterfaceInfo input
+    //
+    TInt InetInterfaceOption(TUint aName, const TSoInet6InterfaceInfo &aInfo, const TInetSuffix* aDomainSuffix);
+    //
+    // Modify Inet Interface information (SetOption part!) for TSoInetInterfaceInfoExtnDnsSuffix input
+    // To support supplementary interface fields i.e. domain search list for an interface
+    //
+    TInt InetInterfaceOption(TUint aName, const TSoInetInterfaceInfoExtnDnsSuffix &aInfo);
     //
     // Query Interface Information
     //
@@ -790,7 +795,10 @@
     MDestinationCache *iDestinationCache;  //< Destination cache (for transport protocol params).
     
 public: // GCC doesn't compile Linkage, if this is private! -- msa
-    RTimeout iTimeout;                  //< Hook to the timer service (MTimeoutManager)
+    RTimeout iTimeout;					//< Hook to the timer service (MTimeoutManager)
+public:
+	// Enumerate domain suffices on an interface and read suffix name to the reference object passed in
+	virtual TInt DomainSuffixInfo(TName aActiveEnumInterface, TUint aDomainSuffixIndex, TInetSuffix &aDomainSuffix);
     };
 
 //
@@ -1863,6 +1871,11 @@
 #endif //SYMBIAN_TCPIPDHCP_UPDATE
 public: // GCC doesn't compile CIp6InterfaceLinkage, if this is private! -- msa
     RTimeout iTimeout;          //< Hook to the timer service (MTimeoutManager)
+private:
+    RInetSuffixList iSuffixList;	// Container to store list of optional domain search list on the interface
+private:
+	// Process SetOpt request for updating domain suffices based on the function mode set on the structure passed in
+	void ProcessDomainSuffixL(const TInetSuffix* aSuffix);
     };
 
 //
@@ -3412,6 +3425,15 @@
         TPckgBuf<TSoIfConnectionInfo> netinfo;
         netinfo().iIAPId = iRoute->iInterface.iScope[EScopeType_IAP];
         netinfo().iNetworkId = iRoute->iInterface.iScope[EScopeType_NET];
+
+   if(iInfo.iLockType == EScopeType_IAP  && iInfo.iLockId != netinfo().iIAPId)
+            {
+                iInfo.iLockId = netinfo().iIAPId;
+	#ifdef _LOG
+                 Log::Printf(_L("\t\tFlow[%u] Connect ConnectionInfo changed: Lock_type:%d, Lock_id:%d"),this,iInfo.iLockType, iInfo.iLockId); 
+	#endif
+            }
+
         Bearer(netinfo);
         RefreshFlow();
         return;
@@ -5535,13 +5557,13 @@
 */
 TInt CIp6Interface::SetId(TIp6AddressInfo &aId, const TIp6Addr &aAddr, const TInt aPrefix, const TInt aAddressType)
     {
-    // Should this also check whether address type is same?
-    // Changing just type does not work with this code!
-    // -- msa 24.10.2003
     if (aPrefix < 0 || aPrefix > 128)
         return 0;       // Invalid length, do nothing!
     if (TIp46Addr::Cast(aAddr).IsMulticast())
         return 0;       // A multicast address cannot be my own.
+    // Should this also check whether address type is same?
+    // Changing just type does not work with this code!
+    // -- msa 24.10.2003
     if (aId.IsSet() && aPrefix == aId.iPrefix && aAddr.IsEqual(aId.iId))
         {
 		// Id has not changed but expecting some change in any of 
@@ -7282,6 +7304,7 @@
     // are wasted on destructor. Should not cause
     // any problems... -- msa
     Reset();
+    iSuffixList.Close();
     LOG(Log::Printf(_L("\tIF %u [%S] Deleted"), iScope[0], &iName));
     }
 
@@ -9412,14 +9435,17 @@
 // **************************
 /**
 // Locate the next interface after aIndex and return the
-// information and assigned interface index.
-//
+// information and assigned interface index
+// The structure being used is a legacy type for retreiving basic information
+//
+// @param aIndex    index in the interface list after which we need extract the interface information
+// @param aInfo     Structure to store interface properties for the application layer to read
 // @return
 //  @li = 0, if no next interface exists
 //  @li > 0, interface index, aInfo updated to describe this interface
 */
 TUint CIp6Manager::InterfaceInfo(TUint aIndex, TSoInetInterfaceInfo &aInfo) const
-    {
+	{
     // ..yes, this is silly O(n!) (?) algorithm for scanning the interfaces. Each time
     // this is called, it has find and count all entries that come before the specified
     // aIndex.
@@ -9571,8 +9597,44 @@
             }
         }
     return 0;
-    }
-
+	}
+
+// CIp6Manager::DomainSuffixInfo
+// *****************************
+/**
+// Locate the next domain suffix after aDomainSuffixIndex on the interface with name aActiveEnumInterface
+// and return the information and assigned domain suffix index.
+// The structure being used is a new type for retreiving extended information
+//
+// @param aActiveEnumInterface  active interface name on which enumeration is to carried out
+// @param aDomainSuffixIndex    index in the domain suffix list after which we need extract the information
+// @param aInfoStructure 		to store domain suffix properties for the application layer to read
+// @return
+//  @li = 0, if no next domain suffix exists
+//  @li > 0, interface index, aInfo updated to describe this domain suffix in the list
+//	@li = KErrNotFound, if interface does not exist (or) when no domain suffix available for the interfce
+*/
+TInt CIp6Manager::DomainSuffixInfo(TName aActiveEnumInterface, TUint aDomainSuffixIndex, TInetSuffix &aDomainSuffix)
+    {
+	CIp6Interface* iface = FindInterface(aActiveEnumInterface);
+	
+    if (iface == NULL)
+    	{
+    	return KErrNotFound;
+		}
+    	
+	TInt count = iface->iSuffixList.Count();
+	if(count == 0 || count < aDomainSuffixIndex)
+		return KErrNotFound;
+		
+	if (count == aDomainSuffixIndex)    	
+		return 0;
+		
+	aDomainSuffix.Copy(iface->iSuffixList[aDomainSuffixIndex]);
+    aDomainSuffix.iDomainSuffixFunction = EInetFunctionUndefined;
+    
+    return ++aDomainSuffixIndex;
+    }
 
 TInt CIp6Manager::GetInterfaces(TDes8& aOption) const
     {
@@ -9989,9 +10051,10 @@
 
 // CIp6Manager::InetInterfaceOption
 // ********************************
-// Modify Inet Interface information (SetOption part)
-//
-TInt CIp6Manager::InetInterfaceOption(TUint aName, const TSoInet6InterfaceInfo &aInfo)
+// Modify Inet Interface information (SetOption part!) for TSoInet6InterfaceInfo input
+// For maintaining backward compatibility
+//
+TInt CIp6Manager::InetInterfaceOption(TUint aName, const TSoInet6InterfaceInfo &aInfo, const TInetSuffix* aDomainSuffix)
     {
     #ifdef _LOG
         TBuf<39> addressStr;
@@ -10148,6 +10211,15 @@
         iface->iSMtu = iface->iRMtu = iface->iPMtu = aInfo.iMtu;
     if (aInfo.iSpeedMetric > 0)
         iface->iSpeedMetric = aInfo.iSpeedMetric;
+
+	// Copy the domain search list (if any) to the interface object
+	if (aDomainSuffix)
+		{
+		TRAPD(err, iface->ProcessDomainSuffixL(aDomainSuffix));
+		if (err != KErrNone)
+			return err;
+		}
+    	
     if (aInfo.iDoState)
         {
         if (aInfo.iState == EIfDown)
@@ -10265,6 +10337,51 @@
     return KErrNone;
     }
 
+// CIp6Manager::ProcessDomainSuffixL
+// *********************************
+// Process SetOpt calls with TSoInetInterfaceInfoExtnDnsSuffix which contains
+// domain suffix information for the interface in form of TInetSuffix structure
+// This function is responsible to perform domain suffix updates (i.e. add/delete/deleteall)
+// to the interface based on the operation mode specified in the structure
+void CIp6Interface::ProcessDomainSuffixL(const TInetSuffix* aSuffix)
+	{
+	if (aSuffix->iDomainSuffixFunction == EInetAddSuffix)
+		{
+		// Perform addition of the incoming suffix name to the list maintained by interface object
+		iSuffixList.AppendL(aSuffix->iSuffixName);
+		TSuffixName tmpBuf;
+		tmpBuf.Copy(iSuffixList[iSuffixList.Count()-1]);
+		LOG(Log::Printf( _L( "Added domain suffix to interface %S - %S"), &iName, &tmpBuf));
+		}
+	else if(aSuffix->iDomainSuffixFunction == EInetDeleteSuffix)
+		{
+		// Perform deletion of the suffix name from the list of suffices in the interface object
+		TInt pos;
+		pos = iSuffixList.Find(aSuffix->iSuffixName);
+		User::LeaveIfError(pos);
+		TSuffixName tmpBuf;
+		tmpBuf.Copy(iSuffixList[pos]);
+		iSuffixList.Remove(pos);
+		LOG(Log::Printf( _L( "Removed domain suffix from interface %S - %S"), &iName, &tmpBuf));
+		}
+	else if (aSuffix->iDomainSuffixFunction == EInetDeleteAllSuffixes)
+		{
+		// Flush out all the suffix entries in the interface
+		iSuffixList.Reset();
+		LOG(Log::Printf( _L( "Removed all domain suffix from interface %S"), &iName));
+		}
+	}
+
+// CIp6Manager::InetInterfaceOption
+// ******************************** 
+// Modify Inet Interface information (SetOption part!) for TSoInetInterfaceInfoExtnDnsSuffix input
+// To support supplementary fields i.e. domain search list on an interface
+//
+TInt CIp6Manager::InetInterfaceOption(TUint aName, const TSoInetInterfaceInfoExtnDnsSuffix &aInfo)
+    {
+    return InetInterfaceOption(aName, (TSoInet6InterfaceInfo)aInfo, &aInfo.iDomainSuffix);
+    }
+
 //
 // CIpManager::InterfaceOption
 // ***************************
@@ -10404,10 +10521,18 @@
         if (aName == KSoIpv4LinkLocal &&
                 aOption.Length() == sizeof(TSoInetIpv4LinkLocalInfo))
             return SetIpv4LinkLocalOption((TSoInetIpv4LinkLocalInfo &)ref);
-        
-        if (aOption.Length() != sizeof(TSoInet6InterfaceInfo))
+        if (aOption.Length() == sizeof(TSoInet6InterfaceInfo))
+            {
+			// if the SetOpt() requested with TSoInet6InterfaceInfo structure (legacy)
+            return InetInterfaceOption(aName, (TSoInet6InterfaceInfo &)ref, NULL);
+            }
+        else if (aOption.Length() == sizeof(TSoInetInterfaceInfoExtnDnsSuffix))
+			{
+			// if the SetOpt() requested with new TSoInetInterfaceInfoExtnDnsSuffix structure
+            return InetInterfaceOption(aName, (TSoInetInterfaceInfoExtnDnsSuffix &)ref);
+			}
+        else
             return KErrArgument;
-        return InetInterfaceOption(aName, (TSoInet6InterfaceInfo &)ref);
         }
     else if (aLevel == KSOLInterface)
         {