networkprotocols/tcpipv4v6prt/src/iface.cpp
branchRCL_3
changeset 22 8d540f55e491
parent 21 abbed5a4b42a
child 23 425d8f4f7fa5
equal deleted inserted replaced
21:abbed5a4b42a 22:8d540f55e491
   615     // Returns the event manager instance used by the stack
   615     // Returns the event manager instance used by the stack
   616     inline MEventService *EventManager() const { return iEventManager; }
   616     inline MEventService *EventManager() const { return iEventManager; }
   617 
   617 
   618     // Wrap a packet into ICMP error reply
   618     // Wrap a packet into ICMP error reply
   619     void IcmpSend(RMBufChain &aPacket, const TIcmpTypeCode aIcmp, const TUint32 aParameter = 0, const TInt aMC = 0);
   619     void IcmpSend(RMBufChain &aPacket, const TIcmpTypeCode aIcmp, const TUint32 aParameter = 0, const TInt aMC = 0);
   620 
   620     
   621 private:
   621 private:
   622 #   ifdef WEAK_ES
   622 #   ifdef WEAK_ES
   623     TUint32 IsForMe(const TIp6Addr &aAddr, const CIp6Interface *const aSrcIf,
   623     TUint32 IsForMe(const TIp6Addr &aAddr, const CIp6Interface *const aSrcIf,
   624         const TUint32 aScopeId, const TScopeType aType) const;
   624         const TUint32 aScopeId, const TScopeType aType) const;
   625 #   else
   625 #   else
   665     //
   665     //
   666     // Unconditional removal of the interface
   666     // Unconditional removal of the interface
   667     //
   667     //
   668     void RemoveInterface(CIp6Interface *aIf);
   668     void RemoveInterface(CIp6Interface *aIf);
   669     //
   669     //
   670     // Modify Inet Interface information (SetOption part!)
   670     // Modify Inet Interface information (SetOption part!) for TSoInet6InterfaceInfo input
   671     //
   671     //
   672     TInt InetInterfaceOption(TUint aName, const TSoInet6InterfaceInfo &aInfo);
   672     TInt InetInterfaceOption(TUint aName, const TSoInet6InterfaceInfo &aInfo, const TInetSuffix* aDomainSuffix);
       
   673     //
       
   674     // Modify Inet Interface information (SetOption part!) for TSoInetInterfaceInfoExtnDnsSuffix input
       
   675     // To support supplementary interface fields i.e. domain search list for an interface
       
   676     //
       
   677     TInt InetInterfaceOption(TUint aName, const TSoInetInterfaceInfoExtnDnsSuffix &aInfo);
   673     //
   678     //
   674     // Query Interface Information
   679     // Query Interface Information
   675     //
   680     //
   676     TInt InterfaceQueryOption(TUint aName, TSoInetIfQuery &aQuery, const TInt aLength) const;
   681     TInt InterfaceQueryOption(TUint aName, TSoInetIfQuery &aQuery, const TInt aLength) const;
   677     //
   682     //
   788 
   793 
   789     MEventService *iEventManager;       //< For providing interface and route events to the plugins.
   794     MEventService *iEventManager;       //< For providing interface and route events to the plugins.
   790     MDestinationCache *iDestinationCache;  //< Destination cache (for transport protocol params).
   795     MDestinationCache *iDestinationCache;  //< Destination cache (for transport protocol params).
   791     
   796     
   792 public: // GCC doesn't compile Linkage, if this is private! -- msa
   797 public: // GCC doesn't compile Linkage, if this is private! -- msa
   793     RTimeout iTimeout;                  //< Hook to the timer service (MTimeoutManager)
   798     RTimeout iTimeout;					//< Hook to the timer service (MTimeoutManager)
       
   799 public:
       
   800 	// Enumerate domain suffices on an interface and read suffix name to the reference object passed in
       
   801 	virtual TInt DomainSuffixInfo(TName aActiveEnumInterface, TUint aDomainSuffixIndex, TInetSuffix &aDomainSuffix);
   794     };
   802     };
   795 
   803 
   796 //
   804 //
   797 //  CIp6ManagerTimeoutLinkage
   805 //  CIp6ManagerTimeoutLinkage
   798 //  *************************
   806 //  *************************
  1861     // Global flag, used while composing global address from prefix of RA (with 'A' flag set)
  1869     // Global flag, used while composing global address from prefix of RA (with 'A' flag set)
  1862     TBool iGlobalflag;
  1870     TBool iGlobalflag;
  1863 #endif //SYMBIAN_TCPIPDHCP_UPDATE
  1871 #endif //SYMBIAN_TCPIPDHCP_UPDATE
  1864 public: // GCC doesn't compile CIp6InterfaceLinkage, if this is private! -- msa
  1872 public: // GCC doesn't compile CIp6InterfaceLinkage, if this is private! -- msa
  1865     RTimeout iTimeout;          //< Hook to the timer service (MTimeoutManager)
  1873     RTimeout iTimeout;          //< Hook to the timer service (MTimeoutManager)
       
  1874 private:
       
  1875     RInetSuffixList iSuffixList;	// Container to store list of optional domain search list on the interface
       
  1876 private:
       
  1877 	// Process SetOpt request for updating domain suffices based on the function mode set on the structure passed in
       
  1878 	void ProcessDomainSuffixL(const TInetSuffix* aSuffix);
  1866     };
  1879     };
  1867 
  1880 
  1868 //
  1881 //
  1869 //  CIp6InterfaceTimeoutLinkage
  1882 //  CIp6InterfaceTimeoutLinkage
  1870 //  ***********************
  1883 //  ***********************
  3410             }
  3423             }
  3411 #endif
  3424 #endif
  3412         TPckgBuf<TSoIfConnectionInfo> netinfo;
  3425         TPckgBuf<TSoIfConnectionInfo> netinfo;
  3413         netinfo().iIAPId = iRoute->iInterface.iScope[EScopeType_IAP];
  3426         netinfo().iIAPId = iRoute->iInterface.iScope[EScopeType_IAP];
  3414         netinfo().iNetworkId = iRoute->iInterface.iScope[EScopeType_NET];
  3427         netinfo().iNetworkId = iRoute->iInterface.iScope[EScopeType_NET];
       
  3428 
       
  3429    if(iInfo.iLockType == EScopeType_IAP  && iInfo.iLockId != netinfo().iIAPId)
       
  3430             {
       
  3431                 iInfo.iLockId = netinfo().iIAPId;
       
  3432 	#ifdef _LOG
       
  3433                  Log::Printf(_L("\t\tFlow[%u] Connect ConnectionInfo changed: Lock_type:%d, Lock_id:%d"),this,iInfo.iLockType, iInfo.iLockId); 
       
  3434 	#endif
       
  3435             }
       
  3436 
  3415         Bearer(netinfo);
  3437         Bearer(netinfo);
  3416         RefreshFlow();
  3438         RefreshFlow();
  3417         return;
  3439         return;
  3418         }
  3440         }
  3419     //
  3441     //
  5533 //  value stored as ID is also *ALWAYS* a valid full address for this
  5555 //  value stored as ID is also *ALWAYS* a valid full address for this
  5534 //  interface (some code may depend on it!)
  5556 //  interface (some code may depend on it!)
  5535 */
  5557 */
  5536 TInt CIp6Interface::SetId(TIp6AddressInfo &aId, const TIp6Addr &aAddr, const TInt aPrefix, const TInt aAddressType)
  5558 TInt CIp6Interface::SetId(TIp6AddressInfo &aId, const TIp6Addr &aAddr, const TInt aPrefix, const TInt aAddressType)
  5537     {
  5559     {
  5538     // Should this also check whether address type is same?
       
  5539     // Changing just type does not work with this code!
       
  5540     // -- msa 24.10.2003
       
  5541     if (aPrefix < 0 || aPrefix > 128)
  5560     if (aPrefix < 0 || aPrefix > 128)
  5542         return 0;       // Invalid length, do nothing!
  5561         return 0;       // Invalid length, do nothing!
  5543     if (TIp46Addr::Cast(aAddr).IsMulticast())
  5562     if (TIp46Addr::Cast(aAddr).IsMulticast())
  5544         return 0;       // A multicast address cannot be my own.
  5563         return 0;       // A multicast address cannot be my own.
       
  5564     // Should this also check whether address type is same?
       
  5565     // Changing just type does not work with this code!
       
  5566     // -- msa 24.10.2003
  5545     if (aId.IsSet() && aPrefix == aId.iPrefix && aAddr.IsEqual(aId.iId))
  5567     if (aId.IsSet() && aPrefix == aId.iPrefix && aAddr.IsEqual(aId.iId))
  5546         {
  5568         {
  5547 		// Id has not changed but expecting some change in any of 
  5569 		// Id has not changed but expecting some change in any of 
  5548 		// the other interface fields. So raising a Interface change event
  5570 		// the other interface fields. So raising a Interface change event
  5549 		// for the subscribers to keep themselves updated
  5571 		// for the subscribers to keep themselves updated
  7280     {
  7302     {
  7281     // Note: Reset does some extra inits, which
  7303     // Note: Reset does some extra inits, which
  7282     // are wasted on destructor. Should not cause
  7304     // are wasted on destructor. Should not cause
  7283     // any problems... -- msa
  7305     // any problems... -- msa
  7284     Reset();
  7306     Reset();
       
  7307     iSuffixList.Close();
  7285     LOG(Log::Printf(_L("\tIF %u [%S] Deleted"), iScope[0], &iName));
  7308     LOG(Log::Printf(_L("\tIF %u [%S] Deleted"), iScope[0], &iName));
  7286     }
  7309     }
  7287 
  7310 
  7288 // CIp6Interface::Reset
  7311 // CIp6Interface::Reset
  7289 // ********************
  7312 // ********************
  9410 
  9433 
  9411 // CIp6Manager::InterfaceInfo
  9434 // CIp6Manager::InterfaceInfo
  9412 // **************************
  9435 // **************************
  9413 /**
  9436 /**
  9414 // Locate the next interface after aIndex and return the
  9437 // Locate the next interface after aIndex and return the
  9415 // information and assigned interface index.
  9438 // information and assigned interface index
  9416 //
  9439 // The structure being used is a legacy type for retreiving basic information
       
  9440 //
       
  9441 // @param aIndex    index in the interface list after which we need extract the interface information
       
  9442 // @param aInfo     Structure to store interface properties for the application layer to read
  9417 // @return
  9443 // @return
  9418 //  @li = 0, if no next interface exists
  9444 //  @li = 0, if no next interface exists
  9419 //  @li > 0, interface index, aInfo updated to describe this interface
  9445 //  @li > 0, interface index, aInfo updated to describe this interface
  9420 */
  9446 */
  9421 TUint CIp6Manager::InterfaceInfo(TUint aIndex, TSoInetInterfaceInfo &aInfo) const
  9447 TUint CIp6Manager::InterfaceInfo(TUint aIndex, TSoInetInterfaceInfo &aInfo) const
  9422     {
  9448 	{
  9423     // ..yes, this is silly O(n!) (?) algorithm for scanning the interfaces. Each time
  9449     // ..yes, this is silly O(n!) (?) algorithm for scanning the interfaces. Each time
  9424     // this is called, it has find and count all entries that come before the specified
  9450     // this is called, it has find and count all entries that come before the specified
  9425     // aIndex.
  9451     // aIndex.
  9426     // Also, if between calls, prefixes or id's have been added or removed, the algorithm
  9452     // Also, if between calls, prefixes or id's have been added or removed, the algorithm
  9427     // fails and returns same entries multiple times or skips some that it should have
  9453     // fails and returns same entries multiple times or skips some that it should have
  9569             iface->SetAddressAndScope(aInfo.iAddress, aInfo.iAddress);
  9595             iface->SetAddressAndScope(aInfo.iAddress, aInfo.iAddress);
  9570             return i;
  9596             return i;
  9571             }
  9597             }
  9572         }
  9598         }
  9573     return 0;
  9599     return 0;
  9574     }
  9600 	}
  9575 
  9601 
       
  9602 // CIp6Manager::DomainSuffixInfo
       
  9603 // *****************************
       
  9604 /**
       
  9605 // Locate the next domain suffix after aDomainSuffixIndex on the interface with name aActiveEnumInterface
       
  9606 // and return the information and assigned domain suffix index.
       
  9607 // The structure being used is a new type for retreiving extended information
       
  9608 //
       
  9609 // @param aActiveEnumInterface  active interface name on which enumeration is to carried out
       
  9610 // @param aDomainSuffixIndex    index in the domain suffix list after which we need extract the information
       
  9611 // @param aInfoStructure 		to store domain suffix properties for the application layer to read
       
  9612 // @return
       
  9613 //  @li = 0, if no next domain suffix exists
       
  9614 //  @li > 0, interface index, aInfo updated to describe this domain suffix in the list
       
  9615 //	@li = KErrNotFound, if interface does not exist (or) when no domain suffix available for the interfce
       
  9616 */
       
  9617 TInt CIp6Manager::DomainSuffixInfo(TName aActiveEnumInterface, TUint aDomainSuffixIndex, TInetSuffix &aDomainSuffix)
       
  9618     {
       
  9619 	CIp6Interface* iface = FindInterface(aActiveEnumInterface);
       
  9620 	
       
  9621     if (iface == NULL)
       
  9622     	{
       
  9623     	return KErrNotFound;
       
  9624 		}
       
  9625     	
       
  9626 	TInt count = iface->iSuffixList.Count();
       
  9627 	if(count == 0 || count < aDomainSuffixIndex)
       
  9628 		return KErrNotFound;
       
  9629 		
       
  9630 	if (count == aDomainSuffixIndex)    	
       
  9631 		return 0;
       
  9632 		
       
  9633 	aDomainSuffix.Copy(iface->iSuffixList[aDomainSuffixIndex]);
       
  9634     aDomainSuffix.iDomainSuffixFunction = EInetFunctionUndefined;
       
  9635     
       
  9636     return ++aDomainSuffixIndex;
       
  9637     }
  9576 
  9638 
  9577 TInt CIp6Manager::GetInterfaces(TDes8& aOption) const
  9639 TInt CIp6Manager::GetInterfaces(TDes8& aOption) const
  9578     {
  9640     {
  9579     TOverlayArray<TInetInterfaceInfo> info(aOption);
  9641     TOverlayArray<TInetInterfaceInfo> info(aOption);
  9580     TInt idx = 0, exceed = 0;
  9642     TInt idx = 0, exceed = 0;
  9987     return KErrNone;
 10049     return KErrNone;
  9988     }
 10050     }
  9989 
 10051 
  9990 // CIp6Manager::InetInterfaceOption
 10052 // CIp6Manager::InetInterfaceOption
  9991 // ********************************
 10053 // ********************************
  9992 // Modify Inet Interface information (SetOption part)
 10054 // Modify Inet Interface information (SetOption part!) for TSoInet6InterfaceInfo input
  9993 //
 10055 // For maintaining backward compatibility
  9994 TInt CIp6Manager::InetInterfaceOption(TUint aName, const TSoInet6InterfaceInfo &aInfo)
 10056 //
       
 10057 TInt CIp6Manager::InetInterfaceOption(TUint aName, const TSoInet6InterfaceInfo &aInfo, const TInetSuffix* aDomainSuffix)
  9995     {
 10058     {
  9996     #ifdef _LOG
 10059     #ifdef _LOG
  9997         TBuf<39> addressStr;
 10060         TBuf<39> addressStr;
  9998         aInfo.iAddress.Output( addressStr );
 10061         aInfo.iAddress.Output( addressStr );
  9999         TBuf<39> netMaskStr;
 10062         TBuf<39> netMaskStr;
 10146         return prefix;  // Bad address information
 10209         return prefix;  // Bad address information
 10147     if (aInfo.iMtu > 0)
 10210     if (aInfo.iMtu > 0)
 10148         iface->iSMtu = iface->iRMtu = iface->iPMtu = aInfo.iMtu;
 10211         iface->iSMtu = iface->iRMtu = iface->iPMtu = aInfo.iMtu;
 10149     if (aInfo.iSpeedMetric > 0)
 10212     if (aInfo.iSpeedMetric > 0)
 10150         iface->iSpeedMetric = aInfo.iSpeedMetric;
 10213         iface->iSpeedMetric = aInfo.iSpeedMetric;
       
 10214 
       
 10215 	// Copy the domain search list (if any) to the interface object
       
 10216 	if (aDomainSuffix)
       
 10217 		{
       
 10218 		TRAPD(err, iface->ProcessDomainSuffixL(aDomainSuffix));
       
 10219 		if (err != KErrNone)
       
 10220 			return err;
       
 10221 		}
       
 10222     	
 10151     if (aInfo.iDoState)
 10223     if (aInfo.iDoState)
 10152         {
 10224         {
 10153         if (aInfo.iState == EIfDown)
 10225         if (aInfo.iState == EIfDown)
 10154             iface->iState = KErrNotReady;
 10226             iface->iState = KErrNotReady;
 10155         else if (aInfo.iState == EIfUp)
 10227         else if (aInfo.iState == EIfUp)
 10263         iface->GetRoute(addr, prefix, KRouteAdd_ONLINK, NULL, &lifetime);
 10335         iface->GetRoute(addr, prefix, KRouteAdd_ONLINK, NULL, &lifetime);
 10264         }
 10336         }
 10265     return KErrNone;
 10337     return KErrNone;
 10266     }
 10338     }
 10267 
 10339 
       
 10340 // CIp6Manager::ProcessDomainSuffixL
       
 10341 // *********************************
       
 10342 // Process SetOpt calls with TSoInetInterfaceInfoExtnDnsSuffix which contains
       
 10343 // domain suffix information for the interface in form of TInetSuffix structure
       
 10344 // This function is responsible to perform domain suffix updates (i.e. add/delete/deleteall)
       
 10345 // to the interface based on the operation mode specified in the structure
       
 10346 void CIp6Interface::ProcessDomainSuffixL(const TInetSuffix* aSuffix)
       
 10347 	{
       
 10348 	if (aSuffix->iDomainSuffixFunction == EInetAddSuffix)
       
 10349 		{
       
 10350 		// Perform addition of the incoming suffix name to the list maintained by interface object
       
 10351 		iSuffixList.AppendL(aSuffix->iSuffixName);
       
 10352 		TSuffixName tmpBuf;
       
 10353 		tmpBuf.Copy(iSuffixList[iSuffixList.Count()-1]);
       
 10354 		LOG(Log::Printf( _L( "Added domain suffix to interface %S - %S"), &iName, &tmpBuf));
       
 10355 		}
       
 10356 	else if(aSuffix->iDomainSuffixFunction == EInetDeleteSuffix)
       
 10357 		{
       
 10358 		// Perform deletion of the suffix name from the list of suffices in the interface object
       
 10359 		TInt pos;
       
 10360 		pos = iSuffixList.Find(aSuffix->iSuffixName);
       
 10361 		User::LeaveIfError(pos);
       
 10362 		TSuffixName tmpBuf;
       
 10363 		tmpBuf.Copy(iSuffixList[pos]);
       
 10364 		iSuffixList.Remove(pos);
       
 10365 		LOG(Log::Printf( _L( "Removed domain suffix from interface %S - %S"), &iName, &tmpBuf));
       
 10366 		}
       
 10367 	else if (aSuffix->iDomainSuffixFunction == EInetDeleteAllSuffixes)
       
 10368 		{
       
 10369 		// Flush out all the suffix entries in the interface
       
 10370 		iSuffixList.Reset();
       
 10371 		LOG(Log::Printf( _L( "Removed all domain suffix from interface %S"), &iName));
       
 10372 		}
       
 10373 	}
       
 10374 
       
 10375 // CIp6Manager::InetInterfaceOption
       
 10376 // ******************************** 
       
 10377 // Modify Inet Interface information (SetOption part!) for TSoInetInterfaceInfoExtnDnsSuffix input
       
 10378 // To support supplementary fields i.e. domain search list on an interface
       
 10379 //
       
 10380 TInt CIp6Manager::InetInterfaceOption(TUint aName, const TSoInetInterfaceInfoExtnDnsSuffix &aInfo)
       
 10381     {
       
 10382     return InetInterfaceOption(aName, (TSoInet6InterfaceInfo)aInfo, &aInfo.iDomainSuffix);
       
 10383     }
       
 10384 
 10268 //
 10385 //
 10269 // CIpManager::InterfaceOption
 10386 // CIpManager::InterfaceOption
 10270 // ***************************
 10387 // ***************************
 10271 /**
 10388 /**
 10272 // This method implements *BOTH* SetOption and GetOption when level KSOLInterface
 10389 // This method implements *BOTH* SetOption and GetOption when level KSOLInterface
 10402         if (ret != KErrNone)
 10519         if (ret != KErrNone)
 10403             return ret;
 10520             return ret;
 10404         if (aName == KSoIpv4LinkLocal &&
 10521         if (aName == KSoIpv4LinkLocal &&
 10405                 aOption.Length() == sizeof(TSoInetIpv4LinkLocalInfo))
 10522                 aOption.Length() == sizeof(TSoInetIpv4LinkLocalInfo))
 10406             return SetIpv4LinkLocalOption((TSoInetIpv4LinkLocalInfo &)ref);
 10523             return SetIpv4LinkLocalOption((TSoInetIpv4LinkLocalInfo &)ref);
 10407         
 10524         if (aOption.Length() == sizeof(TSoInet6InterfaceInfo))
 10408         if (aOption.Length() != sizeof(TSoInet6InterfaceInfo))
 10525             {
       
 10526 			// if the SetOpt() requested with TSoInet6InterfaceInfo structure (legacy)
       
 10527             return InetInterfaceOption(aName, (TSoInet6InterfaceInfo &)ref, NULL);
       
 10528             }
       
 10529         else if (aOption.Length() == sizeof(TSoInetInterfaceInfoExtnDnsSuffix))
       
 10530 			{
       
 10531 			// if the SetOpt() requested with new TSoInetInterfaceInfoExtnDnsSuffix structure
       
 10532             return InetInterfaceOption(aName, (TSoInetInterfaceInfoExtnDnsSuffix &)ref);
       
 10533 			}
       
 10534         else
 10409             return KErrArgument;
 10535             return KErrArgument;
 10410         return InetInterfaceOption(aName, (TSoInet6InterfaceInfo &)ref);
       
 10411         }
 10536         }
 10412     else if (aLevel == KSOLInterface)
 10537     else if (aLevel == KSOLInterface)
 10413         {
 10538         {
 10414         const TInt ret = aChecker.CheckPolicy(KPolicyNetworkControl, 0);
 10539         const TInt ret = aChecker.CheckPolicy(KPolicyNetworkControl, 0);
 10415         if (ret != KErrNone)
 10540         if (ret != KErrNone)