diff -r abbed5a4b42a -r 8d540f55e491 tcpiputils/dnd/src/servers.cpp --- a/tcpiputils/dnd/src/servers.cpp Tue Aug 31 16:45:15 2010 +0300 +++ b/tcpiputils/dnd/src/servers.cpp Wed Sep 01 12:33:58 2010 +0100 @@ -1,4 +1,3 @@ -// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -36,6 +35,7 @@ public: TName iName; //< Name of the interface TUint32 iScope[16]; //< The scope vector + RInetSuffixList iSuffixList;//< Structure to hold the interface specific domain search list }; // Item of the configured servers list @@ -70,6 +70,10 @@ TInt BuildServerList(); void AddServerAddress(const TName &aInterface, const TInetAddr &aAddr); void LockByAddress(const TInetAddr &aAddr, TUint32 aNid, TDnsServerFilter &aFilter); + // Retrieves the domain search list configured on the interface associated with the nominated name server + void InterfaceSuffixList(TInt aServerId, RInetSuffixList& aSuffixList); + // Performs the network id selection for the query based on the domain name on the query + void UpdateDomain(TDnsServerFilter &aFilter) const; private: // Build and add interface entry to the list (basic operation) @@ -93,6 +97,9 @@ CArrayFixFlat *iServerList; //< Current list of servers CArrayFixFlat *iInterfaceList; //< Current list of interfaces CArrayFixFlat *iConfiguredList; //< Current list of configured servers + +private: + TInt AddInterfaceEntry(const TSoInetIfQuery &aInfo, RSocket& aSocket); }; @@ -140,18 +147,44 @@ delete iConfiguredList; } -// CDnsServerManager::AddInterfaceData -TInt CDnsServerManager::AddInterfaceEntry(const TSoInetIfQuery &aInfo) +// CDnsServerManager::AddInterfaceEntry +TInt CDnsServerManager::AddInterfaceEntry(const TSoInetIfQuery &aInfo, RSocket& aSocket) { - TRAPD(err, - TDnsInterfaceData &ifd = iInterfaceList->ExtendL(); - ifd.iName = aInfo.iName; - for (TInt i = sizeof(ifd.iScope) / sizeof(ifd.iScope[0]); --i >= 0; ) - ifd.iScope[i] = aInfo.iZone[i]; + TRAPD(err, + TDnsInterfaceData &ifd = iInterfaceList->ExtendL(); + + ifd.iName = aInfo.iName; + for (TInt i = sizeof(ifd.iScope) / sizeof(ifd.iScope[0]); --i >= 0; ) + ifd.iScope[i] = aInfo.iZone[i]; + + if (aSocket.SetOpt(KSoInetEnumDomainSuffix, KSolInetIfCtrl) == KErrNone) + { + ifd.iSuffixList.Reset(); + TInetSuffix data; + TPckg opt(data); + while (aSocket.GetOpt(KSoInetNextDomainSuffix, KSolInetIfCtrl, opt) == KErrNone) + { + TSuffixName tmpBuf; + tmpBuf.Copy(opt().iSuffixName); + ifd.iSuffixList.AppendL(tmpBuf); + } + } ); + return err < 0 ? err : iInterfaceList->Count() - 1; } +TInt CDnsServerManager::AddInterfaceEntry(const TSoInetIfQuery &aInfo) + { + TRAPD(err, + TDnsInterfaceData &ifd = iInterfaceList->ExtendL(); + ifd.iName = aInfo.iName; + for (TInt i = sizeof(ifd.iScope) / sizeof(ifd.iScope[0]); --i >= 0; ) + ifd.iScope[i] = aInfo.iZone[i]; + ); + return err < 0 ? err : iInterfaceList->Count() - 1; + } + // CDnsServerManager::AddToInterfaceList // ************************************* /** @@ -178,13 +211,14 @@ if (data.iName.Compare(aInfo.iName) == 0) return i; // Interface already present in the list } + // // A new interface, get the scope vector // TPckgBuf opt; opt().iName = aInfo.iName; const TInt err = aSocket.GetOpt(KSoInetIfQueryByName, KSolInetIfQuery, opt); - return err < 0 ? err : AddInterfaceEntry(opt()); + return err < 0 ? err : AddInterfaceEntry(opt(), aSocket); } // CDnsServerManager::FindInterface @@ -445,6 +479,32 @@ return TRUE; } +/** +// @name UpdateDomain +// @param aFilter the server filter +// @param aServer to be tested against the filter +*/ +void CDnsServerManager::UpdateDomain(TDnsServerFilter &aFilter) const + { + LOG(Log::Printf(_L("CDnsServerManager -- RHostResolver opened on implicit connection"))); + if ( aFilter.iDomainName.Length() ) + { + TBool updatedDomain(FALSE); + for (TInt i = iInterfaceList->Count(); --i >= 0 && !updatedDomain; ) + { + TDnsInterfaceData &id = iInterfaceList->At(i); + for (TInt i=0; iCount(); + for (TInt i = 0; i < N; ++i) + { + const TDnsServerData &server = iServerList->At(i); + if (server.iServerId == aServerId) + { + aSuffixList = iInterfaceList->At(server.iInterface).iSuffixList; + break; + } + } + }