Committing ZeroConf for 10.1 to the FCL.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/bwins/distribution.policy Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,2 @@
+Category E
+OSD: Optional Replaceable Bonjour Framework
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/bwins/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/bwins/mdnscachemanageru.def Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,29 @@
+EXPORTS
+ ?SetPtrRecord@CCacheEntry@@QAEXPAVCRdTypePtr@@@Z @ 1 NONAME ; void CCacheEntry::SetPtrRecord(class CRdTypePtr *)
+ ?NumberOfEntries@CMDNSCacheManager@@UAEIXZ @ 2 NONAME ; unsigned int CMDNSCacheManager::NumberOfEntries(void)
+ ?DeleteEntryL@CMDNSCacheManager@@UAEHABVTDesC8@@@Z @ 3 NONAME ; int CMDNSCacheManager::DeleteEntryL(class TDesC8 const &)
+ ?AuthoritativeEntriesL@CMDNSCacheManager@@UAEXAAV?$RPointerArray@VCCacheEntry@@@@@Z @ 4 NONAME ; void CMDNSCacheManager::AuthoritativeEntriesL(class RPointerArray<class CCacheEntry> &)
+ ?DumpCacheL@CMDNSCacheManager@@UAEXXZ @ 5 NONAME ; void CMDNSCacheManager::DumpCacheL(void)
+ ?CacheEntryCount@CMDNSCacheManager@@QAEKXZ @ 6 NONAME ; unsigned long CMDNSCacheManager::CacheEntryCount(void)
+ ?SetAddressRecord@CCacheEntry@@QAEXPAVCRdTypeA@@@Z @ 7 NONAME ; void CCacheEntry::SetAddressRecord(class CRdTypeA *)
+ ?NewL@CMDNSCacheManager@@SAPAV1@I@Z @ 8 NONAME ; class CMDNSCacheManager * CMDNSCacheManager::NewL(unsigned int)
+ ?IsAuthoritative@CCacheEntry@@QBEHXZ @ 9 NONAME ; int CCacheEntry::IsAuthoritative(void) const
+ ?NextStaleEntry@CMDNSCacheManager@@UAEPAVCCacheEntry@@HH@Z @ 10 NONAME ; class CCacheEntry * CMDNSCacheManager::NextStaleEntry(int, int)
+ ?SetTxtRecord@CCacheEntry@@QAEXPAVCRdTypeTxt@@@Z @ 11 NONAME ; void CCacheEntry::SetTxtRecord(class CRdTypeTxt *)
+ ?FlushCache@CMDNSCacheManager@@UAEXXZ @ 12 NONAME ; void CMDNSCacheManager::FlushCache(void)
+ ?PtrRecord@CCacheEntry@@QBEPAVCRdTypePtr@@XZ @ 13 NONAME ; class CRdTypePtr * CCacheEntry::PtrRecord(void) const
+ ?NewLC@CCacheEntry@@SAPAV1@XZ @ 14 NONAME ; class CCacheEntry * CCacheEntry::NewLC(void)
+ ?NewL@CCacheEntry@@SAPAV1@XZ @ 15 NONAME ; class CCacheEntry * CCacheEntry::NewL(void)
+ ?SetAuthoritative@CCacheEntry@@QAEXH@Z @ 16 NONAME ; void CCacheEntry::SetAuthoritative(int)
+ ?TxtRecord@CCacheEntry@@QBEPAVCRdTypeTxt@@XZ @ 17 NONAME ; class CRdTypeTxt * CCacheEntry::TxtRecord(void) const
+ ?SessionId@CCacheEntry@@QBEKXZ @ 18 NONAME ; unsigned long CCacheEntry::SessionId(void) const
+ ?SetSessionId@CCacheEntry@@QAEXK@Z @ 19 NONAME ; void CCacheEntry::SetSessionId(unsigned long)
+ ?SetServiceRecord@CCacheEntry@@QAEXPAVCRdTypeSrv@@@Z @ 20 NONAME ; void CCacheEntry::SetServiceRecord(class CRdTypeSrv *)
+ ?FindServiceL@CMDNSCacheManager@@UBEHAAV?$RPointerArray@VCCacheEntry@@@@ABVTDesC8@@W4TDnsType@@@Z @ 21 NONAME ; int CMDNSCacheManager::FindServiceL(class RPointerArray<class CCacheEntry> &, class TDesC8 const &, enum TDnsType) const
+ ?EntryExpired@CCacheEntry@@QBEHXZ @ 22 NONAME ; int CCacheEntry::EntryExpired(void) const
+ ?UpdateCacheL@CMDNSCacheManager@@UAEXAAVCDnsResourceData@@HK@Z @ 23 NONAME ; void CMDNSCacheManager::UpdateCacheL(class CDnsResourceData &, int, unsigned long)
+ ?AddressRecord@CCacheEntry@@QBEPAVCRdTypeA@@XZ @ 24 NONAME ; class CRdTypeA * CCacheEntry::AddressRecord(void) const
+ ?ServiceRecord@CCacheEntry@@QBEPAVCRdTypeSrv@@XZ @ 25 NONAME ; class CRdTypeSrv * CCacheEntry::ServiceRecord(void) const
+ ?NewLC@CMDNSCacheManager@@SAPAV1@I@Z @ 26 NONAME ; class CMDNSCacheManager * CMDNSCacheManager::NewLC(unsigned int)
+ ?NewL@CMDNSCacheManager@@SAPAV1@XZ @ 27 NONAME ; class CMDNSCacheManager * CMDNSCacheManager::NewL(void)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/eabi/distribution.policy Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,2 @@
+Category E
+OSD: Optional Replaceable Bonjour Framework
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/eabi/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/eabi/mdnscachemanageru.def Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,41 @@
+EXPORTS
+ _ZN11CCacheEntry12SetPtrRecordEP10CRdTypePtr @ 1 NONAME
+ _ZN11CCacheEntry12SetSessionIdEm @ 2 NONAME
+ _ZN11CCacheEntry12SetTxtRecordEP10CRdTypeTxt @ 3 NONAME
+ _ZN11CCacheEntry16SetAddressRecordEP8CRdTypeA @ 4 NONAME
+ _ZN11CCacheEntry16SetAuthoritativeEi @ 5 NONAME
+ _ZN11CCacheEntry16SetServiceRecordEP10CRdTypeSrv @ 6 NONAME
+ _ZN11CCacheEntry4NewLEv @ 7 NONAME
+ _ZN11CCacheEntry5NewLCEv @ 8 NONAME
+ _ZN17CMDNSCacheManager10DumpCacheLEv @ 9 NONAME
+ _ZN17CMDNSCacheManager10FlushCacheEv @ 10 NONAME
+ _ZN17CMDNSCacheManager12DeleteEntryLERK6TDesC8 @ 11 NONAME
+ _ZN17CMDNSCacheManager12UpdateCacheLER16CDnsResourceDataim @ 12 NONAME
+ _ZN17CMDNSCacheManager14NextStaleEntryEii @ 13 NONAME
+ _ZN17CMDNSCacheManager15CacheEntryCountEv @ 14 NONAME
+ _ZN17CMDNSCacheManager4NewLEj @ 15 NONAME
+ _ZN17CMDNSCacheManager5NewLCEj @ 16 NONAME
+ _ZNK11CCacheEntry12EntryExpiredEv @ 17 NONAME
+ _ZNK11CCacheEntry13AddressRecordEv @ 18 NONAME
+ _ZNK11CCacheEntry13ServiceRecordEv @ 19 NONAME
+ _ZNK11CCacheEntry15IsAuthoritativeEv @ 20 NONAME
+ _ZNK11CCacheEntry9PtrRecordEv @ 21 NONAME
+ _ZNK11CCacheEntry9SessionIdEv @ 22 NONAME
+ _ZNK11CCacheEntry9TxtRecordEv @ 23 NONAME
+ _ZNK17CMDNSCacheManager12FindServiceLER13RPointerArrayI11CCacheEntryERK6TDesC88TDnsType @ 24 NONAME
+ _ZTI11CCacheEntry @ 25 NONAME
+ _ZTI12CServiceInfo @ 26 NONAME
+ _ZTI13CMDNSCacheMap @ 27 NONAME
+ _ZTI17CMDNSCacheManager @ 28 NONAME
+ _ZTV11CCacheEntry @ 29 NONAME
+ _ZTV12CServiceInfo @ 30 NONAME
+ _ZTV13CMDNSCacheMap @ 31 NONAME
+ _ZTV17CMDNSCacheManager @ 32 NONAME
+ _ZThn4_N17CMDNSCacheManager10DumpCacheLEv @ 33 NONAME
+ _ZThn4_N17CMDNSCacheManager10FlushCacheEv @ 34 NONAME
+ _ZThn4_N17CMDNSCacheManager12DeleteEntryLERK6TDesC8 @ 35 NONAME
+ _ZThn4_N17CMDNSCacheManager12UpdateCacheLER16CDnsResourceDataim @ 36 NONAME
+ _ZThn4_N17CMDNSCacheManager14NextStaleEntryEii @ 37 NONAME
+ _ZThn4_NK17CMDNSCacheManager12FindServiceLER13RPointerArrayI11CCacheEntryERK6TDesC88TDnsType @ 38 NONAME
+ _ZN17CMDNSCacheManager4NewLEv @ 39 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/group/bld.inf Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,29 @@
+/*
+ Copyright (c) 2007 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"
+ which accompanies this distribution, and is available
+ at the URL "http://www.eclipse.org/legal/epl-v10.html".
+
+ Initial Contributors:
+ Nokia Corporation - initial contribution.
+
+ Contributors:
+
+ Description: This file provides the information required for building the
+ mDNS Cache Manager.
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+mdnscachemanager.mmp
+
+PRJ_EXPORTS
+../inc/mdnscachemgr.h /epoc32/include/mdns/mdnscachemgr.h
+../inc/ccacheentry.h /epoc32/include/mdns/ccacheentry.h
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/group/distribution.policy Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,2 @@
+Category E
+OSD: Optional Replaceable Bonjour Framework
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/group/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/group/mdnscachemanager.mmp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,44 @@
+/*
+ Copyright (c) 2007 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"
+ which accompanies this distribution, and is available
+ at the URL "http://www.eclipse.org/legal/epl-v10.html".
+
+ Initial Contributors:
+ Nokia Corporation - initial contribution.
+
+ Contributors:
+
+ Description: Project file for mDNS Cache Manager
+
+*/
+#include <comms-infras/commsdebugutility.mmh>
+
+TARGET mdnscachemanager.dll
+TARGETTYPE DLL
+UID 0x1000008d
+USERINCLUDE ..\inc
+USERINCLUDE ..\..\DnsParser\inc
+SYSTEMINCLUDE \epoc32\include
+USERINCLUDE ..\..\server\inc
+
+
+#ifdef ENABLE_ABIV2_MODE
+DEBUGGABLE
+#endif
+SOURCEPATH ..\src
+SOURCE cmdnscachemap.cpp
+SOURCE cmdnscachemanager.cpp
+SOURCE cserviceinfo.cpp
+
+
+LIBRARY euser.lib
+LIBRARY dnsparser.lib insock.lib commdb.lib
+CAPABILITY All -TCB
+
+SOURCEPATH ..\src
+SOURCE ccacheentry.cpp
+
+MW_LAYER_SYSTEMINCLUDE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/inc/ccacheentry.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef CCACHEENTRY_H_
+#define CCACHEENTRY_H_
+
+#include <mdns/crdtypea.h>
+#include <mdns/crdtypetxt.h>
+#include <mdns/crdtypesrv.h>
+#include <mdns/crdtypeptr.h>
+
+
+class CCacheEntry : public CBase
+ {
+ public:
+
+ IMPORT_C static CCacheEntry* NewL();
+ IMPORT_C static CCacheEntry* NewLC();
+
+ IMPORT_C void SetAddressRecord(CRdTypeA* aAddRecord);
+ IMPORT_C void SetServiceRecord(CRdTypeSrv* aSrvRecord);
+ IMPORT_C void SetPtrRecord(CRdTypePtr* aPtrRecord);
+ IMPORT_C void SetTxtRecord(CRdTypeTxt* aTxtRecord);
+
+ IMPORT_C CRdTypeA* AddressRecord()const;
+ IMPORT_C CRdTypeSrv* ServiceRecord()const;
+ IMPORT_C CRdTypePtr* PtrRecord()const;
+ IMPORT_C CRdTypeTxt* TxtRecord()const;
+
+ IMPORT_C void SetAuthoritative(TBool aAuthoritative);
+ IMPORT_C TBool IsAuthoritative()const;
+
+ IMPORT_C void SetSessionId(TUint32 aSessionId);
+ IMPORT_C TUint32 SessionId()const;
+
+ void SetEntryExpired(TBool aExpired);
+ IMPORT_C TBool EntryExpired()const;
+
+ ~CCacheEntry();
+
+ private:
+
+ void ConstructL();
+ CCacheEntry();
+
+ private:
+
+ CRdTypeA* iAddressRecord;
+ CRdTypeSrv* iServiceRecord;
+ CRdTypePtr* iPtrRecord;
+ CRdTypeTxt* iTxtRecord;
+
+ TBool iAuthoritative;
+ TUint32 iSessionId;
+
+ TBool iEntryExpired;
+
+ };
+
+#endif /*CCACHEENTRY_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/inc/cmdnscacheconsistencymgr_old.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef CMDNSCACHECONSISTENCYMGR_H_
+#define CMDNSCACHECONSISTENCYMGR_H_
+
+#include <e32base.h>
+#include <mdns/mdnscachemgr.h>
+
+
+class CMDNSCacheConsistencyMgr : public CActive
+ {
+ public:
+
+ IMPORT_C static CMDNSCacheConsistencyMgr* NewL(TBool aActiveCacheMgmtEnabled,MDNSCacheMgr& aCache);
+ static CMDNSCacheConsistencyMgr* NewLC(TBool aActiveCacheMgmtEnabled,MDNSCacheMgr& aCache);
+
+ IMPORT_C void Start();
+
+ ~CMDNSCacheConsistencyMgr();
+ void DoCancel();
+
+ private:
+
+ void RunL();
+ TInt RunError(TInt aError);
+
+
+ private:
+
+ CMDNSCacheConsistencyMgr(TBool aActiveCacheMgmtEnabled,MDNSCacheMgr& aCache);
+ void ConstructL();
+
+ private:
+
+ MDNSCacheMgr& iCache;
+
+ TBool iActiveCacheMgmtEnabled;
+
+ TUint iWalkInterval;
+
+ RTimer iTimer;
+ };
+
+
+#endif /*CMDNSCACHECONSISTENCYMGR_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/inc/cmdnscachemanager.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef CMDNSCACHEMANAGER_H_
+#define CMDNSCACHEMANAGER_H_
+
+#include <e32base.h>
+
+#include "cmdnscachemap.h"
+#include "mdnscachemgr.h"
+
+class CMDNSCacheManager : public CBase,public MDNSCacheMgr
+ {
+ public:
+
+ IMPORT_C static CMDNSCacheManager* NewL(TUint aMaxCacheEntries);
+ IMPORT_C static CMDNSCacheManager* NewLC(TUint aMaxCacheEntries);
+ IMPORT_C static CMDNSCacheManager* NewL();
+
+ //From MDNSCacheMgr
+ IMPORT_C void UpdateCacheL(CDnsResourceData& aEntry,TBool aAuthoritative,TUint32 aSessionId);
+ IMPORT_C TInt FindServiceL(RPointerArray <CCacheEntry> & aEntries,const TDesC8& aName,TDnsType aType)const;
+ IMPORT_C TInt DeleteEntryL(const TDesC8& aServiceInstanceName);
+ IMPORT_C void FlushCache();
+ IMPORT_C CCacheEntry* NextStaleEntry(TBool aActiveCacheMgmtEnabled,TBool aIteratorReset);
+ IMPORT_C void AuthoritativeEntriesL(RPointerArray <CCacheEntry> & aEntries);
+ IMPORT_C TUint NumberOfEntries();
+ IMPORT_C void DumpCacheL();
+
+
+ IMPORT_C TUint32 CacheEntryCount();
+
+ ~CMDNSCacheManager();
+
+ private:
+
+ void CacheEntryL(CCacheEntry* aTargetEntry,const CServiceInfo* aSourceEntry)const;
+ void UpdateCacheEntry(CServiceInfo* aEntry,CDnsResourceData* aRecordInfo);
+ CMDNSCacheManager();
+ void ConstructL(TUint aMaxCacheEntries);
+
+ private:
+
+ CMDNSCacheMap* iHashMap;
+
+ RPointerArray <CServiceInfo> iAuthoritativeEntries;
+
+ };
+
+#endif /*CMDNSCACHEMANAGER_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/inc/cmdnscachemap.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef CMDNSCACHEMAP_H_
+#define CMDNSCACHEMAP_H_
+
+#include <e32hashtab.h>
+#include "cserviceinfo.h"
+
+
+class CMDNSCacheMap : public CBase
+ {
+ public:
+
+ static CMDNSCacheMap* NewL(TUint aMaxCacheEntries);
+ static CMDNSCacheMap* NewLC(TUint aMaxCacheEntries);
+
+
+ void UpdateL(const TDesC8& aName, CServiceInfo* aEntry);
+ CServiceInfo* Find(const TDesC8& aServiceInstanceName);
+ void FindEntries(const TDesC8& aName,RPointerArray <const CServiceInfo> & aEntries);
+ /*?? Do I require this method??*/void AuthoritativeRecordsL(RPointerArray <const CServiceInfo> & aEntries);
+ TInt DeleteL(const TDesC8& aServiceInstanceName);
+ void DeleteAllEntries();
+
+ TUint32 NumberOfEntries();
+
+ void DumpCacheL();
+
+ //Used to trace the entire Cache, return number of cache activities
+ CServiceInfo* NextStaleEntry(TBool aActiveCacheMgmtEnabled,TBool aIteratorReset);
+
+ ~CMDNSCacheMap();
+
+
+ private:
+
+ /*What to do if the number of entries in Hash Table exceed 200??
+ * Delete a entries, based on Least Recently Used
+ * Need to keep track of unused entries/ least recently used
+ * in the cache ; to delete them and make room for new entries*/
+
+ //Algorithm to keep track of the Least Recently Used Records
+ TBool DeleteLeastRecentlyUsed();
+
+
+ void ConstructL();
+ CMDNSCacheMap(TUint aMaxCacheEntries);
+
+ private:
+
+ RHashMap<TPtrC8,CServiceInfo*> iCacheEntries;
+
+ THashMapIter<TPtrC8,CServiceInfo*> iterate;
+
+ TUint iMaxCacheEntries;
+
+ /**
+ FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER;
+
+ };
+
+
+#endif /*CMDNSCACHEMAP_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/inc/cmdnsprobemanager.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef CMDNSPROBEMANAGER_H_
+#define CMDNSPROBEMANAGER_H_
+
+#include <e32base.h>
+#include <in_sock.h>
+
+class CMDNSProbeManager : public CTimer
+ {
+ public:
+
+ /*Conflict can happen in 2 cases ,
+ * Case 1: When the Address Record (Type A) is inconsistent, i.e., same
+ * host name for different Ip addresses
+ * Case 2: When the Service Record (Type SRV), is conflicting, two hosts try to
+ * acquire the same service name with the same service type., and same
+
+ /*Case 1:To get Unique Host Name ; to handle Host name conflict,
+ * we need the acquired host name & IPAddress*/
+ static CMDNSProbeManager* NewL(RBuf& aHostName, TInetAddr aAddr);
+ static CMDNSProbeManager* NewLC(RBuf& aHostName, TInetAddr aAddr);
+
+ /*To get Unique Service Name; to handle service name conflict,
+ * we need acquired service name & host name*/
+ static CMDNSProbeManager* NewL(RBuf& aServiceName,RBuf& aHostName);
+ static CMDNSProbeManager* NewLC(RBuf& aServiceName,RBuf& aHostName);
+
+ ~CMDNSProbeManager();
+
+ private:
+
+ void RunL();
+ TInt RunError(TInt aError);
+
+ private:
+
+ TBool CheckForUniqueness();
+
+ void DefensiveResponseReceived();//Get a unique name (DNS Label)
+
+ void SendProbeL(); //Probe for Unique name , Create Probe and Send
+ void SendAnnouncementL();//Send out Gratitous mDNS Announcement , Create Announcement and Send
+ void Schedule(); //Self-Complete, To be called when moved to Probe State.
+
+ void Delay(TUint32 aDelayTime/*In Milliseconds*/); //To introduce Delay between Probes.
+
+ CMDNSProbeManager (RBuf& aHostName, TInetAddr aAddr);
+ CMDNSProbeManager (RBuf& aServiceName,RBuf& aHostName);
+ void ConstructL();
+
+ private:
+
+ enum TProbeStates
+ {
+ EIdle,
+ EProbeBegin,
+ EProbeFirstUnicast,
+ EProbeSecondUnicast,
+ EProbeMulticast,
+ EProbeComplete,
+ EFirstAnnouncement,//First gratuitous mDNS announcement
+ ESecondAnnouncement//Second gratuitous mDNS announcement
+ };
+
+
+ TInetAddr iAddr;
+
+ TProbeStates iCurrentProbeState;
+
+ //MDNSCacheInterface* iCache;
+
+ };
+
+#endif /*CMDNSPROBEMANAGER_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/inc/cserviceinfo.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef CSERVICEINFO_H_
+#define CSERVICEINFO_H_
+
+
+#include "mdnsrecordinfo.h"
+#include "mdnsdebug.h"
+#include <mdns/crdtypea.h>
+#include <mdns/crdtypetxt.h>
+#include <mdns/crdtypesrv.h>
+#include <mdns/crdtypeptr.h>
+
+using namespace HashInfo;
+
+
+class CServiceInfo : public CBase
+ {
+ public:
+
+ static CServiceInfo* NewL();
+ static CServiceInfo* NewLC();
+
+ TBool IsAuthoritative()const;
+ void SetAuthoritative(TBool aAuthoritative);
+
+ const TTime& LastAccessTime()const;
+ void SetAccessTime(TTime aTime);
+
+ TUint32 SessionId()const;
+ void SetSessionId(TUint32 aSessionId);
+
+ void SetAddressRecord(CRdTypeA* aAddressRecord);
+ void SetServiceRecord(CRdTypeSrv* aServiceRecord);
+ void SetPtrRecord(CRdTypePtr* aPtrRecord);
+ void SetTxtRecord(CRdTypeTxt* aTxtRecord);
+
+ const TTime& EntryTime(TCacheEntryType aType)const;
+ const TTime& ExpiryTime(TCacheEntryType aType)const;
+
+ void SetEntryTime(TCacheEntryType aType);
+ void SetExpiryTime(TCacheEntryType aType);
+
+ void SetKeyL(const TDesC8& aKey);
+ const TDesC8& Key()const;
+
+ CRdTypeA* AddressRecord()const;
+ CRdTypeSrv* ServiceRecord()const;
+ CRdTypePtr* PtrRecord()const;
+ CRdTypeTxt* TxtRecord()const;
+
+ TBool EntryExpired();
+
+ TBool EntryToBeQueried();
+
+ CServiceInfo* CloneL()const;
+
+ //Mark the entry as expired if ttl has become zero
+ TBool StaleEntry();
+
+ ~CServiceInfo();
+
+ private:
+
+ void ConstructL();
+ CServiceInfo();
+
+ private:
+
+ CRdTypeA* iAddressRecord;
+ CRdTypeSrv* iServiceRecord;
+ CRdTypePtr* iPtrRecord;
+ CRdTypeTxt* iTxtRecord;
+
+ TTime iLastAccessTime;
+ TBool iAuthoritative;
+ TUint32 iSessionId;
+
+ RBuf8 iKey;
+
+ //Entries are Indexed by TCacheEntryType
+ RArray <TTime> iEntryTime;
+
+ //Entries are Indexed by TCacheEntryType
+ RArray <TTime> iExpiryTime;
+
+ TBool iEntryExpired;
+
+ };
+
+
+#endif /*CSERVICEINFO_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/inc/distribution.policy Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,2 @@
+Category E
+OSD: Optional Replaceable Bonjour Framework
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/inc/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/inc/mdnscachemgr.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef MDNSCACHEMGR_H_
+#define MDNSCACHEMGR_H_
+
+
+#include <e32cmn.h>
+#include <mdns/dnsconstants.h>
+
+
+class CDnsResourceData;
+class CCacheEntry;
+
+
+class MDNSCacheMgr
+ {
+ public:
+
+ /*Inserts a new entry into the Cache
+ @param CDnsResourceData, Resource Record
+ @param aAuthoritative indicates whether the record being inserted is authoritative
+ @param aSessionId, to indicate to which Session does the entry belong to
+ @leave KErrNoMemory if memory could not be allocated to store the copies of Key and Value*/
+ virtual void UpdateCacheL(CDnsResourceData& aEntry,TBool aAuthoritative,TUint32 aSessionId)=0;
+
+ /*Caters to finding varying types of records, for e.g:- find all the entries
+ that correspond to a particular service type or find the host name through the address record
+ @param aEntries List of entries that match the search constraint
+ @param aInfo could represent any serach constraint Service Instance Type or the Host Name
+ @param aType the desired record type
+ */
+ virtual TInt FindServiceL(RPointerArray <CCacheEntry> & aEntries,const TDesC8& aName,TDnsType aType)const=0;
+
+ /*Deletes the specified entry from the Cache
+ @param aServiceInstanceName Instance Name , whose entry needs to be deleted
+ @leave KErrNotFound if specified entry is not found
+ */
+ virtual TInt DeleteEntryL(const TDesC8& aServiceInstanceName)=0;
+
+
+ /*Flush all the entries in the cache
+ * 1. On start up
+ * 2. On Failure
+ * 3. On Topology change
+ */
+ virtual void FlushCache()=0;
+
+ /*During Iteration, fetches the next stale entry ( entry whose ttl has expired - to be deleted
+ or whose 80% ttl has expired - to be queried on the network)
+ @param aActiveCacheMgmtEnabled flag to indicate if Pro-active Cache Mgmt is to be enabled
+ */
+ virtual CCacheEntry* NextStaleEntry(TBool aActiveCacheMgmtEnabled,TBool aIteratorReset)=0;
+
+ /*Returns all the Authoritative Cache En tries for Announcement
+ @param aEntries Output param ,containing all authoritative entries
+ */
+ virtual void AuthoritativeEntriesL(RPointerArray <CCacheEntry> & aEntries)=0;
+
+ /*Returns the current number of entries in Cache*/
+ virtual TUint NumberOfEntries()=0;
+
+ /*Dump all the entries in Cache- Debug Purposes*/
+ virtual void DumpCacheL()=0;
+
+ /*Virtual destructor so that the delete gets called for all the
+ Cache Implementation Interfaces*/
+ virtual ~MDNSCacheMgr(){}
+
+ };
+
+
+
+#endif /*MDNSCACHEMGR_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/inc/mdnsdebug.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef MDNSDEBUG_H_
+#define MDNSDEBUG_H_
+
+#include <comms-infras/commsdebugutility.h>
+
+__FLOG_STMT(_LIT8(KMDNSSubsystem, "MDNS");)
+
+#ifdef __FLOG_ACTIVE
+#define __MDNS_HEAP_FLOG \
+ { \
+ TInt allocated; \
+ TInt largest; \
+ TInt available(User::Heap().Available(largest)); \
+ TInt size(User::Heap().Size()); \
+ User::Heap().AllocSize(allocated); \
+ __FLOG_STATIC_VA((KMDNSSubsystem, KComponent, _L8("Heap: Size = %d, Allocated = %d, Available = %d, Largest block = %d"), size, allocated, available, largest)); \
+ }
+#else
+#define __MDNS_HEAP_FLOG
+#endif // __FLOG_ACTIVE
+#endif /*MDNSDEBUG_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/inc/mdnsrecordinfo.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef MDNSRECORDINFO_H_
+#define MDNSRECORDINFO_H_
+
+#include <e32base.h>
+
+namespace HashInfo
+ {
+ TUint32 TPtrC8Hash(const TPtrC8& aPtr);
+
+ TBool TPtrC8Ident(const TPtrC8& aL, const TPtrC8& aR);
+
+ enum TCacheEntryType
+ {
+ ECacheEntryAddr,
+ ECacheEntryPtr,
+ ECacheEntrySrv,
+ ECacheEntryTxt
+ };
+
+ }
+
+#endif /*MDNSRECORDINFO_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/src/ccacheentry.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,125 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+#include "ccacheentry.h"
+
+EXPORT_C CCacheEntry* CCacheEntry::NewL()
+ {
+ CCacheEntry* self = CCacheEntry::NewLC();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+EXPORT_C CCacheEntry* CCacheEntry::NewLC()
+ {
+ CCacheEntry* self = new (ELeave)CCacheEntry();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+ }
+
+void CCacheEntry::ConstructL()
+ {
+
+ }
+
+CCacheEntry::CCacheEntry()
+ {
+
+ }
+
+CCacheEntry::~CCacheEntry()
+ {
+ delete iAddressRecord;
+ delete iServiceRecord;
+ delete iPtrRecord;
+ delete iTxtRecord;
+ }
+
+EXPORT_C void CCacheEntry::SetAddressRecord(CRdTypeA* aAddRecord)
+ {
+ iAddressRecord = aAddRecord;
+ }
+
+EXPORT_C void CCacheEntry::SetServiceRecord(CRdTypeSrv* aSrvRecord)
+ {
+ iServiceRecord = aSrvRecord;
+ }
+
+EXPORT_C void CCacheEntry::SetPtrRecord(CRdTypePtr* aPtrRecord)
+ {
+ iPtrRecord = aPtrRecord;
+ }
+
+EXPORT_C void CCacheEntry::SetTxtRecord(CRdTypeTxt* aTxtRecord)
+ {
+ iTxtRecord = aTxtRecord;
+ }
+
+EXPORT_C CRdTypeA* CCacheEntry::AddressRecord()const
+ {
+ return iAddressRecord;
+ }
+
+EXPORT_C CRdTypeSrv* CCacheEntry::ServiceRecord()const
+ {
+ return iServiceRecord;
+ }
+
+EXPORT_C CRdTypePtr* CCacheEntry::PtrRecord()const
+ {
+ return iPtrRecord;
+ }
+
+EXPORT_C CRdTypeTxt* CCacheEntry::TxtRecord()const
+ {
+ return iTxtRecord;
+ }
+
+EXPORT_C TBool CCacheEntry::IsAuthoritative()const
+ {
+ return iAuthoritative;
+ }
+
+EXPORT_C void CCacheEntry::SetAuthoritative(TBool aAuthoritative)
+ {
+ iAuthoritative = aAuthoritative;
+ }
+
+EXPORT_C void CCacheEntry::SetSessionId(TUint32 aSessionId)
+ {
+ iSessionId = aSessionId;
+ }
+
+EXPORT_C TUint32 CCacheEntry::SessionId()const
+ {
+ return iSessionId;
+ }
+
+void CCacheEntry::SetEntryExpired(TBool aEntryExpired)
+ {
+ iEntryExpired = aEntryExpired;
+ }
+
+EXPORT_C TBool CCacheEntry::EntryExpired()const
+ {
+ return iEntryExpired;
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/src/cmdnscachemanager.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,413 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include "cmdnscachemanager.h"
+#include "cserviceinfo.h"
+#include "ccacheentry.h"
+#include "dnsconstants.h"
+
+using namespace HashInfo;
+
+EXPORT_C CMDNSCacheManager* CMDNSCacheManager::NewL(TUint aMaxCacheEntries)
+ {
+ CMDNSCacheManager* self = CMDNSCacheManager::NewLC(aMaxCacheEntries);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+EXPORT_C CMDNSCacheManager* CMDNSCacheManager::NewLC(TUint aMaxCacheEntries)
+ {
+ CMDNSCacheManager* self = new (ELeave)CMDNSCacheManager();
+ CleanupStack::PushL(self);
+ self->ConstructL(aMaxCacheEntries);
+ return self;
+ }
+
+EXPORT_C CMDNSCacheManager* CMDNSCacheManager::NewL()
+ {
+ CMDNSCacheManager* self = new (ELeave)CMDNSCacheManager();
+ return self;
+ }
+
+void CMDNSCacheManager::ConstructL(TUint aMaxCacheEntries)
+ {
+ iHashMap=CMDNSCacheMap::NewL(aMaxCacheEntries);
+ }
+
+CMDNSCacheManager::CMDNSCacheManager()
+ {
+
+ }
+
+CMDNSCacheManager::~CMDNSCacheManager()
+ {
+ delete iHashMap;
+ iAuthoritativeEntries.ResetAndDestroy();
+ iAuthoritativeEntries.Close();
+ }
+
+/*Method to Insert / Update entries into Cache
+ * @param aEntry Record Entry to Insert
+ * @param aAuthoritative Flag to indicate whether the entry is Authoritative
+ * @param aSessionId To Store the Session Id for each entry
+ * @leave KErrNoMemory If Insert into Cache Failed because memory unavailability
+ * @leave KErrNotSupported if any record other than SRV, PTR, TXT ot A come
+ */
+EXPORT_C void CMDNSCacheManager::UpdateCacheL(CDnsResourceData& aEntry,TBool aAuthoritative,TUint32 aSessionId)
+ {
+ CDnsResourceData* resourceRecord = NULL;
+ CServiceInfo* foundEntry = NULL;
+ TBuf8<255> name;
+ _LIT8(KDot,".");
+ //Clone the entry to Insert in Cache
+ resourceRecord = aEntry.CloneL();
+
+ TUint16 recType(resourceRecord->Type());
+
+ if(recType == EDnsType_SRV || recType == EDnsType_TXT || recType == EDnsType_A || recType == EDnsType_PTR)
+ {
+ if(recType == EDnsType_PTR)
+ {
+ //Extract the Key- Service Instance Name
+ CRdTypePtr* ptrRecord = static_cast <CRdTypePtr*> (resourceRecord);
+ // before that insert the dot.
+ name.Copy(ptrRecord->DomainName());
+ if(name[name.Size()-1]!='.')
+ name.Append(KDot);
+ ptrRecord->SetDomainNameL(name);
+ foundEntry = iHashMap->Find(ptrRecord->DomainName());
+ }
+ else
+ {
+ //Extract the Key- Service Instance Name or Host Name
+ foundEntry = iHashMap->Find(resourceRecord->Name());
+ }
+
+ if(foundEntry)
+ {
+ //Update if the entry is already present in the Cache.
+ UpdateCacheEntry(foundEntry,resourceRecord);
+ }
+ else
+ {
+ //Entry not found in Cache,Insert it fresh
+ CServiceInfo* recordInfo = NULL;
+ recordInfo = CServiceInfo::NewL();
+ switch(recType)
+ {
+ case EDnsType_SRV:
+ CRdTypeSrv* srvRecord = static_cast <CRdTypeSrv*> (resourceRecord);
+ recordInfo->SetServiceRecord(srvRecord);
+ break;
+
+ case EDnsType_TXT:
+ CRdTypeTxt* txtRecord = static_cast <CRdTypeTxt*> (resourceRecord);
+ recordInfo->SetTxtRecord(txtRecord);
+ break;
+
+ case EDnsType_PTR:
+ CRdTypePtr* ptrRecord = static_cast <CRdTypePtr*> (resourceRecord);
+ recordInfo->SetPtrRecord(ptrRecord);
+ break;
+
+ case EDnsType_A:
+ CRdTypeA* addressRecord = static_cast <CRdTypeA*> (resourceRecord);
+ recordInfo->SetAddressRecord(addressRecord);
+ break;
+
+
+ default:
+ User::Leave(KErrNotSupported);
+ break;
+ }
+
+ recordInfo->SetAuthoritative(aAuthoritative);
+ recordInfo->SetSessionId(aSessionId);
+
+
+ // insert the entry
+ if(recType == EDnsType_PTR )
+ {
+ CRdTypePtr* ptrRecord = static_cast <CRdTypePtr*> (resourceRecord);
+ iHashMap->UpdateL(ptrRecord->DomainName(),recordInfo);
+ }
+ else
+ {
+ iHashMap->UpdateL(resourceRecord->Name(),recordInfo);
+ }
+
+ /*Maintain a list of all Services Published by us
+ (Authoritative records)*/
+ if(recordInfo->IsAuthoritative())
+ {
+ iAuthoritativeEntries.Append(recordInfo->CloneL());
+ }
+ }
+
+ }
+ else
+ {
+ User::Leave(KErrNotSupported);
+ }
+
+ }
+
+
+
+
+/*Caters to finding varying types of records, for e.g:- find all the entries
+ that correspond to a particular service type or find the host name through the address record
+ @param aEntries List of entries that match the search constraint
+ @param aName could represent any search constraint Service Instance Type/ Name or the HostName
+ @param aType the desired record type
+ */
+EXPORT_C TInt CMDNSCacheManager::FindServiceL(RPointerArray <CCacheEntry> & aEntries,const TDesC8& aName,TDnsType aType)const
+ {
+ TInt error(KErrNotFound);
+ TPtrC8 keyToFind(aName);
+ TInt count;
+ switch(aType)
+ {
+ case EDnsType_A:
+ case EDnsType_SRV:
+ case EDnsType_TXT:
+ {
+ //Search for a specific CacheEntry
+ CServiceInfo* cacheEntry = iHashMap->Find(aName);
+ if(cacheEntry)
+ {
+ CCacheEntry* entry = CCacheEntry::NewL();
+ CacheEntryL(entry,cacheEntry);
+ aEntries.Append(entry);
+ error = KErrNone;
+ }
+ }
+ break;
+
+
+ case EDnsType_PTR:
+ //Match for all Cache Entries of the given Service Type
+ RPointerArray <const CServiceInfo> entries;
+ CleanupClosePushL(entries);
+ iHashMap->FindEntries(aName,entries);
+
+ for(count =0; count< entries.Count();count++)
+ {
+ if((*entries[count]).PtrRecord())
+ {
+ //The entries are considered only if they have PTR records
+ CCacheEntry* entry = CCacheEntry::NewL();
+ CacheEntryL(entry,entries[count]);
+ aEntries.Append(entry);
+ error = KErrNone;
+ }
+ }
+
+ CleanupStack::PopAndDestroy(&entries);
+ break;
+
+
+ case EDnsQType_Any:
+ {
+ //Search for a specific CacheEntry
+ CServiceInfo* cacheEntry = iHashMap->Find(aName);
+ if(cacheEntry)
+ {
+ CCacheEntry* entry = CCacheEntry::NewL();
+ CacheEntryL(entry,cacheEntry);
+ aEntries.Append(entry);
+ error = KErrNone;
+ }
+ else // may be its a PTR record
+ {
+ RPointerArray <const CServiceInfo> entries;
+ CleanupClosePushL(entries);
+ iHashMap->FindEntries(aName,entries);
+
+ for(count =0; count< entries.Count();count++)
+ {
+ if((*entries[count]).PtrRecord())
+ {
+ //The entries are considered only if they have PTR records
+ CCacheEntry* entry = CCacheEntry::NewL();
+ CacheEntryL(entry,entries[count]);
+ aEntries.Append(entry);
+ error = KErrNone;
+ }
+ }
+
+ CleanupStack::PopAndDestroy(&entries);
+ }
+ }
+
+ break;
+
+ default:
+ User::Leave(KErrNotSupported);
+ break;
+ }
+ return error;
+ }
+
+/*Deletes the specified entry from the Cache
+ @param aServiceInstanceName Instance Name , whose entry needs to be deleted
+ @leave KErrNotFound if specified entry is not found
+ */
+EXPORT_C TInt CMDNSCacheManager::DeleteEntryL(const TDesC8& aServiceInstanceName)
+ {
+ TInt err = iHashMap->DeleteL(aServiceInstanceName);
+
+ // check if it also on the authoritative list, if so delete it
+
+ for(TInt i=0; i<iAuthoritativeEntries.Count();i++)
+ {
+ if(iAuthoritativeEntries[i]->Key().Compare(aServiceInstanceName)==0)
+ {
+ // found the entry, now delete it;
+ CServiceInfo* info = iAuthoritativeEntries[i];
+ iAuthoritativeEntries.Remove(i);
+ delete info;
+ }
+ }
+ return err;
+ }
+
+
+EXPORT_C void CMDNSCacheManager::FlushCache()
+ {
+ iHashMap->DeleteAllEntries();
+ }
+
+EXPORT_C CCacheEntry* CMDNSCacheManager::NextStaleEntry(TBool aActiveCacheMgmtEnabled,TBool aIteratorReset)
+ {
+ CServiceInfo* nextEntry = iHashMap->NextStaleEntry(aActiveCacheMgmtEnabled,aIteratorReset);
+ CCacheEntry* nextCacheEntry = NULL;
+
+ if(nextEntry)
+ {
+
+ nextCacheEntry = CCacheEntry::NewL();
+ //Construct CCacheEntry object
+ CacheEntryL(nextCacheEntry,nextEntry);
+
+ //Mark whether the entry has to be deleted or to be queried for (i.e., has exceeded 80%)
+ nextCacheEntry->SetEntryExpired(nextEntry->StaleEntry());
+ }
+
+ return nextCacheEntry;
+ }
+
+void CMDNSCacheManager::UpdateCacheEntry(CServiceInfo* aEntry,CDnsResourceData* aRecordInfo)
+ {
+ TUint16 recType(aRecordInfo->Type());
+ switch(recType)
+ {
+ case EDnsType_SRV:
+ CRdTypeSrv* srvRecord = static_cast <CRdTypeSrv*> (aRecordInfo);
+ //Delete the previous Service Record and Insert the fresh one
+ delete aEntry->ServiceRecord();
+ aEntry->SetServiceRecord(srvRecord);
+ break;
+
+ case EDnsType_TXT:
+ CRdTypeTxt* txtRecord = static_cast <CRdTypeTxt*> (aRecordInfo);
+ //Delete the previous Text Record and Insert the fresh one
+ delete aEntry->TxtRecord();
+ aEntry->SetTxtRecord(txtRecord);
+ break;
+
+ case EDnsType_PTR:
+ CRdTypePtr* ptrRecord = static_cast <CRdTypePtr*> (aRecordInfo);
+ //Delete the previous Ptr Record and Insert the fresh one
+ delete aEntry->PtrRecord();
+ aEntry->SetPtrRecord(ptrRecord);
+ break;
+
+ case EDnsType_A:
+ CRdTypeA* addressRecord = static_cast <CRdTypeA*> (aRecordInfo);
+ //Delete the previous Address Record and Insert the fresh one
+ delete aEntry->AddressRecord();
+ aEntry->SetAddressRecord(addressRecord);
+ break;
+
+ default:
+ //Do nothing
+ break;
+ }
+ }
+
+EXPORT_C void CMDNSCacheManager::DumpCacheL()
+ {
+ iHashMap->DumpCacheL();
+ }
+
+EXPORT_C TUint32 CMDNSCacheManager::CacheEntryCount()
+ {
+ return iHashMap->NumberOfEntries();
+ }
+
+
+void CMDNSCacheManager::CacheEntryL(CCacheEntry* aTargetEntry,const CServiceInfo* aSourceEntry)const
+ {
+ //Check whether the specific records existed before making a copy
+ if(aSourceEntry->PtrRecord())
+ {
+ aTargetEntry->SetPtrRecord(static_cast <CRdTypePtr*>( aSourceEntry->PtrRecord()->CloneL()));
+ }
+
+ if(aSourceEntry->AddressRecord())
+ {
+ //This case occurs only for an idividual Address Record
+ aTargetEntry->SetAddressRecord(static_cast <CRdTypeA*>(aSourceEntry->AddressRecord()->CloneL()));
+ }
+
+ if(aSourceEntry->ServiceRecord())
+ {
+ aTargetEntry->SetServiceRecord(static_cast <CRdTypeSrv*>(aSourceEntry->ServiceRecord()->CloneL()));
+ //Set Address Record ; if it exists
+ CServiceInfo* entry = iHashMap->Find(aTargetEntry->ServiceRecord()->Target());
+ if(entry)
+ {
+ aTargetEntry->SetAddressRecord(static_cast <CRdTypeA*>(entry->AddressRecord()->CloneL()));
+ }
+ }
+
+ if(aSourceEntry->TxtRecord())
+ {
+ aTargetEntry->SetTxtRecord(static_cast <CRdTypeTxt*>(aSourceEntry->TxtRecord()->CloneL()));
+ }
+
+ aTargetEntry->SetAuthoritative(aSourceEntry->IsAuthoritative());
+ aTargetEntry->SetSessionId(aSourceEntry->SessionId());
+ }
+
+
+void CMDNSCacheManager::AuthoritativeEntriesL(RPointerArray <CCacheEntry>& aCacheEntries)
+ {
+ for(TInt index =0; index < iAuthoritativeEntries.Count();index++)
+ {
+ CCacheEntry* entry = CCacheEntry::NewL();
+ CacheEntryL(entry,iAuthoritativeEntries[index]);
+ aCacheEntries.Append(entry);
+ }
+ }
+
+TUint CMDNSCacheManager::NumberOfEntries()
+ {
+ return iHashMap->NumberOfEntries();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/src/cmdnscachemap.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,445 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "cmdnscachemap.h"
+#include "mdnsrecordinfo.h"
+#include <mdns/crdtypesrv.h>
+#include <mdns/crdtypea.h>
+#include <mdns/crdtypeptr.h>
+#include <mdns/crdtypetxt.h>
+
+
+__FLOG_STMT(_LIT8(KComponent,"MDNSCache");)
+
+CMDNSCacheMap* CMDNSCacheMap::NewL(TUint aMaxCacheEntries)
+ {
+ CMDNSCacheMap* self = CMDNSCacheMap::NewLC(aMaxCacheEntries);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+CMDNSCacheMap* CMDNSCacheMap::NewLC(TUint aMaxCacheEntries)
+ {
+ CMDNSCacheMap* self = new (ELeave)CMDNSCacheMap(aMaxCacheEntries);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+ }
+
+void CMDNSCacheMap::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ __FLOG(_L8("ConstructL - Entry"));
+
+ __FLOG(_L8("ConstructL - Exit"));
+ }
+
+CMDNSCacheMap::CMDNSCacheMap(TUint aMaxCacheEntries):iCacheEntries(HashInfo::TPtrC8Hash,HashInfo::TPtrC8Ident),iterate(iCacheEntries)
+ {
+ iMaxCacheEntries = aMaxCacheEntries;
+ }
+
+
+CMDNSCacheMap::~CMDNSCacheMap()
+ {
+ __FLOG(_L8("Destructor - Entry"));
+ RHashMap<TPtrC8,CServiceInfo*>::TIter iter(iCacheEntries);
+ TInt count(0);
+ TInt entriesToDelete(iCacheEntries.Count());
+ for(count=0; count<entriesToDelete; count++)
+ {
+ delete *iter.NextValue();
+ }
+
+ iCacheEntries.Close();
+ __FLOG(_L8("Destructor - Exit"));
+ __FLOG_CLOSE;
+ }
+
+TUint32 HashInfo::TPtrC8Hash(const TPtrC8& aPtr)
+ {
+ return DefaultHash::Des8(aPtr);
+ }
+
+TBool HashInfo::TPtrC8Ident(const TPtrC8& aL, const TPtrC8& aR)
+ {
+ return DefaultIdentity::Des8(aL, aR);
+ }
+
+
+void CMDNSCacheMap::UpdateL(const TDesC8& aName, CServiceInfo* aEntry)
+ {
+ __FLOG(_L8("Insert - Entry"));
+ TTime currentTime;
+ currentTime.UniversalTime();
+ aEntry->SetAccessTime(currentTime);
+ TBool authoritative = aEntry->IsAuthoritative();
+
+ //Save the key
+ aEntry->SetKeyL(aName);
+
+ if(NumberOfEntries()<=iMaxCacheEntries)
+ {
+ iCacheEntries.InsertL(aEntry->Key(),aEntry);
+ }
+ else
+ {
+ if(aEntry->IsAuthoritative() && DeleteLeastRecentlyUsed())
+ {
+ iCacheEntries.InsertL(aEntry->Key(),aEntry);
+ }
+ else
+ {
+ delete aEntry;
+ __FLOG_VA((_L8("--------User::Leave on Insert = %d--------"),KErrNoMemory));
+ User::Leave(KErrNoMemory);
+ }
+ }
+
+ __FLOG(_L8("Insert - Exit"));
+
+ }
+
+CServiceInfo* CMDNSCacheMap::Find(const TDesC8& aName)
+ {
+ TTime currentTime;
+ RBuf8 key;
+ key.CreateL(aName);
+
+ //All keys are in LowerCase
+ key.LowerCase();
+
+ CServiceInfo** foundEntry = NULL;
+ foundEntry = iCacheEntries.Find(key);
+ key.Close();
+ currentTime.UniversalTime();
+ if(foundEntry)
+ {
+ (*foundEntry)->SetAccessTime(currentTime);
+ return *foundEntry;
+ }
+ return NULL;
+ }
+
+void CMDNSCacheMap::FindEntries(const TDesC8& aName,RPointerArray <const CServiceInfo> & aEntries)
+ {
+ _LIT8(KRegExp,"*");
+ TInt error;
+ TBuf8 <256> serviceType(KRegExp);
+ TTime currentTime;
+ serviceType.Append(aName);
+ THashMapIter<TPtrC8,CServiceInfo*> iter(iCacheEntries);
+ TInt count;
+ for(count=0; count<iCacheEntries.Count(); count++)
+ {
+ TPtrC8 nextKey=*iter.NextKey();
+ //Match by the regular expression to get all Services by type
+ error=nextKey.MatchF(serviceType);
+ if( error != KErrNotFound)
+ {
+ CServiceInfo* currentEntry= *iter.CurrentValue();
+ aEntries.Append(currentEntry);
+
+ currentTime.UniversalTime();
+ currentEntry->SetAccessTime(currentTime);
+ }
+ }
+ }
+
+/*Not Used : Currently*/
+void CMDNSCacheMap::AuthoritativeRecordsL(RPointerArray <const CServiceInfo> & aEntries)
+ {
+ THashMapIter<TPtrC8,CServiceInfo*> iter(iCacheEntries);
+ TInt count;
+ TTime currentTime;
+ for(count=0; count<iCacheEntries.Count(); count++)
+ {
+ CServiceInfo* entry=*iter.NextValue();
+ if(entry->IsAuthoritative())
+ {
+ aEntries.AppendL(entry);
+ currentTime.UniversalTime();
+ entry->SetAccessTime(currentTime);
+ }
+ }
+ }
+
+TInt CMDNSCacheMap::DeleteL(const TDesC8& aName)
+ {
+ __FLOG(_L8("CMDNSCacheMap::DeleteL - Entry"));
+ TInt error = KErrNone;
+ TBuf8 <256> key(aName);
+
+ //All keys are in LowerCase
+ key.LowerCase();
+
+ #ifdef __FLOG_ACTIVE
+
+ HBufC8* buf(HBufC8::NewLC(aName.Length()));
+ buf->Des().Copy(aName);
+ __FLOG_VA((_L8("Deleted Entry = %S "),buf));
+ CleanupStack::PopAndDestroy(buf);
+
+ #endif
+
+ CServiceInfo* entryToDelete = NULL;
+ TRAPD(err,entryToDelete=iCacheEntries.FindL(key));
+ if(err!=KErrNotFound)
+ {
+ error = iCacheEntries.Remove(key);
+ delete entryToDelete;
+ __FLOG(_L8("CMDNSCacheMap::DeleteL - Delete Cache Entry Successful"));
+ __FLOG(_L8("CMDNSCacheMap::DeleteL - Exit"));
+ }
+ else
+ {
+ __FLOG(_L8("CMDNSCacheMap::DeleteL - Entry not found in Cache"));
+ }
+ return error;
+ }
+
+void CMDNSCacheMap::DeleteAllEntries()
+ {
+ THashMapIter<TPtrC8,CServiceInfo*> iter(iCacheEntries);
+ TInt count;
+ for(count=0; count<iCacheEntries.Count(); count++)
+ {
+ TPtrC8 key=*iter.NextKey();
+ /*TODO: check if object is properly deleted;
+ * destructors are called*/
+ iCacheEntries.Remove(key);
+ delete *iter.NextValue();
+ }
+ }
+
+
+/* Scenarios:
+
+1. All are authoritative in Cache, authoritative record comes for insertion : No Memory
+2. All are authoritative in Cache, non-authoritative comes : No Memory
+3. One or more non-authoritative, non-authoritative comes : No Memory
+4. All are non-authoritative,authoritative comes, one of the records
+ based on LRU (not accurate)of which is deleted, but authoritative WILL BE
+ put into cache
+ */
+
+TBool CMDNSCacheMap::DeleteLeastRecentlyUsed()
+ {
+ THashMapIter<TPtrC8,CServiceInfo*> iter(iCacheEntries);
+ TInt count;
+ TTime accessTime,timeOfLRUEntry;
+ CServiceInfo* entryToDelete = NULL;
+ TBuf8<255> keyToDelete;
+ TBool cacheFull = ETrue;
+
+ for(count=0; count<iCacheEntries.Count(); count++)
+ {
+ CServiceInfo* nextEntry = *iter.NextValue();
+ accessTime = nextEntry->LastAccessTime();
+
+ if(count==0)
+ {
+ timeOfLRUEntry = accessTime;
+ if(!nextEntry->IsAuthoritative())
+ {
+ keyToDelete = *iter.CurrentKey();
+ entryToDelete = nextEntry;
+ }
+ }
+
+ else
+ {
+ if((accessTime < timeOfLRUEntry) && !nextEntry->IsAuthoritative() )
+ {
+ timeOfLRUEntry = accessTime;
+ keyToDelete = *iter.CurrentKey();
+ entryToDelete = nextEntry;
+ }
+ }
+
+ }
+
+ TInt error = iCacheEntries.Remove(keyToDelete);
+
+ if(error != KErrNone)
+ {
+ cacheFull = EFalse;
+ }
+ else
+ {
+ #ifdef __FLOG_ACTIVE
+
+ __FLOG_VA((_L8("Deleting Least Recently Used = %S "),&keyToDelete));
+
+ #endif
+ }
+
+
+ delete entryToDelete;
+
+ return cacheFull;
+ }
+
+TUint32 CMDNSCacheMap::NumberOfEntries()
+ {
+ return iCacheEntries.Count();
+ }
+
+
+CServiceInfo* CMDNSCacheMap::NextStaleEntry(TBool aActiveCacheMgmtEnabled,TBool aIteratorReset)
+ {
+/*
+ if(aIteratorReset)
+ {
+ iterate.Reset();
+ }
+
+ CServiceInfo* nextEntry=*iterate.NextValue();
+
+ if(nextEntry->EntryExpired() || nextEntry->EntryToBeQueried())
+ {
+ __FLOG(_L8("Stale Entry Found"));
+ return nextEntry;
+ }
+
+ return NULL;
+
+*/
+ THashMapIter<TPtrC8,CServiceInfo*> itr(iCacheEntries);
+ CServiceInfo*const* nextEntry=itr.NextValue();
+
+ while(nextEntry!=NULL)
+ {
+ if((*nextEntry)->EntryExpired())
+ {
+ __FLOG(_L8("Stale Entry Found"));
+ return (*nextEntry);
+ }
+ nextEntry=itr.NextValue();
+ }
+
+ return NULL;
+ }
+
+void CMDNSCacheMap::DumpCacheL()
+ {
+ RHashMap<TPtrC8,CServiceInfo*>::TIter iter(iCacheEntries);
+
+ __FLOG(_L8("!!!!!!!!!!!!!!!!!! BEGIN CACHE DUMP !!!!!!!!!!!!!!!!!!!!!"));
+ for(TInt count=0; count<iCacheEntries.Count(); count++)
+ {
+ CServiceInfo* entry = *iter.NextValue();
+
+
+ __FLOG_VA((_L8("--------------------Begin Entry = %d------------------"),count));
+
+
+ TPtrC8 key(*iter.CurrentKey());
+ __FLOG_VA((_L8("--------------------Key is = %S------------------"),&key));
+
+ if(entry->ServiceRecord())
+ {
+ __FLOG(_L8("--------Service-Record Data-----"));
+ HBufC8* buf(HBufC8::NewLC(entry->ServiceRecord()->Name().Length()));
+ buf->Des().Copy(entry->ServiceRecord()->Name());
+ __FLOG_VA((_L8("Service Name = %S "),buf));
+
+ HBufC8* target(HBufC8::NewLC(entry->ServiceRecord()->Target().Length()));
+ target->Des().Copy(entry->ServiceRecord()->Target());
+ __FLOG_VA((_L8("Target Machine = %S "),target));
+
+ __FLOG_VA((_L8("Priority = %d "),entry->ServiceRecord()->Priority()));
+ __FLOG_VA((_L8("Port = %d "),entry->ServiceRecord()->Port()));
+ __FLOG_VA((_L8("TTL = %d "),entry->ServiceRecord()->Ttl()));
+
+ CleanupStack::PopAndDestroy(target);
+ CleanupStack::PopAndDestroy(buf);
+ }
+
+ if(entry->AddressRecord())
+ {
+ __FLOG(_L8("-------Address-Record Data--------"));
+ HBufC8* buf(HBufC8::NewLC(entry->AddressRecord()->Name().Length()));
+ buf->Des().Copy(entry->AddressRecord()->Name());
+ __FLOG_VA((_L8("Host Name = %S "),buf));
+ const TInetAddr addr(entry->AddressRecord()->Address());
+ TBuf <255> ipaddr;
+ addr.Output(ipaddr);
+
+ __FLOG_VA((_L("Inet Address = %S "),&ipaddr));
+
+ __FLOG_VA((_L8("TTL = %d "),entry->AddressRecord()->Ttl()));
+ CleanupStack::PopAndDestroy(buf);
+ }
+
+ if(entry->PtrRecord())
+ {
+ __FLOG(_L8("-------Ptr-Record Data-----------"));
+ HBufC8* buf(HBufC8::NewLC(entry->PtrRecord()->Name().Length()));
+ buf->Des().Copy(entry->PtrRecord()->Name());
+ __FLOG_VA((_L8("PTR Name= %S "),buf));
+
+ HBufC8* domainName(HBufC8::NewLC(entry->PtrRecord()->DomainName().Length()));
+ domainName->Des().Copy(entry->PtrRecord()->DomainName());
+ __FLOG_VA((_L8("PTR Domain Name = %S "),domainName));
+
+ __FLOG_VA((_L8("Type = %d "),entry->PtrRecord()->Type()));
+ __FLOG_VA((_L8("TTL = %d "),entry->PtrRecord()->Ttl()));
+
+ CleanupStack::PopAndDestroy(domainName);
+ CleanupStack::PopAndDestroy(buf);
+ }
+
+ if(entry->TxtRecord())
+ {
+ __FLOG(_L8("--------Txt-Record Data---------"));
+ const RArray <RBuf8>& array = entry->TxtRecord()->Text();
+
+ HBufC8* name(HBufC8::NewLC(entry->TxtRecord()->Name().Length()));
+ name->Des().Copy(entry->TxtRecord()->Name());
+ __FLOG_VA((_L8("Text Name= %S "),name));
+ CleanupStack::PopAndDestroy(name);
+
+
+ for (TInt count=0;count<array.Count();count++)
+ {
+ HBufC8* text(HBufC8::NewLC(array[count].Length()));
+ text->Des().Copy(array[count]);
+ __FLOG_VA((_L8("Text Info = %S "),text));
+ CleanupStack::PopAndDestroy(text);
+ }
+ __FLOG_VA((_L8("TTL = %d "),entry->TxtRecord()->Ttl()));
+ }
+
+ __FLOG_VA((_L8("--------Entry is Authoritative?? = %d--------"),entry->IsAuthoritative()));
+
+ __FLOG_VA((_L8("--------Last Access Time = %ld--------"),entry->LastAccessTime()));
+
+ }
+ __FLOG_VA((_L8("--------Total number of entries = %d--------"),iCacheEntries.Count()));
+ }
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/src/cmdnsprobemanager.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+#include "cmdnsprobemanager.h"
+
+CMDNSProbeManager* CMDNSProbeManager::NewL(RBuf& aHostName, TInetAddr aAddr)
+ {
+ CMDNSProbeManager* self = CMDNSProbeManager::NewLC(aHostName,aAddr);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+CMDNSProbeManager* CMDNSProbeManager::NewLC(RBuf& aHostName, TInetAddr aAddr)
+ {
+ CMDNSProbeManager* self = new (ELeave)CMDNSProbeManager(aHostName,aAddr);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+ }
+
+CMDNSProbeManager::CMDNSProbeManager(RBuf& aHostName, TInetAddr aAddr):CTimer(CActive::EPriorityStandard)
+ {
+
+ }
+
+
+CMDNSProbeManager* CMDNSProbeManager::NewL(RBuf& aServiceName,RBuf& aHostName)
+ {
+ CMDNSProbeManager* self = CMDNSProbeManager::NewLC(aServiceName,aHostName);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+CMDNSProbeManager* CMDNSProbeManager::NewLC(RBuf& aServiceName,RBuf& aHostName)
+ {
+ CMDNSProbeManager* self = new (ELeave)CMDNSProbeManager(aServiceName,aHostName);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+ }
+
+CMDNSProbeManager::CMDNSProbeManager(RBuf& aServiceName,RBuf& aHostName):CTimer(CActive::EPriorityStandard)
+ {
+
+ }
+void CMDNSProbeManager::ConstructL()
+ {
+
+ }
+
+CMDNSProbeManager::~CMDNSProbeManager()
+ {
+
+ }
+
+void CMDNSProbeManager::RunL()
+ {
+ switch(iCurrentProbeState)
+ {
+ case EIdle:
+ break;
+
+ case EProbeBegin:
+ break;
+
+ case EProbeFirstUnicast:
+ break;
+
+ case EProbeSecondUnicast:
+ break;
+
+ case EProbeMulticast:
+ break;
+
+ case EProbeComplete:
+ break;
+
+ case EFirstAnnouncement:
+ break;
+
+ case ESecondAnnouncement:
+ break;
+
+ }
+ }
+
+TInt CMDNSProbeManager::RunError(TInt aError)
+ {
+ return KErrNone;
+ }
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/src/cserviceinfo.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,397 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include "cserviceinfo.h"
+
+const TUint KCacheRecords = 4;
+const TUint KGranularity = 2;
+const TUint KDefaultTtl = 4500;
+const TUint KQueryFactor = 0.2;
+
+
+
+CServiceInfo* CServiceInfo::NewL()
+ {
+ CServiceInfo* self = CServiceInfo::NewLC();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+CServiceInfo* CServiceInfo::NewLC()
+ {
+ CServiceInfo* self = new (ELeave)CServiceInfo();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+ }
+
+CServiceInfo::CServiceInfo():iEntryTime(KCacheRecords),iExpiryTime(KCacheRecords),iAddressRecord(NULL),iServiceRecord(NULL),iPtrRecord(NULL),iTxtRecord(NULL)
+ {
+ iEntryExpired = EFalse;
+ }
+
+CServiceInfo::~CServiceInfo()
+ {
+ delete iAddressRecord;
+ delete iServiceRecord;
+ delete iPtrRecord;
+ delete iTxtRecord;
+ iEntryTime.Close();
+ iExpiryTime.Close();
+ iKey.Close();
+
+ }
+
+void CServiceInfo::ConstructL()
+ {
+ TTime currentTime;
+ currentTime.UniversalTime();
+ TTimeIntervalSeconds ttl = KDefaultTtl;
+
+ //Set default Entry time
+ for(TInt count=0;count<KCacheRecords;count++ )
+ {
+ iEntryTime.AppendL(currentTime);
+ }
+
+
+ //Set default Expiry time
+ for(TInt count=0;count<KCacheRecords;count++ )
+ {
+ iExpiryTime.AppendL(currentTime + ttl);
+ }
+
+ }
+
+TBool CServiceInfo::IsAuthoritative()const
+ {
+ return iAuthoritative;
+ }
+
+void CServiceInfo::SetAuthoritative(TBool aAuthoritative)
+ {
+ iAuthoritative = aAuthoritative;
+ }
+
+const TTime& CServiceInfo::LastAccessTime()const
+ {
+ return iLastAccessTime;
+ }
+
+void CServiceInfo::SetAccessTime(TTime aTime)
+ {
+ iLastAccessTime = aTime;
+ }
+
+TUint32 CServiceInfo::SessionId()const
+ {
+ return iSessionId;
+ }
+
+void CServiceInfo::SetSessionId(TUint32 aSessionId)
+ {
+ iSessionId = aSessionId;
+ }
+
+void CServiceInfo::SetAddressRecord(CRdTypeA* aAddressRecord)
+ {
+
+ SetEntryTime(ECacheEntryAddr);
+ iAddressRecord = aAddressRecord;
+ SetExpiryTime(ECacheEntryAddr);
+
+ }
+
+void CServiceInfo::SetServiceRecord(CRdTypeSrv* aServiceRecord)
+ {
+
+ SetEntryTime(ECacheEntrySrv);
+ iServiceRecord = aServiceRecord;
+ SetExpiryTime(ECacheEntrySrv);
+
+ }
+
+void CServiceInfo::SetPtrRecord(CRdTypePtr* aPtrRecord)
+ {
+
+ SetEntryTime(ECacheEntryPtr);
+ iPtrRecord = aPtrRecord;
+ SetExpiryTime(ECacheEntryPtr);
+
+ }
+
+void CServiceInfo::SetTxtRecord(CRdTypeTxt* aTxtRecord)
+ {
+
+ SetEntryTime(ECacheEntryTxt);
+ iTxtRecord = aTxtRecord;
+ SetExpiryTime(ECacheEntryTxt);
+
+ }
+
+
+CRdTypeA* CServiceInfo::AddressRecord()const
+ {
+ return iAddressRecord;
+ }
+
+CRdTypeSrv* CServiceInfo::ServiceRecord()const
+ {
+ return iServiceRecord;
+ }
+
+CRdTypePtr* CServiceInfo::PtrRecord()const
+ {
+ return iPtrRecord;
+ }
+
+CRdTypeTxt* CServiceInfo::TxtRecord()const
+ {
+ return iTxtRecord;
+ }
+
+void CServiceInfo::SetKeyL(const TDesC8& aKey)
+ {
+ iKey.Close();
+ iKey.CreateL(aKey);
+ iKey.LowerCase();
+ }
+
+const TDesC8& CServiceInfo::Key()const
+ {
+ return iKey;
+ }
+
+void CServiceInfo::SetEntryTime(TCacheEntryType aType)
+ {
+ TTime currentTime;
+ currentTime.UniversalTime();
+
+ //Set the Entry Time when the record data is obtained for
+ //the first time
+
+ switch(aType)
+ {
+ case ECacheEntryAddr:
+ //if(!AddressRecord())
+ {
+ iEntryTime.Insert(currentTime,ECacheEntryAddr);
+ }
+ break;
+
+
+ case ECacheEntryPtr:
+ //if(!PtrRecord())
+ {
+ iEntryTime.Insert(currentTime,ECacheEntryPtr);
+ }
+ break;
+
+
+ case ECacheEntrySrv:
+ //if(!ServiceRecord())
+ {
+ iEntryTime.Insert(currentTime,ECacheEntrySrv);
+ }
+ break;
+
+ case ECacheEntryTxt:
+ //if(!TxtRecord())
+ {
+ iEntryTime.Insert(currentTime,ECacheEntryTxt);
+ }
+ break;
+ }
+
+ }
+
+
+void CServiceInfo::SetExpiryTime(TCacheEntryType aType)
+ {
+ TTimeIntervalSeconds ttl;
+
+ //Set/Update the Expiry time
+ switch(aType)
+ {
+ case ECacheEntryAddr:
+ ttl = AddressRecord()->Ttl();
+ break;
+
+
+ case ECacheEntryPtr:
+ ttl = PtrRecord()->Ttl();
+ break;
+
+
+ case ECacheEntrySrv:
+ ttl = ServiceRecord()->Ttl();
+ break;
+
+ case ECacheEntryTxt:
+ ttl = TxtRecord()->Ttl();
+ break;
+ }
+
+ //Set the Expiry Time
+ TTime expiryTime = iEntryTime[aType] + ttl;
+ iExpiryTime.Insert(expiryTime,aType);
+ }
+
+
+TBool CServiceInfo::EntryExpired()
+ {
+ TTime currentTime;
+ currentTime.UniversalTime();
+
+ if(AddressRecord())
+ {
+ if(iExpiryTime[ECacheEntryAddr] <= currentTime)
+ {
+ iEntryExpired = ETrue;
+ return iEntryExpired;
+ }
+ }
+
+ if(PtrRecord())
+ {
+ if(iExpiryTime[ECacheEntryPtr] <= currentTime)
+ {
+ iEntryExpired = ETrue;
+ return iEntryExpired;
+ }
+ }
+
+
+ if(ServiceRecord())
+ {
+ if(iExpiryTime[ECacheEntrySrv] <= currentTime)
+ {
+ iEntryExpired = ETrue;
+ return iEntryExpired;
+ }
+ }
+
+
+ if(TxtRecord())
+ {
+ if(iExpiryTime[ECacheEntryTxt] <= currentTime)
+ {
+ iEntryExpired = ETrue;
+ return iEntryExpired;
+ }
+ }
+
+ return EFalse;
+ }
+
+
+// This Clone funtion returns back what is necessary.
+
+CServiceInfo* CServiceInfo::CloneL()const
+ {
+ CServiceInfo* serviceInfo = CServiceInfo::NewL();
+
+ if(iAddressRecord)
+ {
+ serviceInfo->SetAddressRecord(static_cast<CRdTypeA*>(iAddressRecord->CloneL()));
+ }
+ if(iServiceRecord)
+ {
+ serviceInfo->SetServiceRecord(static_cast<CRdTypeSrv*>(iServiceRecord->CloneL()));
+ }
+ if(iPtrRecord)
+ {
+ serviceInfo->SetPtrRecord(static_cast<CRdTypePtr*>(iPtrRecord->CloneL()));
+ }
+ if(iTxtRecord)
+ {
+ serviceInfo->SetTxtRecord(static_cast<CRdTypeTxt*>(iTxtRecord->CloneL()));
+ }
+
+ serviceInfo->SetKeyL(iKey);
+ serviceInfo->SetSessionId(iSessionId);
+
+ return serviceInfo;
+ }
+
+TBool CServiceInfo::EntryToBeQueried()
+ {
+ //Check if any record in the entry has exceeded 80% ttl, if yes, Query!
+
+ TTime currentTime;
+ currentTime.UniversalTime();
+
+
+ if(AddressRecord())
+ {
+ TInt64 addExpiryTime = iExpiryTime[ECacheEntryAddr].Int64();
+ TInt64 current = currentTime.Int64();
+ //Converted to seconds
+ TUint64 addExpiryFactor = (addExpiryTime - current) / 1000000;
+ if( addExpiryFactor < (0.2)*(AddressRecord()->Ttl()))
+ {
+ return ETrue;
+ }
+ }
+
+ if(PtrRecord())
+ {
+ TInt64 ptrExpiryTime = iExpiryTime[ECacheEntryPtr].Int64();
+ TInt64 current = currentTime.Int64();
+ //Converted to seconds
+ TUint64 ptrExpiryFactor = (ptrExpiryTime - current) / 1000000;
+ if( ptrExpiryFactor < (0.2)*(PtrRecord()->Ttl()))
+ {
+ return ETrue;
+ }
+ }
+
+
+ if(ServiceRecord())
+ {
+ TInt64 srvExpiryTime = iExpiryTime[ECacheEntrySrv].Int64();
+ TInt64 current = currentTime.Int64();
+ //Converted to seconds
+ TUint64 srvExpiryFactor = (srvExpiryTime - current) / 1000000;
+ if( srvExpiryFactor < (0.2)*(ServiceRecord()->Ttl()))
+ {
+ return ETrue;
+ }
+ }
+
+
+ if(TxtRecord())
+ {
+ TInt64 txtExpiryTime = iExpiryTime[ECacheEntryTxt].Int64();
+ TInt64 current = currentTime.Int64();
+ //Converted to seconds
+ TUint64 txtExpiryFactor = (txtExpiryTime - current) / 1000000;
+ if( txtExpiryFactor < (0.2)*(TxtRecord()->Ttl()))
+ {
+ return ETrue;
+ }
+ }
+
+ return EFalse;
+ }
+
+
+TBool CServiceInfo::StaleEntry()
+ {
+ return iEntryExpired;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/src/distribution.policy Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,2 @@
+Category E
+OSD: Optional Replaceable Bonjour Framework
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/cachemanager/src/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/bwins/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/bwins/mdnsclientu.def Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,11 @@
+EXPORTS
+ ?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+ ?WaitForNotificationL@RMdns@@QAEXABVRPnPParameterBundle@@@Z @ 2 NONAME ; void RMdns::WaitForNotificationL(class RPnPParameterBundle const &)
+ ?Cancel@RMdns@@QAEHABVRPnPParameterBundle@@@Z @ 3 NONAME ; int RMdns::Cancel(class RPnPParameterBundle const &)
+ ?RegisterServiceL@RMdns@@QAEXABVRPnPParameterBundle@@H@Z @ 4 NONAME ; void RMdns::RegisterServiceL(class RPnPParameterBundle const &, int)
+ ?Open@RMdns@@QAEHH@Z @ 5 NONAME ; int RMdns::Open(int)
+ ?Close@RMdns@@QAEHXZ @ 6 NONAME ; int RMdns::Close(void)
+ ?QueryL@RMdns@@QAEXABVRPnPParameterBundle@@@Z @ 7 NONAME ; void RMdns::QueryL(class RPnPParameterBundle const &)
+ ?ResolveL@RMdns@@QAEXABVRPnPParameterBundle@@@Z @ 8 NONAME ; void RMdns::ResolveL(class RPnPParameterBundle const &)
+ ??0RMdns@@QAE@XZ @ 9 NONAME ; RMdns::RMdns(void)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/eabi/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/eabi/mdnsclientu.def Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,24 @@
+EXPORTS
+ _Z24ImplementationGroupProxyRi @ 1 NONAME
+ _ZN5RMdns16RegisterServiceLERK19RPnPParameterBundlei @ 2 NONAME
+ _ZN5RMdns20WaitForNotificationLERK19RPnPParameterBundle @ 3 NONAME
+ _ZN5RMdns4OpenEi @ 4 NONAME
+ _ZN5RMdns5CloseEv @ 5 NONAME
+ _ZN5RMdns6CancelERK19RPnPParameterBundle @ 6 NONAME
+ _ZN5RMdns6QueryLERK19RPnPParameterBundle @ 7 NONAME
+ _ZN5RMdns8ResolveLERK19RPnPParameterBundle @ 8 NONAME
+ _ZN5RMdnsC1Ev @ 9 NONAME
+ _ZN5RMdnsC2Ev @ 10 NONAME
+ _ZTI21CMdnsRegisterNotifier @ 11 NONAME
+ _ZTI25CMDnsServiceDiscoveryImpl @ 12 NONAME
+ _ZTI25CMDnsServicePublisherImpl @ 13 NONAME
+ _ZTI25CMdnsQueryPublishNotifier @ 14 NONAME
+ _ZTIN4Meta5TMetaI9TInetAddrEE @ 15 NONAME
+ _ZTIN4Meta5TMetaIiEE @ 16 NONAME
+ _ZTV21CMdnsRegisterNotifier @ 17 NONAME
+ _ZTV25CMDnsServiceDiscoveryImpl @ 18 NONAME
+ _ZTV25CMDnsServicePublisherImpl @ 19 NONAME
+ _ZTV25CMdnsQueryPublishNotifier @ 20 NONAME
+ _ZTVN4Meta5TMetaI9TInetAddrEE @ 21 NONAME
+ _ZTVN4Meta5TMetaIiEE @ 22 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/group/bld.inf Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2008 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+PRJ_EXPORTS
+../inc/mdnsparamset.h /epoc32/include/mdns/mdnsparamset.h
+../inc/mdnsparamset.inl /epoc32/include/mdns/mdnsparamset.inl
+..\inc\cmdnsclient.h mdns\cmdnsclient.h
+..\inc\cmdnsquerypublishnotifier.h mdns\cmdnsquerypublishnotifier.h
+..\inc\cmdnsserverconstants.h mdns\cmdnsserverconstants.h
+..\inc\cmdnsregisternotifier.h mdns\cmdnsregisternotifier.h
+
+
+PRJ_MMPFILES
+mdnsclient.mmp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/group/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/group/mdnsclient.mmp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2008 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+/**
+MDns specific dll that provides support for applications to create parameter bundles of
+desired type for carrying out various MDns operations like discovery,describe etc.
+*/
+
+#include <comms-infras/commsdebugutility.mmh>
+
+TARGET mdnsclient.dll
+TARGETTYPE PLUGIN
+CAPABILITY ALL -TCB
+
+UID 0x10009D8D 0x2000D066 //0x2000D05D
+VENDORID 0x70000001
+
+
+
+SOURCEPATH ../src
+SOURCE ecom_impl.cpp
+SOURCE mdnsparamsextfactory.cpp
+SOURCE cmdnsquerypublishnotifier.cpp
+SOURCE cmdnsclient.cpp
+SOURCE cmdnsregisternotifier.cpp
+SOURCE cmdnspnpservicepublisher.cpp
+SOURCE cpnpservicediscovery.cpp
+DEFFILE mdnsclient.def
+
+START RESOURCE 2000D066.rss
+TARGET mdnsclient.rsc
+END
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE /epoc32/include
+SYSTEMINCLUDE /epoc32/include/mdns
+
+USERINCLUDE ../inc
+USERINCLUDE ../../common/inc
+
+
+LIBRARY esock.lib
+LIBRARY netmeta.lib
+LIBRARY euser.lib
+LIBRARY commsdataobjects.lib
+LIBRARY efsrv.lib
+LIBRARY c32root.lib
+LIBRARY commsfw.lib
+LIBRARY commsdat.lib
+LIBRARY insock.lib
+LIBRARY estor.lib
+LIBRARY charconv.lib
+LIBRARY rpnp.lib
+LIBRARY esocksvr.lib
+
+
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/inc/cmdnsclient.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,180 @@
+/*
+* Copyright (c) 2008 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+/**
+@file
+@PublishedAll
+*/
+
+#ifndef __MDNSCLIENT_H__
+#define __MDNSCLIENT_H__
+
+#include <e32base.h>
+#include <pnp/pnpparameterbundle.h>
+#include <mdns/cmdnsquerypublishnotifier.h>
+#include <mdns/cmdnsregisternotifier.h>
+#include "mdnsdebug.h"
+class RMdns : public RSessionBase
+ {
+ public:
+ //These are the helper class which help in notifying the application observer
+ //when the query and notify messages are served.
+ friend class CMdnsQueryPublishNotifier;
+ friend class CMdnsRegisterNotifier;
+ /**
+ * Opens a new session with the multicast DNS server. Must be called before
+ * any other function may be used.
+ *
+ * @param aConnectionHandle Handle to the RConnection Object
+ * @param aSocketServerHandle Handle to the RSocketServ Object
+ * @param aObserver The callback function where the return values are commnunicated back
+ * along with the error codes.
+ * @return A CService object comprising a complete description of the service parameters.
+ * @brief Opens a new session with the zeroconf server.
+ */
+
+ IMPORT_C TInt Open(TInt aConnectionHandle);
+
+
+ /**
+ * ASynchronously lists all the available servicves of the type specified.
+ *
+ * @param aServiceType A unicode descriptor containing the type of the service you wish to resolve, including leading underscore (e.g. '_http'.)
+ * @param aProtocol The protocol the service runs over, one of TCP or UDP.
+ * @brief Asynchronously resolves a network service.
+ */
+
+ IMPORT_C void QueryL( const RPnPParameterBundle& aQueryParams );
+
+
+ /**
+ * ASynchronously resolves a network service. The results are returned using the Observer callback
+ *
+ * @param aServiceName A unicode descriptor containing the name of the service you wish to resolve.
+ * @param aServiceType A unicode descriptor containing the type of the service you wish to resolve, including leading underscore (e.g. '_http'.)
+ * @param aProtocol The protocol the service runs over, one of TCP or UDP.
+ * @brief Asynchronously resolves a network service.
+ */
+
+ IMPORT_C void ResolveL( const RPnPParameterBundle& aResolveParams );
+
+
+
+ /**
+ * Registers a service on the local device and will send out presence announcement on the local link
+ *
+ * @param aServiceName A unicode descriptor containing the name of the service you wish to register.
+ * @param aServiceType A unicode descriptor containing the type of the service you wish to register, including leading underscore (e.g. '_http'.)
+ * @param aProtocol The protocol the service runs over, one of TCP or UDP.
+ * @return Service registration id is returned
+ * @brief
+ */
+
+ IMPORT_C void RegisterServiceL( const RPnPParameterBundle& aPublishParams ,TBool aIsUpdate = EFalse);
+
+
+
+ /**
+ * Register receiving notification on the desired service instance names or types
+ *
+ * @param aServiceName A unicode descriptor containing the name of the service you wish to register for notification.
+ * @param aServiceType A unicode descriptor containing the type of the service you wish to register for notification,
+ * @param aProtocol The protocol the service runs over, one of TCP or UDP.
+ * @return Service registration id is returned
+ * @brief
+ */
+
+ IMPORT_C void WaitForNotificationL( const RPnPParameterBundle& aNotifyParams );
+
+
+ /**
+ * Cancel the ongoing request.
+ *
+ * @param aRequestType A enum specifying the type of request to be canceled.
+ * @param aServiceName A unicode descriptor containing the name of the service .
+ * @param aServiceType A unicode descriptor containing the type of the service ,
+ * @param aProtocol The protocol the service runs over, one of TCP or UDP.
+ * @return
+ * @brief
+ */
+
+ IMPORT_C TInt Cancel( const RPnPParameterBundle& aCancelParams );
+
+
+
+
+ /**
+ *
+ * De-register the service from the device and send out absence announcement on the local-link
+ *
+ * @param aServiceRegId A integer id that uniquely identifies a registered service.
+ * @return Success or failure of the close request.
+ * @brief
+ */
+
+ IMPORT_C TInt Close();
+
+ /**
+ Default Constructor
+ */
+ IMPORT_C RMdns::RMdns();
+
+
+ private:
+ /*
+ * Based on the buffer size set by the query request Recieve Message is called
+ * which return the set of records got from the query.
+ * @param aData reference to a buffer to which the records should be set.
+ */
+ void RecieveMessage(TDes8& aData);
+ /*
+ * These is an asynchroonous request called internally by the WaitForNotification request.
+ * @param aData contains the list of new ptr records recieved on WaitForNotification request.
+ * @param aStatus used to complete asynchronous request.
+ */
+ void RecieveNotifyMessageL(TDes8& aData,TRequestStatus& aStatus);
+ private:
+ /*
+ * Query and publish request will be notifies to this object.
+ */
+ CMdnsQueryPublishNotifier* iEventNotifier;
+ /*
+ * Register for a paritcular record will be notified to this object.
+ */
+ CMdnsRegisterNotifier* iRegisterNotifier;
+ /*
+ *Buffer used to store the data in the RPnPParameter bundle and send it across to
+ *the server.
+ */
+ HBufC8* iBuffer;
+ /*
+ * Keeps the count of entries requested for notification.
+ */
+ TInt iNotifierCount;
+ /*
+ * Pointer to the descriptor iBuffer.
+ */
+ TPtr8 iBufPointer;
+ /**
+ FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+
+#endif /* __MDNSCLIENT_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/inc/cmdnspnpservicepublisherimpl.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,61 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef __CMDNSPNPPSERVICEPUBLISHERIMPL_H__
+#define __CMDNSPNPPSERVICEPUBLISHERIMPL_H__
+
+
+#include <pnp/cpnpservicepublisherbase.h>
+#include <pnp/mpnpobserver.h>
+
+//User includes
+#include "cmdnsclient.h"
+#include "mdnsparamset.h"
+#include "mdnsdebug.h"
+
+//Uid3 of this ecomplugin interface.
+const TUint KMDnsPublisherUid = 0x2001DC8A;
+/* Body of RPnPServicePublisher class and calls the SubmitRequest and NotifyResults
+ of respective classes
+ */
+class CMDnsServicePublisherImpl :public CPnPServicePublisherBase
+ {
+public:
+ static CMDnsServicePublisherImpl* NewL();
+ ~CMDnsServicePublisherImpl ( );
+
+private:
+ TInt Construct ( TUint aTierId );
+ void Publish ( const RPnPParameterBundle& aServiceInfo );
+ void SendNotify ( const RPnPParameterBundle& aServiceInfo );
+ CControlChannelBase* InitiateControlL ();
+
+
+private:
+ CMDnsServicePublisherImpl ( );
+ void PublishL ( const RPnPParameterBundle& aServiceInfo );
+ void SendNotifyL ( const RPnPParameterBundle& aServiceInfo );
+
+private:
+ //Mdns client instance.
+ RMdns iMdns;
+ /**
+ FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+ };
+
+#endif // __CMdnsPNPPSERVICEPUBLISHERIMPL_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/inc/cmdnsquerypublishnotifier.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,62 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmdnsquerypublishnotifier.h
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+#ifndef __CMDNSQUERYPUBLISHNOTIFIER_H__
+#define __CMDNSQUERYPUBLISHNOTIFIER_H__
+#include <e32base.h>
+#include "cmdnsserverconstants.h"
+#include <mdns/dnsconstants.h>
+#include "mdnsdebug.h"
+class MPnPObserver;
+
+class RMdns;
+class CMdnsQueryPublishNotifier :public CActive
+ {
+ public :
+ static CMdnsQueryPublishNotifier* NewL(RMdns& aMdns);
+ ~CMdnsQueryPublishNotifier();
+ void RunL();
+ void DoCancel();
+ TPckg<TInt>& BufferLength();
+ void SetEventNotifierActive();
+ TRequestStatus& EventNotifierStatus();
+ void SetPnpObserver(MPnPObserver* aObserver);
+ TMdnsServerMessages State() const ;
+ void SetState(TMdnsServerMessages aState);
+
+ private:
+ CMdnsQueryPublishNotifier(RMdns& aMdns);
+ void ConstructL();
+ private:
+ TInt iBufferLength;
+ TPckg<TInt> iPckgLength;
+ RMdns& iMdns;
+ MPnPObserver* iObserver;
+ TMdnsServerMessages iState;
+ TInt iPublishResult;
+ TBuf8<KMaxDNSNameLength> iPublishName;
+ /**
+ FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/inc/cmdnsregisternotifier.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,61 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmdnsregisternotifier.h
+//
+//
+
+/**
+@file
+@internalTechnology
+*/
+
+#ifndef CMDNSREGISTERNOTIFIER_H_
+#define CMDNSREGISTERNOTIFIER_H_
+
+//System Include
+#include <e32base.h>
+
+//User Include
+#include "cmdnsserverconstants.h"
+#include <mdns/dnsconstants.h>
+#include "mdnsdebug.h"
+class MPnPObserver;
+
+class RMdns;
+
+class CMdnsRegisterNotifier : public CActive
+ {
+ public:
+ static CMdnsRegisterNotifier* NewL(RMdns& aMdns);
+ ~CMdnsRegisterNotifier();
+ void SetPnpObserver(MPnPObserver* aObserver);
+ private:
+ CMdnsRegisterNotifier(RMdns& aMdns);
+ void ConstructL();
+ void RunL();
+ void DoCancel();
+ TInt RunError(TInt aError);
+ void Start();
+ private:
+ RMdns& iMdns;
+ HBufC8* iNotifyRcvdMessage;
+ TPtr8 iPtrNotifyRcvdMessage;
+ MPnPObserver* iObserver;
+ /**
+ FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+#endif /* CMDNSREGISTERNOTIFIER_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/inc/cmdnsserverconstants.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef __MDNSSERVERCONSTANTS_H__
+#define __MDNSSERVERCONSTANTS_H__
+
+#include <e32base.h>
+
+ _LIT(KMdnsServerName, "MDnsServer");
+ _LIT(KMdnsServerExe, "\\sys\\bin\\zeroconf_20008AD8.exe");
+
+enum TMdnsServerMessages
+ {
+ EZeroconfServerMessageVersion,
+ EMdnsServerQueryMessages,
+ EMdnsServerRecieveMessages,
+ EMndsServerPublishMessages,
+ EMdnsServerRecieveNotifyMessages,
+ EMdnsServerStartNotifyMessages,
+ EMdnsServerStopNotifyMessages,
+ };
+
+//const TVersion mdnsServerVersion(0, 8, 0);
+const TUid KZeroconfServerSID = { 0x20008AD8 };
+
+#endif /* __MDNSSERVERCONSTANTS_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/inc/cmdnsservicediscoveryimpl.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,67 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cpnpservicediscovery.h
+//
+//
+
+#ifndef __CMDNSPSERVICEDISCOVERYIMPL_H__
+#define __CMDNSPSERVICEDISCOVERYIMPL_H__
+
+//System include
+#include <es_sock.h>
+#include <pnp/cpnpservicediscoverybase.h>
+
+//User include.
+#include "cmdnsclient.h"
+#include "mdnsdebug.h"
+
+const TInt KUPnPDiscoveryUid = 0x2001DC88 ;
+
+/* Body of RPnPServiceDiscovery class and calls the SubmitRequest and NotifyResults
+ of respective classes
+ @internalComponent
+ */
+class CMDnsServiceDiscoveryImpl : public CPnPServiceDiscoveryBase
+ {
+public:
+ static CMDnsServiceDiscoveryImpl* NewL();
+ ~CMDnsServiceDiscoveryImpl ();
+
+private:
+ // From CPnPServiceDiscoveryBase
+ TInt Construct( TUint aTierId);
+ void Discover ( const RPnPParameterBundle& aServiceInfo );
+ void Describe ( const RPnPParameterBundle& aServiceInfo );
+ void Subscribe ( const RPnPParameterBundle& aServiceInfo );
+ void RegisterNotify ( const RPnPParameterBundle& aServiceInfo );
+ void Cancel ( const RPnPParameterBundle& aServiceInfo );
+ CControlChannelBase* InitiateControlL ( const TDesC8& aUri );
+
+private:
+ CMDnsServiceDiscoveryImpl ();
+
+ void DiscoverL ( const RPnPParameterBundle& aServiceInfo );
+ void RegisterNotifyL ( const RPnPParameterBundle& aServiceInfo );
+ void SubscribeL ( const RPnPParameterBundle& aServiceInfo );
+ void DescribeL ( const RPnPParameterBundle& aServiceInfo );
+
+private:
+ RMdns iMdns;
+ /**
+ FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+#endif // __CMDNSPSERVICEDISCOVERYIMPL_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/inc/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/inc/mdnsparamset.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,272 @@
+/*
+* Copyright (c) 2008 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef __MDNSPARAMSET_H__
+#define __MDNSPARAMSET_H__
+
+#include <es_sock.h>
+#include <pnp/pnpparameterbundle.h>
+#include <in_sock.h>
+
+
+const TInt KMDnsParamsFactoryUid = 0x2000D067;//0x2000D05E;
+
+/**
+MDns ParameterSet Family Identifiers.
+@publishedPartner
+@prototype
+*/
+enum TMDnsParamSetFamily
+ {
+ EMDnsDiscoverRequestParamSet = 1,
+ EMdnsPtrParamset = 2,
+ EMdnsSrvParamset = 3,
+ EMdnsAddrParamset = 4,
+ EMdnsTxtParamset = 5,
+ EMdnsPublishResponseParamset = 6,
+ EMdnsRegisterNotifyParamset = 7,
+ EMdnsPublishParamset = 8,
+ //@internalTechnology
+ //@prototype
+ };
+
+/**
+class TMDnsEvent
+MDnsEvent class defines the reason code for an event callback.
+@publishedPartner
+@prototype
+*/
+NONSHARABLE_CLASS(TMDnsEvent)
+ {
+public:
+ /** Type of MDns Event. */
+ enum TEventType
+ {
+ /** This signifies that the operation completed successfully. */
+ ESuccess,
+ /** This is a 'catch-all' for communicating failures. The actual error reason is
+ shown in error code. */
+ EFail,
+ /** This signifies a discovery search timeout */
+ EDiscoveryTimeout,
+ /** This signifies a subscription request timeout */
+ ESubscriptionTimeout
+ };
+
+public:
+ /** The event status. */
+ TInt iStatus;
+ /** The error code value. */
+ TInt iErrorCode;
+ };
+
+
+
+
+/**
+The base class for all MDns ParamSet classes.
+
+@internalTechnology
+@prototype
+*/
+NONSHARABLE_CLASS (CMDnsParamSetBase) : public CSubConExtensionParameterSet
+ {
+ public:
+ inline static CMDnsParamSetBase* NewL ( RParameterFamily& aFamily, TMDnsParamSetFamily aFamilyType );
+ protected:
+ inline CMDnsParamSetBase ();
+ };
+
+
+// -------------------------------------------------------------------
+
+/**
+Parameter set class containing a Uri. All UPnP Request ParamSet classes derive from this class.
+
+@internalTechnology
+@prototype
+*/
+NONSHARABLE_CLASS ( CMDnsQueryRequestParamSet ) : public CMDnsParamSetBase
+ {
+ protected:
+ RBuf8 iInstanceName;
+ TInt iQueryType;
+ TInt iProtocol;
+ RBuf8 iServiceType;
+ public:
+ inline static CMDnsQueryRequestParamSet* NewL( RParameterFamily& aFamily );
+ inline void SetInstanceNameL ( const TDesC8& aName );
+ inline const TDesC8& InstanceName () const;
+ inline void SetQueryTypeL(TInt aQueryType );
+ inline TInt QueryType()const;
+ inline void SetProtocol(TInt aProtocol);
+ inline TInt Protocol()const;
+ inline void SetServiceTypeL(const TDesC8& aServiceType);
+ inline const TDesC8& ServiceType() const;
+ protected:
+ inline ~CMDnsQueryRequestParamSet ();
+ protected:
+ DATA_VTABLE
+ };
+
+// ----------------------------------------------------------------------
+NONSHARABLE_CLASS (CMDnsPtrParamSet): public CMDnsParamSetBase
+ {
+ protected:
+ RBuf8 iInstanceName;
+ RBuf8 iDomainName;
+ TInt iTtl;
+ public:
+ inline static CMDnsPtrParamSet* NewL(RParameterFamily& aFamily) ;
+ inline void SetInstanceNameL(const TDesC8& aName);
+ inline const TDesC8& InstanceName()const;
+ inline void SetDomainNameL(const TDesC8& aDomainName);
+ inline const TDesC8& DomainName() const;
+ inline void SetTtlL(TInt aTtl);
+ inline TInt Ttl() const;
+ protected:
+ inline ~CMDnsPtrParamSet();
+ protected:
+ DATA_VTABLE
+
+ };
+
+//---------------------------------------------------------------------------
+NONSHARABLE_CLASS (CMDnsSrvParamSet): public CMDnsParamSetBase
+ {
+ protected:
+ RBuf8 iDomainName;
+ RBuf8 iTarget;
+ TUint16 iPrio;
+ TUint16 iWeight;
+ TUint16 iPort;
+
+ public:
+ inline static CMDnsSrvParamSet* NewL(RParameterFamily& aFamily) ;
+ inline void SetDomainNameL(const TDesC8& aDomainName);
+ inline const TDesC8& DomainName() const;
+ inline void SetTargetL(const TDesC8& aName);
+ inline const TDesC8& Target()const;
+ inline void SetPriority(TUint16 aPriority);
+ inline TUint16 Priority()const;
+ inline void SetWeight(TUint16 aWeight);
+ inline TUint16 Weight()const;
+ inline void SetPort(TUint16 aPort);
+ inline TUint16 Port()const;
+ protected:
+ inline ~CMDnsSrvParamSet();
+ protected:
+ DATA_VTABLE
+
+ };
+//------------------------------------------------------------------------------
+NONSHARABLE_CLASS (CMDnsAddrParamSet): public CMDnsParamSetBase
+ {
+ protected:
+ RBuf8 iDomainName;
+ TInetAddr iAddr;
+
+ public:
+ inline static CMDnsAddrParamSet* NewL(RParameterFamily& aFamily) ;
+ inline void SetDomainNameL(const TDesC8& aDomainName);
+ inline const TDesC8& DomainName() const;
+ inline void SetAddress(TInetAddr aAddr);
+ inline TInetAddr Address()const;
+ protected:
+ inline ~CMDnsAddrParamSet();
+ protected:
+ DATA_VTABLE
+
+ };
+
+//-------------------------------------------------------------------------------
+NONSHARABLE_CLASS (CMDnsTxtParamSet): public CMDnsParamSetBase
+ {
+ protected:
+ RBuf8 iDomainName;
+ RBuf8 iTxtData;
+ private:
+ TInt iCount;
+ public:
+ inline static CMDnsTxtParamSet* NewL(RParameterFamily& aFamily) ;
+ inline void SetDomainNameL(const TDesC8& aDomainName);
+ inline const TDesC8& DomainName() const;
+ inline void AppendTxtData(TDesC8& aData);
+ inline void TxtDataL(RArray<RBuf8>& aTxtData);
+ private:
+ inline void TokenizeStringL(RBuf8& aString, RArray<RBuf8>& aList, TChar aSeparator);
+ protected:
+ inline ~CMDnsTxtParamSet();
+ protected:
+ DATA_VTABLE
+
+ };
+//--------------------------------------------------------------------------------
+NONSHARABLE_CLASS (CMDnsPublishResponseParamSet): public CMDnsParamSetBase
+ {
+ protected:
+ RBuf8 iDomainName;
+ TInt iError;
+ public:
+ inline static CMDnsPublishResponseParamSet* NewL(RParameterFamily& aFamily) ;
+ inline void SetDomainNameL(const TDesC8& aDomainName);
+ inline const TDesC8& DomainName() const;
+ inline void SetError(TInt aError);
+ inline TInt Error()const;
+ protected:
+ inline ~CMDnsPublishResponseParamSet();
+ protected:
+ DATA_VTABLE
+
+ };
+
+//--------------------------------------------------------------------------------
+NONSHARABLE_CLASS (CMDnsRegisterNotifyParamSet): public CMDnsParamSetBase
+ {
+ protected:
+ RBuf8 iInstanceName;
+
+ public :
+ inline static CMDnsRegisterNotifyParamSet* NewL(RParameterFamily& aFamily);
+ inline void SetInstanceNameL(const TDesC8& aInstanceName);
+ inline const TDesC8& InstanceName()const;
+ protected:
+ inline ~CMDnsRegisterNotifyParamSet();
+ protected:
+ DATA_VTABLE
+
+ };
+
+//--------------------------------------------------------------------------------
+NONSHARABLE_CLASS (CMDnsPublishParamSet): public CMDnsParamSetBase
+ {
+ protected:
+ TBool isPublish;
+ public:
+ inline static CMDnsPublishParamSet* NewL(RParameterFamily& aFamily) ;
+ inline void SetPublishUpdate(TBool aFlag);
+ inline TBool PublishUpdate()const;
+ protected:
+ inline ~CMDnsPublishParamSet();
+ protected:
+ DATA_VTABLE
+
+ };
+#include <mdns/mdnsparamset.inl>
+
+#endif // __MDNSPARAMSET_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/inc/mdnsparamset.inl Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,374 @@
+/*
+* Copyright (c) 2008 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+CMDnsParamSetBase* CMDnsParamSetBase::NewL ( RParameterFamily& aFamily, TMDnsParamSetFamily aFamilyType )
+ {
+ STypeId typeId;
+ typeId = STypeId::CreateSTypeId( KMDnsParamsFactoryUid, aFamilyType );
+ CMDnsParamSetBase* self = static_cast < CMDnsParamSetBase* > ( CSubConParameterSet::NewL( typeId ) );
+ TBool containerValue = aFamily.IsNull();
+ if(!containerValue)
+ {
+ CleanupStack::PushL ( self );
+ aFamily.AddParameterSetL ( self, RParameterFamily::ERequested );
+ CleanupStack::Pop ( self );
+ }
+ return self;
+ }
+CMDnsParamSetBase::CMDnsParamSetBase ()
+ {
+ }
+
+// ------------------------------------------
+CMDnsQueryRequestParamSet* CMDnsQueryRequestParamSet::NewL ( RParameterFamily& aFamily )
+ {
+ return static_cast < CMDnsQueryRequestParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMDnsDiscoverRequestParamSet ) );
+ }
+
+void CMDnsQueryRequestParamSet::SetInstanceNameL ( const TDesC8& aName )
+ {
+ iInstanceName.Close ();
+ iInstanceName.CreateL(aName);
+ }
+
+const TDesC8& CMDnsQueryRequestParamSet::InstanceName () const
+ {
+ return iInstanceName;
+ }
+
+void CMDnsQueryRequestParamSet::SetQueryTypeL(TInt aQueryType)
+ {
+ iQueryType = aQueryType;
+ }
+
+TInt CMDnsQueryRequestParamSet::QueryType()const
+ {
+ return iQueryType;
+ }
+
+void CMDnsQueryRequestParamSet::SetProtocol(TInt aProtocol)
+ {
+ iProtocol = aProtocol;
+ }
+
+TInt CMDnsQueryRequestParamSet::Protocol() const
+ {
+ return iProtocol;
+ }
+
+void CMDnsQueryRequestParamSet::SetServiceTypeL(const TDesC8& aServiceType)
+ {
+ iServiceType.Close();
+ iServiceType.CreateL(aServiceType);
+ }
+
+const TDesC8& CMDnsQueryRequestParamSet::ServiceType()const
+ {
+ return iServiceType;
+ }
+
+CMDnsQueryRequestParamSet::~CMDnsQueryRequestParamSet ()
+ {
+ iInstanceName.Close ();
+ iServiceType.Close ();
+ }
+
+// -------------------------------------------------------------------------
+
+
+CMDnsPtrParamSet* CMDnsPtrParamSet::NewL(RParameterFamily& aFamily)
+ {
+ return static_cast < CMDnsPtrParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMdnsPtrParamset ) );
+ }
+
+
+void CMDnsPtrParamSet::SetInstanceNameL(const TDesC8& aName)
+ {
+ iInstanceName.Close ();
+ iInstanceName.CreateL(aName);
+ }
+
+
+const TDesC8& CMDnsPtrParamSet::InstanceName()const
+ {
+ return iInstanceName;
+ }
+
+
+void CMDnsPtrParamSet::SetDomainNameL(const TDesC8& aDomainName)
+ {
+ iDomainName.Close ();
+ iDomainName.CreateL(aDomainName);
+ }
+
+
+const TDesC8& CMDnsPtrParamSet::DomainName() const
+ {
+ return iDomainName;
+ }
+
+void CMDnsPtrParamSet::SetTtlL(TInt aTtl)
+ {
+ iTtl = aTtl;
+ }
+
+TInt CMDnsPtrParamSet::Ttl() const
+ {
+ return iTtl;
+ }
+
+
+
+CMDnsPtrParamSet::~CMDnsPtrParamSet()
+ {
+ iInstanceName.Close();
+ iDomainName.Close();
+ }
+
+
+//----------------------------------------------------------------------------------------
+CMDnsSrvParamSet* CMDnsSrvParamSet::NewL(RParameterFamily& aFamily)
+ {
+ return static_cast < CMDnsSrvParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMdnsSrvParamset ) );
+ }
+
+void CMDnsSrvParamSet::SetDomainNameL(const TDesC8& aDomainName)
+ {
+ iDomainName.Close ();
+ iDomainName.CreateL(aDomainName);
+ }
+
+const TDesC8& CMDnsSrvParamSet::DomainName() const
+ {
+ return iDomainName;
+ }
+
+void CMDnsSrvParamSet::SetTargetL(const TDesC8& aTarget)
+ {
+ iTarget.Close ();
+ iTarget.CreateL(aTarget);
+ }
+
+const TDesC8& CMDnsSrvParamSet::Target() const
+ {
+ return iTarget;
+ }
+
+void CMDnsSrvParamSet::SetPriority(TUint16 aPriority)
+ {
+ iPrio = aPriority;
+ }
+
+TUint16 CMDnsSrvParamSet::Priority()const
+ {
+ return iPrio;
+ }
+
+void CMDnsSrvParamSet::SetWeight(TUint16 aWeight)
+ {
+ iWeight = aWeight;
+ }
+
+TUint16 CMDnsSrvParamSet::Weight()const
+ {
+ return iWeight;
+ }
+
+
+void CMDnsSrvParamSet::SetPort(TUint16 aPort)
+ {
+ iPort = aPort;
+ }
+
+TUint16 CMDnsSrvParamSet::Port()const
+ {
+ return iPort;
+ }
+
+
+CMDnsSrvParamSet::~CMDnsSrvParamSet()
+ {
+ iTarget.Close();
+ iDomainName.Close();
+ }
+
+//--------------------------------------------------------------------------------
+
+CMDnsAddrParamSet* CMDnsAddrParamSet::NewL(RParameterFamily& aFamily)
+ {
+ return static_cast < CMDnsAddrParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMdnsAddrParamset ) );
+ }
+
+void CMDnsAddrParamSet::SetDomainNameL(const TDesC8& aDomainName)
+ {
+ iDomainName.Close ();
+ iDomainName.CreateL(aDomainName);
+ }
+
+const TDesC8& CMDnsAddrParamSet::DomainName() const
+ {
+ return iDomainName;
+ }
+void CMDnsAddrParamSet::SetAddress(TInetAddr aAddr)
+ {
+ iAddr = aAddr;
+ }
+
+TInetAddr CMDnsAddrParamSet::Address()const
+ {
+ return iAddr;
+ }
+
+CMDnsAddrParamSet::~CMDnsAddrParamSet()
+ {
+ iDomainName.Close();
+ }
+
+//-----------------------------------------------------------------------------------
+CMDnsTxtParamSet* CMDnsTxtParamSet::NewL(RParameterFamily& aFamily)
+ {
+ return static_cast < CMDnsTxtParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMdnsTxtParamset ) );
+ }
+void CMDnsTxtParamSet::SetDomainNameL(const TDesC8& aDomainName)
+ {
+ iDomainName.Close ();
+ iDomainName.CreateL(aDomainName);
+ }
+
+const TDesC8& CMDnsTxtParamSet::DomainName() const
+ {
+ return iDomainName;
+ }
+
+void CMDnsTxtParamSet::AppendTxtData(TDesC8& aData)
+ {
+ _LIT8(KNewLine,"\n");
+ RBuf8 temp;
+ temp.Create(iTxtData.Length() + aData.Length() + KNewLine().Length());
+ temp.Append(iTxtData);
+ temp.Append(aData);
+ temp.Append(KNewLine);
+ iTxtData.Close();
+ iTxtData.Create(temp);
+ temp.Close();
+ }
+void CMDnsTxtParamSet::TxtDataL(RArray<RBuf8>& aTxtArray)
+ {
+ TokenizeStringL(iTxtData,aTxtArray,'\n');
+ }
+
+void CMDnsTxtParamSet::TokenizeStringL(RBuf8& aString, RArray<RBuf8>& aList, TChar aSeparator)
+ {
+ TLex8 lexer(aString);
+
+ while(!lexer.Eos())
+ {
+ lexer.SkipSpaceAndMark();
+
+ while(!lexer.Eos() && lexer.Get() != aSeparator)
+ {
+ }
+
+ if(!lexer.Eos())
+ {
+ lexer.UnGet(); // Do not include trailing ','
+ }
+ RBuf8 temp;
+ temp.Create(lexer.MarkedToken());
+ aList.Append(temp);
+ lexer.Inc();
+ }
+ }
+CMDnsTxtParamSet::~CMDnsTxtParamSet()
+ {
+ iDomainName.Close();
+ iTxtData.Close();
+ }
+
+//-----------------------------------------------------------------------------------
+CMDnsPublishResponseParamSet* CMDnsPublishResponseParamSet::NewL(RParameterFamily& aFamily)
+ {
+ return static_cast < CMDnsPublishResponseParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMdnsSrvParamset ) );
+ }
+void CMDnsPublishResponseParamSet::SetDomainNameL(const TDesC8& aDomainName)
+ {
+ iDomainName.Close ();
+ iDomainName.CreateL(aDomainName);
+ }
+
+const TDesC8& CMDnsPublishResponseParamSet::DomainName() const
+ {
+ return iDomainName;
+ }
+
+void CMDnsPublishResponseParamSet::SetError(TInt aError)
+ {
+ iError = aError;
+ }
+TInt CMDnsPublishResponseParamSet::Error()const
+ {
+ return iError;
+ }
+
+CMDnsPublishResponseParamSet::~CMDnsPublishResponseParamSet()
+ {
+ iDomainName.Close();
+
+ }
+//----------------------------------------------------------------------------------------------------------------------------
+
+CMDnsRegisterNotifyParamSet* CMDnsRegisterNotifyParamSet::NewL(RParameterFamily& aFamily)
+ {
+ return static_cast < CMDnsRegisterNotifyParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMdnsRegisterNotifyParamset ) );
+ }
+
+void CMDnsRegisterNotifyParamSet::SetInstanceNameL(const TDesC8& aDomainName)
+ {
+ iInstanceName.Close ();
+ iInstanceName.CreateL(aDomainName);
+ }
+
+const TDesC8& CMDnsRegisterNotifyParamSet::InstanceName() const
+ {
+ return iInstanceName;
+ }
+
+CMDnsRegisterNotifyParamSet::~CMDnsRegisterNotifyParamSet()
+ {
+ iInstanceName.Close();
+ }
+//-----------------------------------------------------------------------------------
+CMDnsPublishParamSet* CMDnsPublishParamSet::NewL(RParameterFamily& aFamily)
+ {
+ return static_cast < CMDnsPublishParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMdnsPublishParamset ) );
+ }
+void CMDnsPublishParamSet::SetPublishUpdate(TBool aFlag)
+ {
+ isPublish = aFlag;
+ }
+
+TBool CMDnsPublishParamSet::PublishUpdate()const
+ {
+ return isPublish;
+ }
+
+CMDnsPublishParamSet::~CMDnsPublishParamSet()
+ {
+
+ }
+//----------------------------------------------------------------------------------------------------------------------------
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/inc/mdnsparamset__.inl Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,345 @@
+/*
+* Copyright (c) 2008 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+CMDnsParamSetBase* CMDnsParamSetBase::NewL ( RParameterFamily& aFamily, TMDnsParamSetFamily aFamilyType )
+ {
+ //STypeId typeId( KMDnsParamsFactoryUid, aFamilyType );
+ STypeId typeId;
+ typeId = STypeId::CreateSTypeId( KMDnsParamsFactoryUid, aFamilyType );
+
+ CMDnsParamSetBase* self = static_cast < CMDnsParamSetBase* > ( CSubConParameterSet::NewL( typeId ) );
+ TBool containerValue = aFamily.IsNull();
+ if(!containerValue)
+ {
+ CleanupStack::PushL ( self );
+ aFamily.AddParameterSetL ( self, RParameterFamily::ERequested );
+ CleanupStack::Pop ( self );
+ }
+ return self;
+ }
+CMDnsParamSetBase::CMDnsParamSetBase ()
+ {
+ }
+
+// ------------------------------------------
+CMDnsQueryRequestParamSet* CMDnsQueryRequestParamSet::NewL ( RParameterFamily& aFamily )
+ {
+ return static_cast < CMDnsQueryRequestParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMDnsDiscoverRequestParamSet ) );
+ }
+
+void CMDnsQueryRequestParamSet::SetInstanceNameL ( const TDesC8& aName )
+ {
+ iInstanceName.Close ();
+ iInstanceName.CreateL(aName);
+ }
+
+const TDesC8& CMDnsQueryRequestParamSet::InstanceName () const
+ {
+ return iInstanceName;
+ }
+
+void CMDnsQueryRequestParamSet::SetQueryTypeL(TInt aQueryType)
+ {
+ iQueryType = aQueryType;
+ }
+
+TInt CMDnsQueryRequestParamSet::QueryType()const
+ {
+ return iQueryType;
+ }
+
+void CMDnsQueryRequestParamSet::SetProtocol(TInt aProtocol)
+ {
+ iProtocol = aProtocol;
+ }
+
+TInt CMDnsQueryRequestParamSet::Protocol() const
+ {
+ return iProtocol;
+ }
+
+void CMDnsQueryRequestParamSet::SetServiceTypeL(const TDesC8& aServiceType)
+ {
+ iServiceType.Close();
+ iServiceType.CreateL(aServiceType);
+ }
+
+const TDesC8& CMDnsQueryRequestParamSet::ServiceType()const
+ {
+ return iServiceType;
+ }
+
+CMDnsQueryRequestParamSet::~CMDnsQueryRequestParamSet ()
+ {
+ iInstanceName.Close ();
+ iServiceType.Close ();
+ }
+
+// -------------------------------------------------------------------------
+
+
+CMDnsPtrParamSet* CMDnsPtrParamSet::NewL(RParameterFamily& aFamily)
+ {
+ return static_cast < CMDnsPtrParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMdnsPtrParamset ) );
+ }
+
+
+void CMDnsPtrParamSet::SetInstanceNameL(const TDesC8& aName)
+ {
+ iInstanceName.Close ();
+ iInstanceName.CreateL(aName);
+ }
+
+
+const TDesC8& CMDnsPtrParamSet::InstanceName()const
+ {
+ return iInstanceName;
+ }
+
+
+void CMDnsPtrParamSet::SetDomainNameL(const TDesC8& aDomainName)
+ {
+ iDomainName.Close ();
+ iDomainName.CreateL(aDomainName);
+ }
+
+
+const TDesC8& CMDnsPtrParamSet::DomainName() const
+ {
+ return iDomainName;
+ }
+
+
+CMDnsPtrParamSet::~CMDnsPtrParamSet()
+ {
+ iInstanceName.Close();
+ iDomainName.Close();
+ }
+
+
+//----------------------------------------------------------------------------------------
+CMDnsSrvParamSet* CMDnsSrvParamSet::NewL(RParameterFamily& aFamily)
+ {
+ return static_cast < CMDnsSrvParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMdnsSrvParamset ) );
+ }
+
+void CMDnsSrvParamSet::SetDomainNameL(const TDesC8& aDomainName)
+ {
+ iDomainName.Close ();
+ iDomainName.CreateL(aDomainName);
+ }
+
+const TDesC8& CMDnsSrvParamSet::DomainName() const
+ {
+ return iDomainName;
+ }
+
+void CMDnsSrvParamSet::SetTargetL(const TDesC8& aTarget)
+ {
+ iTarget.Close ();
+ iTarget.CreateL(aTarget);
+ }
+
+const TDesC8& CMDnsSrvParamSet::Target() const
+ {
+ return iTarget;
+ }
+
+void CMDnsSrvParamSet::SetPriority(TUint16 aPriority)
+ {
+ iPrio = aPriority;
+ }
+
+TUint16 CMDnsSrvParamSet::Priority()const
+ {
+ return iPrio;
+ }
+
+void CMDnsSrvParamSet::SetWeight(TUint16 aWeight)
+ {
+ iWeight = aWeight;
+ }
+
+TUint16 CMDnsSrvParamSet::Weight()const
+ {
+ return iWeight;
+ }
+
+
+void CMDnsSrvParamSet::SetPort(TUint16 aPort)
+ {
+ iPort = aPort;
+ }
+
+TUint16 CMDnsSrvParamSet::Port()const
+ {
+ return iPort;
+ }
+
+
+CMDnsSrvParamSet::~CMDnsSrvParamSet()
+ {
+ iTarget.Close();
+ iDomainName.Close();
+ }
+
+//--------------------------------------------------------------------------------
+
+CMDnsAddrParamSet* CMDnsAddrParamSet::NewL(RParameterFamily& aFamily)
+ {
+ return static_cast < CMDnsAddrParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMdnsAddrParamset ) );
+ }
+
+void CMDnsAddrParamSet::SetDomainNameL(const TDesC8& aDomainName)
+ {
+ iDomainName.Close ();
+ iDomainName.CreateL(aDomainName);
+ }
+
+const TDesC8& CMDnsAddrParamSet::DomainName() const
+ {
+ return iDomainName;
+ }
+void CMDnsAddrParamSet::SetAddress(TInetAddr aAddr)
+ {
+ iAddr = aAddr;
+ }
+
+TInetAddr CMDnsAddrParamSet::Address()const
+ {
+ return iAddr;
+ }
+
+CMDnsAddrParamSet::~CMDnsAddrParamSet()
+ {
+ iDomainName.Close();
+ }
+
+//-----------------------------------------------------------------------------------
+CMDnsTxtParamSet* CMDnsTxtParamSet::NewL(RParameterFamily& aFamily)
+ {
+ return static_cast < CMDnsTxtParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMdnsTxtParamset ) );
+ }
+void CMDnsTxtParamSet::SetDomainNameL(const TDesC8& aDomainName)
+ {
+ iDomainName.Close ();
+ iDomainName.CreateL(aDomainName);
+ }
+
+const TDesC8& CMDnsTxtParamSet::DomainName() const
+ {
+ return iDomainName;
+ }
+
+void CMDnsTxtParamSet::AppendTxtData(TDesC8& aData)
+ {
+ _LIT8(KNewLine,"\n");
+ RBuf8 temp;
+ temp.Create(iTxtData.Length() + aData.Length() + KNewLine().Length());
+ temp.Append(iTxtData);
+ temp.Append(aData);
+ temp.Append(KNewLine);
+ iTxtData.Close();
+ iTxtData.Create(temp);
+ temp.Close();
+ }
+void CMDnsTxtParamSet::TxtDataL(RArray<RBuf8>& aTxtArray)
+ {
+ TokenizeStringL(iTxtData,aTxtArray,'\n');
+ }
+
+void CMDnsTxtParamSet::TokenizeStringL(RBuf8& aString, RArray<RBuf8>& aList, TChar aSeparator)
+ {
+ TLex8 lexer(aString);
+
+ while(!lexer.Eos())
+ {
+ lexer.SkipSpaceAndMark();
+
+ while(!lexer.Eos() && lexer.Get() != aSeparator)
+ {
+ }
+
+ if(!lexer.Eos())
+ {
+ lexer.UnGet(); // Do not include trailing ','
+ }
+ RBuf8 temp;
+ temp.Create(lexer.MarkedToken());
+ aList.Append(temp);
+ lexer.Inc();
+ }
+ }
+CMDnsTxtParamSet::~CMDnsTxtParamSet()
+ {
+ iDomainName.Close();
+ iTxtData.Close();
+ }
+
+//-----------------------------------------------------------------------------------
+CMDnsPublishResponseParamSet* CMDnsPublishResponseParamSet::NewL(RParameterFamily& aFamily)
+ {
+ return static_cast < CMDnsPublishResponseParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMdnsSrvParamset ) );
+ }
+void CMDnsPublishResponseParamSet::SetDomainNameL(const TDesC8& aDomainName)
+ {
+ iDomainName.Close ();
+ iDomainName.CreateL(aDomainName);
+ }
+
+const TDesC8& CMDnsPublishResponseParamSet::DomainName() const
+ {
+ return iDomainName;
+ }
+
+void CMDnsPublishResponseParamSet::SetError(TInt aError)
+ {
+ iError = aError;
+ }
+TInt CMDnsPublishResponseParamSet::Error()const
+ {
+ return iError;
+ }
+
+CMDnsPublishResponseParamSet::~CMDnsPublishResponseParamSet()
+ {
+ iDomainName.Close();
+
+ }
+//----------------------------------------------------------------------------------------------------------------------------
+
+CMDnsRegisterNotifyParamSet* CMDnsRegisterNotifyParamSet::NewL(RParameterFamily& aFamily)
+ {
+ return static_cast < CMDnsRegisterNotifyParamSet* > ( CMDnsParamSetBase::NewL( aFamily, EMdnsRegisterNotifyParamset ) );
+ }
+
+void CMDnsRegisterNotifyParamSet::SetInstanceNameL(const TDesC8& aDomainName)
+ {
+ iInstanceName.Close ();
+ iInstanceName.CreateL(aDomainName);
+ }
+
+const TDesC8& CMDnsRegisterNotifyParamSet::InstanceName() const
+ {
+ return iInstanceName;
+ }
+
+CMDnsRegisterNotifyParamSet::~CMDnsRegisterNotifyParamSet()
+ {
+ iInstanceName.Close();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/inc/mdnsparamsextfactory.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2008 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+#ifndef __MDNSPARAMSEXTFACTORY_H__
+#define __MDNSPARAMSEXTFACTORY_H__
+
+#include <e32base.h>
+
+class CMDnsParamSetBase;
+
+class CMDnsParamsExtFactory : public CBase
+{
+ public:
+ static CMDnsParamSetBase* NewL ( TAny* aConstructionParams );
+};
+
+#endif // __MDNSPARAMSEXTFACTORY_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/inc/mmdnseventnotification.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2008 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef __MMDNSEVENTNOTIFICATION_H_
+#define __MMDNSEVENTNOTIFICATION_H_
+#include <e32def.h>
+
+class MMDnsEventNotification
+ {
+public:
+ virtual void OnNotificationL(TUint32)=0;
+ };
+
+#endif /*MMDNSEVENTNOTIFICATION_H_*/
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/src/2000D066.rss Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2008 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+{
+dll_uid = 0x2000D066;
+interfaces =
+ {
+ INTERFACE_INFO
+ {
+ interface_uid = 0x10204303;
+ implementations =
+ {
+ IMPLEMENTATION_INFO
+ {
+ implementation_uid = 0x2000D067;
+ version_no = 1;
+ display_name = "UPnP Sub-Connection Extension Parameter Set Factory";
+ default_data = "text/wml";
+ }
+ };
+ },
+ INTERFACE_INFO
+ {
+ interface_uid = 0x2000D060;
+ implementations =
+ {
+ IMPLEMENTATION_INFO
+ {
+ implementation_uid = 0x2001DC88;
+ version_no = 1;
+ display_name = "Mdns Discovery";
+ default_data = "536924288/Client";
+ },
+ IMPLEMENTATION_INFO
+ {
+ implementation_uid = 0x2001DC8A;
+ version_no = 1;
+ display_name = "Mdns Publish";
+ default_data = "536992906/Server";
+ }
+ };
+ }
+
+ };
+}
+//INTERFACE_INFO
+ // {
+ // interface_uid = 0x10204305;
+ // implementations =
+ // {
+ // IMPLEMENTATION_INFO
+ // {
+ // implementation_uid = 0x2000D05F;
+ // version_no = 1;
+ // display_name = "UPnP Sub-Connection Events Factory";
+ // default_data = "text/wml";
+ // }
+ // };
+ // },
+
+ // IMPLEMENTATION_INFO
+ // {
+ // implementation_uid = 0x2001DC6A;
+ // version_no = 1;
+ // display_name = "UPnP Publish";
+ // default_data = "536924244/Server";
+ // }
+ // };
+ // }
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/src/cmdnsclient.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,252 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmdnsclient.cpp
+//
+//
+/**
+@file
+@PublishedAll
+*/
+
+//User include
+#include "cmdnsclient.h"
+#include "cmdnsserverconstants.h"
+
+
+//System include
+#include <mdns/dnsconstants.h>
+#include <s32mem.h>
+#include <in_sock.h>
+
+__FLOG_STMT(_LIT8(KComponent,"MDNSClient");)
+/*
+ * Default constructor -Assigns the buffer pointer to Null
+ */
+EXPORT_C RMdns::RMdns():iBufPointer(NULL,0)
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ }
+
+/*
+ * Interface to start the Mdns server .
+ * KMdnsServerName referes to the name of the Mdns server.
+ * @param aConnectionHandle handle to the RConnection object // TODO
+ * @param aSocketServerHandle handler to the RSocketServ object //TODO
+ *
+ */
+EXPORT_C TInt RMdns::Open(TInt aConnectionHandle)
+ {
+ __FLOG(_L8("RMdns::Open - Entry"));
+ TVersion serverVersion(0, 0, 0);
+ //creates a new session if the server exists and it is up and running .
+ //returns KErrNotFound if the server needs to be launched.
+ TInt err = CreateSession(KMdnsServerName, serverVersion, 2);
+ if (err == KErrNotFound)
+ {
+ // try starting the server, since create session didn't work
+ //iap refers to the iap application wants to use.
+ TBuf<16> iap;
+ iap.AppendNum(aConnectionHandle);
+ RProcess server;
+ User::LeaveIfError(server.Create(KMdnsServerExe, iap));
+ server.Resume();
+ TRequestStatus status;
+ status = KRequestPending;
+ server.Rendezvous(status);
+ //waits for the server to construct all the required object.
+ User::WaitForRequest(status);
+ User::LeaveIfError(status.Int());
+ User::LeaveIfError(CreateSession(KMdnsServerName, serverVersion, 2));
+ server.Close();
+ }
+ else
+ {
+ User::LeaveIfError(err);
+ }
+ iNotifierCount =0;
+ //creates a buffer object with buffer length KDnsBufferlength = 1000 this is the max application
+ //could send stored in the bundle.
+ iBuffer = HBufC8::NewL(KDnsBufferlength);
+ //Set the pointer to point buffer.
+ iBufPointer.Set(iBuffer->Des());
+ //Create a notifier which will be used to catch all the publish and
+ // query response . There will be only one eventobserver for the client.
+ //Will be destroyed when the client will be closed.
+ TRAPD(error,iEventNotifier = CMdnsQueryPublishNotifier::NewL(*this));
+ __FLOG(_L8("RMdns::Open - Exit"));
+ return error;
+ }
+
+/*
+ * Hanldes any queries either the ptr ,srv txt and address record
+ * IN case of PTR query will be send to the network .
+ * For SRV and TXT if it exist in the cache ,request will be completed immediately .
+ * @param aQueryParams contains the query bundle.
+ * Leaves with KErrAlreadyExists if a request is pending.
+ */
+EXPORT_C void RMdns::QueryL( const RPnPParameterBundle& aQueryParams )
+ {
+ __FLOG(_L8("RMdns::QueryL - Entry"));
+ //Get the status of the event notifies . If it is KRequestPending
+ //there exists a query which needs to be completed .
+ //Leaves with KErrAlreadyExist if there is query which is pending.
+ TRequestStatus &status = iEventNotifier->EventNotifierStatus();
+ if( status.Int() == KRequestPending)
+ {
+ User::Leave(KErrAlreadyExists);
+ }
+ //Set the buffer pointer to zero and convert bundle in to buffer and store it in buffer.
+ iBufPointer.Zero();
+ TInt temp = aQueryParams.Length();
+ aQueryParams.Store(iBufPointer);
+ //TODO
+ //Create a reference to buffer length and send it along the with the request.
+ //On completion contains the length of the buffer client should create to get the
+ //response for the query.
+ //TPckg<TInt> len(iEventNotifier->BufferLength());
+ TIpcArgs args(&iBufPointer,&iEventNotifier->BufferLength());
+ //Set Event notifier active
+ iEventNotifier->SetEventNotifierActive();
+ iEventNotifier->SetPnpObserver(aQueryParams.PnPObserver());
+ //Set the state as query message so that on response it can decide wheteher it is query or publish.
+ iEventNotifier->SetState(EMdnsServerQueryMessages);
+ TRAPD(error,SendReceive(EMdnsServerQueryMessages,args, status));
+ __FLOG(_L8("RMdns::QueryL - Exit"));
+ }
+
+//TODO yet to decide wat to do with this
+//as query itself can handle all the requests
+
+EXPORT_C void RMdns::ResolveL( const RPnPParameterBundle& aResolveParams )
+ {
+ __FLOG(_L8("RMdns::ResolveL - Entry"));
+ QueryL(aResolveParams);
+ __FLOG(_L8("RMdns::ResolveL - Exit"));
+ }
+
+/*
+ * Interferace for the applicaion to register for a particular service it serves
+ * on the network , A copy of this will be kept in the cache .
+ * applicaion dont have to renew the service .Consistency Manager will take care of renewing the service.
+ * @param aPublishParam contains the srv record and the txt record if required need to be published.
+ *
+ */
+EXPORT_C void RMdns::RegisterServiceL( const RPnPParameterBundle& aPublishParams ,TBool aIsUpdate)
+ {
+ __FLOG(_L8("RMdns::RegisterServiceL - Entry"));
+ iBufPointer.Zero();
+ aPublishParams.Store(iBufPointer);
+ TIpcArgs args(&iBufPointer,&iEventNotifier->BufferLength(),aIsUpdate);
+ iEventNotifier->SetEventNotifierActive();
+ iEventNotifier->SetPnpObserver(aPublishParams.PnPObserver());
+ TRequestStatus &status = iEventNotifier->EventNotifierStatus();
+ iEventNotifier->SetState(EMndsServerPublishMessages);
+ TRAPD(error,SendReceive(EMndsServerPublishMessages,args,status));
+ User::LeaveIfError(error);
+ __FLOG(_L8("RMdns::RegisterServiceL - Exit"));
+ }
+
+/*
+ * An Asychronous request which tells the mdns about the service it is interested in .
+ * Internally it calls RecieveNotifyMessageL which is a private function, feasible only to CMDnsregisterNotifier
+ * CMDnsRegisterNotifier is an active object running all the time waiting for any ptr enteries.
+ * @param aNotifyParam contains the ptr type the application is interrested in ;to be notified.
+ */
+EXPORT_C void RMdns::WaitForNotificationL( const RPnPParameterBundle& aNotifyParams )
+ {
+ __FLOG(_L8("RMdns::WaitForNotificationL - Entry"));
+ if(!iRegisterNotifier)
+ {
+ iRegisterNotifier = CMdnsRegisterNotifier::NewL(*this);
+ }
+ iRegisterNotifier->SetPnpObserver(aNotifyParams.PnPObserver());
+ HBufC8* buffer = HBufC8::NewL(KDnsBufferlength);
+ TPtr8 aNotifyMessage(NULL,0,0);
+ aNotifyMessage.Set(buffer->Des());
+ aNotifyParams.Store(aNotifyMessage);
+ TIpcArgs args(&aNotifyMessage);
+ SendReceive(EMdnsServerStartNotifyMessages,args);
+ iNotifierCount++;
+ delete buffer;
+ __FLOG(_L8("RMdns::WaitForNotificationL - Exit"));
+ }
+
+/*
+ *Interface to cancel any notification client requested for .
+ *@param aCancelParams contains the name of the ptr type client is not interested to be notified.
+ *
+ */
+EXPORT_C TInt RMdns::Cancel( const RPnPParameterBundle& aCancelParams )
+ {
+ __FLOG(_L8("RMdns::Cancel - Entry"));
+ //notifier count keeps track of the number of entries requested for.
+ iNotifierCount--;
+ HBufC8* buffer = HBufC8::NewL(KDnsBufferlength);
+ TPtr8 aNotifyMessage(NULL,0,0);
+ aNotifyMessage.Set(buffer->Des());
+ aCancelParams.Store(aNotifyMessage);
+ TIpcArgs args(&aNotifyMessage);
+ SendReceive(EMdnsServerStopNotifyMessages,args);
+ //when notifier count is zero close the CMdnsRegisterNotifier active object.
+ //count =0 means the concerned client is not interested in any notification.
+ if(iNotifierCount == 0)
+ {
+ iRegisterNotifier->Cancel();
+ }
+ delete buffer;
+ __FLOG(_L8("RMdns::Cancel - Exit"));
+ return KErrNone;
+ }
+
+/*
+ * Destructor
+ */
+EXPORT_C TInt RMdns::Close()
+ {
+ __FLOG(_L8("RMdns::Close - Entry"));
+ RSessionBase::Close();
+ delete iEventNotifier;
+ delete iRegisterNotifier;
+ delete iBuffer;
+ __FLOG(_L8("RMdns::Close - Exit"));
+ __FLOG_CLOSE;
+ return KErrNone;
+ }
+
+/*
+ * Private function used by the Query and publish notifier .
+ * Based on the size of the buffer recieved by the query and publish request.
+ * a new buffer is allocated and sent to recieve the response.
+ * @param aData contains the buffer allocated to recieve the response.
+ */
+void RMdns::RecieveMessage(TDes8& aData)
+ {
+ __FLOG(_L8("RMdns::RecieveMessage - Entry"));
+ TIpcArgs args(&aData);
+ TRAPD(error,SendReceive(EMdnsServerRecieveMessages,args));
+ __FLOG(_L8("RMdns::RecieveMessage - Exit"));
+ }
+
+/*
+ * An synchronous request will be running all the time . whenever a waitfornotification been called.
+ * @param aData contains the buffer for which data to be set to .
+ * @param aStatus used to complete the asynchronous request.
+ */
+void RMdns::RecieveNotifyMessageL(TDes8& aData,TRequestStatus& aStatus)
+ {
+ __FLOG(_L8("RMdns::RecieveNotifyMessageL - Entry"));
+ TIpcArgs args(&aData);
+ SendReceive(EMdnsServerRecieveNotifyMessages,args,aStatus);
+ __FLOG(_L8("RMdns::RecieveNotifyMessageL - Exit"));
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/src/cmdnspnpservicepublisher.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,156 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmdnspnpservicepublisherimpl.cpp
+//
+//
+
+//User include
+#include "cmdnspnpservicepublisherimpl.h"
+__FLOG_STMT(_LIT8(KComponent,"CMDnsServicePublisherImpl");)
+/*
+ *Default constructor
+ */
+CMDnsServicePublisherImpl::CMDnsServicePublisherImpl ()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ }
+
+/*
+ * Two phase constructor
+ */
+CMDnsServicePublisherImpl* CMDnsServicePublisherImpl::NewL()
+ {
+
+ return new ( ELeave ) CMDnsServicePublisherImpl;
+
+ }
+
+/*
+ * Destructor
+ */
+CMDnsServicePublisherImpl::~CMDnsServicePublisherImpl ()
+ {
+ __FLOG(_L8("CMDnsServicePublisherImpl::~CMDnsServicePublisherImpl - Entry"));
+ iMdns.Close();
+ __FLOG(_L8("CMDnsServicePublisherImpl::~CMDnsServicePublisherImpl - Exit"));
+ __FLOG_CLOSE;
+ }
+
+/*
+ * virtual function in the base class CPnPServicePublisherBase
+ * Will be called to construct the object.
+ * Launches the Mdns server if not already and creates a new session.
+ * Graps the Iap and sends the same to server to use .
+ *
+ */
+TInt CMDnsServicePublisherImpl::Construct(TUint /*aTierId*/)
+ {
+ __FLOG(_L8("CMDnsServicePublisherImpl::Construct - Entry"));
+ RSocketServ sockServ;
+ RConnection connection;
+ TInt error = sockServ.Connect();
+ error = connection.Open(sockServ);
+
+ // start a connection, and grab the IAP ID
+ error = connection.Start();
+
+ TUint32 iap ;
+ _LIT(KCommdbIapSetting, "IAP\\Id");
+ connection.GetIntSetting(KCommdbIapSetting, iap);
+ iMdns.Open(iap);
+ connection.Close();
+ sockServ.Close();
+ __FLOG(_L8("CMDnsServicePublisherImpl::Construct - Exit"));
+ return error;
+ }
+
+/*
+ * Publishes the service client sent along with bundle.
+ * any error will be notified back using the Observer inside the bundle.
+ */
+void CMDnsServicePublisherImpl::Publish ( const RPnPParameterBundle& aServiceInfo )
+ {
+ __FLOG(_L8("CMDnsServicePublisherImpl::Publish - Entry"));
+ TRAPD(err, PublishL( aServiceInfo ));
+ if(err != KErrNone )
+ aServiceInfo.PnPObserver()->OnPnPError(err);
+ __FLOG(_L8("CMDnsServicePublisherImpl::Publish - Exit"));
+ }
+
+/*
+ *Leaving function which publish any services client want to .
+ *Might contain the additional text record . If client wish to publish.
+ *@param aServiceInfo RPnpParameterBundle contains the domainName need to be published.
+ */
+void CMDnsServicePublisherImpl::PublishL (const RPnPParameterBundle& aServiceInfo )
+ {
+ __FLOG(_L8("CMDnsServicePublisherImpl::PublishL - Entry"));
+ TBool isUpdate = EFalse;
+ HBufC8* data = HBufC8::NewLC(aServiceInfo.Length());
+ TPtr8 buffer = data->Des();
+ aServiceInfo.Store(buffer);
+ RPnPParameterBundle serviceInfo;
+ serviceInfo.CreateL();
+ serviceInfo.Load(buffer);
+ RParameterFamily publishFamily = serviceInfo.FindFamily( EMdnsPublishParamset) ;
+ if(!publishFamily.IsNull() && publishFamily.CountParameterSets()>0)
+ {
+ CMDnsPublishParamSet* publishParamSet = static_cast<CMDnsPublishParamSet*> (publishFamily.GetParameterSetAtIndex ( 0, RParameterFamily::ERequested ));
+ isUpdate = publishParamSet->PublishUpdate();
+ }
+ iMdns.RegisterServiceL(aServiceInfo,isUpdate);
+ serviceInfo.Close();
+ CleanupStack::PopAndDestroy();//data
+ __FLOG(_L8("CMDnsServicePublisherImpl::PublishL - Exit"));
+ }
+
+/*
+ * Used to request for any notification of the service type client is interested in .
+ * @param aServiceInfo a RPnPParameterBundle which contains the servicetype ,
+ * client is interested in .
+ */
+void CMDnsServicePublisherImpl::SendNotify ( const RPnPParameterBundle& aServiceInfo )
+ {
+ __FLOG(_L8("CMDnsServicePublisherImpl::SendNotify - Entry"));
+ TRAPD( err, SendNotifyL( aServiceInfo ));
+ if ( err != KErrNone )
+ aServiceInfo.PnPObserver()->OnPnPError(err);
+ __FLOG(_L8("CMDnsServicePublisherImpl::SendNotify - Exit"));
+ }
+
+/*
+ *@param aServiceInfo a RPnPParameterBundle which contains the servicetype ,
+ *client is interested in .
+ */
+void CMDnsServicePublisherImpl::SendNotifyL ( const RPnPParameterBundle& aServiceInfo )
+ {
+ __FLOG(_L8("CMDnsServicePublisherImpl::SendNotifyL - Entry"));
+ iMdns.RegisterServiceL(aServiceInfo);
+ __FLOG(_L8("CMDnsServicePublisherImpl::SendNotifyL - Exit"));
+ }
+
+/*
+ * Nothing to do with this .
+ * Might need it in future.
+ */
+CControlChannelBase* CMDnsServicePublisherImpl::InitiateControlL ()
+ {
+ __FLOG(_L8("CMDnsServicePublisherImpl::InitiateControlL - Entry"));
+ //Nothing to do .
+ //Not Implemented
+ __FLOG(_L8("CMDnsServicePublisherImpl::InitiateControlL - Exit"));
+ return NULL;
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/src/cmdnsquerypublishnotifier.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,187 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmdnsquerypublishnotifier.cpp
+//
+//
+
+/**
+@file
+@internalTechnology
+*/
+//User include
+#include "cmdnsquerypublishnotifier.h"
+#include "cmdnsclient.h"
+
+//System include
+#include <pnp/mpnpobserver.h>
+#include <mdns/mdnsparamset.h>
+__FLOG_STMT(_LIT8(KComponent,"CMdnsQueryPublishNotifier");)
+/*
+ * Two phase constructor.
+ * @param aMdns a refernce to the mdns client .
+ * @return returns the instance .
+ */
+CMdnsQueryPublishNotifier* CMdnsQueryPublishNotifier::NewL(RMdns& aMdns)
+ {
+ CMdnsQueryPublishNotifier* self = new (ELeave)CMdnsQueryPublishNotifier(aMdns);
+ return self;
+ }
+
+/*
+ * Destructor
+ */
+CMdnsQueryPublishNotifier::~CMdnsQueryPublishNotifier()
+ {
+ __FLOG(_L8("CMdnsQueryPublishNotifier::~CMdnsQueryPublishNotifier - Entry"));
+ iObserver = NULL;
+ __FLOG(_L8("CMdnsQueryPublishNotifier::~CMdnsQueryPublishNotifier - Exit"));
+ __FLOG_CLOSE;
+ }
+/*
+ * :)Function gets hit whenever a query or publish request gets completed.
+ * On completeion iBufferlength contains the no of bytes to be allocated to read
+ * the response.
+ */
+void CMdnsQueryPublishNotifier::RunL()
+ {
+ __FLOG(_L8("CMdnsQueryPublishNotifier::RunL - Entry"));
+ if(iStatus.Int() == KErrNone )
+ {
+ HBufC8* data = HBufC8::NewL(iBufferLength);
+ CleanupStack::PushL(data);
+ TPtr8 dataPointer(data->Des());
+ RPnPParameterBundle responseBundle;
+ responseBundle.CreateL();
+ switch (iState)
+ {
+ case EMdnsServerQueryMessages :
+ {
+ iMdns.RecieveMessage(dataPointer);
+ responseBundle.Load(dataPointer);
+ iObserver->OnPnPEventL(responseBundle);
+
+
+ break;
+ }
+ case EMndsServerPublishMessages:
+ {
+ iMdns.RecieveMessage(dataPointer);
+ responseBundle.Load(dataPointer);
+ iObserver->OnPnPEventL(responseBundle);
+ break;
+
+ }
+ }
+ responseBundle.Close();
+ CleanupStack::PopAndDestroy();//data
+ }
+ else
+ {
+ iObserver->OnPnPError(iStatus.Int());
+ }
+ __FLOG(_L8("CMdnsQueryPublishNotifier::RunL - Exit"));
+ }
+
+
+void CMdnsQueryPublishNotifier::DoCancel()
+ {
+ __FLOG(_L8("CMdnsQueryPublishNotifier::DoCancel - Entry"));
+ iObserver = NULL;
+ __FLOG(_L8("CMdnsQueryPublishNotifier::DoCancel - Exit"));
+ }
+
+/*
+ * Constructor
+ * @param reference to RMdns
+ */
+CMdnsQueryPublishNotifier::CMdnsQueryPublishNotifier(RMdns& aMdns):CActive(EPriorityStandard),iMdns(aMdns),iPckgLength(iBufferLength)
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ __FLOG(_L8("CMdnsQueryPublishNotifier::CMdnsQueryPublishNotifier - Entry"));
+ CActiveScheduler::Add(this);
+ __FLOG(_L8("CMdnsQueryPublishNotifier::CMdnsQueryPublishNotifier - Exit"));
+ }
+
+/*
+ * return reference to iBufferLength object .\\
+ * Same will be used to set the size of the buffer client can expect on completion of
+ * query and publish.
+ * @return iBufferlength areference to iBufferLength object
+ */
+TPckg<TInt>& CMdnsQueryPublishNotifier::BufferLength()
+ {
+ __FLOG(_L8("CMdnsQueryPublishNotifier::BufferLength - Entry"));
+ return iPckgLength;
+ __FLOG(_L8("CMdnsQueryPublishNotifier::BufferLength - Exit"));
+ }
+
+/*
+ * Cancel the asynchoronous request if it is already active.
+ * Calls SetActive and sets the status to KRequestPending.
+ */
+void CMdnsQueryPublishNotifier::SetEventNotifierActive()
+ {
+ __FLOG(_L8("CMdnsQueryPublishNotifier::SetEventNotifierActive - Entry"));
+ if(IsActive())
+ {
+ Cancel();
+ }
+ SetActive();
+ iStatus = KRequestPending;
+ __FLOG(_L8("CMdnsQueryPublishNotifier::SetEventNotifierActive - Exit"));
+ }
+
+/*
+ * Returns the refernce to iStatus of the active object
+ * @return iStatus reference to status of the active object.
+ */
+TRequestStatus& CMdnsQueryPublishNotifier::EventNotifierStatus()
+ {
+ __FLOG(_L8("CMdnsQueryPublishNotifier::EventNotifierStatus - Entry"));
+ return iStatus;
+ __FLOG(_L8("CMdnsQueryPublishNotifier::EventNotifierStatus - Exit"));
+ }
+
+/*
+ * Function to keep a refernce to the observer of the client.
+ * @param aObserver An observer to the client.
+ */
+
+void CMdnsQueryPublishNotifier::SetPnpObserver(MPnPObserver* aObserver)
+ {
+ __FLOG(_L8("CMdnsQueryPublishNotifier::SetPnpObserver - Entry"));
+ iObserver = aObserver;
+ __FLOG(_L8("CMdnsQueryPublishNotifier::SetPnpObserver - Exit"));
+ }
+/*
+ * Set the state to either query or publish based on the request.
+ * @param aState either query or publish.
+ */
+void CMdnsQueryPublishNotifier::SetState(TMdnsServerMessages aState)
+ {
+ __FLOG(_L8("CMdnsQueryPublishNotifier::SetState - Entry"));
+ iState = aState;
+ __FLOG(_L8("CMdnsQueryPublishNotifier::SetState - Exit"));
+ }
+
+/*
+ * Returns the service notifier is in
+ * @return iState returns the state.
+ */
+TMdnsServerMessages CMdnsQueryPublishNotifier::State() const
+ {
+ __FLOG(_L8("CMdnsQueryPublishNotifier::State - Entry"));
+ return iState;
+ __FLOG(_L8("CMdnsQueryPublishNotifier::State - Exit"));
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/src/cmdnsregisternotifier.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,155 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmdnsregisternotifier.cpp
+//
+//
+
+/**
+@file
+@internalTechnology
+*/
+
+//System include
+#include <mdns/mdnsparamset.h>
+#include <pnp/mpnpobserver.h>
+
+//User include
+#include "cmdnsregisternotifier.h"
+#include "cmdnsclient.h"
+__FLOG_STMT(_LIT8(KComponent,"CMdnsRegisterNotifier");)
+/*
+ * Two phase constructor
+ * @param aMdns reference to RMdns client object
+ */
+CMdnsRegisterNotifier* CMdnsRegisterNotifier::NewL(RMdns& aMdns)
+ {
+ CMdnsRegisterNotifier* self = new (ELeave) CMdnsRegisterNotifier(aMdns);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self ;
+ }
+/*
+ * Destructor
+ */
+CMdnsRegisterNotifier::~CMdnsRegisterNotifier()
+ {
+ __FLOG(_L8("CMdnsRegisterNotifier:: - Entry"));
+ //Cancel any pending asynchronous request.
+ Cancel();
+ delete iNotifyRcvdMessage;
+ iNotifyRcvdMessage = NULL;
+ __FLOG(_L8("CMdnsRegisterNotifier:: - Exit"));
+ __FLOG_CLOSE;
+ }
+
+/*
+ * Constructor
+ * @param aMdns reference to mdns object.
+ */
+CMdnsRegisterNotifier::CMdnsRegisterNotifier(RMdns& aMdns):CActive(EPriorityStandard),iMdns(aMdns),iPtrNotifyRcvdMessage(NULL,0,0)
+ {
+
+ }
+
+/*
+ * Two phase constructor
+ * Construct a buffer to recieve a new record from the network.
+ * and start listening to it.
+ */
+void CMdnsRegisterNotifier::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ __FLOG(_L8("CMdnsRegisterNotifier::ConstructL - Entry"));
+ CActiveScheduler::Add(this);
+ iNotifyRcvdMessage = HBufC8::NewL(KMaxDNSNameLength);
+ iPtrNotifyRcvdMessage.Set(iNotifyRcvdMessage->Des());
+ Start();
+ __FLOG(_L8("CMdnsRegisterNotifier::ConstructL - Exit"));
+ }
+/*
+ * Constructs a bundle and notifies the same to the client.
+ *
+ */
+void CMdnsRegisterNotifier::RunL()
+ {
+ __FLOG(_L8("CMdnsRegisterNotifier::RunL - Entry"));
+ if(iObserver != NULL)
+ {
+ if(iStatus.Int() == KErrNone)
+ {
+ RPnPParameterBundle pnpBundle;
+ pnpBundle.CreateL();
+ pnpBundle.Load(iPtrNotifyRcvdMessage);
+ iObserver->OnPnPEventL(pnpBundle);
+ pnpBundle.Close();
+ }
+ else
+ {
+ iObserver->OnPnPError(iStatus.Int());
+ }
+ }
+ Start();
+ __FLOG(_L8("CMdnsRegisterNotifier::RunL - Exit"));
+ }
+
+/*
+ * Clears the buffer .
+ */
+void CMdnsRegisterNotifier::DoCancel()
+ {
+ __FLOG(_L8("CMdnsRegisterNotifier::DoCancel - Entry"));
+ TRequestStatus * status = &iStatus;
+ User::RequestComplete(status,KErrCancel);
+ delete iNotifyRcvdMessage;
+ iNotifyRcvdMessage = NULL;
+ __FLOG(_L8("CMdnsRegisterNotifier::DoCancel - Exit"));
+ }
+
+/*
+ * Returns the error to activeschedluler as the RunL is not expected to leave.
+ * @param aError error with which RunL leaves.
+ * @return aError returns the error back to activescheduler .
+ */
+TInt CMdnsRegisterNotifier::RunError(TInt aError)
+ {
+ __FLOG(_L8("CMdnsRegisterNotifier::RunError - Entry"));
+ return aError;
+ __FLOG(_L8("CMdnsRegisterNotifier::RunError - Exit"));
+ }
+
+/*
+ * Start as Asynchoronous request and wait for this to be completed by the server .
+ * Will be called internally whenever a client requests for the notification.
+ *
+ */
+void CMdnsRegisterNotifier::Start()
+ {
+ __FLOG(_L8("CMdnsRegisterNotifier::Start - Entry"));
+ iStatus = KRequestPending;
+ iMdns.RecieveNotifyMessageL(iPtrNotifyRcvdMessage,iStatus);
+ SetActive();
+ __FLOG(_L8("CMdnsRegisterNotifier::Start - Exit"));
+ }
+
+/*
+ * Set the observer
+ * @param aObserver a pointer to the observer sent by the client along with the bundle.
+ */
+void CMdnsRegisterNotifier::SetPnpObserver(MPnPObserver* aObserver)
+ {
+ __FLOG(_L8("CMdnsRegisterNotifier::SetPnpObserver - Entry"));
+ iObserver = aObserver;
+ __FLOG(_L8("CMdnsRegisterNotifier::SetPnpObserver - Exit"));
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/src/cpnpservicediscovery.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,182 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cpnpservicediscovery.cpp
+//
+//
+//System include
+#include <connpref.h>
+
+//User include
+#include "CMDnsServiceDiscoveryImpl.h"
+#include "pnp/mpnpobserver.h"
+__FLOG_STMT(_LIT8(KComponent,"CMDnsServiceDiscoveryImpl");)
+/*
+ * Constructor.
+ */
+CMDnsServiceDiscoveryImpl::CMDnsServiceDiscoveryImpl ()
+ {
+ }
+/*
+ * Two phase constructor
+ */
+CMDnsServiceDiscoveryImpl* CMDnsServiceDiscoveryImpl::NewL()
+ {
+ CMDnsServiceDiscoveryImpl* self = new (ELeave) CMDnsServiceDiscoveryImpl;
+ return self;
+ }
+
+/*
+ * Destructor
+ */
+CMDnsServiceDiscoveryImpl::~CMDnsServiceDiscoveryImpl ()
+ {
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry"));
+ iMdns.Close();
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit"));
+ __FLOG_CLOSE;
+ }
+
+/*
+ * Explicitly start the connection
+ * Read the iap using RConnection and send the same to the RMdns.
+ * @param aTierId implementation uid of the plugin
+ */
+TInt CMDnsServiceDiscoveryImpl::Construct( TUint aTierId )
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry"));
+ RSocketServ sockServ;
+ RConnection connection;
+ User::LeaveIfError(sockServ.Connect());
+ User::LeaveIfError(connection.Open(sockServ));
+
+ // start a connection, and grab the IAP ID
+ User::LeaveIfError(connection.Start());
+
+ TUint32 iap ;
+ _LIT(KCommdbIapSetting, "IAP\\Id");
+ User::LeaveIfError(connection.GetIntSetting(KCommdbIapSetting, iap));
+ iMdns.Open(iap);
+ connection.Close();
+ sockServ.Close();
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit"));
+ return KErrNone;
+ }
+
+/*
+ * Any query request will be handled by this.
+ * @param aServiceInfo parameter bundle which contains the query.
+ */
+void CMDnsServiceDiscoveryImpl::Discover ( const RPnPParameterBundle& aServiceInfo )
+ {
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry"));
+ TRAPD( err, DiscoverL( aServiceInfo ));
+ if(err != KErrNone )
+ aServiceInfo.PnPObserver()->OnPnPError(err);
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit"));
+ }
+
+/*
+ * Any query request will be handled by this.
+ * @param aServiceInfo parameter bundle which contains the query.
+ */
+void CMDnsServiceDiscoveryImpl::DiscoverL ( const RPnPParameterBundle& aServiceInfo )
+ {
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry"));
+ iMdns.QueryL(aServiceInfo);
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit"));
+ }
+
+/*
+ * Not supported in ZeroConf.
+ */
+void CMDnsServiceDiscoveryImpl::Describe( const RPnPParameterBundle& aServiceInfo )
+ {
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry"));
+ TRAPD( err, DescribeL( aServiceInfo ));
+ if(err != KErrNone )
+ aServiceInfo.PnPObserver()->OnPnPError(err);
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit"));
+ }
+
+/*
+ * Not supported in ZeroConf.
+ */
+void CMDnsServiceDiscoveryImpl::DescribeL ( const RPnPParameterBundle& /*aServiceInfo*/ )
+ {
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry"));
+ User::Leave(KErrNotSupported);
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit"));
+ }
+/*
+ * Not supported in ZeroConf.
+ */
+void CMDnsServiceDiscoveryImpl::Subscribe ( const RPnPParameterBundle& aServiceInfo )
+ {
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry"));
+ TRAPD( err, SubscribeL( aServiceInfo ));
+ if(err != KErrNone )
+ aServiceInfo.PnPObserver()->OnPnPError(err);
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit"));
+ }
+
+/*
+ * Not supported in ZeroConf.
+ */
+void CMDnsServiceDiscoveryImpl::SubscribeL ( const RPnPParameterBundle& /* aServiceInfo*/ )
+ {
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry"));
+ User::Leave(KErrNotSupported);
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit"));
+ }
+/*
+ * Client intersted in any new service to be notified, will call this.
+ * @param aServiceInfo parameter bundle which contains the ptr domain name client is intersted in.
+ */
+void CMDnsServiceDiscoveryImpl::RegisterNotify( const RPnPParameterBundle& aServiceInfo )//done
+ {
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry"));
+ TRAPD( err, RegisterNotifyL( aServiceInfo ));
+ if(err != KErrNone )
+ aServiceInfo.PnPObserver()->OnPnPError(err);
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit"));
+ }
+// Used to register for advertisements of specific service type
+void CMDnsServiceDiscoveryImpl::RegisterNotifyL ( const RPnPParameterBundle& aServiceInfo )//done
+ {
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry"));
+ iMdns.WaitForNotificationL(aServiceInfo);
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit"));
+ }
+
+/* Used to cancel previous requests of services. */
+void CMDnsServiceDiscoveryImpl::Cancel ( const RPnPParameterBundle& aServiceInfo )//done
+ {
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry"));
+ //Ignore the error.
+ TRAP_IGNORE(iMdns.Cancel(aServiceInfo));
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit"));
+ }
+
+
+/*
+ * Not supported in ZeroConf.
+ */
+CControlChannelBase* CMDnsServiceDiscoveryImpl::InitiateControlL (const TDesC8& /*aUri*/ )
+ {
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Entry"));
+ __FLOG(_L8("CMDnsServiceDiscoveryImpl:: - Exit"));
+ return NULL;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/src/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/src/ecom_impl.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,37 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// ecom_impl.cpp
+//
+//
+
+#include <ecom/implementationproxy.h>
+#include "mdnsparamsextfactory.h"
+#include "mdnsparamset.h"
+#include "cmdnsservicediscoveryimpl.h"
+#include "cmdnspnpservicepublisherimpl.h"
+
+
+const TImplementationProxy ImplementationTable[] =
+ {
+ IMPLEMENTATION_PROXY_ENTRY(KMDnsParamsFactoryUid, CMDnsParamsExtFactory::NewL),
+ IMPLEMENTATION_PROXY_ENTRY(KUPnPDiscoveryUid, CMDnsServiceDiscoveryImpl::NewL),
+ IMPLEMENTATION_PROXY_ENTRY(KMDnsPublisherUid, CMDnsServicePublisherImpl::NewL)
+ };
+
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+ {
+ aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+ return ImplementationTable;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/client/src/mdnsparamsextfactory.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,112 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// ecom_impl.cpp
+//
+//
+
+#include <e32base.h>
+#include <comms-infras/metabuffer.h>
+#include "mdnsparamsextfactory.h"
+#include "mdnsparamset.h"
+
+
+START_ATTRIBUTE_TABLE(CMDnsQueryRequestParamSet, KMDnsParamsFactoryUid, EMDnsDiscoverRequestParamSet)
+ REGISTER_ATTRIBUTE(CMDnsQueryRequestParamSet, iInstanceName, TMetaBuf8)
+ REGISTER_ATTRIBUTE(CMDnsQueryRequestParamSet, iQueryType, TMetaNumber)
+ REGISTER_ATTRIBUTE(CMDnsQueryRequestParamSet, iProtocol, TMetaNumber)
+ REGISTER_ATTRIBUTE(CMDnsQueryRequestParamSet, iServiceType, TMetaBuf8)
+END_ATTRIBUTE_TABLE()
+
+
+START_ATTRIBUTE_TABLE(CMDnsPtrParamSet, KMDnsParamsFactoryUid, EMdnsPtrParamset)
+ REGISTER_ATTRIBUTE(CMDnsPtrParamSet, iInstanceName, TMetaBuf8)
+ REGISTER_ATTRIBUTE(CMDnsPtrParamSet, iDomainName, TMetaBuf8)
+ REGISTER_ATTRIBUTE(CMDnsPtrParamSet, iTtl, TMetaNumber)
+ END_ATTRIBUTE_TABLE()
+
+START_ATTRIBUTE_TABLE(CMDnsSrvParamSet, KMDnsParamsFactoryUid, EMdnsSrvParamset)
+ REGISTER_ATTRIBUTE(CMDnsSrvParamSet, iDomainName, TMetaBuf8)
+ REGISTER_ATTRIBUTE(CMDnsSrvParamSet, iTarget, TMetaBuf8)
+ REGISTER_ATTRIBUTE(CMDnsSrvParamSet, iPrio, TMetaNumber)
+ REGISTER_ATTRIBUTE(CMDnsSrvParamSet, iWeight, TMetaNumber)
+ REGISTER_ATTRIBUTE(CMDnsSrvParamSet, iPort, TMetaNumber)
+END_ATTRIBUTE_TABLE()
+
+START_ATTRIBUTE_TABLE(CMDnsAddrParamSet, KMDnsParamsFactoryUid, EMdnsAddrParamset)
+ REGISTER_ATTRIBUTE(CMDnsAddrParamSet, iDomainName, TMetaBuf8)
+ REGISTER_ATTRIBUTE(CMDnsAddrParamSet, iAddr, TMeta<TInetAddr>)
+END_ATTRIBUTE_TABLE()
+
+START_ATTRIBUTE_TABLE(CMDnsTxtParamSet, KMDnsParamsFactoryUid, EMdnsTxtParamset)
+ REGISTER_ATTRIBUTE(CMDnsTxtParamSet, iDomainName, TMetaBuf8)
+ REGISTER_ATTRIBUTE(CMDnsTxtParamSet, iTxtData, TMetaBuf8)
+END_ATTRIBUTE_TABLE()
+
+START_ATTRIBUTE_TABLE(CMDnsPublishResponseParamSet, KMDnsParamsFactoryUid, EMdnsPublishResponseParamset)
+ REGISTER_ATTRIBUTE(CMDnsPublishResponseParamSet, iDomainName, TMetaBuf8)
+ REGISTER_ATTRIBUTE(CMDnsPublishResponseParamSet, iError, TMetaNumber)
+END_ATTRIBUTE_TABLE()
+
+START_ATTRIBUTE_TABLE(CMDnsRegisterNotifyParamSet, KMDnsParamsFactoryUid, EMdnsRegisterNotifyParamset)
+ REGISTER_ATTRIBUTE(CMDnsRegisterNotifyParamSet, iInstanceName, TMetaBuf8)
+END_ATTRIBUTE_TABLE()
+
+START_ATTRIBUTE_TABLE(CMDnsPublishParamSet, KMDnsParamsFactoryUid, EMdnsPublishParamset)
+ REGISTER_ATTRIBUTE(CMDnsPublishParamSet, isPublish, TMetaNumber)
+END_ATTRIBUTE_TABLE()
+CMDnsParamSetBase* CMDnsParamsExtFactory::NewL ( TAny* aConstructionParams )
+ {
+ const TInt32 familyType = reinterpret_cast<TInt32>(aConstructionParams);
+ CMDnsParamSetBase* myMDnsParamBase = NULL;
+ switch ( familyType )
+ {
+ case EMDnsDiscoverRequestParamSet:
+ myMDnsParamBase = new (ELeave) CMDnsQueryRequestParamSet;
+ break;
+
+ case EMdnsPtrParamset:
+ myMDnsParamBase = new (ELeave) CMDnsPtrParamSet;
+ break;
+
+ case EMdnsSrvParamset :
+ myMDnsParamBase = new (ELeave) CMDnsSrvParamSet;
+ break;
+
+ case EMdnsAddrParamset :
+ myMDnsParamBase = new (ELeave) CMDnsAddrParamSet;
+ break;
+
+ case EMdnsTxtParamset :
+ myMDnsParamBase = new (ELeave) CMDnsTxtParamSet;
+ break;
+
+ case EMdnsPublishResponseParamset:
+ myMDnsParamBase = new (ELeave) CMDnsPublishResponseParamSet;
+ break;
+
+ case EMdnsRegisterNotifyParamset:
+ myMDnsParamBase = new (ELeave) CMDnsRegisterNotifyParamSet;
+ break;
+
+ case EMdnsPublishParamset:
+ myMDnsParamBase = new (ELeave) CMDnsPublishParamSet;
+ break;
+
+ default:
+ ASSERT(0);
+ break;
+ }
+ return myMDnsParamBase;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/common/inc/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/common/inc/mdnsdebug.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2006 - 2007 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+/**
+@file
+@internalComponent
+*/
+
+#ifndef MDNSDEBUG_H
+#define MDNSDEBUG_H
+
+#include <comms-infras/commsdebugutility.h>
+
+__FLOG_STMT(_LIT8(KMDNSSubsystem, "MDNS");)
+
+#ifdef __FLOG_ACTIVE
+#define __MDNS_HEAP_FLOG \
+ { \
+ TInt allocated; \
+ TInt largest; \
+ TInt available(User::Heap().Available(largest)); \
+ TInt size(User::Heap().Size()); \
+ User::Heap().AllocSize(allocated); \
+ __FLOG_STATIC_VA((KMDNSSubsystem, KComponent, _L8("Heap: Size = %d, Allocated = %d, Available = %d, Largest block = %d"), size, allocated, available, largest)); \
+ }
+#else
+#define __MDNS_HEAP_FLOG
+#endif // __FLOG_ACTIVE
+
+#endif // MDNSDEBUG_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/bwins/distribution.policy Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,2 @@
+Category E
+OSD: Optional Replaceable Bonjour Framework
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/bwins/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/bwins/dnsparseru.def Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,63 @@
+EXPORTS
+ ?SetHeader@CDnsMessage@@QAEXABVTDnsHeader@@@Z @ 1 NONAME ; void CDnsMessage::SetHeader(class TDnsHeader const &)
+ ?NewL@CRdTypePtr@@SAPAV1@XZ @ 2 NONAME ; class CRdTypePtr * CRdTypePtr::NewL(void)
+ ?AppendTextDataL@CRdTypeTxt@@QAEXABVRBuf8@@@Z @ 3 NONAME ; void CRdTypeTxt::AppendTextDataL(class RBuf8 const &)
+ ?Size@CRdTypeTxt@@UBEGXZ @ 4 NONAME ; unsigned short CRdTypeTxt::Size(void) const
+ ?SetUnicast@CDnsQuestion@@QAEXH@Z @ 5 NONAME ; void CDnsQuestion::SetUnicast(int)
+ ?NewL@CRdTypeTxt@@SAPAV1@XZ @ 6 NONAME ; class CRdTypeTxt * CRdTypeTxt::NewL(void)
+ ?SetFlushBit@CDnsResourceData@@QAEXH@Z @ 7 NONAME ; void CDnsResourceData::SetFlushBit(int)
+ ?Type@CDnsSection@@QBEGXZ @ 8 NONAME ; unsigned short CDnsSection::Type(void) const
+ ?IsFlushBitSet@CDnsResourceData@@QBEHXZ @ 9 NONAME ; int CDnsResourceData::IsFlushBitSet(void) const
+ ?AppendQueryL@CDnsMessage@@QAEXPBVCDnsQuestion@@@Z @ 10 NONAME ; void CDnsMessage::AppendQueryL(class CDnsQuestion const *)
+ ?Priority@CRdTypeSrv@@QBEGXZ @ 11 NONAME ; unsigned short CRdTypeSrv::Priority(void) const
+ ?NewL@CRdTypeA@@SAPAV1@XZ @ 12 NONAME ; class CRdTypeA * CRdTypeA::NewL(void)
+ ?Size@CDnsMessage@@QBEGXZ @ 13 NONAME ; unsigned short CDnsMessage::Size(void) const
+ ?IsUnicast@CDnsQuestion@@QBEHXZ @ 14 NONAME ; int CDnsQuestion::IsUnicast(void) const
+ ??1CRdTypeTxt@@UAE@XZ @ 15 NONAME ; CRdTypeTxt::~CRdTypeTxt(void)
+ ?AppendAuthorityL@CDnsMessage@@QAEXPBVCDnsResourceData@@@Z @ 16 NONAME ; void CDnsMessage::AppendAuthorityL(class CDnsResourceData const *)
+ ?SetDomainNameL@CRdTypePtr@@QAEXABVTDesC8@@@Z @ 17 NONAME ; void CRdTypePtr::SetDomainNameL(class TDesC8 const &)
+ ?CreateMessageL@CDnsMessageComposerParser@@QAEXAAVRBuf8@@ABVCDnsMessage@@@Z @ 18 NONAME ; void CDnsMessageComposerParser::CreateMessageL(class RBuf8 &, class CDnsMessage const &)
+ ?Text@CRdTypeTxt@@QBEABV?$RArray@VRBuf8@@@@XZ @ 19 NONAME ; class RArray<class RBuf8> const & CRdTypeTxt::Text(void) const
+ ?SetNameL@CDnsSection@@QAEXABVTDesC8@@@Z @ 20 NONAME ; void CDnsSection::SetNameL(class TDesC8 const &)
+ ?Queries@CDnsMessage@@QBEABV?$RPointerArray@VCDnsQuestion@@@@XZ @ 21 NONAME ; class RPointerArray<class CDnsQuestion> const & CDnsMessage::Queries(void) const
+ ?AppendAdditionalL@CDnsMessage@@QAEXPBVCDnsResourceData@@@Z @ 22 NONAME ; void CDnsMessage::AppendAdditionalL(class CDnsResourceData const *)
+ ?Class@CDnsSection@@QBEGXZ @ 23 NONAME ; unsigned short CDnsSection::Class(void) const
+ ?SetPort@CRdTypeSrv@@QAEXG@Z @ 24 NONAME ; void CRdTypeSrv::SetPort(unsigned short)
+ ??1CDnsResourceData@@UAE@XZ @ 25 NONAME ; CDnsResourceData::~CDnsResourceData(void)
+ ?SetTargetL@CRdTypeSrv@@QAEXABVTDesC8@@@Z @ 26 NONAME ; void CRdTypeSrv::SetTargetL(class TDesC8 const &)
+ ?SetTtl@CDnsResourceData@@QAEXK@Z @ 27 NONAME ; void CDnsResourceData::SetTtl(unsigned long)
+ ?NewL@CDnsMessage@@SAPAV1@GH@Z @ 28 NONAME ; class CDnsMessage * CDnsMessage::NewL(unsigned short, int)
+ ?Answers@CDnsMessage@@QBEABV?$RPointerArray@VCDnsResourceData@@@@XZ @ 29 NONAME ; class RPointerArray<class CDnsResourceData> const & CDnsMessage::Answers(void) const
+ ?Additional@CDnsMessage@@QBEABV?$RPointerArray@VCDnsResourceData@@@@XZ @ 30 NONAME ; class RPointerArray<class CDnsResourceData> const & CDnsMessage::Additional(void) const
+ ?Size@CRdTypeA@@UBEGXZ @ 31 NONAME ; unsigned short CRdTypeA::Size(void) const
+ ?Target@CRdTypeSrv@@QBEABVTDesC8@@XZ @ 32 NONAME ; class TDesC8 const & CRdTypeSrv::Target(void) const
+ ?Header@CDnsMessage@@QBEABVTDnsHeader@@XZ @ 33 NONAME ; class TDnsHeader const & CDnsMessage::Header(void) const
+ ??1CRdTypeA@@UAE@XZ @ 34 NONAME ; CRdTypeA::~CRdTypeA(void)
+ ?Size@CRdTypePtr@@UBEGXZ @ 35 NONAME ; unsigned short CRdTypePtr::Size(void) const
+ ?NewL@CRdTypeSrv@@SAPAV1@XZ @ 36 NONAME ; class CRdTypeSrv * CRdTypeSrv::NewL(void)
+ ?Address@CRdTypeA@@QBEABVTInetAddr@@XZ @ 37 NONAME ; class TInetAddr const & CRdTypeA::Address(void) const
+ ?AppendAnswerL@CDnsMessage@@QAEXPBVCDnsResourceData@@@Z @ 38 NONAME ; void CDnsMessage::AppendAnswerL(class CDnsResourceData const *)
+ ?DomainName@CRdTypePtr@@QBEABVTDesC8@@XZ @ 39 NONAME ; class TDesC8 const & CRdTypePtr::DomainName(void) const
+ ?CloneL@CDnsResourceData@@QBEPAV1@XZ @ 40 NONAME ; class CDnsResourceData * CDnsResourceData::CloneL(void) const
+ ?ParseMessageL@CDnsMessageComposerParser@@QAEPAVCDnsMessage@@ABVTDesC8@@@Z @ 41 NONAME ; class CDnsMessage * CDnsMessageComposerParser::ParseMessageL(class TDesC8 const &)
+ ?SetWeight@CRdTypeSrv@@QAEXG@Z @ 42 NONAME ; void CRdTypeSrv::SetWeight(unsigned short)
+ ?NewL@CDnsMessageComposerParser@@SAPAV1@XZ @ 43 NONAME ; class CDnsMessageComposerParser * CDnsMessageComposerParser::NewL(void)
+ ??1CRdTypePtr@@UAE@XZ @ 44 NONAME ; CRdTypePtr::~CRdTypePtr(void)
+ ??1CDnsQuestion@@UAE@XZ @ 45 NONAME ; CDnsQuestion::~CDnsQuestion(void)
+ ?Size@CRdTypeSrv@@UBEGXZ @ 46 NONAME ; unsigned short CRdTypeSrv::Size(void) const
+ ?SetPriority@CRdTypeSrv@@QAEXG@Z @ 47 NONAME ; void CRdTypeSrv::SetPriority(unsigned short)
+ ?Weight@CRdTypeSrv@@QBEGXZ @ 48 NONAME ; unsigned short CRdTypeSrv::Weight(void) const
+ ?SetType@CDnsSection@@QAEXG@Z @ 49 NONAME ; void CDnsSection::SetType(unsigned short)
+ ??1CDnsSection@@UAE@XZ @ 50 NONAME ; CDnsSection::~CDnsSection(void)
+ ?SetRdLength@CDnsResourceData@@QAEXG@Z @ 51 NONAME ; void CDnsResourceData::SetRdLength(unsigned short)
+ ??1CRdTypeSrv@@UAE@XZ @ 52 NONAME ; CRdTypeSrv::~CRdTypeSrv(void)
+ ?Port@CRdTypeSrv@@QBEGXZ @ 53 NONAME ; unsigned short CRdTypeSrv::Port(void) const
+ ?RdLength@CDnsResourceData@@QBEGXZ @ 54 NONAME ; unsigned short CDnsResourceData::RdLength(void) const
+ ?Authorities@CDnsMessage@@QBEABV?$RPointerArray@VCDnsResourceData@@@@XZ @ 55 NONAME ; class RPointerArray<class CDnsResourceData> const & CDnsMessage::Authorities(void) const
+ ?Name@CDnsSection@@QBEABVTDesC8@@XZ @ 56 NONAME ; class TDesC8 const & CDnsSection::Name(void) const
+ ?NewL@CDnsQuestion@@SAPAV1@XZ @ 57 NONAME ; class CDnsQuestion * CDnsQuestion::NewL(void)
+ ?Ttl@CDnsResourceData@@QBEKXZ @ 58 NONAME ; unsigned long CDnsResourceData::Ttl(void) const
+ ?Size@CDnsQuestion@@QBEGXZ @ 59 NONAME ; unsigned short CDnsQuestion::Size(void) const
+ ?SetClass@CDnsSection@@QAEXG@Z @ 60 NONAME ; void CDnsSection::SetClass(unsigned short)
+ ?SetAddr@CRdTypeA@@QAEXABVTInetAddr@@@Z @ 61 NONAME ; void CRdTypeA::SetAddr(class TInetAddr const &)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/eabi/distribution.policy Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,2 @@
+Category E
+OSD: Optional Replaceable Bonjour Framework
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/eabi/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/eabi/dnsparseru.def Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,101 @@
+EXPORTS
+ _ZN10CRdTypePtr14SetDomainNameLERK6TDesC8 @ 1 NONAME
+ _ZN10CRdTypePtr4NewLEv @ 2 NONAME
+ _ZN10CRdTypePtrD0Ev @ 3 NONAME
+ _ZN10CRdTypePtrD1Ev @ 4 NONAME
+ _ZN10CRdTypePtrD2Ev @ 5 NONAME
+ _ZN10CRdTypeSrv10SetTargetLERK6TDesC8 @ 6 NONAME
+ _ZN10CRdTypeSrv11SetPriorityEt @ 7 NONAME
+ _ZN10CRdTypeSrv4NewLEv @ 8 NONAME
+ _ZN10CRdTypeSrv9SetWeightEt @ 9 NONAME
+ _ZN10CRdTypeSrvD0Ev @ 10 NONAME
+ _ZN10CRdTypeSrvD1Ev @ 11 NONAME
+ _ZN10CRdTypeSrvD2Ev @ 12 NONAME
+ _ZN10CRdTypeTxt15AppendTextDataLERK5RBuf8 @ 13 NONAME
+ _ZN10CRdTypeTxt4NewLEv @ 14 NONAME
+ _ZN10CRdTypeTxtD0Ev @ 15 NONAME
+ _ZN10CRdTypeTxtD1Ev @ 16 NONAME
+ _ZN10CRdTypeTxtD2Ev @ 17 NONAME
+ _ZN11CDnsMessage12AppendQueryLEPK12CDnsQuestion @ 18 NONAME
+ _ZN11CDnsMessage13AppendAnswerLEPK16CDnsResourceData @ 19 NONAME
+ _ZN11CDnsMessage16AppendAuthorityLEPK16CDnsResourceData @ 20 NONAME
+ _ZN11CDnsMessage17AppendAdditionalLEPK16CDnsResourceData @ 21 NONAME
+ _ZN11CDnsMessage4NewLEti @ 22 NONAME
+ _ZN11CDnsMessage9SetHeaderERK10TDnsHeader @ 23 NONAME
+ _ZN11CDnsSection7SetTypeEt @ 24 NONAME
+ _ZN11CDnsSection8SetClassEt @ 25 NONAME
+ _ZN11CDnsSection8SetNameLERK6TDesC8 @ 26 NONAME
+ _ZN11CDnsSectionD0Ev @ 27 NONAME
+ _ZN11CDnsSectionD1Ev @ 28 NONAME
+ _ZN11CDnsSectionD2Ev @ 29 NONAME
+ _ZN12CDnsQuestion10SetUnicastEi @ 30 NONAME
+ _ZN12CDnsQuestion4NewLEv @ 31 NONAME
+ _ZN12CDnsQuestionD0Ev @ 32 NONAME
+ _ZN12CDnsQuestionD1Ev @ 33 NONAME
+ _ZN12CDnsQuestionD2Ev @ 34 NONAME
+ _ZN16CDnsResourceData11SetFlushBitEi @ 35 NONAME
+ _ZN16CDnsResourceData11SetRdLengthEt @ 36 NONAME
+ _ZN16CDnsResourceData6SetTtlEm @ 37 NONAME
+ _ZN16CDnsResourceDataD0Ev @ 38 NONAME
+ _ZN16CDnsResourceDataD1Ev @ 39 NONAME
+ _ZN16CDnsResourceDataD2Ev @ 40 NONAME
+ _ZN25CDnsMessageComposerParser13ParseMessageLERK6TDesC8 @ 41 NONAME
+ _ZN25CDnsMessageComposerParser14CreateMessageLER5RBuf8RK11CDnsMessage @ 42 NONAME
+ _ZN25CDnsMessageComposerParser4NewLEv @ 43 NONAME
+ _ZN8CRdTypeA4NewLEv @ 44 NONAME
+ _ZN8CRdTypeA7SetAddrERK9TInetAddr @ 45 NONAME
+ _ZN8CRdTypeAD0Ev @ 46 NONAME
+ _ZN8CRdTypeAD1Ev @ 47 NONAME
+ _ZN8CRdTypeAD2Ev @ 48 NONAME
+ _ZNK10CRdTypePtr10DomainNameEv @ 49 NONAME
+ _ZNK10CRdTypePtr4SizeEv @ 50 NONAME
+ _ZNK10CRdTypeSrv4SizeEv @ 51 NONAME
+ _ZNK10CRdTypeSrv6TargetEv @ 52 NONAME
+ _ZNK10CRdTypeSrv6WeightEv @ 53 NONAME
+ _ZNK10CRdTypeSrv8PriorityEv @ 54 NONAME
+ _ZNK10CRdTypeTxt4SizeEv @ 55 NONAME
+ _ZNK10CRdTypeTxt4TextEv @ 56 NONAME
+ _ZNK11CDnsMessage10AdditionalEv @ 57 NONAME
+ _ZNK11CDnsMessage11AuthoritiesEv @ 58 NONAME
+ _ZNK11CDnsMessage4SizeEv @ 59 NONAME
+ _ZNK11CDnsMessage6HeaderEv @ 60 NONAME
+ _ZNK11CDnsMessage7AnswersEv @ 61 NONAME
+ _ZNK11CDnsMessage7QueriesEv @ 62 NONAME
+ _ZNK11CDnsSection4NameEv @ 63 NONAME
+ _ZNK11CDnsSection4TypeEv @ 64 NONAME
+ _ZNK11CDnsSection5ClassEv @ 65 NONAME
+ _ZNK12CDnsQuestion4SizeEv @ 66 NONAME
+ _ZNK12CDnsQuestion9IsUnicastEv @ 67 NONAME
+ _ZNK16CDnsResourceData13IsFlushBitSetEv @ 68 NONAME
+ _ZNK16CDnsResourceData3TtlEv @ 69 NONAME
+ _ZNK16CDnsResourceData6CloneLEv @ 70 NONAME
+ _ZNK16CDnsResourceData8RdLengthEv @ 71 NONAME
+ _ZNK8CRdTypeA4SizeEv @ 72 NONAME
+ _ZNK8CRdTypeA7AddressEv @ 73 NONAME
+ _ZTI10CDnsMsgBuf @ 74 NONAME
+ _ZTI10CDnsPacket @ 75 NONAME
+ _ZTI10CRdTypePtr @ 76 NONAME
+ _ZTI10CRdTypeSrv @ 77 NONAME
+ _ZTI10CRdTypeTxt @ 78 NONAME
+ _ZTI11CDnsMessage @ 79 NONAME
+ _ZTI11CDnsSection @ 80 NONAME
+ _ZTI12CDnsQuestion @ 81 NONAME
+ _ZTI13CStringParser @ 82 NONAME
+ _ZTI16CDnsResourceData @ 83 NONAME
+ _ZTI25CDnsMessageComposerParser @ 84 NONAME
+ _ZTI8CRdTypeA @ 85 NONAME
+ _ZTV10CDnsMsgBuf @ 86 NONAME
+ _ZTV10CDnsPacket @ 87 NONAME
+ _ZTV10CRdTypePtr @ 88 NONAME
+ _ZTV10CRdTypeSrv @ 89 NONAME
+ _ZTV10CRdTypeTxt @ 90 NONAME
+ _ZTV11CDnsMessage @ 91 NONAME
+ _ZTV11CDnsSection @ 92 NONAME
+ _ZTV12CDnsQuestion @ 93 NONAME
+ _ZTV13CStringParser @ 94 NONAME
+ _ZTV16CDnsResourceData @ 95 NONAME
+ _ZTV25CDnsMessageComposerParser @ 96 NONAME
+ _ZTV8CRdTypeA @ 97 NONAME
+ _ZN10CRdTypeSrv7SetPortEt @ 98 NONAME
+ _ZNK10CRdTypeSrv4PortEv @ 99 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/group/bld.inf Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+PRJ_EXPORTS
+../inc/cdnsmessagecomposerparser.h /epoc32/include/mdns/cdnsmessagecomposerparser.h
+../inc/cdnsmessage.h /epoc32/include/mdns/cdnsmessage.h
+../inc/cdnssection.h /epoc32/include/mdns/cdnssection.h
+../inc/cdnsquestion.h /epoc32/include/mdns/cdnsquestion.h
+../inc/cdnsresourcedata.h /epoc32/include/mdns/cdnsresourcedata.h
+../inc/crdtypea.h /epoc32/include/mdns/crdtypea.h
+../inc/crdtypesrv.h /epoc32/include/mdns/crdtypesrv.h
+../inc/crdtypeptr.h /epoc32/include/mdns/crdtypeptr.h
+../inc/crdtypetxt.h /epoc32/include/mdns/crdtypetxt.h
+../inc/tdnsheader.h /epoc32/include/mdns/tdnsheader.h
+../inc/tdnsheader.inl /epoc32/include/mdns/tdnsheader.inl
+../inc/dnsconstants.h /epoc32/include/mdns/dnsconstants.h
+
+
+
+PRJ_MMPFILES
+dnsparser.mmp
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/group/distribution.policy Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,2 @@
+Category E
+OSD: Optional Replaceable Bonjour Framework
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/group/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/group/dnsparser.mmp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+TARGET dnsparser.dll
+TARGETTYPE dll
+UID 0x1000008d 0x01827777
+
+CAPABILITY ALL -TCB
+
+SOURCEPATH ../src
+SOURCE cdnsmessagecomposerparser.cpp
+SOURCE cdnsmessage.cpp
+SOURCE cdnssection.cpp
+SOURCE cdnsresourcedata.cpp
+SOURCE cdnsquestion.cpp
+SOURCE crdtypea.cpp
+SOURCE crdtypesrv.cpp
+SOURCE crdtypeptr.cpp
+SOURCE crdtypetxt.cpp
+SOURCE cdnspacket.cpp
+SOURCE cstringparser.cpp cdnsmsgbuf.cpp
+
+USERINCLUDE ../inc
+SYSTEMINCLUDE /epoc32/include
+
+LIBRARY euser.lib
+LIBRARY esock.lib
+LIBRARY insock.lib
+
+MW_LAYER_SYSTEMINCLUDE
+
+#include <comms-infras/commsdebugutility.mmh>
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/cdnsmessage.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef __CDNSMESSAGE_H__
+#define __CDNSMESSAGE_H__
+
+#include <e32base.h>
+#include <mdns/cdnsquestion.h>
+#include <mdns/crdtypeptr.h>
+#include <mdns/crdtypea.h>
+#include <mdns/crdtypesrv.h>
+#include <mdns/crdtypetxt.h>
+#include <mdns/tdnsheader.h>
+
+
+//This class represents the complete dns message
+class CDnsMessage : public CBase
+ {
+public:
+ ~CDnsMessage();
+ IMPORT_C static CDnsMessage* NewL(TUint16 aId, TBool aQuery);
+ IMPORT_C void AppendQueryL(const CDnsQuestion* aQuery );
+ IMPORT_C void AppendAnswerL( const CDnsResourceData* aAnswer );
+ IMPORT_C void AppendAuthorityL( const CDnsResourceData* aAuthority );
+ IMPORT_C void AppendAdditionalL(const CDnsResourceData* aAdditional );
+ IMPORT_C void SetHeader(const TDnsHeader& aHeader);
+ IMPORT_C const RPointerArray<CDnsQuestion>& Queries()const;
+ IMPORT_C const RPointerArray<CDnsResourceData>& Answers()const;
+ IMPORT_C const RPointerArray<CDnsResourceData>& Authorities()const;
+ IMPORT_C const RPointerArray<CDnsResourceData>& Additional()const;
+ IMPORT_C const TDnsHeader& Header()const;
+ IMPORT_C TUint16 Size()const;
+
+private :
+ CDnsMessage(TUint16 aId, TBool aQuery);
+
+private:
+ TDnsHeader iHeader;
+ RPointerArray<CDnsQuestion> iQueries;
+ RPointerArray<CDnsResourceData> iAnswers;
+ RPointerArray<CDnsResourceData> iAuthorities;
+ RPointerArray<CDnsResourceData> iAdditional;
+ };
+
+#endif //__CDNSMESSAGE_H__
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/cdnsmessagecomposerparser.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef __CDNSMESSAGECOMPOSERPARSER_H__
+#define __CDNSMESSAGECOMPOSERPARSER_H__
+
+#include <e32base.h>
+#include <comms-infras/commsdebugutility.h>
+#include <es_sock.H>
+#include <mdns/cdnsmessage.h>
+#include <mdns/cdnsquestion.h>
+#include <mdns/crdtypeptr.h>
+#include <mdns/crdtypea.h>
+#include <mdns/crdtypesrv.h>
+#include <mdns/crdtypetxt.h>
+#include <mdns/dnsconstants.h>
+
+class CDnsPacket;
+class CDnsMsgBuf;
+
+//Main class which mDNS Responder will be making use to evoke compose and parse operations
+class CDnsMessageComposerParser: public CBase
+ {
+public:
+ IMPORT_C static CDnsMessageComposerParser* NewL();
+ IMPORT_C void CreateMessageL(RBuf8& aMessageBuffer, const CDnsMessage& aMessage );
+ IMPORT_C CDnsMessage* ParseMessageL(const TDesC8& aBuffer);
+ ~CDnsMessageComposerParser();
+ void ConstructL();
+
+private:
+ CDnsMessageComposerParser();
+ CDnsResourceData* GetResourceRecordsL();
+ void AppendResourceRecordsL( CDnsResourceData* aResourceRecord );
+ TUint16 GetLength( const CDnsMessage& aMessage )const;
+
+private:
+ RBuf8 iBuf;
+ CDnsPacket* iPacket;
+ CDnsMsgBuf* iMsgBuf;
+ __FLOG_DECLARATION_MEMBER;
+ };
+
+#endif //__CDNSMESSAGECOMPOSERPARSER_H__
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/cdnsmsgbuf.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+#ifndef __CDNSMSGBUF_H__
+#define __CDNSMSGBUF_H__
+
+#include <e32base.h>
+#include <es_sock.h>
+#include <in_sock.h>
+
+#include "tdnsheader.h"
+#include "cstringparser.h"
+
+
+//CDnsMsgBuf class composes a raw buffer from the supplied inputs
+class CDnsMsgBuf : public CBase
+ {
+public:
+ ~CDnsMsgBuf();
+ static CDnsMsgBuf* NewL(const TDesC8& aBuf);
+ void SetChar(TUint8 aVal);
+ void SetInt16(TUint16 aVal);
+ void SetInt32(TUint32 aVal);
+ void SetDomainNameL(const TDesC8& aName);
+ void SetText(const TDesC8& aTxt);
+ void SetPtrRdLengthL(const TDesC8& aName);
+ void SetSrvRdLengthL(const TDesC8& aName);
+ void SetTxtRdLength(const RArray<RBuf8>& aTxtList);
+
+private:
+ void ConstructL(const TDesC8& aBuf);
+ CDnsMsgBuf(const TDesC8& aBuf);
+ TUint16 GetDomainLengthL(const TDesC8& aName)const;
+
+private:
+ TUint8* iPtr;
+ TUint iIndex;
+ TUint iDataLength;
+ };
+
+#endif //__CDNSMSGBUF_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/cdnspacket.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+#ifndef __CDNSPACKET_H__
+#define __CDNSPACKET_H__
+
+#include <e32base.h>
+#include <es_sock.h>
+#include <in_sock.h>
+
+#include "tdnsheader.h"
+
+#define __OOB(aIndex,aDataLength) {if(aIndex >= aDataLength) User::Leave(KErrCorrupt);}
+
+_LIT8(KDot,".");
+
+class CDnsPacket : public CBase
+ {
+public:
+ ~CDnsPacket();
+ static CDnsPacket* NewL(const TDes8& aPacketPtr);
+ TUint8 GetCharL();
+ TUint16 GetInt16L();
+ TUint32 GetInt32L();
+ const TDnsHeader& GetHeaderL();
+ void GetDomainNameL(TDes8& aName);
+ void GetRdDomainNameL(TDes8& aDomainName,TUint aLength);
+ void GetStringL(TDes8& aString, TUint16 aLength);
+
+private:
+ void ConstructL();
+ CDnsPacket(const TDes8& aPacketPtr);
+ void GetStringAtIndexL(TDes8& aLabel, TUint aOffset);
+ void GetDomainNameAtIndexL(TDes8& aDomainName, TUint aOffset);
+
+private:
+ TDnsHeader iHeader;
+ const TUint8* iPtr;
+ TUint iIndex;
+ TUint iDataLength;
+ TUint iMaxLength;
+ };
+
+#endif //__CDNSPACKET_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/cdnsquestion.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef __CDNSQUESTION_H__
+#define __CDNSQUESTION_H__
+
+#include <mdns/cdnssection.h>
+#include <mdns/tdnsheader.h>
+#include <mdns/dnsconstants.h>
+
+/* 1 1 1 1 1 1
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | |
+ / QNAME /
+ / /
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | QTYPE |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ |UC QCLASS |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+
+*/
+
+class CDnsQuestion : public CDnsSection
+ {
+public:
+ IMPORT_C ~CDnsQuestion();
+ IMPORT_C static CDnsQuestion* NewL();
+
+ IMPORT_C TBool IsUnicast()const;
+ IMPORT_C void SetUnicast(TBool);
+
+ IMPORT_C TUint16 Size()const;
+
+private:
+ CDnsQuestion();
+ };
+
+#endif //__CDNSQUESTION_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/cdnsresourcedata.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+#ifndef __CDNSRESOURCEDATA_H__
+#define __CDNSRESOURCEDATA_H__
+
+
+#include <mdns/cdnssection.h>
+#include <mdns/tdnsheader.h>
+#include <mdns/dnsconstants.h>
+
+
+/* 1 1 1 1 1
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | |
+ / /
+ / NAME /
+ | |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | TYPE |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ |FL CLASS |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | TTL |
+ | |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | RDLENGTH |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
+ / RDATA /
+ / /
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+
+*/
+
+class CDnsResourceData: public CDnsSection
+ {
+public:
+ IMPORT_C virtual ~CDnsResourceData();
+
+ IMPORT_C CDnsResourceData* CloneL()const;
+
+ IMPORT_C TBool IsFlushBitSet()const;
+ IMPORT_C void SetFlushBit(TBool aFlushBit);
+
+ IMPORT_C TUint16 RdLength()const;
+ IMPORT_C void SetRdLength(TUint16 aRdLength);
+
+ IMPORT_C TUint32 Ttl()const;
+ IMPORT_C void SetTtl(TUint32 aTtl);
+
+ virtual TUint16 Size()const;
+
+protected:
+ CDnsResourceData();
+
+
+protected:
+ TUint16 iRdLength;
+ TUint32 iTtl;
+ };
+
+#endif __CDNSRESOURCEDATA_H__
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/cdnssection.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+#ifndef __CDNSSECTION_H__
+#define __CDNSSECTION_H__
+
+#include <e32base.h>
+#include <mdns/dnsconstants.h>
+
+
+// Base class for Question and Data section of the message
+class CDnsSection : public CBase
+ {
+public:
+ IMPORT_C virtual ~CDnsSection();
+ IMPORT_C const TDesC8& Name()const;
+ IMPORT_C void SetNameL(const TDesC8& aName);
+
+ IMPORT_C TUint16 Type()const;
+ IMPORT_C void SetType(TUint16 aType);
+
+ IMPORT_C TUint16 Class()const;
+ IMPORT_C void SetClass(TUint16 aClass);
+
+protected:
+ CDnsSection();
+
+protected:
+ RBuf8 iName;
+ TUint16 iType;
+ TUint16 iClass;
+ };
+
+#endif // __CDNSSECTION_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/crdtypea.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef _CRDTYPEA_H__
+#define _CRDTYPEA_H__
+
+#include <e32base.h>
+#include <in_sock.h>
+#include <mdns/cdnsresourcedata.h>
+#include <mdns/dnsconstants.h>
+
+class CRdTypeA : public CDnsResourceData
+ {
+public:
+ IMPORT_C ~CRdTypeA();
+ IMPORT_C static CRdTypeA* NewL();
+
+ IMPORT_C const TInetAddr& Address()const;
+ IMPORT_C void SetAddr(const TInetAddr& aAddr );
+
+ IMPORT_C TUint16 Size()const;
+
+private:
+ CRdTypeA();
+
+private:
+ TInetAddr iAddr;
+ };
+
+#endif //_CRDTYPEA_H__
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/crdtypeptr.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+#ifndef __CRDTYPEPTR_H__
+#define __CRDTYPEPTR_H__
+
+#include <e32base.h>
+#include <mdns/cdnsresourcedata.h>
+#include <mdns/dnsconstants.h>
+
+
+/*
+The compression scheme allows a domain name in a message to be
+represented as either:
+
+ - a sequence of labels ending in a zero octet
+
+ - a pointer
+
+ - a sequence of labels ending with a pointer
+*/
+
+
+class CRdTypePtr : public CDnsResourceData
+ {
+public:
+ IMPORT_C ~CRdTypePtr();
+ IMPORT_C static CRdTypePtr* NewL();
+
+ IMPORT_C const TDesC8& DomainName()const;
+ IMPORT_C void SetDomainNameL(const TDesC8& aDomainName);
+
+ void ConstructL(const TDesC8& aDomainName);
+ IMPORT_C TUint16 Size()const;
+
+private :
+ CRdTypePtr();
+
+private :
+ RBuf8 iDomainName;
+ };
+
+#endif //__CRDTYPEPTR_H__
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/crdtypesrv.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+#ifndef __CRDTYPESRV_H__
+#define __CRDTYPESRV_H__
+
+#include <e32base.h>
+#include <mdns/cdnsresourcedata.h>
+#include <mdns/dnsconstants.h>
+
+class CRdTypeSrv : public CDnsResourceData
+ {
+public:
+ IMPORT_C ~CRdTypeSrv();
+ IMPORT_C static CRdTypeSrv* NewL();
+
+ IMPORT_C TUint16 Priority()const;
+ IMPORT_C void SetPriority(TUint16 aPriority);
+
+ IMPORT_C TUint16 Weight()const;
+ IMPORT_C void SetWeight(TUint16 aWeight);
+
+ IMPORT_C TUint16 Port()const;
+ IMPORT_C void SetPort(TUint16 aPort);
+
+ IMPORT_C const TDesC8& Target()const;
+ IMPORT_C void SetTargetL(const TDesC8& aTarget);
+
+ void ConstructL(const TDesC8& aTarget);
+ IMPORT_C TUint16 Size()const;
+
+private:
+ CRdTypeSrv();
+
+private:
+ RBuf8 iTarget;
+ TUint16 iPrio;
+ TUint16 iWeight;
+ TUint16 iPort;
+ };
+
+#endif //__CRDTYPESRV_H__
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/crdtypetxt.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef __CRDTYPETXT_H__
+#define __CRDTYPETXT_H__
+
+#include <e32base.h>
+
+#include <mdns/cdnsresourcedata.h>
+#include <mdns/dnsconstants.h>
+
+class CRdTypeTxt : public CDnsResourceData
+ {
+public:
+ IMPORT_C ~CRdTypeTxt();
+ IMPORT_C static CRdTypeTxt* NewL();
+ IMPORT_C const RArray<RBuf8>& Text()const;
+ IMPORT_C void AppendTextDataL(const RBuf8& aTextData);
+ void ConstructL();
+ IMPORT_C TUint16 Size()const;
+
+private:
+ CRdTypeTxt();
+
+private:
+ RArray<RBuf8> iTxtData;
+ };
+
+#endif //__CRDTYPETXT_H__
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/cstringparser.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef __CSTRINGPARSER_H__
+#define __CSTRINGPARSER_H__
+
+// String parser class to parse a string incremently
+class CStringParser : public CBase
+ {
+public:
+ static CStringParser* NewL ( const TDesC8& aBuffer );
+
+ virtual ~CStringParser ();
+
+ TBool GetNextCharacter ( TChar& aChar );
+ TBool GetCurrentCharacter ( TChar& aChar );
+ TBool ParseTill ( TPtrC8& aWord, TChar aEndChar );
+ void ParseTill ( TPtrC8& aWord, const TDesC8& aCharSet );
+
+ TBool SkipLength ( TInt aLen );
+
+ void GetRemainder ( TPtrC8& aBuffer );
+protected:
+ CStringParser ( const TDesC8& aBuffer );
+
+private:
+ void IncrementCurrentPos ();
+
+private:
+ const TDesC8& iBuffer;
+ TInt iCurrentPos;
+ };
+
+#endif // __CSTRINGPARSER_H__
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/distribution.policy Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,2 @@
+Category E
+OSD: Optional Replaceable Bonjour Framework
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/dnsconstants.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef __DNSCONSTANTS_H__
+#define __DNSCONSTANTS_H__
+
+#include <in_sock.h>
+
+const TInt KDnsPort = 53;
+const TInt KMdnsPort = 5353;
+const TUint32 KMDnsAddr = INET_ADDR(224, 0, 0, 251);
+
+const TInt KDnsTtl = 60 * 60; //< default one hour TTL
+const TInt KKnownAnswerTtl = 120;
+const TInt KQueryWaitInterval = 225; //<milliseconds between query loops.
+const TInt KProbeWaitInterval = 250; //<milliseconds between probe loops.
+const TInt KResponseMinWaitInterval = 20; //<minimal wait interval for response.
+const TInt KResponseMaxWaitInterval = 115; //<maximal wait interval for response
+const TInt KProbeConflictInterval = 1000; //<milliseconds to wait after conflict.
+const TInt KAnnounceWaitInterval = 1000; //<milliseconds between Announce loops.
+const TInt KRecordReaperInterval = 10000; //<milliseconds between cache cleanups.
+
+const TInt KMaxDnsPacketSize = 9216; //<max mdns packet size
+
+//Dns Opcodes
+const TUint16 KDnsOpcode_QUERY = 0x00; //< Standard Query
+const TUint16 KDnsOpcode_IQUERY = 0x01; //< Inverse Query (historical)
+const TUint16 KDnsOpcode_STATUS = 0x02; //< Server Status Query
+const TUint16 KDnsOpcode_UPDATE = 0x05; //< Dynamic mDNS
+
+
+const TInt KResponseBit = 0x8000;
+const TInt KPointerBit = 0xC0;
+const TInt KPointerOffsetBit = 0x3F;
+const TUint16 KFlushBit = 0x8000;
+const TUint16 KQueryBit = KFlushBit;
+
+const TUint KMaxLabelLength = 63;
+const TUint KMaxDNSNameLength= 256;
+const TInt KDnsBufferlength = 1000;
+
+//mDNS RR Types
+enum TDnsType
+ {
+ EDnsType_IGNORE = 0, //< This is a hack to stop further processing
+ EDnsType_A = 1, //< a host address
+ EDnsType_NS = 2, //< an authoritative name server
+ EDnsType_MD = 3, //< a mail destination (Obsolete - use MX)
+ EDnsType_MF = 4, //< a mail forwarder (Obsolete - use MX)
+ EDnsType_CNAME = 5, //< the canonical name for an alias
+ EDnsType_SOA = 6, //< marks the start of a zone of authority
+ EDnsType_MB = 7, //< a mailbox domain name
+ EDnsType_MG = 8, //< a mail group member
+ EDnsType_MR = 9, //< a mail rename domain name
+ EDnsType_NULL = 10, //< a null RR
+ EDnsType_WKS = 11, //< a well known service description
+ EDnsType_PTR = 12, //< a domain name pointer
+ EDnsType_HINFO = 13, //< host information
+ EDnsType_MINFO = 14, //< mailbox or mail list information
+ EDnsType_MX = 15, //< mail exchange
+ EDnsType_TXT = 16, //< text strings
+ EDnsType_AAAA = 28, //< single IPv6 address (RFC-1886)
+ EDnsType_DNAME = 29, //< Non-Terminal DNS Name Redirection (RFC-2672)
+ EDnsType_SRV = 33, //< Location of Services (RFC-2782)
+ EDnsType_NAPTR = 35, //< Naming Authority Pointer (RFC-2915)
+ EDnsQType_Any = 255 //< Request for all records
+ };
+
+
+//mDNS Class Types
+enum TDnsClass
+ {
+ EDnsClass_IN = 1, //< public final static Internet
+ EDnsClass_CS = 2, //< CSNET
+ EDnsClass_CH= 3, //< CHAOS
+ EDnsClass_HS = 4, //< Hesiod
+ EDnsClass_NONE = 254, //< Used in DNS UPDATE [RFC 2136]
+ EDnsClass_ANY = 255 //< Not a DNS class, but a DNS query class, meaning "all classes"
+ };
+
+
+//Flags
+enum TFlags
+ {
+ EFlagReserved = 0x0070,
+ EFlagRecursionAvailable = 0x0080,
+ EFlagRecurse = 0x0100,
+ EFlagTruncated = 0x0200,
+ EFlagAuthoritative = 0x0400,
+ EFlagOpcode = 0x0F00,
+ EFlagQuery = 0x8000,
+ EFlagResponseCode = 0x000F
+ };
+
+
+// Response Codes
+enum TDnsRcode
+ {
+ EDnsRcode_NOERROR = 0,
+ EDnsRcode_FORMAT_ERROR = 1,
+ EDnsRcode_SERVER_FAILURE = 2,
+ EDnsRcode_NAME_ERROR = 3,
+ EDnsRcode_NOT_IMPLEMENTED = 4,
+ EDnsRcode_REFUSED = 5
+ };
+
+#endif //__DNSCONSTANTS_H__
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/tdnsheader.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+#ifndef __TDNSHEADER_H__
+#define __TDNSHEADER_H__
+
+#include <mdns/dnsconstants.h>
+
+class TDnsHeader
+ {
+public:
+ inline TUint16 Id()const;
+ inline TUint16 IsQuery()const;
+ inline TUint16 Opcode()const;
+ inline TUint16 IsAuthoritative()const;
+ inline TUint16 IsTruncated()const;
+ inline TUint16 RecursionDesired()const;
+ inline TUint16 RecursionAvailable()const;
+ inline TUint16 Reserved()const;
+ inline TUint16 ResponseCode()const;
+ inline TUint16 QueryCount()const;
+ inline TUint16 AnswerCount()const;
+ inline TUint16 AuthorityNSCount()const;
+ inline TUint16 AdditionalRCount()const;
+ inline TUint16 Flags()const;
+
+ inline void SetId(TUint16 aId);
+ inline void SetQuery(TBool aQuery);
+ inline void SetOpcode(TUint16 aOpcode);
+ inline void SetAuthoritative(TBool aAuthBit);
+ inline void SetTruncated(TBool aTruncBit);
+ inline void SetRecursionDesired(TBool aRecDesired);
+ inline void SetRecursionAvailable(TBool aRecAvailable);
+ inline void SetReserved(TUint16 aResv);
+ inline void SetResponseCode(TUint16 aRespCode);
+ inline void SetFlags(TUint16 aFlags);
+ inline void SetQueryCount(TUint16 aCount);
+ inline void SetAnswerCount(TUint16 aCount);
+ inline void SetAuthorityNSCount(TUint16 aCount);
+ inline void SetAdditionalRCount(TUint16 aCount);
+
+ inline TDnsHeader();
+ inline TDnsHeader(const TDnsHeader& aHeader);
+
+private:
+/* 1 1 1 1 1 1
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | ID |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ |QR| Opcode |AA|TC|RD|RA| Z | RCODE |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | QDCOUNT |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | ANCOUNT |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | NSCOUNT |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | ARCOUNT |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+
+*/
+ TUint16 iID;
+ TUint16 iFlags;
+ TUint16 iQCount;
+ TUint16 iACount;
+ TUint16 iNSCount;
+ TUint16 iARCount;
+ };
+
+#include <mdns/tdnsheader.inl>
+
+#endif //__TDNSHEADER_H__
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/inc/tdnsheader.inl Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,206 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef __TDNSHEADER_INL__
+#define __TDNSHEADER_INL__
+
+
+TDnsHeader::TDnsHeader()
+ {
+ iQCount = 0;
+ iACount = 0;
+ iNSCount = 0;
+ iARCount = 0;
+ iID = 0;
+ iFlags = 0;
+ }
+
+
+TDnsHeader::TDnsHeader(const TDnsHeader& aHeader)
+ {
+ iQCount = aHeader.QueryCount();
+ iACount = aHeader.AnswerCount();
+ iNSCount = aHeader.AuthorityNSCount();
+ iARCount = aHeader.AdditionalRCount();
+ iID = aHeader.Id();
+ iFlags = aHeader.Flags();
+ }
+
+
+
+TUint16 TDnsHeader::Id()const
+ {
+ return iID;
+ }
+
+TUint16 TDnsHeader::IsQuery()const
+ {
+ return !(iFlags & EFlagQuery);
+ }
+
+TUint16 TDnsHeader::Opcode()const
+ {
+ return (iFlags >> 3) & EFlagOpcode;
+ }
+
+TUint16 TDnsHeader::IsAuthoritative()const
+ {
+ return iFlags & EFlagAuthoritative;
+ }
+
+TUint16 TDnsHeader::IsTruncated()const
+ {
+ return iFlags & EFlagTruncated;
+ }
+
+TUint16 TDnsHeader::RecursionDesired()const
+ {
+ return iFlags & EFlagRecurse;
+ }
+
+TUint16 TDnsHeader::RecursionAvailable()const
+ {
+ return iFlags & EFlagRecursionAvailable;
+ }
+
+TUint16 TDnsHeader::Reserved()const
+ {
+ return iFlags & EFlagReserved;
+ }
+
+TUint16 TDnsHeader::ResponseCode()const
+ {
+ return iFlags & EFlagResponseCode;
+ }
+
+TUint16 TDnsHeader::Flags()const
+ {
+ return iFlags;
+ }
+
+TUint16 TDnsHeader::QueryCount()const
+ {
+ return iQCount;
+ }
+
+TUint16 TDnsHeader::AnswerCount()const
+ {
+ return iACount;
+ }
+
+TUint16 TDnsHeader::AuthorityNSCount()const
+ {
+ return iNSCount;
+ }
+
+TUint16 TDnsHeader::AdditionalRCount()const
+ {
+ return iARCount;
+ }
+
+void TDnsHeader::SetId(TUint16 aId)
+ {
+ iID = aId;
+ }
+
+void TDnsHeader::SetQuery(TBool aQuery)
+ {
+ if (!aQuery)
+ iFlags |= EFlagQuery;
+ else
+ iFlags &= ~EFlagQuery;
+ }
+
+
+void TDnsHeader::SetOpcode(TUint16 aOpcode)
+ {
+ aOpcode << 11;
+ iFlags |= aOpcode ;
+ }
+
+void TDnsHeader::SetAuthoritative(TBool aAuthBit)
+ {
+ if(aAuthBit)
+ iFlags |= EFlagAuthoritative;
+ else
+ iFlags &= ~EFlagAuthoritative;
+ }
+
+
+void TDnsHeader::SetTruncated(TBool aTruncBit)
+ {
+ if(aTruncBit)
+ iFlags |= EFlagTruncated;
+ else
+ iFlags &= ~EFlagTruncated;
+ }
+
+void TDnsHeader::SetRecursionDesired(TBool aRecDesired)
+ {
+ if (aRecDesired)
+ iFlags |= EFlagRecurse;
+ else
+ iFlags &= ~EFlagRecurse;
+ }
+
+void TDnsHeader::SetRecursionAvailable(TBool aRecAvailable)
+ {
+ if (aRecAvailable)
+ iFlags |= EFlagRecursionAvailable;
+ else
+ iFlags &= ~EFlagRecursionAvailable;
+ }
+
+void TDnsHeader::SetReserved(TUint16 aResv)
+ {
+ aResv << 4;
+ iFlags |= aResv;
+ }
+
+void TDnsHeader::SetResponseCode(TUint16 aRespCode)
+ {
+ iFlags |= aRespCode;
+ }
+
+void TDnsHeader::SetFlags(TUint16 aFlags)
+ {
+ iFlags = aFlags;
+ }
+
+void TDnsHeader::SetQueryCount(TUint16 aCount)
+ {
+ iQCount = aCount;
+ }
+
+void TDnsHeader::SetAnswerCount(TUint16 aCount)
+ {
+ iACount = aCount;
+ }
+
+void TDnsHeader::SetAuthorityNSCount(TUint16 aCount)
+ {
+ iNSCount = aCount;
+ }
+
+void TDnsHeader::SetAdditionalRCount(TUint16 aCount)
+ {
+ iARCount = aCount;
+ }
+
+#endif //__TDNSHEADER_INL__
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/src/cdnsmessage.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,134 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+#include "cdnsmessage.h"
+
+
+CDnsMessage::CDnsMessage(TUint16 aId, TBool aQuery)
+ {
+ iHeader.SetId(aId);
+ iHeader.SetQuery(aQuery);
+ }
+
+EXPORT_C CDnsMessage* CDnsMessage::NewL(TUint16 aId, TBool aQuery)
+ {
+ return ( new(ELeave)CDnsMessage(aId, aQuery) );
+ }
+
+CDnsMessage::~CDnsMessage()
+ {
+ iQueries.ResetAndDestroy();
+ iQueries.Close();
+ iAnswers.ResetAndDestroy();
+ iAnswers.Close();
+ iAuthorities.ResetAndDestroy();
+ iAuthorities.Close();
+ iAdditional.ResetAndDestroy();
+ iAdditional.Close();
+ }
+
+EXPORT_C void CDnsMessage::SetHeader(const TDnsHeader& aHeader)
+ {
+ iHeader = aHeader;
+ }
+
+EXPORT_C void CDnsMessage::AppendQueryL(const CDnsQuestion* aQuery)
+ {
+ iQueries.AppendL(aQuery);
+ iHeader.SetQueryCount(iQueries.Count());
+ }
+
+EXPORT_C void CDnsMessage::AppendAnswerL(const CDnsResourceData* aAnswer)
+ {
+ iAnswers.AppendL(aAnswer);
+ iHeader.SetAnswerCount(iAnswers.Count());
+ }
+
+EXPORT_C void CDnsMessage::AppendAuthorityL(const CDnsResourceData* aAuthority)
+ {
+ iAuthorities.AppendL(aAuthority);
+ iHeader.SetAuthorityNSCount(iAuthorities.Count());
+ }
+
+EXPORT_C void CDnsMessage::AppendAdditionalL(const CDnsResourceData* aAdditional)
+ {
+ iAdditional.AppendL(aAdditional);
+ iHeader.SetAdditionalRCount(iAdditional.Count());
+ }
+
+EXPORT_C const RPointerArray<CDnsQuestion>& CDnsMessage::Queries()const
+ {
+ return iQueries;
+ }
+
+EXPORT_C const RPointerArray<CDnsResourceData>& CDnsMessage::Answers()const
+ {
+ return iAnswers;
+ }
+
+EXPORT_C const RPointerArray<CDnsResourceData>& CDnsMessage::Authorities()const
+ {
+ return iAuthorities;
+ }
+
+EXPORT_C const RPointerArray<CDnsResourceData>& CDnsMessage::Additional()const
+ {
+ return iAdditional;
+ }
+
+EXPORT_C const TDnsHeader& CDnsMessage::Header()const
+ {
+ return iHeader;
+ }
+
+//Calculates the size of the dns message
+EXPORT_C TUint16 CDnsMessage::Size()const
+ {
+ TUint16 size =0;
+ size += sizeof(iHeader);
+
+ TInt i;
+
+ for ( i=0; i<iQueries.Count(); i++)
+ {
+ CDnsQuestion* ques = iQueries[i];
+ size += ques->Size();
+ }
+
+ for ( i=0; i<iAnswers.Count(); i++)
+ {
+ CDnsResourceData* rData = iAnswers[i];
+ size += rData->Size();
+ }
+
+ for ( i=0; i<iAuthorities.Count(); i++)
+ {
+ CDnsResourceData* rData = iAuthorities[i];
+ size += rData->Size();
+ }
+
+ for ( i=0; i<iAdditional.Count(); i++)
+ {
+ CDnsResourceData* rData = iAdditional[i];
+ size += rData->Size();
+ }
+ return size ;
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/src/cdnsmessagecomposerparser.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,372 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include "cdnsmessagecomposerparser.h"
+#include "cdnsmsgbuf.h"
+#include "cdnspacket.h"
+
+
+__FLOG_STMT(_LIT8(KSubsys,"Dns Message Composer Parser");)
+__FLOG_STMT(_LIT8(KComponent,"DnsMessage");)
+
+
+
+CDnsMessageComposerParser::CDnsMessageComposerParser()
+ {
+ }
+
+
+EXPORT_C CDnsMessageComposerParser* CDnsMessageComposerParser::NewL()
+ {
+ CDnsMessageComposerParser* self= new(ELeave)CDnsMessageComposerParser;
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+
+CDnsMessageComposerParser::~CDnsMessageComposerParser()
+ {
+ iBuf.Close();
+ delete iPacket;
+ delete iMsgBuf;
+ __FLOG(_L8("-> Composer Parser destroyed"));
+ __FLOG_CLOSE;
+ }
+
+
+void CDnsMessageComposerParser::ConstructL()
+ {
+ __FLOG_OPEN(KSubsys, KComponent);
+ __FLOG(_L8("-> Composer parser created"));
+ }
+
+
+/**
+ Composes mdns message
+ @param aMessage
+ @param aType RR type
+ @param aUnicast
+ @return iBuf composed dns buffer
+ */
+EXPORT_C void CDnsMessageComposerParser::CreateMessageL(RBuf8& aMessageBuffer, const CDnsMessage& aMessage )
+ {
+ __FLOG(_L8("-> Composing Dns Message"));
+
+ aMessageBuffer.CreateL(GetLength(aMessage));
+
+ iMsgBuf = CDnsMsgBuf::NewL(aMessageBuffer);
+
+ const TDnsHeader& header = aMessage.Header();
+ iMsgBuf->SetInt16(header.Id());
+ iMsgBuf->SetInt16(header.Flags());
+
+ const RPointerArray<CDnsQuestion>& quesList = aMessage.Queries();
+ const RPointerArray<CDnsResourceData>& ansList = aMessage.Answers();
+ const RPointerArray<CDnsResourceData>& authList= aMessage.Authorities();
+ const RPointerArray<CDnsResourceData>& additionalList = aMessage.Additional();
+
+ iMsgBuf->SetInt16(quesList.Count());
+ iMsgBuf->SetInt16(ansList.Count());
+ iMsgBuf->SetInt16(authList.Count());
+ iMsgBuf->SetInt16(additionalList.Count());
+
+ TInt i;
+ for(i=0; i<quesList.Count(); i++ )
+ {
+ CDnsQuestion* ques = quesList[i];
+
+ iMsgBuf->SetDomainNameL(ques->Name());
+ iMsgBuf->SetInt16(ques->Type());
+ iMsgBuf->SetInt16(ques->Class());
+ }
+
+ // add answer section
+ for(i=0; i<ansList.Count(); i++ )
+ {
+ AppendResourceRecordsL(ansList[i]);
+ }
+
+ // add authority section
+ for(i=0; i<authList.Count(); i++ )
+ {
+ AppendResourceRecordsL(authList[i]);
+ }
+
+ // add additional section
+ for(i=0; i<additionalList.Count(); i++ )
+ {
+ AppendResourceRecordsL(additionalList[i]);
+ }
+ aMessageBuffer.SetLength(GetLength(aMessage));
+ }
+
+
+/**
+ Parses the raw dns packet
+ @param aBuf
+ @return dnsMessage Dns Message Structure
+ */
+EXPORT_C CDnsMessage* CDnsMessageComposerParser::ParseMessageL(const TDesC8& aBuf)
+ {
+ __FLOG(_L8("-> Parsing Dns Raw Buffer"));
+ iBuf.CreateL(aBuf);
+ iPacket = CDnsPacket::NewL(iBuf.LeftTPtr(iBuf.Length()));
+
+ const TDnsHeader& header = iPacket->GetHeaderL();
+
+ CDnsMessage* dnsMessage = CDnsMessage::NewL(header.Id(),header.IsQuery());
+ CleanupStack::PushL(dnsMessage);
+
+ dnsMessage->SetHeader(header);
+
+ TInt i;
+ // extract the query section;
+ for(i=0; i<header.QueryCount(); i++)
+ {
+ __FLOG(_L8("-> Retrieving Query Section"));
+ RBuf8 domainName;
+ domainName.CreateL(KMaxDNSNameLength);
+ iPacket->GetDomainNameL(domainName);
+ CDnsQuestion* question = CDnsQuestion::NewL();
+ CleanupStack::PushL(question);
+ question->SetNameL(domainName);
+ question->SetType(iPacket->GetInt16L());
+ question->SetClass(iPacket->GetInt16L());
+ domainName.Close();
+ dnsMessage->AppendQueryL(question);
+ CleanupStack::Pop(question);
+ }
+
+ // extract the answer section
+ for(i=0; i<header.AnswerCount(); i++)
+ {
+ __FLOG(_L8("-> Retrieving Answer Section"));
+ CDnsResourceData* resourceRecord = GetResourceRecordsL();
+ CleanupStack::PushL(resourceRecord);
+ dnsMessage->AppendAnswerL(resourceRecord);
+ CleanupStack::Pop(resourceRecord);
+ }
+
+ // extract the authority section
+ for(i=0; i<header.AuthorityNSCount(); i++)
+ {
+ __FLOG(_L8("-> Retrieving Authority NS Section"));
+ CDnsResourceData* resourceRecord = GetResourceRecordsL();
+ CleanupStack::PushL(resourceRecord);
+ dnsMessage->AppendAuthorityL(resourceRecord);
+ CleanupStack::Pop(resourceRecord);
+ }
+
+ // extract the additional section
+ for(i=0; i<header.AdditionalRCount(); i++)
+ {
+ __FLOG(_L8("-> Retrieving Additional Record Section"));
+ CDnsResourceData* resourceRecord = GetResourceRecordsL();
+ CleanupStack::PushL(resourceRecord);
+ dnsMessage->AppendAdditionalL(resourceRecord);
+ CleanupStack::Pop(resourceRecord);
+ }
+
+ CleanupStack::Pop(dnsMessage);
+ return dnsMessage;
+ }
+
+
+CDnsResourceData* CDnsMessageComposerParser::GetResourceRecordsL()
+ {
+ __FLOG(_L8("-> Retrieving Resource Records"));
+ RBuf8 name;
+ name.CreateL(KMaxDNSNameLength);
+ iPacket->GetDomainNameL(name);
+ TUint16 type = iPacket->GetInt16L();
+ TUint16 classType = iPacket->GetInt16L();
+ TUint32 ttl = iPacket->GetInt32L();
+ TUint16 rdLength = iPacket->GetInt16L();
+
+ CDnsResourceData* resourceData = NULL;
+
+ switch(type)
+ {
+ case EDnsType_A : // A record
+ {
+ TInetAddr addr;
+ addr.SetAddress(iPacket->GetInt32L());
+
+ CRdTypeA* addrRecord = CRdTypeA::NewL();
+ CleanupStack::PushL(addrRecord);
+
+ addrRecord->SetNameL(name);
+ addrRecord->SetType(type);
+ addrRecord->SetClass(classType);
+ addrRecord->SetTtl(ttl);
+ addrRecord->SetRdLength(rdLength);
+ addrRecord->SetAddr(addr);
+
+ CleanupStack::Pop(addrRecord);
+ resourceData = addrRecord;
+ }
+ break;
+ case EDnsType_PTR: // PTR record
+ {
+ RBuf8 ptrDomainName;
+ ptrDomainName.CreateL(KMaxDNSNameLength);
+ iPacket->GetRdDomainNameL(ptrDomainName,rdLength);
+
+ CRdTypePtr* ptrRecord = CRdTypePtr::NewL();
+ CleanupStack::PushL(ptrRecord);
+
+ ptrRecord->SetNameL(name);
+ ptrRecord->SetType(type);
+ ptrRecord->SetClass(classType);
+ ptrRecord->SetTtl(ttl);
+ ptrRecord->SetRdLength(rdLength);
+ ptrRecord->SetDomainNameL(ptrDomainName);
+
+ ptrDomainName.Close();
+ CleanupStack::Pop(ptrRecord);
+ resourceData = ptrRecord;
+ }
+ break;
+ case EDnsType_SRV: // SRC record
+ {
+ TUint16 priority = iPacket->GetInt16L();
+ TUint16 weight = iPacket->GetInt16L();
+ TUint16 port = iPacket->GetInt16L();
+ RBuf8 srvDomainName;
+ srvDomainName.CreateL(KMaxDNSNameLength);
+ TInt length1 = sizeof(priority);
+ TInt length2 = sizeof(weight);
+ TInt length3 = sizeof(port);
+ TInt length = length1+length2+length3; // 6 = sizeof( prio + weight + port )
+ iPacket->GetRdDomainNameL(srvDomainName,rdLength - length);
+
+ CRdTypeSrv* srvRecord = CRdTypeSrv::NewL();
+ CleanupStack::PushL(srvRecord);
+
+ srvRecord->SetNameL(name);
+ srvRecord->SetType(type);
+ srvRecord->SetClass(classType);
+ srvRecord->SetTtl(ttl);
+ srvRecord->SetRdLength(rdLength);
+ srvRecord->SetPriority(priority);
+ srvRecord->SetWeight(weight);
+ srvRecord->SetPort(port);
+ srvRecord->SetTargetL(srvDomainName);
+
+ srvDomainName.Close();
+ CleanupStack::Pop(srvRecord);
+ resourceData = srvRecord;
+ }
+ break;
+ case EDnsType_TXT: // TXT record
+ {
+ TInt strLength = 0;
+ CRdTypeTxt* txtRecord = CRdTypeTxt::NewL();
+ CleanupStack::PushL(txtRecord);
+
+ txtRecord->SetNameL(name);
+ txtRecord->SetType(type);
+ txtRecord->SetClass(classType);
+ txtRecord->SetTtl(ttl);
+ txtRecord->SetRdLength(rdLength);
+
+ while(rdLength)
+ {
+ RBuf8 txtString;
+ strLength = iPacket->GetCharL();
+ rdLength--;
+ txtString.CreateL(strLength);
+ iPacket->GetStringL(txtString,strLength);
+ rdLength -= strLength;
+ txtRecord->AppendTextDataL(txtString);
+ }
+ CleanupStack::Pop(txtRecord);
+ resourceData = txtRecord;
+ }
+ break;
+ default:
+ //User::Leave(KErrCorrupt);
+ break;
+ }
+ name.Close();
+ return resourceData;
+ }
+
+
+void CDnsMessageComposerParser::AppendResourceRecordsL( CDnsResourceData* aResourceRecord )
+ {
+ __FLOG(_L8("-> Adding Resource Records to buffer"));
+
+ iMsgBuf->SetDomainNameL(aResourceRecord->Name());
+ iMsgBuf->SetInt16(aResourceRecord->Type());
+ iMsgBuf->SetInt16(aResourceRecord->Class());
+ iMsgBuf->SetInt32(aResourceRecord->Ttl());
+
+ switch( aResourceRecord->Type())
+ {
+ case EDnsType_A: // A record
+ {
+ CRdTypeA* addrRecord = static_cast<CRdTypeA*>(aResourceRecord);
+ const TInetAddr& addr = addrRecord->Address();
+ iMsgBuf->SetInt16(4);
+ iMsgBuf->SetInt32(addr.Address());
+ }
+ break;
+ case EDnsType_PTR: // PTR record
+ {
+ CRdTypePtr* ptrRecord = static_cast<CRdTypePtr*>(aResourceRecord);
+ iMsgBuf->SetPtrRdLengthL(ptrRecord->DomainName());
+ iMsgBuf->SetDomainNameL(ptrRecord->DomainName());
+ }
+ break;
+ case EDnsType_SRV: // SRV record
+ {
+ CRdTypeSrv* srvRecord = static_cast<CRdTypeSrv*>(aResourceRecord);
+ iMsgBuf->SetSrvRdLengthL(srvRecord->Target());
+ iMsgBuf->SetInt16(srvRecord->Priority());
+ iMsgBuf->SetInt16( srvRecord->Weight());
+ iMsgBuf->SetInt16( srvRecord->Port());
+ iMsgBuf->SetDomainNameL(srvRecord->Target());
+ }
+ break;
+ case EDnsType_TXT: // TXT record
+ {
+ CRdTypeTxt* txtRecord = static_cast<CRdTypeTxt*>(aResourceRecord);
+ const RArray<RBuf8>& txtList = txtRecord->Text();
+ iMsgBuf->SetTxtRdLength(txtList);
+ for(TInt j=0; j<txtList.Count(); j++)
+ {
+ RBuf8 txt;
+ txt.CreateL(txtList[j]);
+ iMsgBuf->SetText(txt);
+ txt.Close();
+ }
+ }
+ break;
+ }
+ }
+
+
+//Returns the size of the dns message
+TUint16 CDnsMessageComposerParser::GetLength(const CDnsMessage& aMessage)const
+ {
+ return (aMessage.Size());
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/src/cdnsmsgbuf.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,166 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include "cdnsmsgbuf.h"
+
+
+CDnsMsgBuf::CDnsMsgBuf(const TDesC8& aBuf):iDataLength(aBuf.Size())
+ {
+ }
+
+CDnsMsgBuf* CDnsMsgBuf::NewL(const TDesC8& aBuf)
+ {
+ CDnsMsgBuf* self = new (ELeave) CDnsMsgBuf(aBuf);
+ CleanupStack::PushL(self);
+ self->ConstructL(aBuf);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+CDnsMsgBuf::~CDnsMsgBuf()
+ {
+ }
+
+void CDnsMsgBuf::ConstructL(const TDesC8& aBuf)
+ {
+ iPtr = (TUint8*)aBuf.Ptr();
+ iIndex = 0;
+ }
+
+void CDnsMsgBuf::SetChar(TUint8 aVal)
+ {
+ *(iPtr+iIndex) = aVal;
+ iIndex += sizeof(TUint8);
+ }
+
+void CDnsMsgBuf::SetInt16(TUint16 aVal)
+ {
+ BigEndian::Put16(iPtr + iIndex, aVal);
+ iIndex += sizeof(TUint16);
+ }
+
+void CDnsMsgBuf::SetInt32(TUint32 aVal)
+ {
+ BigEndian::Put32(iPtr + iIndex, aVal);
+ iIndex += sizeof(TUint32);
+ }
+
+void CDnsMsgBuf::SetDomainNameL(const TDesC8& aName)
+ {
+ RBuf8 name;
+ if(aName.LocateReverse('.')== aName.Length()-1)
+ {
+ name.Create(aName.Left(aName.Length()-1));
+ }
+ else
+ {
+ name.Create(aName);
+ }
+ CStringParser* strParser = CStringParser::NewL (name);
+ CleanupStack::PushL ( strParser );
+ TPtrC8 token;
+ TChar ch = '.';
+ TUint8 len = 0;
+ while(1)
+ {
+ TBool result = strParser->ParseTill(token,ch);
+ len = token.Size();
+ SetChar(len);
+ for(TInt i = 0; i< len; i++)
+ {
+ SetChar(token.Ptr()[i]);
+ }
+ strParser->SkipLength(1);
+ if(!result)
+ break;
+ }
+
+ // append a zero at the end
+ SetChar(NULL);
+ CleanupStack::PopAndDestroy ( strParser );
+ name.Close();
+ }
+
+void CDnsMsgBuf::SetText(const TDesC8& aTxt)
+ {
+ TUint8 len = 0;
+ len = aTxt.Size();
+ SetChar(len);
+ for(TInt i=0; i<len; i++)
+ {
+ SetChar(aTxt.Ptr()[i]);
+ }
+ }
+
+void CDnsMsgBuf::SetPtrRdLengthL(const TDesC8& aName)
+ {
+ TUint16 len = GetDomainLengthL(aName);
+ SetInt16(len);
+ }
+
+void CDnsMsgBuf::SetSrvRdLengthL(const TDesC8& aName)
+ {
+ TUint16 len = GetDomainLengthL(aName);
+ len += 6; //sizeof(prio+weight+port)
+ SetInt16(len);
+ }
+
+void CDnsMsgBuf::SetTxtRdLength(const RArray<RBuf8>& aTxtList)
+ {
+ TUint16 len = 0;
+ TInt count = aTxtList.Count();
+ for (TInt i=0; i< count; i++)
+ {
+ len++;
+ len += aTxtList[i].Size();
+ }
+ SetInt16(len);
+ }
+
+TUint16 CDnsMsgBuf::GetDomainLengthL(const TDesC8& aName)const
+ {
+ RBuf8 name;
+ if(aName.LocateReverse('.')== aName.Length()-1)
+ {
+ name.Create(aName.Left(aName.Length()-1));
+ }
+ else
+ {
+ name.Create(aName);
+ }
+
+ CStringParser* strParser = CStringParser::NewL (name);
+ CleanupStack::PushL ( strParser );
+ TPtrC8 token;
+ TChar ch = '.';
+ TUint16 len = 0;
+ while(1)
+ {
+ TBool result = strParser->ParseTill(token,ch);
+ len++;
+ len += token.Size();
+ strParser->SkipLength(1);
+ if(!result)
+ break;
+ }
+ len++; //0 length octet appended at the end
+ CleanupStack::PopAndDestroy ( strParser );
+ name.Close();
+ return len;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/src/cdnspacket.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,254 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include "cdnspacket.h"
+
+
+CDnsPacket::CDnsPacket(const TDes8& aPacketPtr): iPtr(aPacketPtr.Ptr()),iDataLength(aPacketPtr.Size()),
+ iMaxLength(aPacketPtr.MaxSize())
+ {
+ }
+
+CDnsPacket* CDnsPacket::NewL(const TDes8& aPacketPtr)
+ {
+ CDnsPacket* self = new (ELeave) CDnsPacket( aPacketPtr );
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+CDnsPacket::~CDnsPacket()
+ {
+ }
+
+void CDnsPacket::ConstructL()
+ {
+ iIndex = 0;
+ }
+
+TUint8 CDnsPacket::GetCharL()
+ {
+ __OOB(iIndex,iDataLength)
+ TUint8 val = *(iPtr+iIndex);
+ iIndex += sizeof(TUint8);
+ return val;
+ }
+
+TUint16 CDnsPacket::GetInt16L()
+ {
+ __OOB(iIndex,iDataLength)
+ TUint16 val = BigEndian::Get16(iPtr+iIndex);
+ iIndex += sizeof(TUint16);
+ return val;
+ }
+
+TUint32 CDnsPacket::GetInt32L()
+ {
+ __OOB(iIndex,iDataLength)
+ TUint32 val = BigEndian::Get32(iPtr+iIndex);
+ iIndex += sizeof(TUint32);
+ return val;
+ }
+
+const TDnsHeader& CDnsPacket::GetHeaderL()
+ {
+ iHeader.SetId(GetInt16L());
+ iHeader.SetFlags(GetInt16L());
+ iHeader.SetQueryCount(GetInt16L());
+ iHeader.SetAnswerCount(GetInt16L());
+ iHeader.SetAuthorityNSCount(GetInt16L());
+ iHeader.SetAdditionalRCount(GetInt16L());
+
+ return iHeader;
+ }
+
+void CDnsPacket::GetDomainNameL(TDes8& aName)
+ {
+ TInt labelLen = GetCharL();
+ RBuf8 label;
+ TInt isStartingWithPointer = labelLen & KPointerBit;
+
+ if(isStartingWithPointer)
+ {
+ TUint16 pointerOffset = labelLen & KPointerOffsetBit;
+ __OOB(pointerOffset,iDataLength)
+ pointerOffset = (pointerOffset << 8) + GetCharL();
+ GetDomainNameAtIndexL(aName, pointerOffset);
+ }
+ else
+ {
+ while(labelLen)
+ {
+ TInt isPointer = labelLen & KPointerBit;
+ if(isPointer)
+ {
+ TUint16 pointerOffset = labelLen & KPointerOffsetBit;
+ __OOB(pointerOffset,iDataLength)
+ pointerOffset = (pointerOffset << 8) + GetCharL();
+ label.CreateL(KMaxDNSNameLength);
+ GetStringAtIndexL(label,pointerOffset);
+ }
+ else
+ {
+ label.CreateL(labelLen);
+ GetStringL(label,labelLen);
+ }
+ aName.Append(label);
+ if(aName[aName.Size()-1]!='.')
+ aName.Append(KDot);
+ label.Close();
+ if(isPointer )
+ {
+ break;
+ }
+ else
+ {
+ labelLen = GetCharL();
+ }
+ }
+ }
+ }
+
+void CDnsPacket::GetRdDomainNameL(TDes8& aDomainName,TUint aLength)
+ {
+ TInt labelLen = GetCharL();
+ aLength--;
+ RBuf8 label;
+ TInt isStartingWithPointer = labelLen & KPointerBit;
+
+ while(aLength)
+ {
+ TInt isPointer = labelLen & KPointerBit;
+ if(isPointer)
+ {
+ TUint16 pointerOffset = labelLen & KPointerOffsetBit;
+ __OOB(pointerOffset,iDataLength)
+ pointerOffset = (pointerOffset << 8) + GetCharL();
+ aLength--;
+ label.CreateL(KMaxLabelLength);
+ if(isStartingWithPointer )
+ {
+ GetDomainNameAtIndexL(aDomainName, pointerOffset);
+ }
+ else
+ {
+ GetDomainNameAtIndexL(label, pointerOffset);
+ //GetStringAtIndexL(label, pointerOffset);
+ }
+ }
+ else
+ {
+ label.CreateL(labelLen);
+ GetStringL(label,labelLen);
+ aLength-=labelLen;
+ }
+
+ aDomainName.Append(label);
+ label.Close();
+ if(isStartingWithPointer)
+ {
+ break;
+ }
+ else
+ {
+ if(aLength )
+ {
+ labelLen = GetCharL();
+ aLength--;
+ if(aDomainName[aDomainName.Size()-1]!='.')
+ aDomainName.Append(KDot);
+ }
+ }
+ }
+ }
+
+void CDnsPacket::GetStringL(TDes8& aString, TUint16 aLength)
+ {
+ __OOB(iIndex,iDataLength)
+ aString.Copy(iPtr+iIndex,aLength);
+ iIndex+= aLength;
+ }
+
+void CDnsPacket::GetDomainNameAtIndexL(TDes8& aDomainName, TUint aOffset)
+ {
+ __OOB(aOffset,iDataLength)
+ TUint8 labelLen = *(iPtr + aOffset);
+ RBuf8 label;
+ TInt isPointer;
+ TUint16 pointerOffset;
+ TInt isStartingWithPointer = labelLen & KPointerBit;
+ TUint8 ptrPos;
+ if(isStartingWithPointer)
+ {
+ pointerOffset = labelLen & KPointerOffsetBit;
+ __OOB(aOffset,iDataLength)
+ aOffset++;
+ ptrPos = *(iPtr + aOffset);
+ pointerOffset = (pointerOffset << 8) + ptrPos;
+ GetDomainNameAtIndexL(aDomainName, pointerOffset);
+ }
+ else
+ {
+ while(labelLen)
+ {
+ label.CreateL(KMaxLabelLength);
+ GetStringAtIndexL(label, aOffset);
+ aDomainName.Append(label);
+ if(aDomainName[aDomainName.Size()-1]!='.')
+ aDomainName.Append(KDot);
+ __OOB(aOffset,iDataLength)
+ aOffset++; // increment by one byte for length field
+ aOffset += labelLen;
+ label.Close();
+ labelLen = *(iPtr + aOffset);
+ isPointer = labelLen & KPointerBit;
+ if(isPointer)
+ {
+ pointerOffset = labelLen & KPointerOffsetBit;
+ __OOB(aOffset,iDataLength)
+ aOffset++;
+ ptrPos = *(iPtr + aOffset);
+ pointerOffset = (pointerOffset << 8) + ptrPos;
+ label.CreateL(KMaxLabelLength);
+ GetStringAtIndexL(label, pointerOffset);
+ aDomainName.Append(label);
+ if(aDomainName[aDomainName.Size()-1]!='.')
+ aDomainName.Append(KDot);
+ label.Close();
+ break;
+ }
+ }
+ }
+ }
+
+void CDnsPacket::GetStringAtIndexL(TDes8& aLabel, TUint aOffset)
+ {
+ __OOB(aOffset,iDataLength)
+ TUint8 labelLen = *(iPtr + aOffset);
+ if(labelLen & KPointerBit) // recursive pointers
+ {
+ TUint16 pointerOffset = labelLen & KPointerOffsetBit;
+ pointerOffset = (pointerOffset << 8) + GetCharL();
+ GetStringAtIndexL(aLabel, pointerOffset);
+ }
+ else
+ {
+ aLabel.Copy(iPtr+aOffset+1, labelLen);
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/src/cdnsquestion.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include "CDnsQuestion.h"
+
+
+EXPORT_C CDnsQuestion* CDnsQuestion::NewL()
+ {
+ return (new(ELeave) CDnsQuestion());
+ }
+
+CDnsQuestion::CDnsQuestion():CDnsSection()
+ {
+
+ }
+
+EXPORT_C CDnsQuestion::~CDnsQuestion()
+ {
+ }
+
+EXPORT_C TBool CDnsQuestion::IsUnicast()const
+ {
+ if(iClass & KQueryBit)
+ return ETrue;
+ else
+ return EFalse;
+ }
+
+EXPORT_C void CDnsQuestion::SetUnicast(TBool )
+ {
+ iClass |= KQueryBit;
+ }
+
+EXPORT_C TUint16 CDnsQuestion::Size()const
+ {
+ TUint16 count = 0;
+ count += iName.Size();
+ count += 2; // 2 bytes = descriptor length+ 0 length octet at the end
+ count += sizeof(iType);
+ count += sizeof(iClass);
+ return count;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/src/cdnsresourcedata.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,169 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include "cdnsresourcedata.h"
+#include "crdtypeptr.h"
+#include "crdtypea.h"
+#include "crdtypesrv.h"
+#include "crdtypetxt.h"
+
+
+CDnsResourceData::CDnsResourceData():CDnsSection()
+ {
+ }
+
+EXPORT_C CDnsResourceData::~CDnsResourceData()
+ {
+ }
+
+
+EXPORT_C TBool CDnsResourceData::IsFlushBitSet()const
+ {
+ if(iClass & KFlushBit)
+ return ETrue;
+ else
+ return EFalse;
+ }
+
+EXPORT_C void CDnsResourceData::SetFlushBit(TBool aFlushBit)
+ {
+ if(aFlushBit)
+ iClass |= KFlushBit;
+ else
+ iClass &= ~KFlushBit;
+ }
+
+EXPORT_C TUint16 CDnsResourceData::RdLength()const
+ {
+ return iRdLength;
+ }
+
+EXPORT_C void CDnsResourceData::SetRdLength(TUint16 aRdLength)
+ {
+ iRdLength = aRdLength;
+ }
+
+EXPORT_C TUint32 CDnsResourceData::Ttl()const
+ {
+ return iTtl;
+ }
+
+EXPORT_C void CDnsResourceData::SetTtl(TUint32 aTtl)
+ {
+ iTtl = aTtl;
+ }
+
+
+//Creates a new copy of this object. Leaves if a memory allocation fails
+EXPORT_C CDnsResourceData* CDnsResourceData::CloneL()const
+ {
+ CDnsResourceData* recordData = NULL;
+
+ switch(Type())
+ {
+ case EDnsType_A: // A record
+ {
+ const CRdTypeA* addrRecord = static_cast<const CRdTypeA*>(this);
+ CRdTypeA* rrAddrRecord = CRdTypeA::NewL();
+ CleanupStack::PushL(rrAddrRecord);
+
+ rrAddrRecord->SetNameL(addrRecord->Name());
+ rrAddrRecord->SetType(addrRecord->Type());
+ rrAddrRecord->SetClass(addrRecord->Class());
+ rrAddrRecord->SetTtl(addrRecord->Ttl());
+ rrAddrRecord->SetRdLength(addrRecord->RdLength());
+ rrAddrRecord->SetAddr(addrRecord->Address());
+
+ CleanupStack::Pop(rrAddrRecord);
+ recordData = rrAddrRecord;
+ }
+ break;
+
+ case EDnsType_PTR: // ptr record
+ {
+ const CRdTypePtr* ptrRecord = static_cast<const CRdTypePtr*>(this);
+ CRdTypePtr* rrPtrRecord = CRdTypePtr::NewL();
+ CleanupStack::PushL(rrPtrRecord);
+
+ rrPtrRecord->SetNameL(ptrRecord->Name());
+ rrPtrRecord->SetType(ptrRecord->Type());
+ rrPtrRecord->SetClass(ptrRecord->Class());
+ rrPtrRecord->SetTtl(ptrRecord->Ttl());
+ rrPtrRecord->SetRdLength(ptrRecord->RdLength());
+ rrPtrRecord->SetDomainNameL(ptrRecord->DomainName());
+
+ CleanupStack::Pop(rrPtrRecord);
+ recordData = rrPtrRecord;
+ }
+ break;
+
+ case EDnsType_SRV: // srv record
+ {
+ const CRdTypeSrv* srvRecord = static_cast<const CRdTypeSrv*>(this);
+ CRdTypeSrv* rrSrvRecord = CRdTypeSrv::NewL();
+ CleanupStack::PushL(rrSrvRecord);
+
+ rrSrvRecord->SetNameL(srvRecord->Name());
+ rrSrvRecord->SetClass(srvRecord->Class());
+ rrSrvRecord->SetType(srvRecord->Type());
+ rrSrvRecord->SetTtl(srvRecord->Ttl());
+ rrSrvRecord->SetRdLength(srvRecord->RdLength());
+ rrSrvRecord->SetPriority(srvRecord->Priority());
+ rrSrvRecord->SetWeight(srvRecord->Weight());
+ rrSrvRecord->SetPort(srvRecord->Port());
+ rrSrvRecord->SetTargetL(srvRecord->Target());
+
+ CleanupStack::Pop(rrSrvRecord);
+ recordData = rrSrvRecord;
+ }
+ break;
+
+ case EDnsType_TXT: // Txt record
+ {
+ const CRdTypeTxt* txtRecord = static_cast<const CRdTypeTxt*>(this);
+ CRdTypeTxt* rrTxtRecord = CRdTypeTxt::NewL();
+ CleanupStack::PushL(rrTxtRecord);
+
+ rrTxtRecord->SetNameL(txtRecord->Name());
+ rrTxtRecord->SetType(txtRecord->Type());
+ rrTxtRecord->SetClass(txtRecord->Class());
+ rrTxtRecord->SetTtl(txtRecord->Ttl());
+ rrTxtRecord->SetRdLength(txtRecord->RdLength());
+
+ const RArray<RBuf8>& txtList = txtRecord->Text();
+ TInt count = txtList.Count();
+ for(TInt j=0; j<count; j++)
+ {
+ RBuf8 txtBuf;
+ txtBuf.CreateL(txtList[j]);
+ rrTxtRecord->AppendTextDataL(txtBuf);
+ }
+ CleanupStack::Pop(rrTxtRecord);
+ recordData = rrTxtRecord;
+ }
+ break;
+ }
+ return recordData;
+ }
+
+TUint16 CDnsResourceData::Size()const
+ {
+ return 0;
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/src/cdnssection.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include "cdnssection.h"
+
+
+
+CDnsSection::CDnsSection()
+ {
+ }
+
+EXPORT_C const TDesC8& CDnsSection::Name()const
+ {
+ return iName;
+ }
+
+EXPORT_C void CDnsSection::SetNameL(const TDesC8& aName)
+ {
+ iName.Close();
+ iName.CreateL(aName);
+ }
+
+EXPORT_C TUint16 CDnsSection::Type()const
+ {
+ return iType;
+ }
+
+EXPORT_C void CDnsSection::SetType(TUint16 aType)
+ {
+ iType = aType;
+ }
+
+EXPORT_C TUint16 CDnsSection::Class()const
+ {
+ return iClass;
+ }
+
+EXPORT_C void CDnsSection::SetClass(TUint16 aClass)
+ {
+ iClass = aClass;
+ }
+
+EXPORT_C CDnsSection::~CDnsSection()
+ {
+ iName.Close();
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/src/crdtypea.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+#include "crdtypea.h"
+
+
+CRdTypeA::CRdTypeA():CDnsResourceData()
+ {
+ }
+
+EXPORT_C CRdTypeA* CRdTypeA::NewL()
+ {
+ return (new(ELeave)CRdTypeA());
+ }
+
+EXPORT_C CRdTypeA::~CRdTypeA()
+ {
+ }
+
+EXPORT_C const TInetAddr& CRdTypeA::Address()const
+ {
+ return iAddr;
+ }
+
+EXPORT_C void CRdTypeA::SetAddr(const TInetAddr& aAddr )
+ {
+ iAddr = aAddr;
+ }
+
+EXPORT_C TUint16 CRdTypeA::Size()const
+ {
+ TUint16 count = 0;
+ count += iName.Size();
+ count += 2; // 2 bytes = descriptor length+ 0 length octet at the end
+ count += sizeof(iType);
+ count += sizeof(iClass);
+ count += sizeof(iTtl);
+ count += sizeof(iRdLength);
+ count += sizeof(iAddr);
+ return count;
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/src/crdtypeptr.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include "crdtypeptr.h"
+
+
+CRdTypePtr::CRdTypePtr():CDnsResourceData()
+ {
+ }
+
+EXPORT_C CRdTypePtr* CRdTypePtr::NewL()
+ {
+ return (new(ELeave)CRdTypePtr());
+ }
+
+EXPORT_C CRdTypePtr::~CRdTypePtr()
+ {
+ iDomainName.Close();
+ }
+
+EXPORT_C const TDesC8& CRdTypePtr::DomainName()const
+ {
+ return iDomainName;
+ }
+
+EXPORT_C void CRdTypePtr::SetDomainNameL(const TDesC8& aDomainName)
+ {
+ iDomainName.Close();
+ iDomainName.CreateL(aDomainName);
+ }
+
+EXPORT_C TUint16 CRdTypePtr::Size()const
+ {
+ TUint16 count = 0;
+ count += iName.Size();
+ count += 2; // 2 bytes = descriptor length+ 0 length octet at the end
+ count += sizeof(iType);
+ count += sizeof(iClass);
+ count += sizeof(iTtl);
+ count += sizeof(iRdLength);
+ count += iDomainName.Size();
+ count += 2; // 2 bytes = descriptor length+ 0 length octet at the end
+ return count;
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/src/crdtypesrv.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include "crdtypesrv.h"
+
+
+CRdTypeSrv::CRdTypeSrv():CDnsResourceData()
+ {
+ }
+
+EXPORT_C CRdTypeSrv* CRdTypeSrv::NewL()
+ {
+ return (new(ELeave)CRdTypeSrv());
+ }
+
+EXPORT_C CRdTypeSrv::~CRdTypeSrv()
+ {
+ iTarget.Close();
+ }
+
+EXPORT_C TUint16 CRdTypeSrv::Priority()const
+ {
+ return iPrio;
+ }
+
+EXPORT_C void CRdTypeSrv::SetPriority(TUint16 aPriority)
+ {
+ iPrio = aPriority;
+ }
+
+EXPORT_C TUint16 CRdTypeSrv::Weight() const
+ {
+ return iWeight;
+ }
+
+EXPORT_C void CRdTypeSrv::SetWeight(TUint16 aWeight)
+ {
+ iWeight = aWeight;
+ }
+
+EXPORT_C TUint16 CRdTypeSrv::Port()const
+ {
+ return iPort;
+ }
+EXPORT_C void CRdTypeSrv::SetPort(TUint16 aPort)
+ {
+ iPort = aPort;
+ }
+
+EXPORT_C const TDesC8& CRdTypeSrv::Target() const
+ {
+ return iTarget;
+ }
+
+EXPORT_C void CRdTypeSrv::SetTargetL(const TDesC8& aTarget)
+ {
+ iTarget.Close();
+ iTarget.CreateL(aTarget);
+ }
+
+EXPORT_C TUint16 CRdTypeSrv::Size()const
+ {
+ TUint16 count = 0;
+ count += iName.Size();
+ count += 2; // 2 bytes = descriptor length+ 0 length octet at the end
+ count += sizeof(iType);
+ count += sizeof(iClass);
+ count += sizeof(iTtl);
+ count += sizeof(iRdLength);
+ count += sizeof(iPrio);
+ count += sizeof(iWeight);
+ count += sizeof(iPort);
+ count += iTarget.Size();
+ count += 2; // 2 bytes = descriptor length+ 0 length octet at the end
+ return count;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/src/crdtypetxt.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include "crdtypetxt.h"
+
+
+CRdTypeTxt::CRdTypeTxt():CDnsResourceData()
+ {
+ }
+
+EXPORT_C CRdTypeTxt* CRdTypeTxt::NewL()
+ {
+ return (new(ELeave)CRdTypeTxt());
+ }
+
+EXPORT_C CRdTypeTxt::~CRdTypeTxt()
+ {
+ for ( TInt i=0 ; i < iTxtData.Count(); i++)
+ {
+ iTxtData[i].Close();
+ }
+ iTxtData.Close();
+ }
+
+
+EXPORT_C void CRdTypeTxt::AppendTextDataL( const RBuf8& aTextData )
+ {
+ iTxtData.AppendL(aTextData);
+ }
+
+EXPORT_C const RArray<RBuf8>& CRdTypeTxt::Text()const
+ {
+ return iTxtData;
+ }
+
+EXPORT_C TUint16 CRdTypeTxt::Size()const
+ {
+ TUint16 count = 0;
+ count += iName.Size();
+ count += 2; // 2 bytes = descriptor length+ 0 length octet at the end
+ count += sizeof(iType);
+ count += sizeof(iClass);
+ count += sizeof(iTtl);
+ count += sizeof(iRdLength);
+ for ( TInt i= 0; i<iTxtData.Count(); i++)
+ {
+ count += iTxtData[i].Size();
+ count += 1; // one byte for descriptor length
+ }
+ return count;
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/src/cstringparser.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,168 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include <e32base.h>
+#include "cstringparser.h"
+
+
+CStringParser::CStringParser ( const TDesC8& aBuffer ): iBuffer ( aBuffer ),
+ iCurrentPos ( 0 )
+ {
+ }
+
+CStringParser::~CStringParser ()
+ {
+ }
+
+
+CStringParser* CStringParser::NewL ( const TDesC8& aBuffer )
+ {
+ return (new( ELeave)CStringParser( aBuffer ));
+ }
+
+/**
+ Get the next character from the current position, and increments the
+ current position by 1.
+
+ @param aChar [out] Next character to be read
+
+ @return TBool ETrue if the current position is less than the string length
+ else returns EFalse
+ */
+TBool CStringParser::GetNextCharacter ( TChar& aChar )
+ {
+ IncrementCurrentPos ();
+ return ( GetCurrentCharacter ( aChar ) );
+ }
+
+/**
+ Get the character from the current position.
+
+ @param aChar [out] Current character to be read
+
+ @return TBool ETrue if the current position is less than the string length
+ else returns EFalse
+ */
+TBool CStringParser::GetCurrentCharacter ( TChar& aChar )
+ {
+ if ( iCurrentPos >= iBuffer.Length () )
+ {
+ return EFalse;
+ }
+
+ aChar = iBuffer[ iCurrentPos ];
+ return ETrue;
+ }
+
+/**
+ Parses the string till it finds the aEndChar.
+
+ @param TChar [in] Character to search for.
+ @see GetNextWorrd
+ */
+TBool CStringParser::ParseTill ( TPtrC8& aWord, TChar aEndChar )
+ {
+ TPtrC8 cur( iBuffer.Mid( iCurrentPos ) );
+ TBool found = ETrue;
+ TInt pos = cur.Locate( aEndChar );
+ if ( pos < 0 )
+ {
+ // Unable to locate the aEndChar. Sets the end position to
+ // the length of the string.
+ pos = iBuffer.Length ();
+ found = EFalse;
+ }
+
+ aWord.Set ( cur.Left (pos) );
+ SkipLength ( pos );
+ return found;
+ }
+
+/**
+ Increments the current parsing position by aLen.
+
+ @param TInt [in] Number of character to skip.
+
+ @return TBool ETrue if the current parsing position is less than the buffer length
+ else returns EFalse.
+ */
+TBool CStringParser::SkipLength ( TInt aLen )
+ {
+ iCurrentPos += aLen;
+
+ if ( iCurrentPos < iBuffer.Length () )
+ {
+ return ETrue;
+ }
+ return EFalse;
+ }
+
+/**
+ Finds the remainder string from the current parsing position to the buffer length.
+
+ @param TPtrC8& [out] Points to the current starting position till end
+
+ @return TBool ETrue if the current parsing position is less than the buffer length
+ else returns EFalse.
+ */
+void CStringParser::GetRemainder ( TPtrC8& aBuffer )
+ {
+ aBuffer.Set ( iBuffer.Mid ( iCurrentPos ) );
+ SkipLength ( aBuffer.Length () );
+ }
+
+/**
+ Increments the current parsing position by 1.
+ */
+void CStringParser::IncrementCurrentPos ( )
+ {
+ ++iCurrentPos;
+ }
+
+/**
+ Parses till the first occurrence of any one of a set of characters in aCharSet,
+ from the current parsing position.
+
+ @param TPtrC8& [out] Points to the current starting position.
+ @param const TDesC8& [in] Descriptor containing characters for matching.
+ */
+void CStringParser::ParseTill ( TPtrC8& aWord, const TDesC8& aCharSet )
+ {
+ TPtrC8 cur( iBuffer.Mid( iCurrentPos ) );
+
+ TInt lowpos = cur.Length ();
+ TInt pos = KErrNotFound;
+
+ for ( TInt i = 0; i < aCharSet.Length(); ++i )
+ {
+ pos = cur.Locate ( aCharSet [ i ] );
+
+ if ( (pos != KErrNotFound) && (pos < lowpos ) )
+ {
+ lowpos = pos;
+ }
+ }
+
+ aWord.Set ( cur.Left ( lowpos ) );
+ SkipLength ( lowpos );
+ }
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/src/distribution.policy Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,2 @@
+Category E
+OSD: Optional Replaceable Bonjour Framework
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/dnsparser/src/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/group/bld.inf Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+
+#include "../dnsparser/group/bld.inf"
+#include "../cachemanager/group/bld.inf"
+#include "../server/group/bld.inf"
+#include "../client/group/bld.inf"
+
+PRJ_TESTMMPFILES
+PRJ_MMPFILES
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/group/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/group/bld.inf Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,19 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+PRJ_MMPFILES
+mdnsserver.mmp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/group/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/group/mdnsserver.mmp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#include <comms-infras/commsdebugutility.mmh>
+TARGET zeroconf_20008AD8.exe
+TARGETTYPE exe
+UID 0 0x20008AD8
+VENDORID 0
+
+
+CAPABILITY NetworkServices LocalServices ALL -TCB
+
+SOURCEPATH ..\src
+
+// ______________________________
+// | FRONT END SRV |
+//
+
+SOURCE mdns.cpp
+SOURCE mdnsserver.cpp
+SOURCE mdnsserversession.cpp
+SOURCE shutdowntimer.cpp
+
+//
+SOURCE csockethandler.cpp
+SOURCE cadvertizehandler.cpp
+SOURCE cbasehandler.cpp
+SOURCE cmessagehandler.cpp
+SOURCE cqueryhandler.cpp
+SOURCE cresponsehandler.cpp
+SOURCE csendmessagequeue.cpp
+SOURCE cmdnsprobemanager.cpp cinternalmessagequeue.cpp cmdnscacheconsistencymgr.cpp
+SOURCE CEngSettingsObserver.cpp
+
+//
+// |____________________________|
+//
+
+
+USERINCLUDE ..\inc
+USERINCLUDE ..\..\CacheManager\inc
+USERINCLUDE ..\..\client\inc
+USERINCLUDE ..\..\common\inc
+
+
+SYSTEMINCLUDE \epoc32\include
+SYSTEMINCLUDE \epoc32\include\mw
+SYSTEMINCLUDE \epoc32\include\platform\mw
+
+LIBRARY euser.lib
+LIBRARY esock.lib
+LIBRARY commdb.lib
+LIBRARY insock.lib
+LIBRARY charconv.lib
+LIBRARY efsrv.lib
+LIBRARY estor.lib
+LIBRARY mdnscachemanager.lib
+LIBRARY dnsparser.lib
+LIBRARY rpnp.lib
+LIBRARY inetprotutil.lib
+LIBRARY ecom.lib
+LIBRARY btengsettings.lib commsdataobjects.lib c32root.lib commsfw.lib commsdat.lib
+
+
+MW_LAYER_SYSTEMINCLUDE
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/CEngSettingsObserver.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+/*
+ * CEngSettingsObserver.h
+ *
+ * Created on: Jun 17, 2010
+ * Author: lachamar
+ */
+
+#ifndef CENGSETTINGSOBSERVER_H_
+#define CENGSETTINGSOBSERVER_H_
+
+
+#endif /* CENGSETTINGSOBSERVER_H_ */
+
+#include <e32base.h>
+#include <btserversdkcrkeys.h>
+#include <btengsettings.h>
+
+
+
+class CEngSettingsObserver : public CBase,public MBTEngSettingsObserver
+ {
+
+ public:
+
+ void PowerStateChanged( TBTPowerStateValue aState );
+
+ void VisibilityModeChanged( TBTVisibilityMode aState );
+
+ public:
+
+ static CEngSettingsObserver* NewLC();
+
+ ~CEngSettingsObserver();
+
+ private:
+
+ CEngSettingsObserver();
+ void ConstructL();
+
+ private:
+
+ };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/cadvertizehandler.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2008 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+/**
+@file
+@internalTechnology
+*/
+
+#ifndef __CADVERTIZEHANDLER_H__
+#define __CADVERTIZEHANDLER_H__
+
+//User include
+#include "cmessagehandler.h"
+#include <mdns/cdnsmessage.h>
+#include "cbasehandler.h"
+#include "cmdnsprobemanager.h"
+#include "mmessagehandler.h"
+#include "mdnsdebug.h"
+
+class CAdvertizeHandler : public CBaseHandler ,public MMessageHandler
+ {
+ public:
+ static CAdvertizeHandler* NewL(CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled = ETrue);
+ ~CAdvertizeHandler();
+ void HandleIncomingPacketL(CDnsMessage& aMessage);
+ void AdvertizePacketL(const RPointerArray<CDnsResourceData> aData, TInt aSessionId, TBool aIsUpdate);
+ void SetAutoResolve(TBool aFlag);
+ //From MMessageHandler
+ void OnPacketSendL(TInt aError);
+ private:
+ CAdvertizeHandler(CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled);
+ void ConstructL();
+ void RunL();
+ TInt RunError(TInt aError);
+ void Schedule();
+ TInt GenerateNonConflictingName();
+ TBool DefensiveResponseL();
+ void SendAnnouncementL();
+ void InsertInCache();
+ void SendProbeL(TBool aUnicast);
+ void ChangeDomainL(TDesC8& aName);
+ private:
+ RBuf8 iName;
+ TBool iAutoResolveEnabled;
+ TProbeStates iCurrentProbeState;
+ TConflictResolveState iConflict;
+ TInt iProbeCounter;
+ RPointerArray<CDnsResourceData> iData;
+ RBuf8 iProbeName;
+ RBuf8 iProbeType;
+ TInt iSessionId;
+ /**
+ FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+
+
+#endif //__CADVERTIZEHANDLER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/cbasehandler.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,100 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cbasehandler.h
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+#ifndef __CBASEHANDLER_H__
+#define __CBASEHANDLER_H__
+//System include
+#include <mdns/cdnsmessage.h>
+
+//User include
+#include "cmessagehandler.h"
+#include "mdnsdebug.h"
+
+class COutStandingQuery : public CBase
+ {
+ public :
+ static COutStandingQuery* NewL(CDnsMessage* aDnsMessage,TInt aTransactionId,TTime aTime, TSockAddr aAddr);
+ ~COutStandingQuery();
+ TTime GetAddTime()const;
+ TInt TransactionId()const ;
+ TSockAddr SocketAddress()const;
+ CDnsMessage& DnsMessage()const;
+ TInt ClientHandle()const;
+ void SetClientHandle(TInt aHandle);
+ private:
+ void ConstructL();
+ COutStandingQuery(CDnsMessage* aDnsMessage,TInt aTransactionId,TTime aTime, TSockAddr aAddr);
+
+
+ private:
+ TInt iTransactionID;
+ TTime iReviewTime;
+ TSockAddr iSockAddress;
+ CDnsMessage* iDnsMessage;
+ TInt iClientHandle;
+ /**
+ *FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+/**
+This is a Baseclass to handle common functionality to both the response and query handler
+this contains a reference to messagehandler which the derived class can make use of using
+the MessageHandler() api
+
+A reference to cache entry to be passed in order to build a cache wrapper as cache requires
+all the records to be present in the CacheEntry variable.
+
+Seperate functions are provide to handle address,pointer,text and srv records as , same can
+be used by both query and response handler.
+
+*/
+class CBaseHandler : public CTimer
+ {
+ public :
+ static CBaseHandler* NewL(CMessageHandler& aMessageHandler);
+ virtual ~CBaseHandler();
+
+ //From CTimer
+ void RunL();
+ void DoCancel();
+
+ virtual void HandleIncomingPacketL(CDnsMessage& aMessage, const TSockAddr& aAddr);
+
+ protected:
+ CBaseHandler(CMessageHandler& aMessageHandler);
+ void ConstructL();
+ CMessageHandler& MessageHandler()const;
+
+ protected:
+ RPointerArray<COutStandingQuery> iOutStandingQueryArray;
+ TBool IsLastTruncated;
+
+ private:
+ CMessageHandler& iMessageHandler;
+ /**
+ *FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/cinternalmessagequeue.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,81 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cinternalmessagequeue.h
+//
+//
+
+#ifndef CINTERNALMESSAGEQUEUE_H_
+#define CINTERNALMESSAGEQUEUE_H_
+
+//System Include
+#include <e32base.h>
+#include "mdnsdebug.h"
+class CMdnsServer;
+
+//Message type server handles as of now.
+enum TMessageType
+ {
+ EQueryMessage,
+ EPublishMessage,
+ ERegisterMessage
+ };
+/*
+ * CInternalMessageQueue class is used to keep a refernce of all the services
+ * requested by the client to the server.
+ * There are two cases where this is used.
+ * case1:
+ * When the server is probing the hostname and it recieves a query or publish request.
+ * case2:
+ * When the server is adveritsing a packet and it reiceves one more request for advertizement.
+ *
+ *
+ */
+
+class CInternalMessageQueue : public CBase
+ {
+ public:
+ static CInternalMessageQueue* NewL(CMdnsServer& aServer);
+ ~CInternalMessageQueue();
+ void StartProcessing();
+ TInt Count();
+ void AppendMessageL(TMessageType aType, const RMessage2& aMessage,TInt aSessionId );
+ private:
+ class TMessageObject
+ {
+ private:
+ TMessageType iType;
+ TInt iSessionId;
+ RMessage2 iMessage;
+ public:
+ inline TMessageObject(TMessageType aType , const RMessage2& aMessage,TInt aSessionId):iType(aType), iMessage(aMessage),iSessionId(aSessionId){}
+ inline const TMessageType Type()const{return iType;}
+ inline const RMessage2& MessageObject()const {return iMessage;}
+ inline const TInt SessionId()const{return iSessionId;}
+ };
+ void ConstructL();
+ CInternalMessageQueue(CMdnsServer& aServer);
+
+ private:
+ TInt iQueueLength;
+ RArray<TMessageObject> iMessageQueue;
+ CMdnsServer& iServer;
+ /**
+ *FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+ };
+
+
+#endif /* CINTERNALMESSAGEQUEUE_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/cmdnscacheconsistencymgr.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,86 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmdnsconsistencymgr.cpp
+//
+//
+
+#ifndef CMDNSCACHECONSISTENCYMGR_H_
+#define CMDNSCACHECONSISTENCYMGR_H_
+
+#include <e32base.h>
+#include <mdns/mdnscachemgr.h>
+#include <mdns/ccacheentry.h>
+#include <mdns/cdnsmessage.h>
+#include "mmessagehandler.h"
+#include "mdnsdebug.h"
+
+const TUint KDefaultCheckInterval = 10;//*60; // TODO:Change to 60 seconds for practical purposes
+//#include "cmessagehandler.h"
+class CMessageHandler;
+class CMDNSCacheConsistencyMgr : public CActive,public MMessageHandler
+ {
+ public:
+
+ static CMDNSCacheConsistencyMgr* NewL(TBool aActiveCacheMgmtEnabled,CMessageHandler& aMessageHandler);
+ static CMDNSCacheConsistencyMgr* NewLC(TBool aActiveCacheMgmtEnabled,CMessageHandler& aMessageHandler);
+
+ //From MMessageHandler
+ void OnPacketSendL(TInt aError);
+
+ void Start(TUint aWalkInterval = KDefaultCheckInterval);
+
+ void Stop();
+
+ ~CMDNSCacheConsistencyMgr();
+ void DoCancel();
+
+ private:
+
+ void RunL();
+ TInt RunError(TInt aError);
+
+ void IterateCacheL();
+ void DeleteEntry(CCacheEntry* aEntry);
+ void Query(CCacheEntry* aEntry);
+ const TDesC8& GetHostName(CCacheEntry* aEntry);
+ const TDesC8& GetServiceName(CCacheEntry* aEntry);
+
+ void Delay(TRequestStatus& status);
+
+ private:
+
+ CMDNSCacheConsistencyMgr(TBool aActiveCacheMgmtEnabled,CMessageHandler& aMessageHandler);
+ void ConstructL();
+
+ private:
+
+ //MDNSCacheMgr& iCache;
+
+ TBool iActiveCacheMgmtEnabled;
+
+ CMessageHandler& iMessageHandler;
+
+ TUint iWalkInterval;
+
+ RTimer iTimer;
+
+ /**
+ FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+ };
+
+
+#endif /*CMDNSCACHECONSISTENCYMGR_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/cmdnsprobemanager.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,132 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmdnsprobemanager.h
+//
+//
+#ifndef CMDNSPROBEMANAGER_H_
+#define CMDNSPROBEMANAGER_H_
+
+#include <e32base.h>
+#include <in_sock.h>
+#include "mdnscachemgr.h"
+#include "cmessagehandler.h"
+#include "mmessagehandler.h"
+#include "mdnsdebug.h"
+
+const TUint32 KProbeDelay = 250;
+
+const TUint32 KMaxFailures = 15;
+
+const TUint16 KMaxLength = 255;
+
+/*Maximum Length allocated for the service name part of the ServiceInstanceName
+excluding the service type*/
+const TUint16 KMaxNameLength = 128;
+enum TConflictResolveState
+ {
+ ESuccess=0,
+ EConflictWithAutoReslove,
+ EConflictWithoutAutoResolve,
+ EFail,
+ };
+enum TProbeStates
+ {
+ EIdle,
+ EStart,
+ EProbeBegin,
+ EProbeFirstUnicast,
+ EProbeSecondUnicast,
+ EProbeMulticast,
+ EProbeComplete,
+ EFirstAnnouncement,//First gratuitous mDNS announcement
+ ESecondAnnouncement//Second gratuitous mDNS announcement
+ };
+
+class CMDNSProbeManager : public CTimer,public MMessageHandler
+ {
+ public:
+
+ /*Probe Handler to probe for Unique Host Name*/
+ static CMDNSProbeManager* NewL(MDNSCacheMgr& aCache,CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled);
+ /*Probe Handler to probe for Service Instance Name*/
+ static CMDNSProbeManager* NewLC(MDNSCacheMgr& aCache,CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled);
+
+ ~CMDNSProbeManager();
+
+ //From MMessageHandler
+ void OnPacketSendL(TInt aError);
+
+
+ TInt StartNameProbeL(const TDesC8&aHostName,TInetAddr aAddr);
+ TInt StartServiceProbeL(const TDesC8& aServiceName,const TDesC8& aTargetMachine,TUint16 aPort);
+
+ //Called if Auto Resolve Enabled,Probe Manager would have obtained new name
+ const TDesC8& GetUniqueName();
+
+ private:
+
+ void RunL();
+ TInt RunError(TInt aError);
+
+ private:
+
+ CRdTypeA* FormAddressRecordL();
+ CRdTypeSrv* FormServiceRecordL();
+
+ void InsertInCache();
+
+ TInt GenerateNonConflictingName();
+
+ TBool DefensiveResponseL();//Get a unique name (DNS Label)
+
+ void Schedule();
+
+ void SendProbeL(TBool aUnicast); //Probe for Unique name , Create Probe and Send
+ void SendAnnouncementL();//Send out Gratitous mDNS Announcement , Create Announcement and Send
+
+ CMDNSProbeManager (MDNSCacheMgr& aCache,CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled);
+
+ void ConstructL();
+
+
+ private:
+
+
+
+ TProbeStates iCurrentProbeState;
+ TConflictResolveState iConflict;
+
+ TInt iProbeCounter;
+
+ MDNSCacheMgr& iCache;
+
+ TBool iAutoResolveEnabled;
+
+ CMessageHandler& iMessageHandler;
+
+ TDnsType iType;
+ RBuf8 iName;
+ RBuf8 iProbeName;
+ RBuf8 iProbeType;
+ TInetAddr iAddr;
+ TUint16 iPort;
+ RBuf8 iTarget;
+ /**
+ *FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+
+ };
+
+#endif /*CMDNSPROBEMANAGER_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/cmessagehandler.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,107 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmessagehandler.h
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+#ifndef __CMESSAGEHANDLER_H__
+#define __CMESSAGEHANDLER_H__
+
+//System include
+#include <e32base.h>
+#include <es_sock.h>
+#include <mdns/mdnscachemgr.h>
+#include <mdns/cdnsmessage.h>
+#include <mdns/cdnsresourcedata.h>
+#include <mdns/dnsconstants.h>
+
+//user include
+#include "cmdnscachemanager.h"
+#include "msockethandlerobserver.h"
+#include "csockethandler.h"
+#include "csendmessagequeue.h"
+#include "mdnsserver.h"
+#include "mmessagehandler.h"
+#include "mdnsdebug.h"
+
+//
+_LIT8(KTcpProtocolType, "_tcp.");
+_LIT8(KUdpProtocolType, "_udp.");
+_LIT8(KLocalTld, "local");
+//
+class CBaseHandler;
+class CQueryHandler;
+class CResponseHandler;
+class CAdvertizeHandler;
+
+
+/**
+
+Derives from the abstract class MSocketHandlerObserver
+This instance of this will be owned by the bonjour server.
+This holds an instance of
+1.iRecieveSocket Pointer to CSocketHandler which continously reads packet from the mdns port .
+2.iOperationHandler Pointer to CBaseHandler ,
+3.iSendMessageQueue Pointer to CSendMessageQueue Any resonse ,query or advertizig packet to be sent ,should be added to send message queue.
+4.iServer Used to notify server on any new service arrival.
+5.iDnsCache pointer to dnscache
+
+*/
+class CMessageHandler : public CBase, public MSocketHandlerObserver
+ {
+
+ public:
+ static CMessageHandler* NewL(CMdnsServer& aServer);
+ MDNSCacheMgr& DnsCache()const;
+ //Derived from MSocketHandlerObserver
+ virtual void OnCompletionL(TDesC8& aData, const TSockAddr& aAddr, TInt length ) ;
+ virtual void OnError(TInt aError);
+ ~CMessageHandler();
+ void ServiceClientQueryL(CDnsMessage* aMessage,TInt aHandle);
+ CSendMessageQueue& MessageQueue()const;
+ void NotifyClientQuery(TInt aClientHandle);
+ void NotifyServicePublishL(const RBuf8& aName,TInt aError, TInt aSessionId);
+ void SendQueryL(CDnsMessage* aMessage, MMessageHandler& aObserver);
+ void AdvertizePacketL(const RPointerArray<CDnsResourceData> aData, TInt aSessionId ,TBool aIsUpdate=EFalse);
+ void SetStateHostProbing(TBool aProbing);
+ void NotifyNewServiceL(const RArray<RBuf8>& aName);
+ CMdnsServer& Server();
+ private:
+ CMessageHandler(CMdnsServer& aServer);
+ void ConstructL();
+
+ void HandleIncomingPacketL(TDesC8& aData, const TSockAddr& aAddr, TInt length);
+ CBaseHandler& GetHandlerL(CDnsMessage& aMessage);
+
+ private:
+ CSocketHandler* iRecieveSocket;
+ CQueryHandler* iQueryHandler;
+ CResponseHandler* iResponseHandler;
+ CAdvertizeHandler* iAdvertizeHandler;
+ CSendMessageQueue* iSendMessageQueue;
+ CMdnsServer& iServer;
+ HBufC8* iPacket;
+ MDNSCacheMgr* iDnsCache;
+ CBaseHandler* iDummyhandler;
+ /**
+ *FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/cqueryhandler.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,64 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cqueryhandler.h
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+
+
+#ifndef __CQUERYHANDLER_H__
+#define __CQUERYHANDLER_H__
+
+//User include
+#include "cmessagehandler.h"
+#include <mdns/cdnsmessage.h>
+#include "cbasehandler.h"
+#include "mmessagehandler.h"
+#include "mdnsdebug.h"
+/**
+Derived From CBaseHandler
+Used to process response packet read from the mdns port
+*/
+class CQueryHandler : public CBaseHandler,public MMessageHandler
+ {
+ public :
+ static CQueryHandler* NewL(CMessageHandler& aMessageHandler);
+ ~CQueryHandler();
+
+ // Derived from CBaseHandler
+ void HandleIncomingPacketL(CDnsMessage& aMessage, const TSockAddr& aAddr);
+ void ServiceClientQueryL(CDnsMessage* aMessage,TInt aClientHandle);
+ void OnPacketSendL(TInt aError);
+ void SendQueryL(CDnsMessage* aMessage, MMessageHandler& aObserver);
+ private:
+ CQueryHandler(CMessageHandler& aMessageHandler);
+ void ConstructL();
+ TBool SuppressDuplicateAnswerL(const RPointerArray<CDnsResourceData>& aAnswers,const CDnsResourceData& aResourceData);
+ void HandleAnyQuestionL(CDnsMessage* aPacket,const RPointerArray<CDnsResourceData>& aAnswers,const CCacheEntry& aEntry);
+
+ void ScheduleOutStandingQueryL(TInt aClientHandle , TBool aTriggerNow, TTime aInTime);
+ private :
+ TInt iClientHandle;
+ /**
+ *FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/cresponsehandler.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,65 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cresponsehandler.cpp
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+#ifndef __CRESPONSEHANDLER_H__
+#define __CRESPONSEHANDLER_H__
+
+//System include
+#include <mdns/cdnsmessage.h>
+#include <mdns/cdnsresourcedata.h>
+//User include
+#include "cmessagehandler.h"
+#include "cbasehandler.h"
+#include "mdnsdebug.h"
+
+/**
+Derived From CBaseHandler
+Used to process response packet read from the mdns port
+*/
+
+class CResponseHandler : public CBaseHandler
+ {
+ public:
+ static CResponseHandler* NewL(CMessageHandler& aMessageHandler);
+ ~CResponseHandler();
+
+ //Derived from CBaseHandler
+ void HandleIncomingPacketL(CDnsMessage& aMessage ,const TSockAddr& aAddr);
+
+ private:
+ CResponseHandler(CMessageHandler& aMessageHandler);
+ void ConstructL();
+ void HandlePacketAnswersL(CDnsResourceData* aResourceData);
+ void HandleAddrAnswersL(CDnsResourceData* aResourceData);
+ void HandlePTRAnswersL(CDnsResourceData* aResourceData);
+ void HandleTXTAnswersL(CDnsResourceData* aResourceData);
+ void HandleAAAAAnswersL(CDnsResourceData* aResourceData);
+ void HandleSRVAnswersL(CDnsResourceData* aResourceData);
+
+ private:
+ RArray< RBuf8> iNotifyPtrName;
+ /**
+ *FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/csendmessagequeue.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,98 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// csendmessagequeue.h
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+#ifndef __CSENDMESSAGEQUEUE_H__
+#define __CSENDMESSAGEQUEUE_H__
+
+//system include
+#include <e32base.h>
+#include <es_sock.h>
+#include <e32math.h>
+#include <mdns/cdnsmessage.h>
+#include <mdns/cdnsmessagecomposerparser.h>
+
+//user include
+
+#include "msockethandlerobserver.h"
+#include "csockethandler.h"
+#include "mmessagehandler.h"
+#include "mdnsdebug.h"
+
+class MMessageHandler;
+class CSendMessageData
+ {
+ public:
+ static CSendMessageData* NewL(CDnsMessage* aDnsMessage, TBool aUnicast,TSockAddr aAddr, MMessageHandler& aCallback);
+ const CDnsMessage& GetDnsMessage()const;
+ const TSockAddr& GetSockAddress()const;
+ const TBool& IsUnicast()const;
+ ~CSendMessageData();
+ MMessageHandler& Callback();
+ private:
+ void ConstructL();
+ CSendMessageData(CDnsMessage* aDnsMessage,TBool aUnicast,TSockAddr aAddr, MMessageHandler& aCallback);
+
+ private:
+ CDnsMessage* iMessage;
+ TBool iUnicast;
+ TSockAddr iSockAddr ;
+ MMessageHandler& iCallback;
+ /**
+ *FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+
+class CSendMessageQueue : public CTimer, public MSocketHandlerObserver
+ {
+ public:
+ static CSendMessageQueue* NewL(RSocket& aSocket);
+ ~CSendMessageQueue();
+ virtual void OnCompletionL(TDesC8& aData, const TSockAddr& aAddr, TInt aLength);
+ virtual void OnError(TInt aError);
+ void RunL();
+ void DoCancel();
+ void QueueDnsMessageL(const CSendMessageData& aMessageData);
+
+ private:
+ CSendMessageQueue();
+ void ConstructL(RSocket& aSocket);
+ void NextTransmitTime(TTime aTime);
+ void StartTransmit();
+ CSendMessageData* NextDnsMessageL();
+ TBool MessageReady();
+
+ private:
+ CSendMessageData* iSendMessageData;
+ CSocketHandler* iSendSocket;
+ RPointerArray<CSendMessageData> iMessageQueue;
+ TInt64 iRandomSeed;
+ TTime iNextTransmit;
+ TBool iIsSocketActive;
+ RBuf8 iOutput;
+ /**
+ *FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/csockethandler.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,101 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// csockethandler.h
+//
+//
+/**
+@file
+@internalTechnology
+*/
+#ifndef __CSOCKETHANDLER_H__
+#define __CSOCKETHANDLER_H__
+
+//System include
+#include <e32base.h>
+#include <in_sock.h>
+#include <es_mbuf.h>
+
+
+//User include
+#include "msockethandlerobserver.h"
+#include "mdnsdebug.h"
+
+/*
+ 1. This is an Active Object which can be activated to recieve or
+ send asynchronusly as per the operation list mentioned.An Observer should be
+ provided at the time of construction so as to notify the success or failure of
+ opertion.The client using CSocketHandler should implement the observer class
+ MSOcketHandlerObserver.
+
+ 2. Maximum size of the packet this could either send or recieve is KMaxDnsPacketSize = 9216
+
+ 3. TSocketHandlerParams-- This is typedef from TIpcArgs ,which can hold an
+ pointer to an array of four variables.
+ a. The first variable it is pointing to should specify the operation(TSocketOPeration).
+ b. Second should provide the packet to be send .
+ c. Third should provide the address to which it should be send.
+
+
+ */
+
+const TInt KDefaultFlags = 0;
+//const TInt KMaxDnsPacketSize = 9216;
+
+enum TSocketOperation
+ {
+ ESocketIdle,
+ ESocketSend,
+ ESocketSendTo,
+ ESocketRecieve,
+ ESocketRecieveFrom,
+ };
+
+typedef TIpcArgs TSocketHandlerParams;
+
+class CSocketHandler : public CActive
+ {
+ public:
+
+ static CSocketHandler* NewL(RSocket& aSocket, MSocketHandlerObserver& aObserver, TSocketOperation aOperation);
+ void Activate ( const TSocketHandlerParams& aParams );
+ ~CSocketHandler();
+
+ private:
+ CSocketHandler(RSocket& aSocket, MSocketHandlerObserver& aObserver, TSocketOperation aOperation);
+ void ConstructL();
+ void CompleteSelf ( TInt aError );
+ void CancelCurrent();
+ void NotifyCompletionL( );
+
+ //Derived from CActive
+ void RunL();
+ void DoCancel();
+ TInt RunError(TInt aError);
+
+ private:
+ HBufC8* iPacketBuffer;
+ TPtr8 iPacketPtr;
+ TSockAddr iSockAddr;
+ TSocketOperation iOperation;
+ RSocket& iSocket;
+ MSocketHandlerObserver& iObserver;
+ TSockXfrLength iLength;
+ /**
+ *FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/mdnsserver.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,131 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mdnsserver.h
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+#ifndef __MDNSSERVER_H__
+#define __MDNSSERVER_H__
+
+#include <e32base.h>
+#include <es_sock.h>
+#include <in_sock.h>
+#include <e32property.h>
+#include <mdns/dnsconstants.h>
+
+#include "cinternalmessagequeue.h"
+#include "mmessagehandler.h"
+#include "mdnsdebug.h"
+
+//class TMessageType;
+class CMessageHandler;
+class CMDNSProbeManager;
+class CMDNSCacheConsistencyMgr;
+// zeroconf messages policy - all NetworkService
+
+const TUint zeroconfRangeCount = 1;
+const TInt zeroconfRanges[zeroconfRangeCount] =
+ {
+ 0
+ };
+
+const TUint8 zeroconfElementsIndex[zeroconfRangeCount] =
+ {
+ 0
+ };
+
+const CPolicyServer::TPolicyElement zeroconfElements[] =
+ {
+ {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkServices), CPolicyServer::EFailClient}
+ };
+
+const CPolicyServer::TPolicy zeroconfPolicy =
+ {
+ CPolicyServer::EAlwaysPass,
+ zeroconfRangeCount,
+ zeroconfRanges,
+ zeroconfElementsIndex,
+ zeroconfElements,
+ };
+
+// The zeroconf server class
+
+class CSocketHandler;
+class CShutdownTimer;
+
+class CMdnsServer : public CPolicyServer,public MMessageHandler
+ {
+public:
+ static CMdnsServer* NewL();
+ static CMdnsServer* NewLC();
+
+ CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
+
+ TInt NewSession();
+ void DropSession();
+ void BeginShutdownL();
+ void JoinMulticastGroupL(TInetAddr& aMulticastAddr);
+ RSocket& Socket();
+ CMessageHandler& MessageHandler()const;
+ void NotifyClientQuery(TInt aClientHandle);
+ void NotifyServicePublishL(const RBuf8& aName,TInt aError, TInt aSessionId);
+ ~CMdnsServer();
+ TDesC8& HostName()const;
+ void SetHostNameL(const TDesC8& aName);
+ void SetStateHostProbing(TBool aProbing);
+ void SetPublishingService(TBool aFlag);
+ TBool IsHostProbing()const;
+ TBool IsPublishingService() const;
+ void ProcessQueuedMessage(const RMessage2& aMessage, const TMessageType aType,TInt aSessionId);
+ void NotifyNewServiceL(const RArray<RBuf8>& aName);
+ CInternalMessageQueue* MessageQueue();
+ //From MMessageHandler
+ void OnPacketSendL(TInt aError);
+
+
+private:
+ TInt GetLocalHost ( TSockAddr& aAddr );
+ CMdnsServer();
+ void ConstructL();
+
+
+
+private:
+ RSocketServ iSockServ;
+ RConnection iConnection;
+ RSocket iSocket;
+
+ CShutdownTimer* iShutdownTimer;
+ CMessageHandler* iMessageHandler;
+ CInternalMessageQueue* iInternalMessageQueue;
+ CMDNSCacheConsistencyMgr* iCacheConsistencyMgr;
+ TInt iConnectionCount;
+ TInt iSessionIdCounter;
+ TBool iShutdownInProgress;
+ CMDNSProbeManager* iProbeManager;
+ RBuf8 iHostName;
+ TBool iData;
+ TBool iIsHostProbing;
+ TBool iIsPublishing;
+ /**
+ *FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+#endif /* __MDNSSERVER_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/mdnsserversession.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,86 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mdnsserversession.h
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+#ifndef __MDNSSERVERSESSION_H__
+#define __MDNSSERVERSESSION_H__
+
+#include <e32base.h>
+#include <pnp/pnpparameterbundle.h>
+#include <mdns/mdnsparamset.h>
+#include <mdns/ccacheentry.h>
+
+//User Include
+#include "cmessagehandler.h"
+#include "mdnsdebug.h"
+class CMdnsServer;
+
+
+class CMdnsServerSession : public CSession2
+ {
+public:
+ static CMdnsServerSession* NewL(const CMdnsServer& aServer);
+ static CMdnsServerSession* NewLC(const CMdnsServer& aServer);
+
+ void ServiceL(const RMessage2& aMessage);
+ void ServiceError(const RMessage2& aMessage, TInt aError);
+ TInt OutStandQueryClientHandle()const;
+ void SendResponseL();
+ //void HandleNameChangeL();
+ void HandleServiceNameConflictL(const RBuf8& aName,TInt aError);
+ void ServiceQueryL(const RMessage2& aMessage);
+ void PublishL(const RMessage2& aMessage);
+ void NewServiceL(const RArray<RBuf8>& aName);
+ TInt SessionId();
+ ~CMdnsServerSession();
+
+private:
+ CMdnsServerSession(const CMdnsServer& aServer);
+ void ConstructL();
+ TInt CountResources();
+ void RegisterNotifyL(const RMessage2& aMessage);
+ void ServerVersionL(const RMessage2& aMessage);
+ void StopNotifyL (const RMessage2& aMessage);
+ void CleanUp();
+ void CreateAnyQueryResponseL(CCacheEntry& aEntry);
+private:
+ CMdnsServer& iServer;
+ RMessage2 iClientQuery;
+ RMessage2 iPublishRequest;
+ RMessage2 iNotifyMessageRequest;
+ RPnPParameterBundle iQueryBundle;
+ RPnPParameterBundle iResponseBundle;
+ RPnPParameterBundle iPublishBundle;
+ RArray<RBuf8> iRegisterNotifyArray;
+
+ //TInt iNextSubsessionId;
+ TInt iSessionId;
+ TBool iIsNotifyRequested;
+
+ TInt iLastTypeSent;
+
+ TInt iLastServiceSent;
+ /**
+ *FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+#endif /* __MDNSSERVERSESSION_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/mmessagehandler.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+/*
+ * mmessagehandler.h
+ *
+ * Created on: Oct 6, 2009
+ * Author: kiprabha
+ */
+
+#ifndef MMESSAGEHANDLER_H_
+#define MMESSAGEHANDLER_H_
+
+class MMessageHandler
+ {
+ public:
+ virtual void OnPacketSendL(TInt aError) =0 ;
+ };
+
+#endif /* MMESSAGEHANDLER_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/msockethandlerobserver.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2008 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+/**
+@file
+@internalTechnology
+*/
+#ifndef __MSOCKETHANDLEROBSERVER_H__
+#define __MSOCKETHANDLEROBSERVER_H__
+
+class MSocketHandlerObserver
+ {
+ public:
+ virtual void OnCompletionL(TDesC8& aData, const TSockAddr& aAddr, TInt length ) = 0;
+ virtual void OnError(TInt aError)=0;
+
+ };
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/inc/shutdowntimer.h Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,49 @@
+/*
+ Copyright (c) 2007 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"
+ which accompanies this distribution, and is available
+ at the URL "http://www.eclipse.org/legal/epl-v10.html".
+
+ Initial Contributors:
+ Nokia Corporation - initial contribution.
+
+ Contributors:
+
+ Description: A simple shutdown timer definition.
+
+*/
+
+#ifndef __SHUTDOWNTIMER_H__
+#define __SHUTDOWNTIMER_H__
+
+#include <e32base.h>
+#include "mdnsdebug.h"
+// shutdown delay, 5 minutes.
+const TInt KShutdownDelay = 5 * 60 * 1000000;
+
+class CMdnsServer;
+
+class CShutdownTimer : public CTimer
+ {
+public:
+ static CShutdownTimer* NewL(CMdnsServer& aServer);
+ static CShutdownTimer* NewLC(CMdnsServer& aServer);
+
+ void Start();
+ void RunL();
+ TInt RunError(TInt aError);
+ ~CShutdownTimer();
+private:
+ CShutdownTimer(CMdnsServer& aServer);
+
+private:
+ CMdnsServer& iServer;
+ /**
+ FLOGGER debug trace member variable.
+ */
+ __FLOG_DECLARATION_MEMBER_MUTABLE;
+ };
+
+#endif /* __SHUTDOWNTIMER_H__ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/CBaseHandler.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,237 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cbasehandler.cpp
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+//System include
+#include <mdns/ccacheentry.h>
+#include <mdns/cdnsmessage.h>
+
+//User Include
+#include "cbasehandler.h"
+__FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
+/*
+ * Two phase constructor
+ * @param aDnsMessage pointer to DnsMessage which should be sent to the network.
+ * @param aTransactionId transaction id
+ * @param aTime time at which this message should be scheduled.
+ * @Param aSockAddr address to which this should be sent.
+ */
+COutStandingQuery* COutStandingQuery::NewL(CDnsMessage* aDnsMessage,TInt aTransactionId,TTime aTime, TSockAddr aAddr)
+ {
+ COutStandingQuery* self = new (ELeave) COutStandingQuery(aDnsMessage,aTransactionId, aTime, aAddr);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+/*
+ * Destructor
+ */
+COutStandingQuery::~COutStandingQuery()
+ {
+ __FLOG(_L8("COutStandingQuery::~COutStandingQuery- Entry"));
+ delete iDnsMessage;
+ __FLOG(_L8("COutStandingQuery::~COutStandingQuery- Exit"));
+ __FLOG_CLOSE;
+ }
+
+/*
+ * @return iReviewTime returns the time data is added to queue.
+ */
+ TTime COutStandingQuery::GetAddTime() const
+ {
+ __FLOG(_L8("COutStandingQuery::GetAddTime- Entry"));
+ __FLOG(_L8("COutStandingQuery::GetAddTime- Exit"));
+ return iReviewTime;
+ }
+
+ /*
+ *Sets the clienhandle (session) which request for the query.
+ *@param aHandle Sessionid of the client.
+ */
+void COutStandingQuery::SetClientHandle(TInt aHandle)
+ {
+ __FLOG(_L8("COutStandingQuery::SetClientHandle- Entry"));
+ iClientHandle = aHandle;
+ __FLOG(_L8("COutStandingQuery::SetClientHandle- Exit"));
+ }
+
+/*
+ * @return returns ths transaction id
+ */
+TInt COutStandingQuery::TransactionId()const
+ {
+ __FLOG(_L8("COutStandingQuery::TransactionId- Entry"));
+ return iTransactionID;
+ }
+
+/*
+ * @return returns the socket address
+ */
+TSockAddr COutStandingQuery::SocketAddress()const
+ {
+ __FLOG(_L8("COutStandingQuery::SocketAddress- Entry"));
+ return iSockAddress;
+ }
+
+/*
+ * @return iDnsMessage returns the reference to dns message.
+ */
+CDnsMessage& COutStandingQuery::DnsMessage()const
+ {
+ __FLOG(_L8("COutStandingQuery::DnsMessage- Entry"));
+ return *iDnsMessage;
+ }
+
+/*
+ * Two phase constructor
+ */
+void COutStandingQuery::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ }
+
+/*
+ * Constructor
+ * @param aDnsMessage pointer to DnsMessage which should be sent to the network.
+ * @param aTransactionId transaction id
+ * @param aTime time at which this message should be scheduled.
+ * @Param aSockAddr address to which this should be sent.
+ */
+COutStandingQuery::COutStandingQuery(CDnsMessage* aDnsMessage,TInt aTransactionId,TTime aTime, TSockAddr aAddr): iDnsMessage(aDnsMessage) , iTransactionID(aTransactionId) ,iReviewTime(aTime), iSockAddress(aAddr)
+ {
+ iClientHandle = 0;
+ }
+
+/*
+ * @return iClientHandle clinethandle to which request is handled.
+ */
+TInt COutStandingQuery::ClientHandle() const
+ {
+ __FLOG(_L8("COutStandingQuery::ClientHandle- Entry"));
+ return iClientHandle;
+ }
+
+/**
+Two phase constructor
+@param aMessageHandler refernce to messagehandler
+@return void
+*/
+CBaseHandler* CBaseHandler::NewL(CMessageHandler& aMessageHandler)
+ {
+ CBaseHandler* self = new (ELeave)CBaseHandler(aMessageHandler);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+/**
+Destructor
+*/
+CBaseHandler::~CBaseHandler()
+ {
+ __FLOG(_L8("CBaseHandler::~CBaseHandler - Entry"));
+ Cancel();
+ iOutStandingQueryArray.ResetAndDestroy();
+ iOutStandingQueryArray.Close();
+ __FLOG(_L8("CBaseHandler::~CBaseHandler - Exit"));
+ __FLOG_CLOSE;
+ }
+
+/**
+Constructor
+*/
+CBaseHandler::CBaseHandler(CMessageHandler& aMessageHandler): CTimer(EPriorityStandard),iMessageHandler(aMessageHandler)
+ {
+
+ CActiveScheduler::Add(this);
+
+ }
+/**
+Two phase constructor
+*/
+void CBaseHandler::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ __FLOG(_L8("CBaseHandler::Open - Entry"));
+ CTimer::ConstructL();
+ __FLOG(_L8("CBaseHandler::Open - Exit"));
+ }
+/**
+Constant function returns a reference to messagehandler
+*/
+CMessageHandler& CBaseHandler::MessageHandler()const
+ {
+ __FLOG(_L8("CBaseHandler::MessageHandler - Entry Exit"));
+ return iMessageHandler;
+ }
+
+/**
+Handles any incoming packet
+@param aMessage packet recieved form mdns port
+*/
+void CBaseHandler::HandleIncomingPacketL(CDnsMessage& /*aMessage*/, const TSockAddr& /*aAddr*/)
+ {
+ __FLOG(_L8("CBaseHandler::HandleIncomingPacketL - Entry"));
+ //Nothing To do ...........
+ __FLOG(_L8("CBaseHandler::HandleIncomingPacketL - Exit"));
+ }
+
+/*
+ * Wait for 120ms after the query is sent to the network.
+ * After 120ms asynchronous request gets complete and will hit this runl
+ * server will be notified with the same and it will take care of sending the
+ * response back to client.
+ */
+void CBaseHandler::RunL()
+ {
+ __FLOG(_L8("CBaseHandler::RunL - Entry"));
+ COutStandingQuery* query = iOutStandingQueryArray[0];
+ if(0 != query->ClientHandle())
+ {
+ MessageHandler().NotifyClientQuery(query->ClientHandle());
+ }
+ else
+ {
+ IsLastTruncated = EFalse;
+ }
+ iOutStandingQueryArray.Remove(0);
+ if(iOutStandingQueryArray.Count())
+ {
+ SetActive();
+ const TTime outTime = iOutStandingQueryArray[0]->GetAddTime();
+ At(outTime);
+ }
+ __FLOG(_L8("CBaseHandler::Open - Exit"));
+ delete query;
+ }
+
+/*
+ * Nothing to do.
+ */
+void CBaseHandler::DoCancel()
+ {
+ __FLOG(_L8("CBaseHandler::RunL - Exit"));
+ }
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/CEngSettingsObserver.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+/*
+ * CEngSettingsObserver.cpp
+ *
+ * Created on: Jun 17, 2010
+ * Author: lachamar
+ */
+
+#include "cengsettingsobserver.h"
+
+
+
+CEngSettingsObserver* CEngSettingsObserver::NewLC()
+ {
+ CEngSettingsObserver* self = new (ELeave)CEngSettingsObserver();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+
+CEngSettingsObserver::CEngSettingsObserver()
+ {
+
+ }
+
+CEngSettingsObserver::~CEngSettingsObserver()
+ {
+
+ }
+
+
+void CEngSettingsObserver::ConstructL()
+ {
+
+ }
+
+void CEngSettingsObserver::PowerStateChanged( TBTPowerStateValue aState )
+ {
+
+ }
+
+void CEngSettingsObserver::VisibilityModeChanged( TBTVisibilityMode aState )
+ {
+
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/cadvertizehandler.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,470 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cadvertizehandler.cpp
+//
+//
+/**
+@file
+@internalTechnology
+*/
+//System include
+#include <mdns/ccacheentry.h>
+
+//UserInclude
+#include "cadvertizehandler.h"
+__FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
+
+/*
+ * Two phase constructor
+ * @param aMessagHandler areference to messagehandler object.
+ * @param aAutoResolveEnabled If true sercice name conflict will be handled.
+ * aAutoResolveEnabled is True by default
+ */
+CAdvertizeHandler* CAdvertizeHandler::NewL(CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled)
+ {
+ CAdvertizeHandler* self = new (ELeave) CAdvertizeHandler(aMessageHandler,aAutoResolveEnabled);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+/*
+ * Destructor
+ */
+CAdvertizeHandler::~CAdvertizeHandler()
+ {
+ __FLOG(_L8("CAdvertizeHandler::~CAdvertizeHandler- Entry"));
+ iData.ResetAndDestroy();
+ iData.Close();
+ iName.Close();
+ iProbeName.Close();
+ iProbeType.Close();
+ __FLOG(_L8("CAdvertizeHandler::~CAdvertizeHandler- Exit"));
+ __FLOG_CLOSE;
+ }
+/*
+ * No incoming packet for this so no need to handle
+ */
+void CAdvertizeHandler::HandleIncomingPacketL(CDnsMessage& /*aMessage*/)
+ {
+ __FLOG(_L8("CAdvertizeHandler::HandleIncomingPacketL- Entry"));
+ //Nothing To Do ............
+ __FLOG(_L8("CAdvertizeHandler::HandleIncomingPacketL- Exit"));
+ }
+
+static void CleanUpCache(TAny* aAny)
+ {
+
+ //RPointerArray <CCacheEntry> records = static_cast < RPointerArray <CCacheEntry> > (*aAny);
+ RPointerArray <CCacheEntry>* records = static_cast < RPointerArray <CCacheEntry> *> (aAny);
+ records->ResetAndDestroy();
+ records->Close();
+ }
+/*
+ * Constructor
+ * @param aMessageHandler reference to messagehandler
+ * @param aAutoResolveEnabled will be true by default ,if true servicename conflict
+ * will be handled by default
+ */
+CAdvertizeHandler::CAdvertizeHandler(CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled):CBaseHandler(aMessageHandler)
+ {
+ __FLOG(_L8("CAdvertizeHandler::CAdvertizeHandler- Entry"));
+ iAutoResolveEnabled = aAutoResolveEnabled;
+ iCurrentProbeState = EIdle;
+ iProbeCounter = 0 ;
+ __FLOG(_L8("CAdvertizeHandler::CAdvertizeHandler- Exit"));
+ }
+
+/*
+ * Twophase constructor
+ */
+void CAdvertizeHandler::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ __FLOG(_L8("CAdvertizeHandler::ConstructL- Entry"));
+ CBaseHandler::ConstructL();
+ //Nothing
+ __FLOG(_L8("CAdvertizeHandler::ConstructL- Exit"));
+ }
+/*
+ * Keeps a copy of the records to be published and starts the active object.
+ * @param aData an array of records to be published.
+ * @param aSessionId session id initiating the advertizement.
+ */
+void CAdvertizeHandler::AdvertizePacketL(const RPointerArray<CDnsResourceData> aData, TInt aSessionId,TBool aIsUpdate)
+ {
+ __FLOG(_L8("CAdvertizeHandler::AdvertizePacketL- Entry"));
+ iName.Close();
+ iName.Create(aData[0]->Name());
+ iProbeName.Close();
+ iProbeName.CreateL(KMaxLength);
+ iProbeName.Append(iName);
+ iCurrentProbeState = EStart;
+ iData.ResetAndDestroy();
+ for(TInt i =0 ; i<aData.Count();i++)
+ {
+ iData.AppendL(aData[i]);
+ }
+ // assign the session id so that, we can send bye-bye packet when the session is closed
+ iSessionId = aSessionId;
+ if(aIsUpdate)
+ {
+ iCurrentProbeState = EIdle;
+ TBool isExist = DefensiveResponseL();
+ if(!isExist)
+ {
+ User::Leave(KErrNotFound);
+ }
+ SendAnnouncementL();
+ InsertInCache();
+ return;
+ }
+ Schedule();
+ __FLOG(_L8("CAdvertizeHandler::AdvertizePacketL- Exit"));
+ }
+/*
+ * This is a callback function will be notified whenever a packet sent from this
+ * client is sent to the network.
+ * @param aError any error in sending the packet.
+ */
+void CAdvertizeHandler::OnPacketSendL(TInt aError)
+ {
+ __FLOG(_L8("CAdvertizeHandler::OnPacketSendL- Entry"));
+ if(aError != KErrNone)
+ {
+ MessageHandler().NotifyServicePublishL(iName,EFail,iSessionId);
+ }
+
+ if( iCurrentProbeState != EIdle)
+ {
+ After(KProbeDelay*1000);//Give more delay than this
+ return;
+ }
+ //When a service is published successfully ,iCurrentProbe state will be
+ //EIdle ,this state change will be used to notify the client .
+ MessageHandler().NotifyServicePublishL(iName,ESuccess,iSessionId);
+ __FLOG(_L8("CAdvertizeHandler::OnPacketSendL- Exit"));
+ }
+
+void CAdvertizeHandler::RunL()
+ {
+ __FLOG(_L8("CAdvertizeHandler::RunL- Entry"));
+ TTime currentTime;
+
+ if(iCurrentProbeState <= EProbeComplete)
+ {
+ if(DefensiveResponseL())
+ {
+ iCurrentProbeState = EStart;
+ if(iAutoResolveEnabled)
+ {
+ GenerateNonConflictingName();
+ if(iProbeCounter >= KMaxFailures)
+ {
+ //If Probe Failure rate is greater then 15 per second, wait for
+ //5 seconds before probing again
+ iProbeCounter = 0;
+ After(5*1000*1000);
+ }
+ }
+ else // to intimate server of failure
+ {
+ MessageHandler().NotifyServicePublishL(iName,EConflictWithoutAutoResolve,iSessionId);
+ }
+
+ }
+ }
+
+ switch(iCurrentProbeState)
+ {
+ case EIdle:
+ break;//Do Nothing
+
+ case EStart:
+ {
+ currentTime.UniversalTime();
+ TInt64 randseed = currentTime.Int64();
+
+ //Random time between 0 & 250 ms
+ TInt delay = Math::Rand(randseed) % 250;
+ iCurrentProbeState = EProbeFirstUnicast;
+ //Convert to microsecond
+
+ After(delay*1000);
+ }
+ break;
+
+ case EProbeFirstUnicast:
+ {
+ SendProbeL(ETrue);
+ iCurrentProbeState = EProbeSecondUnicast;
+ }
+ break;
+
+ case EProbeSecondUnicast:
+ {
+ SendProbeL(ETrue);
+ iCurrentProbeState = EProbeMulticast;
+ }
+ break;
+
+ case EProbeMulticast:
+ {
+ SendProbeL(EFalse);
+ iCurrentProbeState = EProbeComplete;
+ }
+ break;
+
+ case EProbeComplete:
+ {
+ iCurrentProbeState = EFirstAnnouncement;
+ //Probe succeeded ,insert in cache
+ InsertInCache();
+ After(KProbeDelay*1000);
+ //Some Delay ?? Required or defensive response HAS TO come within 750ms?
+ }
+ break;
+
+ case EFirstAnnouncement:
+ {
+ SendAnnouncementL();
+ iCurrentProbeState = ESecondAnnouncement;
+ //After(1000);// A Millisecond delay: Required??
+ }
+ break;
+
+ case ESecondAnnouncement:
+ {
+ SendAnnouncementL();
+ iCurrentProbeState = EIdle;
+ }
+ break;
+ }
+ __FLOG(_L8("CAdvertizeHandler::RunL- Exit"));
+ }
+/*
+ * Handles any leave in RunL
+ * @param aError error with which runL leaves.
+ */
+TInt CAdvertizeHandler::RunError(TInt aError)
+ {
+ __FLOG(_L8("CAdvertizeHandler::RunError- Entry"));
+ return aError;
+ }
+
+/*
+ * Self completes the request.
+ */
+void CAdvertizeHandler::Schedule()
+ {
+ __FLOG(_L8("CAdvertizeHandler::Schedule- Entry"));
+ TRequestStatus* status(&iStatus);
+ *status = KRequestPending;
+ SetActive();
+ User::RequestComplete(status, KErrNone);
+ __FLOG(_L8("CAdvertizeHandler::Schedule- Exit"));
+ }
+
+/*
+ * Function will be called when there is a conflict.
+ * this will change the publishing name by appending a
+ * number at the end of it.
+ * @return iProbeCounter returns probecounter value.
+ */
+TInt CAdvertizeHandler::GenerateNonConflictingName()
+ {
+ __FLOG(_L8("CAdvertizeHandler::GenerateNonConflictingName- Entry"));
+ _LIT8(KDot,".");
+
+ RBuf8 oldName;
+ oldName.CreateL(iName);
+
+ ++iProbeCounter;
+ TBuf8 <KMaxLength> newName;
+ iName.Close();
+ iName.Create(KMaxLength);
+ iName.Append(iProbeName);
+
+ TInt pos = iName.Locate('.');
+ _LIT8(KOpenBrace,"(");
+ newName.Append(KOpenBrace);
+ newName.AppendNum(iProbeCounter);
+ _LIT8(KCloseBrace,")");
+ newName.Append(KCloseBrace);
+ iName.Insert(pos,newName);
+ ChangeDomainL(oldName);
+ oldName.Close();
+ __FLOG(_L8("CAdvertizeHandler::GenerateNonConflictingName- Exit"));
+ return iProbeCounter;
+ }
+
+/*
+ * Finds whether the service already exists in the network .
+ * If service is in the network ,same will be present in the cache.
+ * @return probFailed returns true if probe has failed.
+ */
+TBool CAdvertizeHandler::DefensiveResponseL()
+ {
+ __FLOG(_L8("CAdvertizeHandler::DefensiveResponseL- Entry"));
+ TBool probeFailed(EFalse);
+ RPointerArray <CCacheEntry> entries;
+ CleanupStack::PushL(TCleanupItem(TCleanupOperation(&CleanUpCache),&entries));
+
+ _LIT8(KDot,".");
+ TBuf8 <KMaxLength> buffer;
+
+ buffer.Copy(iName);
+ buffer.Append(KDot);
+ MessageHandler().DnsCache().FindServiceL(entries,buffer,EDnsQType_Any);
+ if(entries.Count()>0)
+ {
+ probeFailed = ETrue;
+ }
+ CleanupStack::PopAndDestroy();
+ //entries.ResetAndDestroy();
+ //entries.Close();
+ __FLOG(_L8("CAdvertizeHandler::DefensiveResponseL- Exit"));
+ return probeFailed;
+ }
+
+/*
+ * creates a DnsMessage object and send it to the messagehandler to handle it.
+ * @param aUnicast true if the packet to be sent is an unicast one;false for multicast.
+ *
+ */
+void CAdvertizeHandler::SendProbeL(TBool aUnicast)
+ {
+ __FLOG(_L8("CAdvertizeHandler::SendProbeL- Entry"));
+ //Construct DNS Message
+ CDnsMessage* message = CDnsMessage::NewL(0,ETrue);
+ CleanupStack::PushL(message);
+
+ //Form the Query/Question part of the message
+ CDnsQuestion* question = CDnsQuestion::NewL();
+ CleanupStack::PushL(question);
+ question->SetNameL(iName);
+ question->SetClass(EDnsClass_IN);
+ question->SetType(EDnsQType_Any);
+ if(aUnicast)
+ {
+ question->SetUnicast(ETrue);
+ }
+
+ //Append the Query to the Message
+ message->AppendQueryL(question);
+ //Append to the Authoritative Section
+ for(TInt i =0 ; i < iData.Count();i++)
+ {
+ message->AppendAuthorityL(iData[i]->CloneL());
+ }
+
+ //Send the query
+ MessageHandler().SendQueryL(message,*this);
+
+ CleanupStack::Pop();//question
+ CleanupStack::Pop();//message
+ __FLOG(_L8("CAdvertizeHandler::SendProbeL- Exit"));
+ }
+
+/*
+ * If probing is successfull ,new service record will
+ * be added to the cache using this.
+ */
+void CAdvertizeHandler::InsertInCache()
+ {
+ __FLOG(_L8("CAdvertizeHandler::InsertInCache- Entry"));
+ TBuf8<KMaxLength> name;
+ _LIT8(KDot,".");
+ //TODO name should be appended with dot
+
+ for(TInt i =0 ; i<iData.Count();i++)
+ {
+ //Append a "." at the end of the name
+ name.Copy(iData[i]->Name());
+ name.Append(KDot);
+ iData[i]->SetNameL(name);
+ MessageHandler().DnsCache().UpdateCacheL(*(iData[i]),ETrue,iSessionId);
+ }
+ __FLOG(_L8("CAdvertizeHandler::InsertInCache- Exit"));
+ }
+
+/*
+ * Announces the new service.
+ */
+void CAdvertizeHandler::SendAnnouncementL()
+ {
+ __FLOG(_L8("CAdvertizeHandler::SendAnnouncementL- Entry"));
+ RPointerArray<CCacheEntry> entries;
+ //An API in Cache Interface that returns a list of all Authoritative records
+ MessageHandler().DnsCache().AuthoritativeEntriesL(entries);
+ CDnsMessage* message = CDnsMessage::NewL(0,EFalse);
+ CleanupStack::PushL(message);
+
+ TDnsHeader header(message->Header());
+ header.SetAuthoritative(ETrue);
+ message->SetHeader(header);
+
+ //Append to the Authoritative Section
+ for(TInt i =0 ; i < iData.Count();i++)
+ {
+ message->AppendAuthorityL(iData[i]->CloneL());
+ }
+
+/*
+ for(TInt index =0; index<entries.Count();index++)
+ {
+ CCacheEntry* entry = entries[index];
+ //Send Announcements for all the Services we have published, and entered in Cache
+
+
+ if(entry->AddressRecord())
+ message->AppendAnswerL(entry->AddressRecord()->CloneL());
+ if(entry->ServiceRecord())
+ message->AppendAnswerL(entry->ServiceRecord()->CloneL());
+ if(entry->PtrRecord())
+ message->AppendAnswerL(entry->PtrRecord()->CloneL());
+ if(entry->TxtRecord())
+ message->AppendAnswerL(entry->TxtRecord()->CloneL());
+
+ //should've been a new API sendresponse
+
+ }
+*/
+ MessageHandler().SendQueryL(message,*this);
+ CleanupStack::Pop();//message
+ entries.ResetAndDestroy();
+ entries.Close();
+ __FLOG(_L8("CAdvertizeHandler::SendAnnouncementL- Exit"));
+ }
+void CAdvertizeHandler::ChangeDomainL(TDesC8& aName)
+ {
+ for(TInt i =0 ; i<iData.Count();i++)
+ {
+ if(iData[i]->Name().Compare(aName) == 0)
+ {
+ iData[i]->SetNameL(iName);
+ }
+ if(iData[i]->Type()==EDnsType_PTR)
+ {
+ CRdTypePtr* ptr = static_cast<CRdTypePtr*>(iData[i]);
+ if(ptr->DomainName().Compare(aName) == 0)
+ {
+ ptr->SetDomainNameL(iName);
+ }
+
+ }
+
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/cinternalmessagequeue.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,106 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cinternalmessagequeue.cpp
+//
+//
+/**
+@file
+@internalTechnology
+*/
+//User include
+#include "cinternalmessagequeue.h"
+#include "mdnsserver.h"
+__FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
+/*
+ * Two phase constructor
+ * @param aServer reference to the server
+ */
+CInternalMessageQueue* CInternalMessageQueue::NewL(CMdnsServer& aServer)
+ {
+ CInternalMessageQueue* self = new (ELeave)CInternalMessageQueue(aServer);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();//self
+ return self;
+ }
+
+//Destructor
+CInternalMessageQueue:: ~CInternalMessageQueue()
+ {
+ __FLOG(_L8("CInternalMessageQueue::~CInternalMessageQueue - Exit"));
+ __FLOG_CLOSE;
+ }
+
+/*
+ * When this is called reads the first request form the
+ * queue and start processing.
+ */
+void CInternalMessageQueue::StartProcessing()
+ {
+ __FLOG(_L8("CInternalMessageQueue::StartProcessing - Entry"));
+ if(iMessageQueue.Count() == 0)
+ {
+ return;
+ }
+ else
+ {
+ TMessageObject message = iMessageQueue[0];
+ iServer.ProcessQueuedMessage(message.MessageObject(),message.Type(),message.SessionId());
+ iMessageQueue.Remove(0);
+ }
+ __FLOG(_L8("CInternalMessageQueue::StartProcessing - Exit"));
+ }
+
+/*
+ * @return count returns the count of messageQueue
+ */
+
+TInt CInternalMessageQueue::Count()
+ {
+ __FLOG(_L8("CInternalMessageQueue::Count - Entry Exit"));
+ return iMessageQueue.Count();
+ }
+
+/*
+ * Interface to append the message to the queue
+ * @param aType represents the type of message.
+ * @param aMessage RMessage object of the query or publish request.
+ * @param aSessionId session to which request is made.
+ */
+void CInternalMessageQueue::AppendMessageL(TMessageType aType, const RMessage2& aMessage,TInt aSessionId )
+ {
+ __FLOG(_L8("CInternalMessageQueue::AppendMessageL - Entry"));
+ TMessageObject messageObject(aType,aMessage,aSessionId);
+ iMessageQueue.AppendL(messageObject);
+ __FLOG(_L8("CInternalMessageQueue::AppendMessageL - Exit"));
+ }
+
+/*
+ * Two phase constructor.
+ */
+void CInternalMessageQueue::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ __FLOG(_L8("CInternalMessageQueue::ConstructL -Entry Exit"));
+ }
+
+/*
+ * Constructor
+ * @param aServer reference to the server.
+ */
+CInternalMessageQueue::CInternalMessageQueue(CMdnsServer& aServer): iServer(aServer)
+ {
+
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/cmdnscacheconsistencymgr.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,360 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmdnsconsistencymgr.cpp
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+//User include
+#include "cmdnscacheconsistencymgr.h"
+#include "cmdnscachemanager.h"
+#include "cmessagehandler.h"
+
+__FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
+
+
+const TUint32 KMinActivityCount = 5;//TODO: to Define correct Min Work Count
+
+
+/*
+ * Two phase constructor
+ * @param aActiveCacheMgmtEnabled
+ * @param aMessageHandler reference to message handler.
+ */
+ CMDNSCacheConsistencyMgr* CMDNSCacheConsistencyMgr::NewL(TBool aActiveCacheMgmtEnabled,CMessageHandler& aMessageHandler)
+ {
+ CMDNSCacheConsistencyMgr* self = CMDNSCacheConsistencyMgr::NewLC(aActiveCacheMgmtEnabled,aMessageHandler);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+/*
+ * Two phase constructor
+ * @param aActiveCacheMgmtEnabled
+ * @param aMessageHandler reference to message handler.
+ */
+CMDNSCacheConsistencyMgr* CMDNSCacheConsistencyMgr::NewLC(TBool aActiveCacheMgmtEnabled,CMessageHandler& aMessageHandler)
+ {
+ CMDNSCacheConsistencyMgr* self = new (ELeave)CMDNSCacheConsistencyMgr(aActiveCacheMgmtEnabled,aMessageHandler);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+ }
+
+/*
+ * Constructor.
+ */
+CMDNSCacheConsistencyMgr::CMDNSCacheConsistencyMgr(TBool aActiveCacheMgmtEnabled,CMessageHandler& aMessageHandler)
+:CActive(EPriorityStandard),iMessageHandler(aMessageHandler)
+ {
+ iActiveCacheMgmtEnabled=aActiveCacheMgmtEnabled;
+ iWalkInterval= KDefaultCheckInterval;
+ CActiveScheduler::Add(this);
+ }
+
+
+//Destructor
+CMDNSCacheConsistencyMgr::~CMDNSCacheConsistencyMgr()
+ {
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::~CMDNSCacheConsistencyMgr - Entry"));
+ iTimer.Close();
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::~CMDNSCacheConsistencyMgr - Exit"));
+ __FLOG_CLOSE;
+ }
+/*
+ * Two phase constructor
+ */
+void CMDNSCacheConsistencyMgr::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::ConstructL - Entry"));
+ User::LeaveIfError(iTimer.CreateLocal());
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::ConstructL - Exit"));
+ }
+
+/*
+ * Function to stop running the consistemcy manager .
+ * Cancels all the asynchronous request.
+ */
+void CMDNSCacheConsistencyMgr::Stop()
+ {
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::Stop - Entry"));
+ Cancel();
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::Stop - Exit"));
+ }
+
+/*
+ * Starts the consistency Manager
+ * @param aWalkInterval specifies the walk interval in seconds.
+ */
+void CMDNSCacheConsistencyMgr::Start(TUint aWalkInterval)
+ {
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::Start - Entry"));
+ iWalkInterval = aWalkInterval;
+ TUint Interval= iWalkInterval*1000000;
+ //Converted to Microseconds
+ iTimer.After(iStatus,Interval);
+ SetActive();
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::Start - Exit"));
+ }
+/*
+ * Delay between two Walk thourgh .
+ * Starts a time to complete the request after an interval mentioned in the iWalkinterval.
+ * @param aStatus reference to status variable.
+ */
+ void CMDNSCacheConsistencyMgr::Delay(TRequestStatus& aStatus)
+ {
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::Delay - Entry"));
+ TUint Interval= iWalkInterval*1000000;
+ //Converted to Microseconds
+ iTimer.After(aStatus,Interval);
+ SetActive();
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::Delay - Exit"));
+ }
+
+
+ /*
+ * Iterates the cache on each hit
+ * and sets a delay for the nexthit.
+ */
+void CMDNSCacheConsistencyMgr::RunL()
+ {
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::RunL - Entry"));
+ IterateCacheL();
+ Delay(iStatus);
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::RunL - Exit"));
+ }
+
+/*
+ * Handles any leave at RunL
+ *
+ */
+TInt CMDNSCacheConsistencyMgr::RunError(TInt aError)
+ {
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::RunError - Entry"));
+ User::LeaveIfError(aError);
+ return aError;
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::RunError - Exit"));
+ }
+
+/*
+ * Cancels any asynchoronous request.
+ */
+void CMDNSCacheConsistencyMgr::DoCancel()
+ {
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::DoCancel - Entry"));
+ iTimer.Cancel();
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::DoCancel - Exit"));
+ }
+
+/*
+ * Walk through the cache .Does two function
+ * 1. Publish any authoritative entries.
+ * 2. Query for the enteries if not authoritative.
+ */
+void CMDNSCacheConsistencyMgr::IterateCacheL()
+ {
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::IterateCacheL - Entry"));
+ TBool iterateReset(ETrue);
+ TBool cacheUpToDate(ETrue);
+ TInt count = iMessageHandler.DnsCache().NumberOfEntries();
+ TInt index(0);
+
+
+
+ for(index=0; index<count;index++)
+ {
+ //Fetch the next entry whose ttl has completely expired or 80%
+ //of ttl has expired
+ CCacheEntry* entry = iMessageHandler.DnsCache().NextStaleEntry(iActiveCacheMgmtEnabled,iterateReset);
+
+ //Reset the iterate flag
+ iterateReset = EFalse;
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::IterateCacheL - 1"));
+ if(entry)
+ {
+ if(entry->EntryExpired())
+ {
+
+ if(entry->IsAuthoritative())
+ {
+ //Republish the record
+ //Goodbye packet is sent while the session for publish is closed
+ CDnsMessage * announcement = CDnsMessage::NewL(0,EFalse);
+ CleanupStack::PushL(announcement);
+ if(entry->PtrRecord())
+ {
+ entry->PtrRecord()->SetTtl(120);
+ announcement->AppendAnswerL(entry->PtrRecord()->CloneL());
+ iMessageHandler.DnsCache().UpdateCacheL(*(entry->PtrRecord()),ETrue,entry->SessionId());
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::IterateCacheL - 2"));
+ }
+ if(entry->ServiceRecord())
+ {
+ entry->ServiceRecord()->SetTtl(120);
+ announcement->AppendAnswerL(entry->ServiceRecord()->CloneL());
+ iMessageHandler.DnsCache().UpdateCacheL(*(entry->ServiceRecord()),ETrue,entry->SessionId());
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::IterateCacheL - 3"));
+ }
+ if(entry->TxtRecord())
+ {
+ entry->TxtRecord()->SetTtl(120);
+ announcement->AppendAnswerL(entry->TxtRecord()->CloneL());
+ iMessageHandler.DnsCache().UpdateCacheL(*(entry->TxtRecord()),ETrue,entry->SessionId());
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::IterateCacheL - 4"));
+ }
+ if(entry->AddressRecord())
+ {
+ entry->AddressRecord()->SetTtl(120);
+ announcement->AppendAnswerL(entry->AddressRecord()->CloneL());
+ iMessageHandler.DnsCache().UpdateCacheL(*(entry->AddressRecord()),ETrue,0);
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::IterateCacheL - 5"));
+ }
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::IterateCacheL - 6"));
+ iMessageHandler.SendQueryL(announcement,*this);
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::IterateCacheL - 7"));
+ CleanupStack::Pop();//announcement
+ }
+ else
+ {
+ if(!entry->IsAuthoritative())
+ {
+ DeleteEntry(entry);
+ //Query(entry);
+ }
+ }
+ }
+ cacheUpToDate = EFalse;
+ }
+ delete entry;
+ }
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::IterateCacheL - Exit"));
+ }
+
+/*
+ * Delete the particular entry from the cache.
+ * @param aEntry cacheentry to be delete.
+ */
+void CMDNSCacheConsistencyMgr::DeleteEntry(CCacheEntry* aEntry)
+ {
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::DeleteEntry - Entry"));
+ RBuf8 key;
+ //Extract the key & delete
+
+ if(aEntry->AddressRecord())
+ {
+ key.CreateL(GetHostName(aEntry));
+ TInt delError = iMessageHandler.DnsCache().DeleteEntryL(key);//TODO: handle error
+ }
+
+ key.Close();
+ key.CreateL(GetServiceName(aEntry));
+
+ TInt error = iMessageHandler.DnsCache().DeleteEntryL(key);
+ //Handle error
+ key.Close();
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::DeleteEntry - Exit"));
+ }
+
+/*
+ * Create a CDnsMessage object to be sent to the network using aEntry.
+ *
+ */
+void CMDNSCacheConsistencyMgr::Query(CCacheEntry* aEntry)
+ {
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::Query - Entry"));
+ //Construct DNS Message
+ CDnsMessage* message = CDnsMessage::NewL(0,ETrue);
+ CleanupStack::PushL(message);
+
+ //Form the Query/Question part of the message
+ CDnsQuestion* question = CDnsQuestion::NewL();
+ CleanupStack::PushL(question);
+
+ question->SetNameL(GetServiceName(aEntry));
+ question->SetClass(EDnsClass_IN);
+ question->SetType(EDnsQType_Any);
+
+ //Append the Query to the Message
+ message->AppendQueryL(question);
+ if(aEntry->AddressRecord())
+ message->AppendAnswerL(aEntry->AddressRecord()->CloneL());
+
+ if(aEntry->ServiceRecord())
+ message->AppendAnswerL(aEntry->ServiceRecord()->CloneL());
+
+ if(aEntry->TxtRecord())
+ message->AppendAnswerL(aEntry->TxtRecord()->CloneL());
+
+ if(aEntry->PtrRecord())
+ message->AppendAnswerL(aEntry->PtrRecord()->CloneL());
+
+
+
+ //Send the query
+ iMessageHandler.SendQueryL(message,*this);
+
+ CleanupStack::Pop();//question
+ CleanupStack::Pop();//message
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::Query - Exit"));
+ }
+
+/*
+ * @return the hostname for the particular record.
+ */
+const TDesC8& CMDNSCacheConsistencyMgr::GetHostName(CCacheEntry* aEntry)
+ {
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::GetHostName - Entry Exit"));
+ return aEntry->AddressRecord()->Name();
+ }
+
+
+/*
+ * @param aEntry for which service name is required.
+ * @return Domain name for the particular service.
+ */
+const TDesC8& CMDNSCacheConsistencyMgr::GetServiceName(CCacheEntry* aEntry)
+ {
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::GetServiceName - Entry"));
+ if(aEntry->ServiceRecord())
+ {
+ return aEntry->ServiceRecord()->Name();
+ }
+ else if (aEntry->TxtRecord())
+ {
+ return aEntry->TxtRecord()->Name();
+ }
+ else if(aEntry->PtrRecord())
+ {
+ return aEntry->PtrRecord()->DomainName();
+ }
+ else if(aEntry->AddressRecord())
+ {
+ return aEntry->AddressRecord()->Name();
+ }
+
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::GetServiceName - Exit"));
+ }
+
+/*
+ * Notified for any queries sent .
+ */
+void CMDNSCacheConsistencyMgr::OnPacketSendL(TInt /*aError*/)
+ {
+ __FLOG(_L8("CMDNSCacheConsistencyMgr::OnPacketSendL - Entry"));
+ //Do nothing
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/cmdnsprobemanager.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,561 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmdnsprobemanager.cpp
+//
+//
+/**
+@file
+@internalTechnology
+*/
+//User include
+#include "e32math.h"
+#include "cmdnsprobemanager.h"
+//System include
+#include <mdns/ccacheentry.h>
+__FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
+/*
+ * Two phase constructor
+ * @param aCache reference to cache
+ * @param aMessageHandler reference to message handler.
+ * @param aAutoresolveEnabled True if name conflict to be handled.
+ */
+CMDNSProbeManager* CMDNSProbeManager::NewL(MDNSCacheMgr& aCache,CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled)
+ {
+ CMDNSProbeManager* self = CMDNSProbeManager::NewLC(aCache,aMessageHandler,aAutoResolveEnabled);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+static void CleanUpCache(TAny* aAny)
+ {
+ RPointerArray <CCacheEntry> * records = static_cast < RPointerArray <CCacheEntry>* > (aAny);
+ records->ResetAndDestroy();
+ records->Close();
+ }
+/*
+ * Two phase constructor
+ * @param aCache reference to cache
+ * @param aMessageHandler reference to message handler.
+ * @param aAutoresolveEnabled True if name conflict to be handled.
+ */
+CMDNSProbeManager* CMDNSProbeManager::NewLC(MDNSCacheMgr& aCache,CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled)
+ {
+ CMDNSProbeManager* self = new (ELeave)CMDNSProbeManager(aCache,aMessageHandler,aAutoResolveEnabled);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+ }
+
+/*
+ * Constructor
+ */
+CMDNSProbeManager::CMDNSProbeManager(MDNSCacheMgr& aCache,CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled)
+:CTimer(CActive::EPriorityStandard),iCache(aCache),iMessageHandler(aMessageHandler),iAutoResolveEnabled(aAutoResolveEnabled)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+/*
+ * Two phase Constructor
+ */
+void CMDNSProbeManager::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ CTimer::ConstructL();
+ iCurrentProbeState = EIdle;
+ }
+/*
+ * Destructor
+ */
+CMDNSProbeManager::~CMDNSProbeManager()
+ {
+ __FLOG(_L8("CMDNSProbeManager::~CMDNSProbeManager - Entry"));
+ iName.Close();
+ iTarget.Close();
+ iProbeName.Close();
+ iProbeType.Close();
+ __FLOG(_L8("CMDNSProbeManager::~CMDNSProbeManager - Exit"));
+ __FLOG_CLOSE;
+ }
+
+/*
+ * State machine which probe send announcement and handle conflicts
+ * if autoresolve enabled.
+ */
+void CMDNSProbeManager::RunL()
+ {
+ __FLOG(_L8("CMDNSProbeManager::RunL - Entry"));
+ TTime currentTime;
+
+ if(iCurrentProbeState <= EProbeComplete)
+ {
+ if(DefensiveResponseL())
+ {
+ iCurrentProbeState = EStart;
+ if(iAutoResolveEnabled)
+ {
+ GenerateNonConflictingName();
+ }
+ // else { }// to intimate server of failure
+ if(iProbeCounter >= KMaxFailures)
+ {
+ //If Probe Failure rate is greater then 15 per second, wait for
+ //5 seconds before probing again
+ iProbeCounter = 0;
+ After(5*1000*1000);
+ }
+ }
+ }
+
+ switch(iCurrentProbeState)
+ {
+ case EIdle:
+ break;//Do Nothing
+
+ case EStart:
+ {
+ currentTime.UniversalTime();
+ TInt64 randseed = currentTime.Int64();
+
+ //Random time between 0 & 250 ms
+ TInt delay = Math::Rand(randseed) % 250;
+ iCurrentProbeState = EProbeFirstUnicast;
+ //Convert to microsecond
+
+ After(delay*1000);
+ }
+ break;
+
+ case EProbeFirstUnicast:
+ {
+ SendProbeL(ETrue);
+ iCurrentProbeState = EProbeSecondUnicast;
+ }
+ break;
+
+ case EProbeSecondUnicast:
+ {
+ SendProbeL(ETrue);
+ iCurrentProbeState = EProbeMulticast;
+ }
+ break;
+
+ case EProbeMulticast:
+ {
+ SendProbeL(EFalse);
+ iCurrentProbeState = EProbeComplete;
+ }
+ break;
+
+ case EProbeComplete:
+ {
+ iCurrentProbeState = EFirstAnnouncement;
+ //Probe succeeded ,insert in cache
+ InsertInCache();
+ iMessageHandler.Server().SetHostNameL(iName);
+ After(KProbeDelay*1000);
+ //Some Delay ?? Required or defensive response HAS TO come within 750ms?
+ }
+ break;
+
+ case EFirstAnnouncement:
+ {
+ SendAnnouncementL();
+ iCurrentProbeState = ESecondAnnouncement;
+ //After(1000);// A Millisecond delay: Required??
+ }
+ break;
+
+ case ESecondAnnouncement:
+ {
+ SendAnnouncementL();
+ iCurrentProbeState = EIdle;
+ }
+ break;
+ }
+ __FLOG(_L8("CMDNSProbeManager::RunL - Exit"));
+ }
+
+/*
+ * Handles any leave from RunL
+ */
+TInt CMDNSProbeManager::RunError(TInt aError)
+ {
+ __FLOG(_L8("CMDNSProbeManager::RunError - Entry Exit"));
+ return aError;
+ }
+
+/*
+ * Probe host
+ * @param aUnicast True if unicast or else multicast.
+ */
+void CMDNSProbeManager::SendProbeL(TBool aUnicast)
+ {
+ __FLOG(_L8("CMDNSProbeManager::SendProbeL - Entry"));
+ //Construct DNS Message
+ CDnsMessage* message = CDnsMessage::NewL(0,ETrue);
+ CleanupStack::PushL(message);
+
+ //Form the Query/Question part of the message
+ CDnsQuestion* question = CDnsQuestion::NewL();
+ CleanupStack::PushL(question);
+ question->SetNameL(iName);
+ question->SetClass(EDnsClass_IN);
+ question->SetType(EDnsQType_Any);
+ if(aUnicast)
+ {
+ question->SetUnicast(ETrue);
+ }
+
+ //Append the Query to the Message
+ message->AppendQueryL(question);
+
+
+ //Form the Record to be filled in the Authoritative Field of the Query
+ switch(iType)
+ {
+ case EDnsType_A:
+ {
+ CRdTypeA* addRec = FormAddressRecordL();
+ //Append to the Authoritative Section
+ message->AppendAuthorityL(addRec);
+ }
+ break;
+
+ case EDnsType_SRV:
+ {
+ CRdTypeSrv* srvRec = FormServiceRecordL();
+ //Append to the Authoritative Section
+ message->AppendAuthorityL(srvRec);
+ }
+
+ break;
+ }
+ //Send the query
+ iMessageHandler.SendQueryL(message,*this);
+
+ CleanupStack::Pop();//question
+ CleanupStack::Pop();//message
+ __FLOG(_L8("CMDNSProbeManager::SendProbeL - Exit"));
+ }
+
+
+/*
+ * Send an announcement if probing is successfull.
+ */
+void CMDNSProbeManager::SendAnnouncementL()
+ {
+ __FLOG(_L8("CMDNSProbeManager::SendAnnouncementL - Entry"));
+ RPointerArray<CCacheEntry> entries;
+
+
+ //An API in Cache Interface that returns a list of all Authoritative records
+ iCache.AuthoritativeEntriesL(entries);
+
+ for(TInt index =0; index<entries.Count();index++)
+ {
+ CCacheEntry* entry = entries[index];
+ //Send Announcements for all the Services we have published, and entered in Cache
+ CDnsMessage* message = CDnsMessage::NewL(0,EFalse);
+ CleanupStack::PushL(message);
+
+ TDnsHeader header(message->Header());
+ header.SetAuthoritative(ETrue);
+ message->SetHeader(header);
+
+ if(entry->AddressRecord())
+ message->AppendAnswerL(entry->AddressRecord()->CloneL());
+ if(entry->ServiceRecord())
+ message->AppendAnswerL(entry->ServiceRecord()->CloneL());
+ if(entry->PtrRecord())
+ message->AppendAnswerL(entry->PtrRecord()->CloneL());
+ if(entry->TxtRecord())
+ message->AppendAnswerL(entry->TxtRecord()->CloneL());
+
+ //should've been a new API sendresponse
+
+ iMessageHandler.SendQueryL(message,*this);
+
+ CleanupStack::Pop();//message
+ entries.ResetAndDestroy();
+ entries.Close();
+ }
+ __FLOG(_L8("CMDNSProbeManager::SendAnnouncementL - Exit"));
+ }
+
+/*
+ * Returns ture hostname exists in the cache.
+ * True means there is already a record in the network with the same name.
+ */
+TBool CMDNSProbeManager::DefensiveResponseL()
+ {
+ __FLOG(_L8("CMDNSProbeManager::DefensiveResponseL - Entry"));
+ TBool probeFailed(EFalse);
+ RPointerArray <CCacheEntry> entries;
+ CleanupStack::PushL(TCleanupItem(TCleanupOperation(&CleanUpCache),&entries));
+
+ _LIT8(KDot,".");
+ TBuf8 <KMaxLength> buffer;
+
+ buffer.Copy(iName);
+ buffer.Append(KDot);
+
+ iCache.FindServiceL(entries,buffer,EDnsQType_Any);
+
+ if(entries.Count()>0)
+ {
+ probeFailed = ETrue;
+ }
+
+ CleanupStack::PopAndDestroy();
+ entries.ResetAndDestroy();
+ entries.Close();
+ __FLOG(_L8("CMDNSProbeManager::DefensiveResponseL - Exit"));
+ return probeFailed;
+ }
+
+TInt CMDNSProbeManager::StartNameProbeL(const TDesC8& aHostName,TInetAddr aAddr)
+ {
+ __FLOG(_L8("CMDNSProbeManager::StartNameProbeL - Entry"));
+ iName.Close();
+ iName.CreateL(aHostName);
+ iProbeName.Close();
+ iProbeName.CreateL(KMaxLength);
+ iProbeName.Append(iName);
+ iAddr = aAddr;
+ iCurrentProbeState = EStart;
+ iType = EDnsType_A;
+ iMessageHandler.SetStateHostProbing(ETrue);
+ Schedule();
+ __FLOG(_L8("CMDNSProbeManager::StartNameProbeL - Exit"));
+ return KErrNone;
+ }
+
+/*
+ * Start probing the service.
+ */
+TInt CMDNSProbeManager::StartServiceProbeL(const TDesC8& aServiceName,const TDesC8& aTargetMachine,TUint16 aPort)
+ {
+ __FLOG(_L8("CMDNSProbeManager::StartServiceProbeL - Entry"));
+ iName.Close();
+ iName.CreateL(aServiceName);
+
+ iTarget.Close();
+ iTarget.CreateL(aTargetMachine);
+
+ iPort = aPort;
+ iType = EDnsType_SRV;
+
+ iCurrentProbeState = EStart;
+
+ Schedule();
+ __FLOG(_L8("CMDNSProbeManager::StartServiceProbeL - Exit"));
+ return KErrNone;
+ }
+
+
+/*
+ * Callback method
+ * Will be notified on successfully sending a packet to the network .
+ * State will be EIdle when an address is successully announced twice.
+ */
+void CMDNSProbeManager::OnPacketSendL(TInt /*aError*/)
+ {
+ __FLOG(_L8("CMDNSProbeManager::OnPacketSendL - Entry"));
+ if( iCurrentProbeState != EIdle)
+ {
+ After(KProbeDelay*1000);//Give more delay than this
+ return;
+ }
+ iMessageHandler.SetStateHostProbing(EFalse);
+ __FLOG(_L8("CMDNSProbeManager::OnPacketSendL - Exit"));
+ }
+
+
+/*
+ * Create an address record
+ * @return returns an address record created.
+ */
+CRdTypeA* CMDNSProbeManager::FormAddressRecordL()
+ {
+ __FLOG(_L8("CMDNSProbeManager::FormAddressRecordL - Entry"));
+ CRdTypeA* addRec = CRdTypeA::NewL();
+ CleanupStack::PushL(addRec);
+
+ TInt dataLength(4);
+
+ addRec->SetNameL(iName);
+ addRec->SetType(EDnsType_A);
+ addRec->SetClass(EDnsClass_IN);
+ addRec->SetFlushBit(EFalse);
+ addRec->SetAddr(iAddr);
+ addRec->SetTtl(120);
+
+ CleanupStack::Pop();//addRec
+ __FLOG(_L8("CMDNSProbeManager::FormAddressRecordL - Exit"));
+ return addRec;
+ }
+
+/*
+ * Create a service record
+ * @return retrun the newly created service record.
+ */
+CRdTypeSrv* CMDNSProbeManager::FormServiceRecordL()
+ {
+ __FLOG(_L8("CMDNSProbeManager::FormServiceRecordL - Entry"));
+ CRdTypeSrv* srvRec = CRdTypeSrv::NewL();
+ CleanupStack::PushL(srvRec);
+
+ srvRec->SetClass(EDnsClass_IN);
+ srvRec->SetFlushBit(EFalse);
+ srvRec->SetNameL(iName);
+ srvRec->SetPort(iPort);
+ srvRec->SetPriority(/*Default Priority*/0 );
+ srvRec->SetTargetL(iTarget);
+ srvRec->SetTtl(120*60);
+ srvRec->SetType(EDnsType_SRV);
+ srvRec->SetWeight(/*Default Weight*/ 0);
+
+
+ CleanupStack::Pop();//srvRec
+ __FLOG(_L8("CMDNSProbeManager::FormServiceRecordL - Exit"));
+ return srvRec;
+ }
+
+void CMDNSProbeManager::InsertInCache()
+ {
+ __FLOG(_L8("CMDNSProbeManager::InsertInCache - Entry"));
+ TBuf8<KMaxLength> name;
+ _LIT8(KDot,".");
+
+ CDnsResourceData* data = NULL;
+
+ switch(iType)
+ {
+ case EDnsType_A:
+ {
+ data = FormAddressRecordL();
+ }
+ break;
+
+ case EDnsType_SRV:
+ {
+ data = FormServiceRecordL();
+ }
+ break;
+
+ }
+
+ //Append a "." at the end of the name
+ name.Copy(iName);
+ name.Append(KDot);
+ data->SetNameL(name);
+
+ iCache.UpdateCacheL(*data,ETrue,0/*session Id*/);
+
+ delete data;
+ __FLOG(_L8("CMDNSProbeManager::InsertInCache - Exit"));
+ }
+
+
+
+
+/*
+ * If autoresolve enable a non conflict name will be generated using this.
+ * @return returns the probecount.
+ */
+TInt CMDNSProbeManager::GenerateNonConflictingName()
+ {
+/*
+ __FLOG(_L8("CMDNSProbeManager::GenerateNonConflictingName - Entry"));
+ _LIT8(KDot,".");
+
+ if(iProbeCounter)
+ {
+ //From 2nd time, chop the last 3 characters
+ iProbeName.SetLength(iProbeName.Length() - 3);
+ }
+
+ ++iProbeCounter;
+
+ TBuf8 <KMaxLength> newName;
+ newName.Append(iProbeName);
+
+ _LIT8(KOpenBrace,"(");
+ newName.Append(KOpenBrace);
+
+ newName.AppendNum(iProbeCounter);
+
+ _LIT8(KCloseBrace,")");
+ newName.Append(KCloseBrace);
+
+ iProbeName.Close();
+ iProbeName.Create(KMaxNameLength);
+ iProbeName.Append(newName);
+
+ iName.Close();
+ iName.Create(KMaxLength);
+ iName.Append(iProbeName);
+
+ iName.Append(KDot);
+ iName.Append(iProbeType);
+
+ __FLOG(_L8("CMDNSProbeManager::GenerateNonConflictingName - Exit"));
+ return iProbeCounter;
+*/
+ //-------------------------------------------------------
+ __FLOG(_L8("CMDNSProbeManager::GenerateNonConflictingName- Entry"));
+ _LIT8(KDot,".");
+
+ ++iProbeCounter;
+
+ TBuf8 <KMaxLength> newName;
+
+ iName.Close();
+ iName.Create(KMaxLength);
+ iName.Append(iProbeName);
+
+ TInt pos = iName.Locate('.');
+ _LIT8(KOpenBrace,"(");
+ newName.Append(KOpenBrace);
+ newName.AppendNum(iProbeCounter);
+ _LIT8(KCloseBrace,")");
+ newName.Append(KCloseBrace);
+ iName.Insert(pos,newName);
+ //ChangeDomainL(iName);
+
+ __FLOG(_L8("CMDNSProbeManager::GenerateNonConflictingName- Exit"));
+ return iProbeCounter;
+
+
+
+
+
+ }
+
+/*
+ * Self complete the request.
+ */
+
+void CMDNSProbeManager::Schedule()
+ {
+ __FLOG(_L8("CMDNSProbeManager::Schedule - Entry"));
+ TRequestStatus* status(&iStatus);
+ *status = KRequestPending;
+ SetActive();
+ User::RequestComplete(status, KErrNone);
+ __FLOG(_L8("CMDNSProbeManager::Schedule - Exit"));
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/cmessagehandler.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,268 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cmessagehandler.cpp
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+//System include
+#include <mdns/cdnsmessagecomposerparser.h>
+#include <mdns/cdnsmessage.h>
+#include <e32base.h>
+
+//user include
+#include "cmessagehandler.h"
+#include "cqueryhandler.h"
+#include "ccacheentry.h"
+#include "cresponsehandler.h"
+#include "cadvertizehandler.h"
+#include <mdns/mdnscachemgr.h>
+
+__FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
+//
+/**
+Two phase constructor
+@param aServer reference to CBonjourServer
+@return pointer to CMessageHandler
+*/
+CMessageHandler* CMessageHandler::NewL(CMdnsServer& aServer)
+ {
+ CMessageHandler* self = new (ELeave) CMessageHandler(aServer);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+/**
+Implementation of MSocketHandlerObserver
+@param aData packet recieved from the mdns port
+@param aAddr address from which packet is recieved
+@param aLength length of the packet reieved
+@return void
+*/
+void CMessageHandler::OnCompletionL(TDesC8& aData, const TSockAddr& aAddr, TInt aLength )
+ {
+ __FLOG(_L8("CMessageHandler::OnCompletionL - Entry"));
+ HandleIncomingPacketL(aData ,aAddr ,aLength );
+ iRecieveSocket->Activate(TSocketHandlerParams(ESocketRecieve));
+ __FLOG(_L8("CMessageHandler::OnCompletionL - Exit"));
+ }
+/**
+Any error in the socket will be notified here
+@paran aError error with which socket leaves
+@return void
+*/
+void CMessageHandler::OnError(TInt /*aError*/)
+ {
+ __FLOG(_L8("CMessageHandler::OnError -Entry Exit"));
+ }
+
+/**
+Constructor
+*/
+CMessageHandler::CMessageHandler(CMdnsServer& aServer):iServer(aServer)
+ {
+
+ }
+
+/**
+Two phase constructor
+*/
+void CMessageHandler::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ __FLOG(_L8("CMessageHandler::ConstructL - Entry"));
+ iQueryHandler = CQueryHandler::NewL(*this);
+ iResponseHandler = CResponseHandler::NewL(*this);
+ iAdvertizeHandler = CAdvertizeHandler::NewL(*this);
+ iRecieveSocket = CSocketHandler::NewL(iServer.Socket(),*this,ESocketRecieve);
+ iSendMessageQueue = CSendMessageQueue::NewL(iServer.Socket());
+ iRecieveSocket->Activate(TSocketHandlerParams(ESocketRecieve));
+ iDnsCache = CMDNSCacheManager::NewL(200);
+ iDummyhandler = CBaseHandler::NewL(*this);
+ __FLOG(_L8("CMessageHandler::ConstructL - Exit"));
+ }
+
+/*
+Destructor
+*/
+CMessageHandler::~CMessageHandler()
+ {
+ __FLOG(_L8("CMessageHandler::~CMessageHandler - Entry"));
+ delete iQueryHandler;
+ delete iResponseHandler;
+ delete iAdvertizeHandler;
+ delete iRecieveSocket;
+ TRAPD(err,iDnsCache->DumpCacheL());
+ delete iDnsCache;
+ delete iPacket;
+ delete iSendMessageQueue;
+ delete iDummyhandler;
+ __FLOG(_L8("CMessageHandler::~CMessageHandler - Exit"));
+ __FLOG_CLOSE;
+ }
+/**
+This method parse the packet and dispatch the packet for handling it based on the operation requested.
+from the header
+@param aData packet read from the mdns port
+@param aAddr address from which the packet is recieved
+@param length lenght of the data recieved
+@return void
+*/
+void CMessageHandler::HandleIncomingPacketL(TDesC8& aData, const TSockAddr& aAddr, TInt /*length*/)
+ {
+ __FLOG(_L8("CMessageHandler::HandleIncomingPacketL - Entry"));
+ CDnsMessageComposerParser* comPos = CDnsMessageComposerParser::NewL();
+ CleanupStack::PushL(comPos);
+ CDnsMessage* message = comPos->ParseMessageL(aData);
+ CleanupStack::PushL(message);
+ CBaseHandler& iOperationHandler = GetHandlerL(*message);
+ iOperationHandler.HandleIncomingPacketL(*message ,aAddr);
+ CleanupStack::PopAndDestroy(message);//comPos and message
+ CleanupStack::PopAndDestroy(comPos);
+ __FLOG(_L8("CMessageHandler::HandleIncomingPacketL - Exit"));
+ }
+
+/**
+This is a factory method which reads the packet and returns the handle to either
+response or query handler
+@param aMessage Dnspacket to read the header and to constructthe appropriate handler.
+@return Poointer to CBaseHandler --base class to both response and query handler.
+*/
+CBaseHandler& CMessageHandler::GetHandlerL(CDnsMessage& aMessage)
+ {
+ __FLOG(_L8("CMessageHandler::GetHandlerL - Entry"));
+ TDnsHeader header = aMessage.Header();
+ //
+ if(header.IsQuery() && !header.IsAuthoritative())
+ {
+ return *iQueryHandler;
+ }
+ else if(header.IsAuthoritative())
+ {
+ return *iResponseHandler;
+ }
+ else
+ {
+ return *iDummyhandler;
+ }
+ __FLOG(_L8("CMessageHandler::GetHandlerL - Exit"));
+ }
+/**
+@return return a reference to CacheManager
+*/
+MDNSCacheMgr& CMessageHandler::DnsCache() const
+ {
+ __FLOG(_L8("CMessageHandler::DnsCache -Entry Exit"));
+ return *iDnsCache;
+ }
+
+/*
+ * Routes the query sent by the client to query handler to handle it.
+ * @param aMessage Pointer to a message object ;contains the query.
+ * @param aHandle session id which generated the query.
+ */
+void CMessageHandler::ServiceClientQueryL(CDnsMessage* aMessage,TInt aHandle)
+ {
+ __FLOG(_L8("CMessageHandler::ServiceClientQueryL - Entry"));
+ iQueryHandler->ServiceClientQueryL(aMessage, aHandle);
+ __FLOG(_L8("CMessageHandler::ServiceClientQueryL - Exit"));
+ }
+
+/*
+ * returns the pointer to the messagequeue.
+ */
+CSendMessageQueue& CMessageHandler::MessageQueue()const
+ {
+ __FLOG(_L8("CMessageHandler::MessageQueue -Entry Exit"));
+ return *iSendMessageQueue;
+ }
+
+/*
+ * Notify the server after the query has been handled.
+ * @param aClientHandle SessionId which had sent the query.
+ */
+void CMessageHandler::NotifyClientQuery(TInt aClientHandle)
+ {
+ __FLOG(_L8("CMessageHandler::NotifyClientQuery - Entry"));
+ iServer.NotifyClientQuery(aClientHandle);
+ __FLOG(_L8("CMessageHandler::NotifyClientQuery - Exit"));
+ }
+
+/*
+ * Route an internal query to the query handler
+ * @param aMessage pointer to the dnsmeesage containg the query.
+ * @param Observer to which successfull delivery of packet to be notified.
+ */
+void CMessageHandler::SendQueryL(CDnsMessage* aMessage, MMessageHandler& aObserver)
+ {
+ __FLOG(_L8("CMessageHandler::SendQueryL - Entry"));
+ iQueryHandler->SendQueryL(aMessage, aObserver);
+ __FLOG(_L8("CMessageHandler::SendQueryL - Exit"));
+ }
+/*
+ * Route the packet to be advertised to the adveritser.
+ * @param aData array of CDnsresourceData to be advertised.
+ * @param aSessionId session which adveritised the packet.
+ */
+void CMessageHandler::AdvertizePacketL(const RPointerArray<CDnsResourceData> aData, TInt aSessionId,TBool aIsUpdate)
+ {
+ __FLOG(_L8("CMessageHandler::AdvertizePacketL - Entry"));
+ iAdvertizeHandler->AdvertizePacketL(aData, aSessionId,aIsUpdate);
+ __FLOG(_L8("CMessageHandler::AdvertizePacketL - Exit"));
+ }
+
+/*
+ * Notify the server when a new service is published
+ * @param aName name of the service published
+ * inacase of autoresolve name will be the new published name.
+ * @param aError will be the result of publish.ESuccess if successfull and E*Conflict.
+ * @param aSessionId session which initaiated publish.
+ *
+ */
+void CMessageHandler::NotifyServicePublishL(const RBuf8& aName,TInt aError, TInt aSessionId)
+ {
+ __FLOG(_L8("CMessageHandler::NotifyServicePublishL - Entry"));
+ iServer.NotifyServicePublishL(aName,aError, aSessionId);
+ __FLOG(_L8("CMessageHandler::NotifyServicePublishL - Exit"));
+ }
+
+/*
+ * @param aProbing ETrue if hostprobing in progress.
+ */
+void CMessageHandler::SetStateHostProbing(TBool aProbing)
+ {
+ __FLOG(_L8("CMessageHandler::SetStateHostProbing - Entry"));
+ iServer.SetStateHostProbing(aProbing);
+ __FLOG(_L8("CMessageHandler::SetStateHostProbing - Exit"));
+ }
+
+/*
+ * notify the server when a new service has been published in the network
+ * @param aName array of new service published , for the servcetype client has requested.
+ */
+void CMessageHandler::NotifyNewServiceL(const RArray<RBuf8>& aName)
+ {
+ __FLOG(_L8("CMessageHandler::NotifyNewServiceL - Entry"));
+ iServer.NotifyNewServiceL(aName);
+ __FLOG(_L8("CMessageHandler::NotifyNewServiceL - Exit"));
+ }
+
+CMdnsServer& CMessageHandler::Server()
+ {
+ return iServer;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/cqueryhandler.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,497 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cqueryhandler.cpp
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+//User include
+#include "cqueryhandler.h"
+//System include
+#include <mdns/cdnsquestion.h>
+#include <mdns/ccacheentry.h>
+#include <mdns/tdnsheader.h>
+__FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
+/*
+ * Two phase constructor
+ * @param aMessageHandler reference to the message handler.
+ */
+CQueryHandler* CQueryHandler::NewL(CMessageHandler& aMessageHandler)
+ {
+ CQueryHandler* self = new(ELeave)CQueryHandler(aMessageHandler);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+/*
+ * Destructor
+ */
+CQueryHandler::~CQueryHandler()
+ {
+ __FLOG(_L8("CQueryHandler::~CQueryHandler - Entry Exit"));
+ __FLOG_CLOSE;
+ }
+
+/*
+ * Handles any query from the network
+ * @param aMessage message which contains the query.
+ * @param aSockAddr address form which query id recieved.
+ */
+void CQueryHandler::HandleIncomingPacketL(CDnsMessage& aMessage ,const TSockAddr& aAddr)
+ {
+ __FLOG(_L8("CQueryHandler::HandleIncomingPacketL - Entry"));
+ if(aMessage.Header().IsQuery())
+ {
+ CDnsMessage* ret= CDnsMessage::NewL(aMessage.Header().Id(),EFalse);
+ CleanupStack::PushL(ret);
+ TInt qCount = aMessage.Header().QueryCount();
+ for(TInt i =0; i< qCount;i++)
+ {
+ const CDnsQuestion* query = aMessage.Queries()[i];
+ TBufC8<100> domainName(query->Name());
+ RPointerArray<CCacheEntry> cacheArray;
+ TRAPD(error,MessageHandler().DnsCache().FindServiceL(cacheArray,domainName,(TDnsType)query->Type()));
+ for(TInt i =0 ; i<cacheArray.Count() ;i++)
+ {
+ if(cacheArray[i]->IsAuthoritative())
+ {
+ TBool suppress = EFalse;
+ switch(query->Type())
+ {
+ case EDnsType_A:
+ {
+ suppress = SuppressDuplicateAnswerL(aMessage.Answers(),*(cacheArray[i]->AddressRecord()));
+ if(suppress == EFalse)
+ {
+ ret->AppendAnswerL(cacheArray[i]->AddressRecord()->CloneL());
+
+ }
+ break;
+ }
+ case EDnsType_PTR:
+ {
+ suppress = SuppressDuplicateAnswerL(aMessage.Answers(),*(cacheArray[i]->PtrRecord()));
+ if(suppress == EFalse)
+ {
+ ret->AppendAnswerL(cacheArray[i]->PtrRecord()->CloneL());
+ }
+ break;
+ }
+ case EDnsType_SRV:
+ {
+ suppress = SuppressDuplicateAnswerL(aMessage.Answers(),*(cacheArray[i]->ServiceRecord()));
+ if(suppress == EFalse)
+ {
+ ret->AppendAnswerL(cacheArray[i]->ServiceRecord()->CloneL());
+ }
+ break;
+ }
+ case EDnsType_TXT:
+ {
+ suppress = SuppressDuplicateAnswerL(aMessage.Answers(),*(cacheArray[i]->TxtRecord()));
+ if(suppress == EFalse)
+ {
+ ret->AppendAnswerL(cacheArray[i]->TxtRecord()->CloneL());
+ }
+ break;
+ }
+ case EDnsType_AAAA:
+ {
+ //HandleAAAAQuestionL();
+ break;
+ }
+ case EDnsQType_Any:
+ {
+ HandleAnyQuestionL(ret,aMessage.Answers(),*cacheArray[i]);
+ break;
+ }
+ default:
+ User::Invariant();
+
+ }
+
+ }
+ }
+ cacheArray.ResetAndDestroy();
+ cacheArray.Close();
+ }
+ if(ret->Header().AnswerCount() == 0 && !IsLastTruncated)
+ {
+ CleanupStack::PopAndDestroy(ret);
+ }
+ else
+ {
+ TDnsHeader& header = const_cast <TDnsHeader&> (ret->Header());
+ header.SetAuthoritative(ETrue);
+ if(IsLastTruncated)
+ {
+ COutStandingQuery* query = NULL;
+ TInt index = 0;
+ for( index =0 ; index< iOutStandingQueryArray.Count();index++)
+ {
+ query = iOutStandingQueryArray[index];
+ if(query->TransactionId() == header.Id() && query->SocketAddress() == aAddr)
+ {
+ break;
+ }
+ }
+ if(index < iOutStandingQueryArray.Count())
+ {
+ CDnsMessage* message = &(query->DnsMessage());
+ TInt i = 0;
+ while(i++ <message->Header().AnswerCount())
+ {
+ ret->AppendAnswerL(message->Answers()[i]);
+ }
+ }
+
+ }
+
+ if(aMessage.Header().IsTruncated())
+ {
+ IsLastTruncated = ETrue;
+ TTime time;
+ time.HomeTime();
+ time + TTimeIntervalMicroSeconds(500);
+ COutStandingQuery* outstandingQuery = COutStandingQuery::NewL(ret,ret->Header().Id(),time,aAddr);
+ iOutStandingQueryArray.Append(outstandingQuery);
+ if(!IsActive())
+ {
+ SetActive();
+ At(time);
+ }
+
+ }
+ else
+ {
+ const TUint32 KMDnsAddr = INET_ADDR(224, 0, 0, 251);
+ TInetAddr addr(KMDnsAddr, KMdnsPort);
+ CSendMessageData* data = CSendMessageData::NewL(ret,ETrue,addr,*this);
+ MessageHandler().MessageQueue().QueueDnsMessageL(*data);
+ }
+ CleanupStack::Pop();
+ }
+ }
+ else
+ {
+ User::Leave(KErrGeneral);
+ }
+ __FLOG(_L8("CQueryHandler::HandleIncomingPacketL - Exit"));
+ }
+/*
+ * Constructor
+ * by default clienthandle is 0
+ */
+CQueryHandler::CQueryHandler(CMessageHandler& aMessageHandler):CBaseHandler(aMessageHandler)
+ {
+
+ iClientHandle =0 ;
+ }
+
+/*
+ * Two phase constructor
+ */
+void CQueryHandler::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ __FLOG(_L8("CQueryHandler::ConstructL - Entry"));
+ CBaseHandler::ConstructL();
+ __FLOG(_L8("CQueryHandler::ConstructL - Exit"));
+ }
+
+/*
+ * compares the answer section and the authoritative entries in the cache .
+ * If there is a match returns ETrue. which mean remove the entry , as the
+ * client is not interested in this record.
+ * @param aAnswers array of records recieved from the external client.
+ * @param aResourceData data from the cache to be checked with the answer section.
+ */
+TBool CQueryHandler::SuppressDuplicateAnswerL(const RPointerArray<CDnsResourceData>& aAnswers,const CDnsResourceData& aResourceData)
+ {
+ __FLOG(_L8("CQueryHandler::SuppressDuplicateAnswerL - Entry"));
+ TBool ret =EFalse;
+ TInt answersCount = aAnswers.Count();
+ for(TInt i=0 ;i< answersCount;i++)
+ {
+ if(0 == aAnswers[i]->Name().Compare(aResourceData.Name()) && aAnswers[i]->Type() == aResourceData.Type())
+ {
+ switch(aResourceData.Type())
+ {
+ case EDnsType_A:
+ {
+ const CRdTypeA& rdata = (CRdTypeA&)(aResourceData);
+ const CRdTypeA* rEntry = static_cast<CRdTypeA*>(aAnswers[i]);
+ if(rdata.Address() == rEntry->Address() && rdata.Ttl() > rEntry->Ttl())
+ {
+ ret = ETrue;
+ }
+ break;
+ }
+ case EDnsType_PTR:
+ {
+ const CRdTypePtr& rdata = (CRdTypePtr&)(aResourceData);
+ const CRdTypePtr* rEntry = static_cast<CRdTypePtr*>(aAnswers[i]);
+ if(0 ==rdata.Name().Compare(rEntry->Name()) && rdata.Ttl() > rEntry->Ttl())
+ {
+ ret = ETrue;
+ }
+ break;
+ }
+ case EDnsType_SRV:
+ {
+ const CRdTypeSrv& rdata = (CRdTypeSrv&)(aResourceData);
+ const CRdTypeSrv* rEntry = static_cast<CRdTypeSrv*>(aAnswers[i]);
+ if(0 == rdata.Name().Compare(rEntry->Name()) && rdata.Port() == rEntry->Port() && rdata.Ttl() > rEntry->Ttl())
+ {
+ ret = ETrue;
+ }
+ break;
+ }
+ case EDnsType_TXT:
+ {
+ const CRdTypeTxt& rdata = (CRdTypeTxt&)(aResourceData);
+ const CRdTypeTxt* rEntry = static_cast<CRdTypeTxt*>(aAnswers[i]);
+ if(rdata.Text().Count() == rEntry->Text().Count())
+ {
+ for(TInt i =0; i< rdata.Text().Count();i++)
+ {
+ if(0 != rdata.Text()[i].Compare(rEntry->Text()[i]))
+ {
+ break;
+ }
+ }
+ ret =ETrue;
+ }
+ break;
+ }
+ default:
+ {
+ User::Invariant();
+ }
+
+ }
+ }
+ }
+ __FLOG(_L8("CQueryHandler::SuppressDuplicateAnswerL - Exit"));
+ return ret;
+
+ }
+
+/*
+ * Handle query from the network of type *Any
+ * @param aPacket packet to be sent to the network in response to the query.
+ * @param aAnswers an array of answers in the query packet.
+ * @param aEntry authoritative entries in the cache.
+ */
+void CQueryHandler::HandleAnyQuestionL(CDnsMessage* aPacket,const RPointerArray<CDnsResourceData>& aAnswers,const CCacheEntry& aEntry)
+ {
+ __FLOG(_L8("CQueryHandler::HandleAnyQuestionL - Entry"));
+ if(aEntry.AddressRecord() && !SuppressDuplicateAnswerL(aAnswers,*(aEntry.AddressRecord())))
+ {
+ aPacket->AppendAnswerL(aEntry.AddressRecord()->CloneL());
+ }
+ if(aEntry.PtrRecord() && !SuppressDuplicateAnswerL(aAnswers,*(aEntry.PtrRecord())))
+ {
+ aPacket->AppendAnswerL(aEntry.PtrRecord()->CloneL());
+ }
+ if(aEntry.ServiceRecord() && !SuppressDuplicateAnswerL(aAnswers,*(aEntry.ServiceRecord())))
+ {
+ aPacket->AppendAnswerL(aEntry.ServiceRecord()->CloneL());
+ }
+ if(aEntry.TxtRecord() && !SuppressDuplicateAnswerL(aAnswers,*(aEntry.TxtRecord())))
+ {
+ aPacket->AppendAnswerL(aEntry.TxtRecord()->CloneL());
+ }
+ __FLOG(_L8("CQueryHandler::HandleAnyQuestionL - Exit"));
+ }
+
+/*
+ * Handles query from the application.
+ * 1.Query for the ptr entries are sent to the network by default.
+ * 2.Query for the srv or txt record will be sent to the network only if it is not present in the cache
+ * @param aMessage contains the query sent by the client.
+ * @param aClientHandle sessionid of the client.
+ */
+void CQueryHandler::ServiceClientQueryL(CDnsMessage* aMessage,TInt aClientHandle)
+ {
+ __FLOG(_L8("CQueryHandler::ServiceClientQueryL - Entry"));
+ TInt queryCount = aMessage->Header().QueryCount();
+ TBool isSendQueryToNw = EFalse;
+ for(TInt i =0 ; i< queryCount ; i++)
+ {
+ switch(aMessage->Queries()[i]->Type())
+ {
+ case EDnsType_A:
+ {
+ RPointerArray<CCacheEntry> iAddressRecords;
+ TInt err = KErrNone;
+ TRAPD(error ,err = MessageHandler().DnsCache().FindServiceL(iAddressRecords, aMessage->Queries()[i]->Name(), EDnsType_A));
+ if(error == KErrNone && err==KErrNotFound /*&& (NULL == iAddressRecords[0]->AddressRecord())*/)
+ {
+ isSendQueryToNw = ETrue;
+ }
+ else
+ {
+ CDnsQuestion* question = aMessage->Queries()[i];
+ const_cast <RPointerArray<CDnsQuestion>&>(aMessage->Queries()).Remove(i);
+ delete question;
+ }
+ iAddressRecords.ResetAndDestroy();
+ iAddressRecords.Close();
+ break;
+ }
+
+ case EDnsType_PTR:
+ case EDnsQType_Any:
+ {
+ RPointerArray<CCacheEntry> ptrRecords;
+ TRAPD(error,MessageHandler().DnsCache().FindServiceL(ptrRecords,aMessage->Queries()[i]->Name(),EDnsType_PTR));
+ for(TInt index =0 ; (error == KErrNone) && index < ptrRecords.Count(); index++)
+ {
+ aMessage->AppendAnswerL(ptrRecords[index]->PtrRecord()->CloneL());
+ }
+ isSendQueryToNw = ETrue;
+ ptrRecords.ResetAndDestroy();
+ ptrRecords.Close();
+ break;
+ }
+
+ case EDnsType_SRV:
+ case EDnsType_TXT:
+ {
+ RPointerArray<CCacheEntry> records;
+ TRAPD(error,MessageHandler().DnsCache().FindServiceL(records,aMessage->Queries()[i]->Name(),(TDnsType)aMessage->Queries()[i]->Type()));
+ if(error == KErrNone && 0 != records.Count())
+ {
+ CDnsQuestion* question = aMessage->Queries()[i];
+ const_cast <RPointerArray<CDnsQuestion>&>(aMessage->Queries()).Remove(i);
+ delete question;
+ }
+ else
+ {
+ isSendQueryToNw = ETrue;
+ }
+ records.ResetAndDestroy();
+ records.Close();
+ break;
+ }
+
+
+ }
+ }
+
+ if(isSendQueryToNw)
+ {
+ SendQueryL(aMessage,*this);
+ iClientHandle = aClientHandle;
+ //On succesfull sending the packet query handler will be notified there query will be
+ // added to outstanding queue
+ }
+ else
+ {
+ delete aMessage;//as the question is not to be send .
+ TTime time;
+ time.HomeTime();
+ ScheduleOutStandingQueryL(aClientHandle,ETrue,time);
+ }
+ __FLOG(_L8("CQueryHandler::ServiceClientQueryL - Exit"));
+ }
+/*
+ * Any queries to be sent to the network goes through this
+ * @param aMessage contains the query to be sent.
+ * @param aObserver callback which is interested in getting notified when
+ * a packet is successfully sent to the network.
+ */
+void CQueryHandler::SendQueryL(CDnsMessage* aMessage, MMessageHandler& aObserver)
+ {
+ __FLOG(_L8("CQueryHandler::SendQueryL - Entry"));
+ //
+ //TODO in case in case the size exceeds max size
+ //
+ TInetAddr addr(KMDnsAddr, KMdnsPort);
+ TBuf<255> buf;
+ addr.Output(buf);
+ CSendMessageData* data = CSendMessageData::NewL(aMessage,EFalse,addr,aObserver);
+ CleanupStack::PushL(data);
+ MessageHandler().MessageQueue().QueueDnsMessageL(*data);
+ CleanupStack::Pop();//data
+ __FLOG(_L8("CQueryHandler::SendQueryL - Exit"));
+ }
+
+
+/*
+ * Creates an outstanding query object from the client query and adds it to the outstanding query arry.
+ * 1. For queries sent to the network ,waits for 120ms before sending the response back .
+ * 2. For queries not sent to network ,reponse will be sent back immediately.
+ */
+void CQueryHandler::ScheduleOutStandingQueryL(TInt aClientHandle , TBool aTriggerNow, TTime aInTime)
+ {
+ __FLOG(_L8("CQueryHandler::ScheduleOutStandingQueryL - Entry"));
+ COutStandingQuery* outstandingQuery = COutStandingQuery::NewL(NULL,0,aInTime,NULL);
+ outstandingQuery->SetClientHandle(aClientHandle);
+ if(aTriggerNow)
+ {
+ if(IsActive())
+ {
+ Cancel();
+ }
+ iOutStandingQueryArray.Insert(outstandingQuery,0);
+ TRequestStatus* status = &iStatus;
+ SetActive();
+ User::RequestComplete(status,KErrNone);
+ }
+ else
+ {
+ TInt pos = 0;
+ for(pos = 0 ; pos< iOutStandingQueryArray.Count(); pos++ )
+ {
+ if(outstandingQuery->GetAddTime().Int64() < iOutStandingQueryArray[pos]->GetAddTime().Int64() )
+ {
+ break;
+ }
+ }
+ iOutStandingQueryArray.Insert(outstandingQuery, pos);
+ if(!IsActive())
+ {
+ TTime nextReview = iOutStandingQueryArray[0]->GetAddTime();
+ At(nextReview);
+ }
+ }
+ __FLOG(_L8("CQueryHandler::ScheduleOutStandingQueryL - Exit"));
+ }
+
+/*Only for the query recieved from the application there should be a delay
+ * before sending the response .So wait for 120ms before sending the response
+ * back to client.
+ * Only for the query recieved from the client ,iClientHandle will not be NULL
+ * @param aError is the error in case any in delivering the packet.
+ */
+void CQueryHandler::OnPacketSendL(TInt /*aError*/)
+ {
+ __FLOG(_L8("CQueryHandler::OnPacketSendL - Entry"));
+ if(iClientHandle != 0)
+ {
+ TTime time;
+ time.HomeTime();
+ time = time + TTimeIntervalMicroSeconds(120000);
+ ScheduleOutStandingQueryL(iClientHandle,EFalse,time);
+ iClientHandle =0 ;
+ }
+ __FLOG(_L8("CQueryHandler::OnPacketSendL - Exit"));
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/cresponsehandler.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,423 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// cresponsehandler.cpp
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+//System include
+#include <mdns/ccacheentry.h>
+
+//User include
+#include "cresponsehandler.h"
+__FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
+/**
+Two phase constructor
+@param aMessageHandler a reference to messagehandler
+*/
+CResponseHandler* CResponseHandler::NewL(CMessageHandler& aMessageHandler)
+ {
+ CResponseHandler* self = new(ELeave) CResponseHandler(aMessageHandler);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+/**
+Destructor
+*/
+CResponseHandler::~CResponseHandler()
+ {
+ __FLOG(_L8("CResponseHandler::~CResponseHandler - Entry"));
+ iNotifyPtrName.Close();
+ __FLOG(_L8("CResponseHandler::~CResponseHandler - Exit"));
+ __FLOG_CLOSE;
+ }
+
+/**
+Handles any resopnse packet recieved from the mdns port
+@param response packet
+@return void
+*/
+void CResponseHandler::HandleIncomingPacketL(CDnsMessage& aMessage, const TSockAddr& /*aAddr*/)
+ {
+ __FLOG(_L8("CResponseHandler::HandleIncomingPacketL - Entry"));
+ iNotifyPtrName.Close();
+ // process the answer section, and add to the host and service caches
+ TInt aCount(aMessage.Header().AnswerCount());
+ const RPointerArray<CDnsResourceData>& answers = aMessage.Answers();
+ for (TInt i = 0; i < aCount; ++i)
+ {
+ HandlePacketAnswersL(answers[i]);
+ }
+ aCount = aMessage.Header().AdditionalRCount();
+ const RPointerArray<CDnsResourceData>& additional = aMessage.Additional();
+ for (TInt i = 0; i < aCount; ++i)
+ {
+ if(additional[i]!=NULL)
+ HandlePacketAnswersL(additional[i]);
+ }
+ aCount = aMessage.Header().AuthorityNSCount();
+ const RPointerArray<CDnsResourceData>& authoritative = aMessage.Authorities();
+ for (TInt i = 0; i < aCount; ++i)
+ {
+ if(authoritative[i]!=NULL)
+ HandlePacketAnswersL(authoritative[i]);
+ }
+
+ if(iNotifyPtrName.Count() > 0 )
+ {
+ MessageHandler().NotifyNewServiceL(iNotifyPtrName);
+ for(TInt i=0 ; i<iNotifyPtrName.Count() ; i++)
+ {
+ iNotifyPtrName[i].Close();
+ }
+ iNotifyPtrName.Close();
+ }
+ __FLOG(_L8("CResponseHandler::HandleIncomingPacketL - Exit"));
+ }
+
+/*
+Constructor
+*/
+CResponseHandler::CResponseHandler(CMessageHandler& aMessageHandler):CBaseHandler(aMessageHandler)
+ {
+
+ }
+
+/**
+Two phasae constructor
+*/
+void CResponseHandler::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ __FLOG(_L8("CResponseHandler::ConstructL - Entry Exit"));
+ }
+/*
+ * Based on the type of query response recieved from the network.
+ * it will route the record to particular interface.
+ * @param aResourceData record recieved from the network.
+ */
+void CResponseHandler::HandlePacketAnswersL(CDnsResourceData* aResourceData)
+ {
+ __FLOG(_L8("CResponseHandler::HandlePacketAnswersL - Entry"));
+ switch(aResourceData->Type())
+ {
+ case EDnsType_A:
+ {
+ HandleAddrAnswersL(aResourceData);
+ break;
+ }
+
+ case EDnsType_PTR:
+ {
+ HandlePTRAnswersL(aResourceData);
+ break;
+ }
+
+ case EDnsType_TXT:
+ {
+ HandleTXTAnswersL(aResourceData);
+ break;
+ }
+
+ case EDnsType_AAAA:
+ {
+ HandleAAAAAnswersL(aResourceData);
+ //MessageHandler().DnsCache().Insert();
+ break;
+ }
+
+ case EDnsType_SRV:
+ {
+ HandleSRVAnswersL(aResourceData);
+ break;
+ }
+ }
+ __FLOG(_L8("CResponseHandler::HandlePacketAnswersL - Exit"));
+ }
+
+/**
+This handles any address content in the answer section .
+If the cache already contains a address entry with the same name .This will notify the server to change the name.
+If the cache doesnt contain the entry it will just add this entry in to it.
+@param aResourceData Contains the answers and nspackets recieved from the mdns port
+@param aEntry Reference to entry to which record should be added so as to add the same to cache later.
+@return void
+*/
+void CResponseHandler::HandleAddrAnswersL(CDnsResourceData* aResourceData)
+ {
+ __FLOG(_L8("CResponseHandler::HandleAddrAnswersL - Entry"));
+ CRdTypeA* addrRecord = static_cast<CRdTypeA*>(aResourceData);
+ CleanupStack::PushL(addrRecord);
+ TBufC8<100> domainName(addrRecord->Name());
+ RPointerArray<CCacheEntry> aCacheArray;
+ TBool isUpdated = EFalse;
+ TRAPD(error,MessageHandler().DnsCache().FindServiceL(aCacheArray,domainName,EDnsType_A));
+ if(error == KErrNone && 0 != aCacheArray.Count())
+ {
+ const CRdTypeA* addrRecordCEntry = (aCacheArray[0])->AddressRecord();
+ if(addrRecordCEntry != NULL && addrRecordCEntry->Name().Compare(domainName) == 0)
+ {
+ if(aCacheArray[0]->IsAuthoritative())
+ {
+ if(addrRecordCEntry->Address() != addrRecord->Address() && addrRecord->IsFlushBitSet())
+ {
+ MessageHandler().DnsCache().UpdateCacheL(*addrRecord,EFalse,0);
+ isUpdated = ETrue;
+ }
+ }
+ else
+ {
+ isUpdated = ETrue;
+ MessageHandler().DnsCache().UpdateCacheL(*addrRecord,EFalse,0);
+ }
+
+ }
+
+ }
+
+ if (! isUpdated&& 0 != aResourceData->Ttl())
+ {
+ // we didn't find it, add a new entry.
+ MessageHandler().DnsCache().UpdateCacheL(*addrRecord,EFalse,0);
+ }
+ aCacheArray.ResetAndDestroy();
+ aCacheArray.Close();
+ CleanupStack::Pop();//addrRecord
+ __FLOG(_L8("CResponseHandler::HandleAddrAnswersL - Exit"));
+ }
+
+/*
+ * Handles any PTR records in the answer section.
+ * 1.Updates the cache if not present .
+ * 2.Notitfies the client about the new service availability if registered for it.
+ * @param aResourceData ptr record recieved from the network.
+ */
+
+void CResponseHandler::HandlePTRAnswersL(CDnsResourceData* aResourceData)
+ {
+ __FLOG(_L8("CResponseHandler::HandlePTRAnswersL - Entry"));
+ CRdTypePtr* ptrEntry = static_cast<CRdTypePtr*>(aResourceData);
+ CleanupStack::PushL(ptrEntry);
+ TBufC8<100> name(ptrEntry->Name());
+ RPointerArray<CCacheEntry> aCacheArray;
+ MessageHandler().DnsCache().FindServiceL(aCacheArray,name,EDnsType_PTR);
+ TBool isUpdated = EFalse;
+ for (TInt i =0 ; i< aCacheArray.Count(); i++)
+ {
+ if(NULL != aCacheArray[i])
+ {
+ const CRdTypePtr* ptrRecord = aCacheArray[i]->PtrRecord();
+ if(ptrRecord->DomainName().CompareF(ptrEntry->DomainName()) == 0)
+ {
+ MessageHandler().DnsCache().UpdateCacheL(*ptrEntry,EFalse,0);
+ isUpdated = ETrue;
+ if(aResourceData->Ttl() == 0)
+ {
+ if(ptrEntry->DomainName().Find(ptrEntry->Name()) != KErrNotFound)
+ {
+ RBuf8 temp;
+ temp.CreateL(ptrEntry->DomainName());
+ if(iNotifyPtrName.Find(temp) == KErrNotFound)
+ {
+ iNotifyPtrName.AppendL(temp);
+ }
+ else
+ {
+ temp.Close();
+ }
+ }
+ CRdTypeSrv* srvRecord = static_cast <CRdTypeSrv*>( aCacheArray[i]->ServiceRecord());
+ if(srvRecord != NULL)
+ {
+ srvRecord->SetTtl(0);
+ MessageHandler().DnsCache().UpdateCacheL(*srvRecord,EFalse,0);
+ }
+ CRdTypeTxt* txtRecord = static_cast <CRdTypeTxt*> (aCacheArray[i]->TxtRecord());
+ if(txtRecord != NULL)
+ {
+ txtRecord->SetTtl(0);
+ MessageHandler().DnsCache().UpdateCacheL(*txtRecord,EFalse,0);
+ }
+ }
+
+ break;
+ }
+ }
+ }
+ if(!isUpdated && 0 != aResourceData->Ttl())
+ {
+ MessageHandler().DnsCache().UpdateCacheL(*ptrEntry,EFalse,0);
+ //Notify the client about new service
+ if(ptrEntry->DomainName().Find(ptrEntry->Name()) != KErrNotFound)
+ {
+ RBuf8 temp;
+ temp.CreateL(ptrEntry->DomainName());
+ if(iNotifyPtrName.Find(temp) == KErrNotFound)
+ {
+ iNotifyPtrName.AppendL(temp);
+ }
+ else
+ {
+ temp.Close();
+ }
+ }
+ }
+ aCacheArray.ResetAndDestroy();
+ aCacheArray.Close();
+ CleanupStack::Pop(ptrEntry);
+ __FLOG(_L8("CResponseHandler::HandlePTRAnswersL - Exit"));
+ }
+
+/*
+ * Handles any TXT records in the answer section.
+ * 1.Updates the cache if not present .
+ * @param aResourceData ptr record recieved from the network.
+ */
+void CResponseHandler::HandleTXTAnswersL(CDnsResourceData* aResourceData)
+ {
+ __FLOG(_L8("CResponseHandler::HandleTXTAnswersL - Entry"));
+ CRdTypeTxt* txtEntry = static_cast<CRdTypeTxt*>(aResourceData);
+ CleanupStack::PushL(txtEntry);
+ RPointerArray<CCacheEntry> aCacheArray;
+ TBool isUpdated = EFalse;
+ TRAPD(error,MessageHandler().DnsCache().FindServiceL(aCacheArray,txtEntry->Name(),EDnsType_TXT));
+ if(error == KErrNone && 0 != aCacheArray.Count() && NULL != aCacheArray[0]->TxtRecord())
+ {
+ const CRdTypeTxt* txtRecord = aCacheArray[0]->TxtRecord();
+ if(NULL != txtRecord && txtRecord->Name().CompareF(txtEntry->Name()) == 0)
+ {
+ if(aCacheArray[0]->IsAuthoritative())
+ {
+ isUpdated = ETrue;
+ MessageHandler().DnsCache().UpdateCacheL(*txtEntry,ETrue,0);
+ }
+ else
+ {
+ isUpdated = ETrue;
+ MessageHandler().DnsCache().UpdateCacheL(*txtEntry,EFalse,0);
+ }
+
+ }
+ }
+ if(!isUpdated && aResourceData->Ttl() != 0 )
+ {
+ MessageHandler().DnsCache().UpdateCacheL(*txtEntry,EFalse,0);
+ }
+ RBuf8 temp;
+ temp.CreateL(txtEntry->Name());
+ if(iNotifyPtrName.Find(temp) == KErrNotFound)
+ {
+ iNotifyPtrName.AppendL(temp);
+ }
+ else
+ {
+ temp.Close();
+ }
+ aCacheArray.ResetAndDestroy();
+ aCacheArray.Close();
+ CleanupStack::Pop();//txtEntry*/
+ __FLOG(_L8("CResponseHandler::HandleTXTAnswersL - Exit"));
+ }
+
+void CResponseHandler::HandleAAAAAnswersL(CDnsResourceData* /*aResourceData*/)
+ {
+
+ }
+
+/*
+ * Handles any SRV records in the answer section.
+ * 1.Updates the cache if not present .
+ * @param aResourceData ptr record recieved from the network.
+ */
+void CResponseHandler::HandleSRVAnswersL(CDnsResourceData* aResourceData)
+ {
+ __FLOG(_L8("CResponseHandler::HandleSRVAnswersL - Entry"));
+ CRdTypeSrv* srvEntry = static_cast<CRdTypeSrv*>(aResourceData);
+ CleanupStack::PushL(srvEntry);
+ RPointerArray<CCacheEntry> cacheArray;
+ TBool isUpdated = EFalse;
+ TRAPD(error,MessageHandler().DnsCache().FindServiceL(cacheArray,srvEntry->Name(),EDnsType_SRV));
+ if(KErrNone == error && cacheArray.Count() != 0 && NULL != cacheArray[0]->ServiceRecord())
+ {
+ const CRdTypeSrv* srvRecord = cacheArray[0]->ServiceRecord();
+ /*if(aResourceData->Ttl() == 0)
+ {
+ if(srvEntry->Name().Find(srvEntry->Target()) != KErrNotFound)
+ {
+ RBuf8 temp;
+ temp.CreateL(srvEntry->Name());
+ if(iNotifyPtrName.Find(temp) == KErrNotFound)
+ {
+ iNotifyPtrName.AppendL(temp);
+ }
+ else
+ {
+ temp.Close();
+ }
+ }
+ CRdTypeSrv* srvRecord = static_cast <CRdTypeSrv*>( cacheArray[i]->ServiceRecord());
+ if(srvRecord != NULL)
+ {
+ srvRecord->SetTtl(0);
+ MessageHandler().DnsCache().UpdateCacheL(*srvRecord,EFalse,0);
+ }
+ CRdTypeTxt* txtRecord = static_cast <CRdTypeTxt*> (aCacheArray[i]->TxtRecord());
+ if(txtRecord != NULL)
+ {
+ txtRecord->SetTtl(0);
+ MessageHandler().DnsCache().UpdateCacheL(*txtRecord,EFalse,0);
+ }
+ }*/
+
+ if(srvRecord->Name().CompareF(srvEntry->Name()) == 0 && srvEntry->IsFlushBitSet())
+ {
+ if(cacheArray[0]->IsAuthoritative())
+ {
+ isUpdated = ETrue;
+ MessageHandler().DnsCache().UpdateCacheL(*srvEntry,ETrue,0);
+ }
+ else
+ {
+ isUpdated = ETrue;
+ MessageHandler().DnsCache().UpdateCacheL(*srvEntry,EFalse,0);
+ }
+ }
+
+ }
+ RBuf8 temp;
+ temp.CreateL(srvEntry->Name());
+ if(iNotifyPtrName.Find(temp) == KErrNotFound)
+ {
+ iNotifyPtrName.AppendL(temp);
+ }
+ else
+ {
+ temp.Close();
+ }
+ if(!isUpdated && srvEntry->Ttl() != 0)
+ {
+ MessageHandler().DnsCache().UpdateCacheL(*srvEntry,EFalse,0);
+ }
+ cacheArray.ResetAndDestroy();
+ cacheArray.Close();
+ CleanupStack::Pop();//srvEntry
+ __FLOG(_L8("CResponseHandler::HandleSRVAnswersL - Exit"));
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/csendmessagequeue.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,338 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// csendmessagequeue.cpp
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+#include "f32file.h"
+
+#include "cmessagehandler.h"
+#include "csendmessagequeue.h"
+__FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
+/**
+Two phase constructor
+@param aDnsMessage Dns message to be sent
+@param aUnicast True if it is a unicast response
+@param aAddr address to which the packet to be send
+@return CSendMessageData object
+*/
+CSendMessageData* CSendMessageData::NewL(CDnsMessage* aDnsMessage, TBool aUnicast,TSockAddr aAddr,MMessageHandler& aCallback)
+ {
+ CSendMessageData* self = new(ELeave)CSendMessageData(aDnsMessage,aUnicast,aAddr,aCallback);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+/**
+Constant function which returns the reference to the Dns message object it wraps
+@return constant reference to dnsmessage object
+*/
+const CDnsMessage& CSendMessageData::GetDnsMessage()const
+ {
+ __FLOG(_L8("CSendMessageData::GetDnsMessage - Exit"));
+ return const_cast<CDnsMessage&> (*iMessage);
+ }
+
+/**
+Constant function which returns the address of the data to be sent
+@return Constant reference to the address
+*/
+const TSockAddr& CSendMessageData::GetSockAddress()const
+ {
+ __FLOG(_L8("CSendMessageData::GetSockAddress - Exit"));
+ return iSockAddr;
+ }
+
+/**
+Constant function which returns true if the message is unicast
+@return True if message is unicast
+*/
+const TBool& CSendMessageData::IsUnicast()const
+ {
+ __FLOG(_L8("CSendMessageData::IsUnicast - Exit"));
+ return iUnicast;
+ }
+/**
+Destructor
+*/
+CSendMessageData::~CSendMessageData()
+ {
+ __FLOG(_L8("CSendMessageData::~CSendMessageData - Entry"));
+ delete iMessage;
+ __FLOG(_L8("CSendMessageData::~CSendMessageData - Exit"));
+ __FLOG_CLOSE;
+ }
+
+/**
+Two phase constructor
+@param aDnsMessage DnsMessage to be send
+*/
+void CSendMessageData::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ }
+
+/**
+Constructor
+@param aUnicast True if it is a unicast response
+@param aAddr Address to which the data to be sent
+*/
+CSendMessageData::CSendMessageData(CDnsMessage* aDnsMessage,TBool aUnicast,TSockAddr aAddr,MMessageHandler& aCallback):iMessage(aDnsMessage),iUnicast(aUnicast),iSockAddr(aAddr),iCallback(aCallback)
+ {
+
+ }
+
+MMessageHandler& CSendMessageData::Callback()
+ {
+ __FLOG(_L8("CSendMessageData::Callback - Exit"));
+ return iCallback;
+ }
+/**
+Two phase Constructor
+@param aSocket reference to the RSocket
+*/
+CSendMessageQueue* CSendMessageQueue::NewL(RSocket& aSocket)
+ {
+ CSendMessageQueue* self = new (ELeave)CSendMessageQueue();
+ CleanupStack::PushL(self);
+ self->ConstructL(aSocket);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+/**
+Constructor
+*/
+CSendMessageQueue::CSendMessageQueue():CTimer(EPriorityStandard)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+/**
+Function derived from MSocketHandler Observer.
+This method will be called on succesfull sending of the packet.
+*/
+void CSendMessageQueue::OnCompletionL(TDesC8& /*aData*/, const TSockAddr& /*aAddr*/, TInt /*aLength*/)
+ {
+ __FLOG(_L8("CSendMessageQueue::OnCompletionL - Entry"));
+ if(iSendMessageData)
+ {
+ iIsSocketActive = EFalse;
+ iSendMessageData->Callback().OnPacketSendL(KErrNone);
+ }
+ delete iSendMessageData;
+ iSendMessageData = NULL;
+ if(iMessageQueue.Count() > 0 && !IsActive() )
+ {
+ StartTransmit();
+ }
+ __FLOG(_L8("CSendMessageQueue::OnCompletionL - Exit"));
+ }
+
+/*
+Function derived from MSocketHandler Observer.
+This method will be called on error in sending the packet.
+*/
+void CSendMessageQueue::OnError(TInt aError)
+ {
+ __FLOG(_L8("CSendMessageQueue::OnError - Entry"));
+ if(iSendMessageData)
+ {
+ iSendMessageData->Callback().OnPacketSendL(aError);
+ }
+ __FLOG(_L8("CSendMessageQueue::OnError - Exit"));
+ }
+
+/**
+Destructor
+*/
+CSendMessageQueue::~CSendMessageQueue()
+ {
+ __FLOG(_L8("CSendMessageQueue::~CSendMessageQueue - Entry"));
+ delete iSendSocket;
+ delete iSendMessageData;
+ iMessageQueue.ResetAndDestroy();
+ iMessageQueue.Close();
+ iOutput.Close();
+ __FLOG(_L8("CSendMessageQueue::~CSendMessageQueue - Exit"));
+ __FLOG_CLOSE;
+ }
+
+/**
+Two phase constructor
+@param refernce to RSocket
+*/
+void CSendMessageQueue::ConstructL(RSocket& aSocket)
+ {
+ __FLOG(_L8("CSendMessageQueue::ConstructL - Entry"));
+ iSendSocket = CSocketHandler::NewL(aSocket, *this, ESocketSend);
+ CTimer::ConstructL();
+ iIsSocketActive = EFalse;
+ __FLOG(_L8("CSendMessageQueue::ConstructL - Exit"));
+ }
+
+/**
+Derived from CActive
+*/
+void CSendMessageQueue::RunL()
+ {
+ __FLOG(_L8("CSendMessageQueue::RunL - Entry"));
+ if (MessageReady())
+ {
+ iSendMessageData = NextDnsMessageL();
+ CleanupStack::PushL(iSendMessageData);
+ const CDnsMessage& dnsMessage = iSendMessageData->GetDnsMessage();
+ // close the previously allocated memory.
+ iOutput.Close();
+ //composes the message from the Dnsmessage object .
+ CDnsMessageComposerParser* comPos = CDnsMessageComposerParser::NewL();
+ CleanupStack::PushL(comPos);
+ comPos->CreateMessageL(iOutput, iSendMessageData->GetDnsMessage());
+ TSocketHandlerParams param(ESocketSendTo,&iOutput,&(iSendMessageData->GetSockAddress()));
+ iSendSocket->Activate(param);
+ iIsSocketActive = ETrue;
+ CleanupStack::PopAndDestroy();//comPos
+ CleanupStack::Pop();
+ }
+ __FLOG(_L8("CSendMessageQueue::RunL - Exit"));
+ }
+/*
+ * Nothing to do.
+ */
+void CSendMessageQueue::DoCancel()
+ {
+ __FLOG(_L8("CSendMessageQueue::DoCancel - Exit"));
+ }
+
+void CSendMessageQueue::QueueDnsMessageL(const CSendMessageData& aMessageData)
+ {
+ __FLOG(_L8("CSendMessageQueue::QueueDnsMessageL - Entry"));
+ if (aMessageData.IsUnicast())
+ {
+ // Unicast replies are to be given higher priority .
+ // Insert the unicast response in the queue.
+ TInt count(iMessageQueue.Count());
+ TInt index(0);
+ for (; index < count; ++index)
+ {
+ if (!iMessageQueue[index]->IsUnicast())
+ {
+ break;
+ }
+ }
+ iMessageQueue.InsertL(&aMessageData, index);
+
+ iNextTransmit.HomeTime();
+ Cancel();
+ }
+ else
+ {
+ // Queue the packet
+ iMessageQueue.AppendL(&aMessageData);
+ }
+
+ // kick the transmit limiter, so we're sure the message will be sent
+ if(!iIsSocketActive)
+ {
+ NextTransmitTime(iNextTransmit);
+ }
+ __FLOG(_L8("CSendMessageQueue::QueueDnsMessageL - Exit"));
+ }
+
+void CSendMessageQueue::NextTransmitTime(TTime aTime)
+ {
+ __FLOG(_L8("CSendMessageQueue::NextTransmitTime - Entry"));
+ // if we aren't already active, set the next TX time
+ if (!IsActive())
+ {
+ TTime now;
+ now.HomeTime();
+
+ if (aTime > now)
+ {
+ At(aTime);
+ }
+ else
+ {
+ StartTransmit();
+ }
+ }
+ __FLOG(_L8("CSendMessageQueue::NextTransmitTime - Exit"));
+ }
+
+void CSendMessageQueue::StartTransmit()
+ {
+ __FLOG(_L8("CSendMessageQueue::StartTransmit - Entry"));
+ SetActive();
+ TRequestStatus *status = &iStatus;
+ User::RequestComplete(status,KErrNone);
+ __FLOG(_L8("CSendMessageQueue::StartTransmit - Exit"));
+ }
+
+CSendMessageData* CSendMessageQueue::NextDnsMessageL()
+ {
+ __FLOG(_L8("CSendMessageQueue::NextDnsMessageL - Entry"));
+ if (0 == iMessageQueue.Count())
+ {
+ User::Leave(KErrNotReady);
+ }
+
+ CSendMessageData* ret = iMessageQueue[0];
+ iMessageQueue.Remove(0);
+ // calculate the next possible transmit time.
+ iNextTransmit.HomeTime();
+ TInt delay = 20 + (Math::Rand(iRandomSeed) % 100);
+ iNextTransmit += TTimeIntervalMicroSeconds(delay * 1000);
+ __FLOG(_L8("CSendMessageQueue::NextDnsMessageL - Exit"));
+ return ret;
+ }
+
+TBool CSendMessageQueue::MessageReady()
+ {
+ __FLOG(_L8("CSendMessageQueue::MessageReady - Entry"));
+ TBool ready = EFalse;
+ if (0 != iMessageQueue.Count())
+ {
+ if (iMessageQueue[0]->IsUnicast())
+ {
+ // unicast messages go out straight away.
+ ready = ETrue;
+ }
+ else
+ {
+ TTime now;
+ now.HomeTime();
+ if (!IsActive())
+ {
+ if (now >= iNextTransmit)
+ {
+ ready = ETrue;
+ }
+ else
+ {
+ NextTransmitTime(iNextTransmit);
+ }
+ }
+ }
+ }
+ __FLOG(_L8("CSendMessageQueue::MessageReady - Exit"));
+ return ready;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/csockethandler.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,241 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// csockethandler.cpp
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+//User include
+#include "csockethandler.h"
+
+#include <mdns/cdnsmessagecomposerparser.h>
+#include <mdns/cdnsmessage.h>
+__FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
+/**
+Two-phase construction method
+@param aSocket Reference to RSocket
+@param aObserver Reference to MSocketHandlerObserver used to notify the client.
+@param aOperation TSocketOperation specfies the operation socket should perform.
+@return a pointer to the requested socket handler object
+*/
+
+CSocketHandler* CSocketHandler::NewL(RSocket& aSocket, MSocketHandlerObserver& aObserver, TSocketOperation aOperation)
+ {
+ CSocketHandler* self = new (ELeave)CSocketHandler(aSocket, aObserver, aOperation);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop();
+ return self;
+ }
+
+
+ /**
+ Destructor
+ */
+CSocketHandler::~CSocketHandler()
+ {
+ __FLOG(_L8("CSocketHandler::~CSocketHandler - Entry"));
+ Cancel();
+ delete iPacketBuffer;
+ __FLOG(_L8("CSocketHandler::~CSocketHandler - Exit"));
+ __FLOG_CLOSE;
+ }
+
+
+/**
+This to activate the socket to perform either send or recieve based on the operation set.
+@param aParams Reference to TSocketHandlerParams containing operation,packet and address
+@return void
+*/
+void CSocketHandler::Activate ( const TSocketHandlerParams& aParams )
+ {
+ __FLOG(_L8("CSocketHandler::Activate - Entry"));
+ iOperation = static_cast < TSocketOperation > ( aParams.iArgs[0] );
+ switch ( iOperation )
+ {
+ case ESocketSend:
+ {
+ iPacketPtr.Zero();
+ HBufC8* bufChain = reinterpret_cast < HBufC8* > ( aParams.iArgs[1] );
+ iLength = 0;
+ iSocket.Send(*bufChain, KDefaultFlags, iStatus, iLength );
+ }
+ break;
+
+ case ESocketSendTo:
+ {
+ iPacketPtr.Zero();
+ RBuf8* bufChain = reinterpret_cast < RBuf8* > ( aParams.iArgs[1] );
+ iSockAddr = *(reinterpret_cast < TSockAddr* > ( aParams.iArgs[2] ));
+ iLength = 0;
+ iSocket.SendTo ( *bufChain, iSockAddr, KDefaultFlags, iStatus, iLength );
+ }
+ break;
+
+ case ESocketRecieve:
+ {
+ iPacketPtr.Zero();
+ iSocket.Recv (iPacketPtr, KDefaultFlags, iStatus );
+ }
+ break;
+
+ case ESocketRecieveFrom:
+ {
+ iPacketPtr.Zero();
+ iSocket.RecvFrom ( iPacketPtr, iSockAddr, KDefaultFlags, iStatus );
+ }
+ break;
+
+ default:
+ User::Invariant ();
+ };
+
+ SetActive();
+ __FLOG(_L8("CSocketHandler::Activate - Exit"));
+ }
+/**
+
+*/
+void CSocketHandler::CompleteSelf ( TInt aError )
+ {
+ __FLOG(_L8("CSocketHandler::CompleteSelf - Entry"));
+ TRequestStatus* pStat = &iStatus;
+ User::RequestComplete ( pStat, aError );
+ SetActive ( );
+ __FLOG(_L8("CSocketHandler::CompleteSelf - Exit"));
+ }
+/**
+Constructor
+*/
+CSocketHandler::CSocketHandler(RSocket& aSocket, MSocketHandlerObserver& aObserver, TSocketOperation aOperation):CActive ( EPriorityNormal ),iSocket(aSocket),iObserver(aObserver),iOperation(aOperation),iPacketPtr(NULL,0)
+ {
+
+ }
+/**
+Constructs a heap to hold the packet of almost 9k size
+*/
+void CSocketHandler::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ __FLOG(_L8("CSocketHandler::ConstructL - Entry"));
+ // Allocate a 9K buffer to contain the biggest mDNS packet allowable
+ iPacketBuffer = HBufC8::NewL(KMaxDnsPacketSize);
+ iPacketPtr.Set(iPacketBuffer->Des());
+ CActiveScheduler::Add(this);
+ __FLOG(_L8("CSocketHandler::ConstructL - Exit"));
+ }
+
+/**
+cancels the current operation
+*/
+void CSocketHandler::CancelCurrent()
+ {
+ __FLOG(_L8("CSocketHandler::CancelCurrent - Entry"));
+ switch ( iOperation )
+ {
+ case ESocketSend:
+ case ESocketSendTo:
+ iSocket.CancelSend ();
+ break;
+
+ case ESocketRecieve:
+ case ESocketRecieveFrom:
+ iSocket.CancelRecv ();
+ break;
+
+ };
+ __FLOG(_L8("CSocketHandler::CancelCurrent - Exit"));
+ }
+/**
+Notifies the client with parameters based on the operation.
+a. Returns the packet and addres for recieve operation.
+b. returns only length of data send for send operation.
+*/
+void CSocketHandler::NotifyCompletionL( )
+ {
+ __FLOG(_L8("CSocketHandler::NotifyCompletionL - Entry"));
+ switch ( iOperation )
+ {
+ case ESocketSend:
+ {
+ iObserver.OnCompletionL(iPacketPtr,NULL,iLength());
+ break;
+ }
+
+ case ESocketSendTo:
+ {
+ iObserver.OnCompletionL(iPacketPtr,iSockAddr,iLength());
+ break;
+ }
+
+ case ESocketRecieve:
+ case ESocketRecieveFrom:
+ {
+
+ iObserver.OnCompletionL(iPacketPtr,iSockAddr,iLength());
+ break;
+ }
+
+ };
+ __FLOG(_L8("CSocketHandler::NotifyCompletionL - Exit"));
+ }
+/**
+Notifies the client after the send or recieve
+//Derived from CActive
+*/
+void CSocketHandler::RunL()
+ {
+ __FLOG(_L8("CSocketHandler::RunL - Entry"));
+ TInt err = iStatus.Int ();
+ if ( err == KErrNone )
+ {
+ NotifyCompletionL();
+ }
+ else
+ {
+ iObserver.OnError ( err );
+ }
+ __FLOG(_L8("CSocketHandler::RunL - Exit"));
+ }
+
+
+/**
+Derived from CActive
+Cancellation of an outstanding request.
+*/
+void CSocketHandler::DoCancel()
+ {
+ __FLOG(_L8("CSocketHandler::DoCancel - Entry"));
+ CancelCurrent ();
+ __FLOG(_L8("CSocketHandler::DoCancel - Exit"));
+ }
+
+
+
+/**
+Handles any leave from the RunL
+@param aError Error with which Runl leaves
+@return error
+*/
+TInt CSocketHandler::RunError(TInt /*aError*/)
+ {
+ __FLOG(_L8("CSocketHandler::RunError - Entry"));
+ //__ASSERT_DEBUG(aError,User::Invariant());
+ //Ignore any leave from RSocket
+ __FLOG(_L8("CSocketHandler::RunError - Exit"));
+ return KErrNone;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/mdns.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,57 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mdns.cpp
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+#include <e32base.h>
+#include <f32file.h>
+#include "mdnsserver.h"
+
+void MainL()
+ {
+
+ CActiveScheduler* sched = new (ELeave) CActiveScheduler;
+ CleanupStack::PushL(sched);
+ CActiveScheduler::Install(sched);
+
+ CMdnsServer::NewLC();
+ RProcess::Rendezvous(KErrNone);
+ CActiveScheduler::Start();
+
+
+
+ CleanupStack::PopAndDestroy();
+ CleanupStack::PopAndDestroy();
+
+ }
+
+TInt E32Main()
+ {
+ // --------- check memory leak -------------
+ __UHEAP_MARK;
+ CTrapCleanup* cleanup = CTrapCleanup::New();
+ TInt err = KErrNone;
+ if (cleanup)
+ {
+ TRAPD(err, MainL());
+ delete cleanup;
+ }
+ __UHEAP_MARKEND;
+ return err;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/mdnsserver.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,450 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mdnsserver.cpp
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+#include "mdnsserver.h"
+#include <commdbConnpref.h>
+#include "mdnsserversession.h"
+#include "shutdowntimer.h"
+#include "cmessagehandler.h"
+#include "cmdnscacheconsistencymgr.h"
+#include <mdns/cmdnsserverconstants.h>
+#include "cmdnsprobemanager.h"
+#include <nifman.h>
+#include <comms-infras/es_config.h>
+#include <EscapeUtils.h>
+#include <ecom/ECom.h>
+#include <btengsettings.h>// Console
+#include "cengsettingsobserver.h"
+__FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
+CMdnsServer* CMdnsServer::NewL()
+ {
+
+ CMdnsServer* self = CMdnsServer::NewLC();
+ CleanupStack::Pop(self);
+
+ return self;
+ }
+
+/*
+ * Two phase constructor
+ */
+CMdnsServer* CMdnsServer::NewLC()
+ {
+ CMdnsServer* self = new (ELeave) CMdnsServer;
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+ }
+
+/*
+ * Derived from CPolicy server
+ * Creates a new session object.
+ */
+CSession2* CMdnsServer::NewSessionL(const TVersion& /*aVersion*/, const RMessage2& /*aMessage*/) const
+ {
+ __FLOG(_L8("CMdnsServer::NewSessionL - Entry"));
+ // if we're in the process of shutting the server down cleanly,
+ // don't accept any more connections.
+ if (iShutdownInProgress)
+ {
+ User::Leave(KErrCouldNotConnect);
+ }
+
+ CMdnsServerSession* session = CMdnsServerSession::NewL(*this);
+ __FLOG(_L8("CMdnsServer::NewSessionL - Exit"));
+ return session;
+ }
+
+TInt CMdnsServer::NewSession()
+ {
+ __FLOG(_L8("CMdnsServer::NewSession - Entry"));
+ iShutdownTimer->Cancel();
+ ++iConnectionCount;
+ ++iSessionIdCounter;
+ __FLOG(_L8("CMdnsServer::NewSession - Exit"));
+ return iSessionIdCounter;
+ }
+
+void CMdnsServer::DropSession()
+ {
+ __FLOG(_L8("CMdnsServer::DropSession - Entry"));
+ if (0 == --iConnectionCount)
+ {
+ //CActiveScheduler::Stop();
+ iShutdownTimer->Start();
+ }
+ __FLOG(_L8("CMdnsServer::DropSession - Exit"));
+ }
+
+void CMdnsServer::BeginShutdownL()
+ {
+ __FLOG(_L8("CMdnsServer::BeginShutdownL - Entry"));
+ iShutdownInProgress = ETrue;
+ CActiveScheduler::Stop();
+ __FLOG(_L8("CMdnsServer::BeginShutdownL - Exit"));
+ }
+
+/*
+ * Destructor
+ */
+CMdnsServer::~CMdnsServer()
+ {
+ __FLOG(_L8("CMdnsServer::~CMdnsServer - Entry"));
+ iCacheConsistencyMgr->Stop();
+ delete iShutdownTimer;
+ delete iMessageHandler;
+ delete iProbeManager;
+ delete iInternalMessageQueue;
+ delete iCacheConsistencyMgr;
+ iConnection.Close();
+ iSockServ.Close();
+ iHostName.Close();
+ REComSession::FinalClose();
+ __FLOG(_L8("CMdnsServer::~CMdnsServer - Exit"));
+ __FLOG_CLOSE;
+ }
+
+CMdnsServer::CMdnsServer()
+ : CPolicyServer(EPriorityStandard, zeroconfPolicy),iConnectionCount(0),iSessionIdCounter(0)
+ {
+ }
+
+/*
+ * Get the system ipaddress by amaking a query to the dns.
+ * @param aAddr on return contains the address.
+ */
+TInt CMdnsServer::GetLocalHost ( TSockAddr& aAddr )
+ {
+ __FLOG(_L8("CMdnsServer::GetLocalHost - Entry"));
+ RSocket socket;
+ TInt err = socket.Open ( iSockServ, KAfInet, KSockStream, KProtocolInetTcp );
+
+ if ( err == KErrNone )
+ {
+ TInetAddr localHost;
+ localHost.SetAddress ( KInetAddrAny );
+ TPckgBuf<TSoInetIfQuery> query;
+ query ().iDstAddr = localHost;
+
+ err = socket.GetOpt ( KSoInetIfQueryByDstAddr, KSolInetIfQuery, query );
+
+ if ( err == KErrNone )
+ {
+ // its local IP address
+ localHost = query ().iSrcAddr;
+ aAddr = localHost;
+ TBuf<255>name ;
+ name.Append(query ().iName);
+ }
+ }
+
+ socket.Close ();
+ __FLOG(_L8("CMdnsServer::GetLocalHost - Exit"));
+ return err;
+ }
+
+/*
+ * Two phase constructor
+ */
+void CMdnsServer::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ __FLOG(_L8("CMdnsServer::ConstructL - Entry"));
+ User::LeaveIfError(iSockServ.Connect());
+ User::LeaveIfError(iConnection.Open(iSockServ));
+
+ // fetch the IAP from the command line
+ HBufC* iapBuf = HBufC::NewLC(User::CommandLineLength());
+ TPtr iapPtr = iapBuf->Des();
+ User::CommandLine(iapPtr);
+
+ TUint32 iap(0);
+ TLex lex(*iapBuf);
+ User::LeaveIfError(lex.Val(iap, EDecimal));
+
+ CleanupStack::PopAndDestroy(iapBuf);
+
+ // start a connection with the appropriate IAP
+ TCommDbConnPref prefs;
+ prefs.SetIapId(iap);
+ prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
+ User::LeaveIfError(iConnection.Start(prefs));
+
+ User::LeaveIfError(iSocket.Open(iSockServ, KAfInet, KSockDatagram, KProtocolInetUdp));
+ User::LeaveIfError(iSocket.SetLocalPort(KMdnsPort));
+ TInetAddr broadcast;
+ //To be added in constant header
+ const TUint32 KMDnsAddr = INET_ADDR(224, 0, 0, 251);
+ broadcast.SetAddress(KMDnsAddr);
+ JoinMulticastGroupL(broadcast);
+ iMessageHandler = CMessageHandler::NewL(*this);
+ iShutdownTimer = CShutdownTimer::NewL(*this);
+ /***************************************PROBE**************************************************/
+ //From here : Probe only for Host Name
+ iProbeManager = CMDNSProbeManager::NewL(iMessageHandler->DnsCache(),*iMessageHandler,ETrue);
+ TInetAddr addr;
+ GetLocalHost(addr);
+ //iHostName.Create(_L8("vadan.Local"));
+ CEngSettingsObserver* observer = CEngSettingsObserver::NewLC();
+
+ CBTEngSettings* btsettings= CBTEngSettings::NewL(observer);
+
+ RBuf name;
+ name.CreateL(64);
+ btsettings->GetLocalName(name);
+ if(name.Length()==0)
+ {
+ iHostName.CreateL(_L8("MyNokiaPhone.Local"));
+ }
+ else
+ {
+ name.Append(_L(".local"));
+ iHostName.CreateL(name.Collapse());
+ }
+
+ iProbeManager->StartNameProbeL(iHostName,addr);
+ /*****************************************END**************************************************/
+ iInternalMessageQueue = CInternalMessageQueue::NewL(*this);
+ /*****************************************ConsistencyMgr***************************************/
+ iCacheConsistencyMgr = CMDNSCacheConsistencyMgr::NewL(ETrue,*iMessageHandler);
+ iCacheConsistencyMgr->Start();
+ // start up the server
+ StartL(KMdnsServerName);
+ __FLOG(_L8("CMdnsServer::ConstructL - Exit"));
+ }
+/*
+ * Interface to join the multicast group.
+ * @param aMulticastAddr specifies the multicast address to which it will join
+ * this is generally the mdns multicast address.
+ */
+void CMdnsServer::JoinMulticastGroupL(TInetAddr& aMulticastAddr)
+ {
+ __FLOG(_L8("CMdnsServer::JoinMulticastGroupL - Entry"));
+ TPckgBuf<TIp6Mreq> mReq;
+
+ if (aMulticastAddr.Family() != KAfInet6)
+ {
+ aMulticastAddr.ConvertToV4Mapped();
+ }
+
+ mReq().iAddr = aMulticastAddr.Ip6Address();
+ mReq().iInterface = 0;
+ User::LeaveIfError(iSocket.SetOpt(KSoIp6MulticastHops, KSolInetIp, 255));
+ User::LeaveIfError(iSocket.SetOpt(KSoIp6JoinGroup, KSolInetIp, mReq));
+ User::LeaveIfError(iSocket.SetOpt(KSoIp6MulticastLoop, KSolInetIp, 0));
+ __FLOG(_L8("CMdnsServer::JoinMulticastGroupL - Exit"));
+ }
+
+/*
+ * @return returns the reference to the socket.
+ */
+RSocket& CMdnsServer::Socket()
+ {
+ __FLOG(_L8("CMdnsServer::Socket -Entry Exit"));
+ return iSocket;
+ }
+/*
+ * returns the reference to messagehandler.
+ */
+CMessageHandler& CMdnsServer::MessageHandler()const
+ {
+ __FLOG(_L8("CMdnsServer::MessageHandler -Entry Exit"));
+ return *iMessageHandler;
+ }
+
+/*
+ * Query from the client should be served after a delay .If sent to the
+ * network. usually 120ms.
+ * Server will be notified with the same after the time elapses.
+ * @param aClientHandle session id which actually requested for the query .
+ *
+ * */
+void CMdnsServer::NotifyClientQuery(TInt aClientHandle)
+ {
+ __FLOG(_L8("CMdnsServer::NotifyClientQuery - Entry"));
+ iSessionIter.SetToFirst();
+ CSession2* session = NULL;
+ while (NULL != (session = iSessionIter++))
+ {
+ CMdnsServerSession* serverSession = static_cast<CMdnsServerSession*>(session);
+ if(serverSession->OutStandQueryClientHandle() == aClientHandle)
+ {
+ serverSession->SendResponseL();
+ }
+ }
+ __FLOG(_L8("CMdnsServer::NotifyClientQuery - Exit"));
+ }
+
+/*
+ * Returns the hostname with which it has been probed.
+ */
+TDesC8& CMdnsServer::HostName()const
+ {
+ __FLOG(_L8("CMdnsServer::HostName -Entry Exit"));
+ return (TDesC8&)iHostName;
+ }
+
+
+void CMdnsServer::SetHostNameL(const TDesC8& aName)
+ {
+ iHostName.Close();
+ iHostName.CreateL(aName);
+ }
+
+/*
+ * When a new service appears in the network.
+ * will be notified to the server using this.
+ * Server in turn looks for the session interested in the service and completes the asynchronous reuest.
+ */
+void CMdnsServer::NotifyNewServiceL(const RArray<RBuf8>& aName)
+ {
+ __FLOG(_L8("CMdnsServer::NotifyNewServiceL - Entry"));
+ iSessionIter.SetToFirst();
+ CSession2* session = NULL;
+ while (NULL != (session = iSessionIter++))
+ {
+ CMdnsServerSession* serverSession = static_cast<CMdnsServerSession*>(session);
+ serverSession->NewServiceL(aName);
+ }
+ __FLOG(_L8("CMdnsServer::NotifyNewServiceL - Exit"));
+ }
+
+/*
+ * After the service has been published succesfully.
+ * Server will be notified with this interface.
+ * @param aName name with which the service is published.
+ * @param aError result of submission.
+ * @param aSessionId session id of the client.
+ */
+void CMdnsServer::NotifyServicePublishL(const RBuf8& aName,TInt aError, TInt aSessionId)
+ {
+ __FLOG(_L8("CMdnsServer::NotifyServicePublishL - Entry"));
+ iSessionIter.SetToFirst();
+ CSession2* session = NULL;
+ while ((NULL != (session = iSessionIter++)) )
+ {
+ CMdnsServerSession* serverSession = static_cast<CMdnsServerSession*>(session);
+ if(serverSession->SessionId() == aSessionId)
+ {
+ serverSession->HandleServiceNameConflictL(aName,aError);
+ }
+ }
+ SetPublishingService(EFalse);
+ if(MessageQueue()->Count()>0)
+ {
+ MessageQueue()->StartProcessing();
+ }
+ __FLOG(_L8("CMdnsServer::NotifyServicePublishL - Exit"));
+ }
+
+/*
+ * This performs two tast.
+ * 1. Set the iIsHostprobing to ETrue if host probing is going on.
+ * 2. If Hostprobing is over it sees whether there are any pending queries or
+ * publish request . IF there are any it will start processing the same .
+ * @param aProbing true if host probing.
+ */
+void CMdnsServer::SetStateHostProbing(TBool aProbing)
+ {
+ __FLOG(_L8("CMdnsServer::SetStateHostProbing - Entry"));
+ iIsHostProbing = aProbing;
+ if(!aProbing && MessageQueue()->Count()>0)
+ {
+ MessageQueue()->StartProcessing();
+ }
+ __FLOG(_L8("CMdnsServer::SetStateHostProbing - Exit"));
+ }
+
+/*
+ * @return returns wheteher host probing is going on or not.
+ */
+TBool CMdnsServer::IsHostProbing()const
+ {
+ __FLOG(_L8("CMdnsServer::IsHostProbing - Exit"));
+ return iIsHostProbing;
+ }
+
+/*
+ * Starts any pending publish or query request in the queue.
+ * @param aMessage query or publish request.
+ * @param aType can be either publish or query.
+ * @param aSessionId session which requested .
+ */
+void CMdnsServer::ProcessQueuedMessage(const RMessage2& aMessage, const TMessageType aType,TInt aSessionId)
+ {
+ __FLOG(_L8("CMdnsServer::ProcessQueuedMessage - Entry"));
+ iSessionIter.SetToFirst();
+ CSession2* session = NULL;
+ while (NULL != (session = iSessionIter++))
+ {
+ CMdnsServerSession* serverSession = static_cast<CMdnsServerSession*>(session);
+ if(aSessionId == serverSession->SessionId())
+ {
+ switch(aType)
+ {
+ case EQueryMessage:
+ {
+ serverSession->ServiceQueryL(aMessage);
+ break;
+ }
+ case EPublishMessage:
+ {
+ serverSession->PublishL(aMessage);
+ break;
+ }
+ }
+ }
+ }
+ __FLOG(_L8("CMdnsServer::ProcessQueuedMessage - Exit"));
+ }
+
+/*
+ * Pointer to the internall message queue.
+ */
+CInternalMessageQueue* CMdnsServer::MessageQueue()
+ {
+ __FLOG(_L8("CMdnsServer::MessageQueue -Entry Exit"));
+ return iInternalMessageQueue;
+ }
+
+
+void CMdnsServer::OnPacketSendL(TInt /*aError*/)
+ {
+ // this is the call back after the bye-bye packet is sent.
+ // do nothing
+ __FLOG(_L8("CMdnsServer::OnPacketSendL -Entry Exit"));
+ }
+/*
+ * if publishing will be set to true.
+ * this is to halt any further publish , till the one undergoing gets over.
+ */
+void CMdnsServer::SetPublishingService(TBool aFlag)
+ {
+ __FLOG(_L8("CMdnsServer::SetPublishingService - Entry"));
+ iIsPublishing = aFlag;
+ __FLOG(_L8("CMdnsServer::SetPublishingService - Exit"));
+
+ }
+TBool CMdnsServer::IsPublishingService() const
+ {
+ __FLOG(_L8("CMdnsServer::IsPublishingService -Entry Exit"));
+ return iIsPublishing ;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/mdnsserversession.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,732 @@
+// Copyright (c) 2008-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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// mdnsserversession.cpp
+//
+//
+/**
+@file
+@internalTechnology
+*/
+
+#include "mdnsserversession.h"
+#include <s32mem.h>
+#include <utf.h>
+#include "mdnsserver.h"
+#include <mdns/cmdnsserverconstants.h>
+#include <f32file.h>
+__FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
+/*
+ * Two phase constructor.
+ */
+CMdnsServerSession* CMdnsServerSession::NewL(const CMdnsServer& aServer)
+ {
+ CMdnsServerSession* self = CMdnsServerSession::NewLC(aServer);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+
+/*
+ * Two phase constructor
+ * @param aServer reference to the server.
+ */
+CMdnsServerSession* CMdnsServerSession::NewLC(const CMdnsServer& aServer)
+ {
+ CMdnsServerSession* self = new (ELeave) CMdnsServerSession(aServer);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ return self;
+ }
+
+/*
+ * @param aMessage RMessage object.
+ */
+void CMdnsServerSession::ServiceL(const RMessage2& aMessage)
+ {
+ __FLOG(_L8("CMdnsServerSession::ServiceL - Entry"));
+ switch (aMessage.Function())
+ {
+ case EZeroconfServerMessageVersion:
+ break;
+
+ case EMdnsServerQueryMessages:
+ {
+ if(NULL != iClientQuery.Handle())
+ {
+ aMessage.Complete(KErrInUse);
+ }
+ else if (iServer.IsHostProbing() )
+ {
+ iServer.MessageQueue()->AppendMessageL(EQueryMessage,aMessage,SessionId());
+ }
+ else
+ {
+ ServiceQueryL(aMessage);
+ }
+ }
+ break;
+
+ case EMdnsServerRecieveMessages:
+ {
+ HBufC8* buffer = HBufC8::NewLC(KDnsBufferlength);
+ TPtr8 bufferPointer(buffer->Des());
+ iResponseBundle.Store(bufferPointer);
+ aMessage.Write(0,bufferPointer);
+ CleanupStack::PopAndDestroy();//delete buffer
+ aMessage.Complete(KErrNone);
+ iResponseBundle.Close();
+ }
+ break;
+
+ case EMndsServerPublishMessages:
+ {
+ if( iServer.IsHostProbing() || iServer.IsPublishingService())
+ {
+ iServer.MessageQueue()->AppendMessageL(EPublishMessage,aMessage,SessionId());
+ }
+ else
+ {
+ iServer.SetPublishingService(ETrue);
+ PublishL(aMessage);
+ }
+ break;
+ }
+ case EMdnsServerStartNotifyMessages:
+ {
+ RegisterNotifyL(aMessage);
+ aMessage.Complete(KErrNone);
+ break;
+ }
+
+ case EMdnsServerStopNotifyMessages:
+ {
+ StopNotifyL(aMessage);
+ aMessage.Complete(KErrNone);
+ break;
+ }
+
+ case EMdnsServerRecieveNotifyMessages:
+ {
+ iNotifyMessageRequest = aMessage;
+ break;
+ }
+ default:
+ User::Leave(KErrUnknown);
+ break;
+ }
+
+ __FLOG(_L8("CMdnsServerSession::ServiceL - Exit"));
+ }
+
+void CMdnsServerSession::ServiceError(const RMessage2& aMessage, TInt aError)
+ {
+ __FLOG(_L8("CMdnsServerSession::ServiceError - Entry Exit"));
+ aMessage.Complete(aError);
+ }
+
+
+
+void CMdnsServerSession::CleanUp()
+ {
+ __FLOG(_L8("CMdnsServerSession::CleanUp - Entry"));
+ // First thing is to send bye-bye packets to the services that we have published.
+
+ RPointerArray <CCacheEntry> cacheEntries;
+ iServer.MessageHandler().DnsCache().AuthoritativeEntriesL(cacheEntries);
+
+ for(TInt index =0; index < cacheEntries.Count();index++)
+ {
+ CCacheEntry* entry = cacheEntries[index];
+ if(entry->SessionId()==iSessionId)
+ {
+ // To filter out address records.
+ if(entry->ServiceRecord())
+ {
+
+ // found the entry to be deleted
+ if(entry->ServiceRecord())
+ entry->ServiceRecord()->SetTtl(0);
+ if(entry->TxtRecord())
+ entry->TxtRecord()->SetTtl(0);
+ if(entry->PtrRecord())
+ entry->PtrRecord()->SetTtl(0);
+
+ // delete the entry in the cache
+
+ // !!!!!! Assuming that the entry will always contain a srv record.
+ iServer.MessageHandler().DnsCache().DeleteEntryL(entry->ServiceRecord()->Name());
+
+ CDnsMessage* message = CDnsMessage::NewL(0,EFalse);
+ CleanupStack::PushL(message);
+
+ TDnsHeader header(message->Header());
+ header.SetAuthoritative(ETrue);
+ message->SetHeader(header);
+
+ if(entry->ServiceRecord())
+ message->AppendAnswerL(entry->ServiceRecord()->CloneL());
+ if(entry->PtrRecord())
+ message->AppendAnswerL(entry->PtrRecord()->CloneL());
+ if(entry->TxtRecord())
+ message->AppendAnswerL(entry->TxtRecord()->CloneL());
+
+ // bye-bye packet on the way to the network !!!
+ iServer.MessageHandler().SendQueryL(message,iServer);
+ CleanupStack::Pop(); //message
+ }
+
+ }
+ }
+
+
+ cacheEntries.ResetAndDestroy();
+ cacheEntries.Close();
+ __FLOG(_L8("CMdnsServerSession::CleanUp - Exit"));
+ }
+/*
+ * Destructor
+ */
+CMdnsServerSession::~CMdnsServerSession()
+ {
+ __FLOG(_L8("CMdnsServerSession::~CMdnsServerSession - Entry"));
+ CleanUp();
+ iQueryBundle.Close();
+ iResponseBundle.Close();
+ iServer.DropSession();
+ for(TInt i =0 ; i<iRegisterNotifyArray.Count();i++ )
+ {
+ iRegisterNotifyArray[i].Close();
+ }
+ iRegisterNotifyArray.Close();
+ __FLOG(_L8("CMdnsServerSession::~CMdnsServerSession - Exit"));
+ __FLOG_CLOSE;
+ }
+/*
+ * Constructor
+ */
+CMdnsServerSession::CMdnsServerSession(const CMdnsServer& aServer)
+ : iServer(const_cast<CMdnsServer&>(aServer))
+ {
+ iSessionId = iServer.NewSession();
+ }
+
+/*
+ * Two phase constructor
+ */
+void CMdnsServerSession::ConstructL()
+ {
+ __FLOG_OPEN(KMDNSSubsystem, KComponent);
+ }
+
+//TODO
+TInt CMdnsServerSession::CountResources()
+ {
+ return 3;
+ }
+
+void CMdnsServerSession::ServerVersionL(const RMessage2& aMessage)
+ {
+ __FLOG(_L8("CMdnsServerSession::ServerVersionL - Entry"));
+ TVersion mdnsServerVersion(0, 8, 0);
+ TPckgC<TVersion> pkg(mdnsServerVersion);
+ aMessage.WriteL(0, pkg);
+ aMessage.Complete(KErrNone);
+ __FLOG(_L8("CMdnsServerSession::ServerVersionL - Exit"));
+
+ }
+/*
+ * Service any query rom the client
+ */
+void CMdnsServerSession::ServiceQueryL(const RMessage2& aMessage)
+ {
+ __FLOG(_L8("CMdnsServerSession::ServiceQueryL - Entry"));
+ iQueryBundle.Close();
+ iClientQuery = aMessage;
+ TInt len = aMessage.GetDesLengthL(0);
+ HBufC8* query = HBufC8::NewLC(aMessage.GetDesLengthL(0));
+ TPtr8 loadPtr = query->Des();
+ aMessage.ReadL(0,loadPtr);
+ iQueryBundle.CreateL();
+ TInt retOnLoad = iQueryBundle.Load(loadPtr);
+ User::LeaveIfError(retOnLoad);
+ RParameterFamily pnpFamily = iQueryBundle.GetFamilyAtIndex(0);
+ TUint count = pnpFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
+ CDnsMessage* message = CDnsMessage::NewL(0,ETrue );
+ CleanupStack::PushL(message);
+ for ( TInt paramIndex = count - 1; paramIndex >= 0; paramIndex-- )
+ {
+ CMDnsQueryRequestParamSet* queryParam = static_cast<CMDnsQueryRequestParamSet*> (pnpFamily.GetParameterSetAtIndex ( paramIndex, RParameterFamily::ERequested ));
+ HBufC8* name = HBufC8::NewL(256);
+ CleanupStack::PushL(name);
+ TPtr8 ptrName(name->Des());
+ ptrName.Append(queryParam->InstanceName());
+ if(queryParam->InstanceName().Length() > 0)
+ {
+ ptrName.Append(_L8("."));
+ }
+ ptrName.Append(queryParam->ServiceType());
+ if(queryParam->QueryType() != EDnsType_A)
+ {
+ ptrName.Append(1 == queryParam->Protocol() ? KTcpProtocolType : KUdpProtocolType);
+ }
+ ptrName.Append(KLocalTld);
+ ptrName.Append(_L8("."));
+ CDnsQuestion* question = CDnsQuestion::NewL();
+ CleanupStack::PushL(question);
+ question->SetNameL(ptrName);
+ question->SetClass(EDnsClass_IN);
+ question->SetType(queryParam->QueryType());
+ question->SetUnicast(EFalse);
+ message->AppendQueryL(question);
+ CleanupStack::Pop();
+ CleanupStack::PopAndDestroy();//name
+ }
+ iServer.MessageHandler().ServiceClientQueryL(message,aMessage.Handle());
+ CleanupStack::Pop();//message
+ CleanupStack::PopAndDestroy();//query
+ __FLOG(_L8("CMdnsServerSession::ServiceQueryL - Exit"));
+ }
+
+TInt CMdnsServerSession::OutStandQueryClientHandle()const
+ {
+ return iClientQuery.Handle();
+ }
+
+void CMdnsServerSession::SendResponseL()
+ {
+ __FLOG(_L8("CMdnsServerSession::SendResponseL - Entry"));
+ RParameterFamily pnpFamily = iQueryBundle.GetFamilyAtIndex(0);
+ TUint count = pnpFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
+ //Open a new reference to ResponseBundle
+ iResponseBundle.Open ();
+ CleanupClosePushL( iResponseBundle );
+ for(TInt index =0 ;index <count ; index++)
+ {
+ CMDnsQueryRequestParamSet* queryParam = static_cast<CMDnsQueryRequestParamSet*> (pnpFamily.GetParameterSetAtIndex ( index, RParameterFamily::ERequested ));
+ HBufC8* name = HBufC8::NewL(KDnsBufferlength);
+ CleanupStack::PushL(name);
+ TPtr8 ptrName(name->Des());
+ ptrName.Append(queryParam->InstanceName());
+ if(queryParam->InstanceName().Size()>0)
+ ptrName.Append(_L8("."));
+ ptrName.Append(queryParam->ServiceType());
+ if(queryParam->QueryType() != EDnsType_A)
+ {
+ ptrName.Append(1 == queryParam->Protocol() ? KTcpProtocolType : KUdpProtocolType);
+ }
+ ptrName.Append(KLocalTld);
+ ptrName.Append(_L8("."));
+ RPointerArray<CCacheEntry> records;
+ iServer.MessageHandler().DnsCache().FindServiceL(records,ptrName,(TDnsType)queryParam->QueryType());
+ TInt count = records.Count();
+ switch((TDnsType)queryParam->QueryType())
+ {
+ case EDnsType_PTR:
+ {
+ RParameterFamily pnpFamily = iResponseBundle.CreateFamilyL (EMdnsPtrParamset);
+ while(count -- > 0 )
+ {
+ iResponseBundle.SetPnPObserver((MPnPObserver*)NULL);
+ CMDnsPtrParamSet* responseParam = CMDnsPtrParamSet::NewL(pnpFamily);
+ responseParam->SetInstanceNameL(records[count]->PtrRecord()->Name());
+ responseParam->SetDomainNameL(records[count]->PtrRecord()->DomainName());
+ //responseParam->SetTtlL(records[count]->PtrRecord()->Ttl());
+ }
+ break;
+ }
+ case EDnsType_SRV:
+ {
+ RParameterFamily pnpFamily = iResponseBundle.CreateFamilyL (EMdnsSrvParamset);
+ while(count -- > 0 )
+ {
+ iResponseBundle.SetPnPObserver((MPnPObserver*)NULL);
+ CMDnsSrvParamSet* responseParam = CMDnsSrvParamSet::NewL(pnpFamily);
+ responseParam->SetDomainNameL(records[count]->ServiceRecord()->Name());
+ responseParam->SetTargetL(records[count]->ServiceRecord()->Target());
+ responseParam->SetPriority(records[count]->ServiceRecord()->Priority());
+ responseParam->SetWeight(records[count]->ServiceRecord()->Weight());
+ responseParam->SetPort(records[count]->ServiceRecord()->Port());
+ }
+ break;
+ }
+ case EDnsType_TXT:
+ {
+ RParameterFamily pnpFamily = iResponseBundle.CreateFamilyL (EMdnsTxtParamset);
+ while(count -- > 0 )
+ {
+ iResponseBundle.SetPnPObserver((MPnPObserver*)NULL);
+ CMDnsTxtParamSet* responseParam = CMDnsTxtParamSet::NewL(pnpFamily);
+ responseParam->SetDomainNameL(records[count]->TxtRecord()->Name());
+ RArray<RBuf8> txtData = records[count]->TxtRecord()->Text();
+
+ for(TInt j=0;j<txtData.Count();j++)
+ {
+ responseParam->AppendTxtData(txtData[j]);
+ }
+ }
+ break;
+ }
+ case EDnsType_A:
+ {
+ RParameterFamily pnpFamily = iResponseBundle.CreateFamilyL (EMdnsAddrParamset);
+ while(count -- > 0 )
+ {
+ iResponseBundle.SetPnPObserver((MPnPObserver*)NULL);
+ CMDnsAddrParamSet* responseParam = CMDnsAddrParamSet::NewL(pnpFamily);
+ responseParam->SetDomainNameL(records[count]->AddressRecord()->Name());
+ responseParam->SetAddress(records[count]->AddressRecord()->Address());
+ }
+ break;
+ }
+ case EDnsQType_Any:
+ {
+ iResponseBundle.SetPnPObserver((MPnPObserver*)NULL);
+ while(count -- > 0 )
+ {
+ CreateAnyQueryResponseL(*records[count]);
+ }
+ break;
+ }
+
+ }
+ records.ResetAndDestroy();
+ records.Close();
+ CleanupStack::PopAndDestroy();//name
+ }//end of for loop
+
+ HBufC8* buffer = HBufC8::NewLC(KDnsBufferlength);
+ TPtr8 bufferPointer(buffer->Des());
+ iResponseBundle.Store(bufferPointer);
+ TInt len = bufferPointer.Length();
+ TPckgC<TInt> lenbuf(len);
+ iClientQuery.Write(1,lenbuf);
+ CleanupStack::PopAndDestroy();//buffer
+ iClientQuery.Complete(KErrNone);
+ CleanupStack::Pop();//iResponseBundle
+ __FLOG(_L8("CMdnsServerSession::SendResponseL - Exit"));
+ }
+
+void CMdnsServerSession::PublishL(const RMessage2& aMessage)
+ {
+ __FLOG(_L8("CMdnsServerSession::PublishL - Entry"));
+ TBool isUpdate = aMessage.Int2();
+ iPublishRequest = aMessage;
+ TInt len = aMessage.GetDesLengthL(0);
+ HBufC8* query = HBufC8::NewLC(aMessage.GetDesLengthL(0));
+ TPtr8 loadPtr = query->Des();
+ aMessage.ReadL(0,loadPtr);
+ iPublishBundle.CreateL();
+ TInt retOnLoad = iPublishBundle.Load(loadPtr);
+ TInt familyCount = iPublishBundle.CountParameterFamilies();
+ RPointerArray<CDnsResourceData> publishRecordArray;
+ for(TInt i =0 ; i< familyCount; i++)
+ {
+ RParameterFamily pnpFamily = iPublishBundle.GetFamilyAtIndex(i);
+ switch (pnpFamily.Id())
+ {
+ case EMdnsSrvParamset:
+ {
+ TUint count = pnpFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
+ for (TInt index= 0; index < count ; index++ )
+ {
+ CMDnsSrvParamSet* srvParamSet = static_cast<CMDnsSrvParamSet*> (pnpFamily.GetParameterSetAtIndex ( index, RParameterFamily::ERequested ));
+ CRdTypeSrv* srvRecord = CRdTypeSrv::NewL();
+ CleanupStack::PushL(srvRecord);
+ srvRecord->SetNameL(srvParamSet->DomainName());
+ srvRecord->SetClass(EDnsClass_IN);
+ srvRecord->SetFlushBit(EFalse);
+ srvRecord->SetPort(srvParamSet->Port());
+ srvRecord->SetPriority(srvParamSet->Priority() );
+ srvRecord->SetTargetL(iServer.HostName());
+ srvRecord->SetTtl(120);
+ srvRecord->SetType(EDnsType_SRV);
+ srvRecord->SetWeight(srvParamSet->Weight());
+ publishRecordArray.AppendL(srvRecord);
+ CleanupStack::Pop();//CRdtypeSrv
+ //Ptr Record
+ /*
+ CRdTypePtr* ptrRecord = CRdTypePtr::NewL();
+ CleanupStack::PushL(ptrRecord);
+ TInt pos = srvParamSet->DomainName().Locate('.');
+ ptrRecord->SetNameL(srvParamSet->DomainName().Mid(pos+1));
+ ptrRecord->SetClass(EDnsClass_IN);
+ ptrRecord->SetFlushBit(EFalse);
+ ptrRecord->SetTtl(120);
+ ptrRecord->SetType(EDnsType_PTR);
+ ptrRecord->SetDomainNameL(srvParamSet->DomainName());
+ publishRecordArray.AppendL(ptrRecord);
+ CleanupStack::Pop();
+ */
+ }
+ break;
+ }
+ case EMdnsPtrParamset:
+ {
+ //do nothing
+ TUint count = pnpFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
+ for (TInt index= 0; index < count ; index++ )
+ {
+ CMDnsPtrParamSet* ptrParamSet = static_cast<CMDnsPtrParamSet*>(pnpFamily.GetParameterSetAtIndex( index, RParameterFamily::ERequested ));
+ CRdTypePtr* ptrRecord = CRdTypePtr::NewL();
+ CleanupStack::PushL(ptrRecord);
+ ptrRecord->SetNameL(ptrParamSet->InstanceName());
+ ptrRecord->SetClass(EDnsClass_IN);
+ ptrRecord->SetFlushBit(EFalse);
+ ptrRecord->SetTtl(120);
+ ptrRecord->SetType(EDnsType_PTR);
+ ptrRecord->SetDomainNameL(ptrParamSet->DomainName());
+ publishRecordArray.AppendL(ptrRecord);
+ CleanupStack::Pop();//Remove Ptr Record from the queue..
+ }
+ break;
+ }
+ case EMdnsAddrParamset:
+ {
+ TUint count = pnpFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
+ for (TInt index= 0; index < count ; index++ )
+ {
+ CMDnsAddrParamSet* addrParamSet = static_cast<CMDnsAddrParamSet*>(pnpFamily.GetParameterSetAtIndex( index, RParameterFamily::ERequested ));
+ CRdTypeA* addrRecord = CRdTypeA::NewL();
+ CleanupStack::PushL(addrRecord);
+ addrRecord->SetAddr(addrParamSet->Address());
+ addrRecord->SetNameL(addrParamSet->DomainName());
+ addrRecord->SetClass(EDnsClass_IN);
+ addrRecord->SetFlushBit(EFalse);
+ addrRecord->SetTtl(120);
+ addrRecord->SetType(EDnsType_A);
+ publishRecordArray.AppendL(addrRecord);
+ CleanupStack::Pop();//remove addrecord from the queue
+ }
+ break;
+ }
+ case EMdnsTxtParamset:
+ {
+ TUint count = pnpFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
+ for (TInt index= 0; index < count ; index++ )
+ {
+ CMDnsTxtParamSet* txtParamSet = static_cast<CMDnsTxtParamSet*>(pnpFamily.GetParameterSetAtIndex( index, RParameterFamily::ERequested ));
+ CRdTypeTxt* txtRecord = CRdTypeTxt::NewL();
+ CleanupStack::PushL(txtRecord);
+ txtRecord->SetNameL(txtParamSet->DomainName());
+ txtRecord->SetClass(EDnsClass_IN);
+ txtRecord->SetFlushBit(EFalse);
+ txtRecord->SetTtl(120);
+ txtRecord->SetType(EDnsType_TXT);
+ RArray<RBuf8> txtArray ;
+ txtParamSet->TxtDataL(txtArray);
+ TInt txtCnt = txtArray.Count();
+ for(TInt count = 0; count < txtCnt ; count ++ )
+ {
+ txtRecord->AppendTextDataL(txtArray[count]);
+ }
+ txtArray.Close();
+ publishRecordArray.AppendL(txtRecord);
+ CleanupStack::Pop();//remove txtRecord from the queue..
+ }
+ break;
+ }
+ }
+
+ }
+ TRAPD(publishError ,iServer.MessageHandler().AdvertizePacketL(publishRecordArray,iSessionId , isUpdate));
+ if(publishError == KErrNotFound)
+ {
+ aMessage.Complete(KErrNotFound);
+ }
+ publishRecordArray.Close();
+ iPublishBundle.Close();
+ CleanupStack::PopAndDestroy(query);
+ __FLOG(_L8("CMdnsServerSession::PublishL - Exit"));
+ }
+
+void CMdnsServerSession::HandleServiceNameConflictL(const RBuf8& aName,TInt aError)
+ {
+ __FLOG(_L8("CMdnsServerSession::HandleServiceNameConflictL - Entry"));
+ iResponseBundle.Open ();
+ CleanupClosePushL( iResponseBundle );
+
+ RParameterFamily pnpFamily = iResponseBundle.CreateFamilyL (EMdnsPublishResponseParamset);
+ iResponseBundle.SetPnPObserver((MPnPObserver*)NULL);
+
+ CMDnsPublishResponseParamSet* responseParam = CMDnsPublishResponseParamSet::NewL(pnpFamily);
+ responseParam->SetDomainNameL(aName);
+ responseParam->SetError(aError);
+
+
+ TInt len = iResponseBundle.Length();
+ TPckgC<TInt> lenbuf(len);
+ iPublishRequest.Write(1,lenbuf);
+
+ iPublishRequest.Complete(KErrNone);
+ CleanupStack::Pop();//iResponseBundle
+ __FLOG(_L8("CMdnsServerSession::HandleServiceNameConflictL - Exit"));
+ }
+
+void CMdnsServerSession::RegisterNotifyL(const RMessage2& aMessage)
+ {
+ __FLOG(_L8("CMdnsServerSession::RegisterNotifyL - Entry"));
+ iIsNotifyRequested = ETrue;
+ RPnPParameterBundle registerBundle;
+ TInt size = aMessage.GetDesLength(0);
+ HBufC8* registerbuf = HBufC8::NewLC(aMessage.GetDesLengthL(0));
+ TPtr8 loadPtr = registerbuf->Des();
+ aMessage.ReadL(0,loadPtr);
+ registerBundle.CreateL();
+ registerBundle.Load(loadPtr);
+ RParameterFamily pnpFamily = registerBundle.GetFamilyAtIndex(0);
+ TUint count = pnpFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
+ for(TInt index =0 ; index<count ; index++)
+ {
+ CMDnsRegisterNotifyParamSet* registerParamSet = static_cast<CMDnsRegisterNotifyParamSet*>(pnpFamily.GetParameterSetAtIndex( index, RParameterFamily::ERequested ));
+ RBuf8 instanceName;
+ instanceName.CreateL(registerParamSet->InstanceName());
+ iRegisterNotifyArray.AppendL(instanceName);
+ }
+ registerBundle.Close();
+ CleanupStack::PopAndDestroy();//registerbuffer
+ __FLOG(_L8("CMdnsServerSession::RegisterNotifyL - Exit"));
+ }
+
+void CMdnsServerSession::StopNotifyL(const RMessage2& aMessage)
+ {
+ __FLOG(_L8("CMdnsServerSession::StopNotifyL - Entry"));
+ RPnPParameterBundle registerBundle;
+ TInt size = aMessage.GetDesLength(0);
+ HBufC8* registerbuf = HBufC8::NewLC(aMessage.GetDesLengthL(0));
+ TPtr8 loadPtr = registerbuf->Des();
+ aMessage.ReadL(0,loadPtr);
+ registerBundle.CreateL();
+ registerBundle.Load(loadPtr);
+ RParameterFamily pnpFamily = registerBundle.GetFamilyAtIndex(0);
+ TUint count = pnpFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
+ for(TInt index =0 ; index< count; index++)
+ {
+ CMDnsRegisterNotifyParamSet* registerParamSet = static_cast<CMDnsRegisterNotifyParamSet*>(pnpFamily.GetParameterSetAtIndex( index, RParameterFamily::ERequested ));
+ RBuf8 instanceName;
+ instanceName.CreateL(registerParamSet->InstanceName());
+ for(TInt i =0 ; i< iRegisterNotifyArray.Count();i++)
+ {
+ if(instanceName.Compare(iRegisterNotifyArray[i]) == 0)
+ {
+ RBuf8& temp = iRegisterNotifyArray[i];
+ iRegisterNotifyArray.Remove(i);
+ temp.Close();
+ }
+ }
+ instanceName.Close();
+ }
+ if(iRegisterNotifyArray.Count() == 0 )
+ {
+ iIsNotifyRequested =EFalse;
+ }
+ registerBundle.Close();
+ CleanupStack::PopAndDestroy();//registerbuffer
+ __FLOG(_L8("CMdnsServerSession::StopNotifyL - Exit"));
+ }
+
+TInt CMdnsServerSession::SessionId()
+ {
+ __FLOG(_L8("CMdnsServerSession::SessionId - Exit"));
+ return iSessionId;
+ }
+void CMdnsServerSession::NewServiceL(const RArray<RBuf8>& aName)
+ {
+ __FLOG(_L8("CMdnsServerSession::NewServiceL - Entry"));
+ if(iIsNotifyRequested && iNotifyMessageRequest.Handle())
+ {
+ RPnPParameterBundle publishBundle;
+ publishBundle.CreateL();
+ RParameterFamily pnpFamily = publishBundle.CreateFamilyL (EMdnsPtrParamset);
+ publishBundle.SetPnPObserver((MPnPObserver*)NULL);
+ for(TInt i =0 ; i < aName.Count();i++)
+ {
+ for(TInt j= 0 ; j< iRegisterNotifyArray.Count(); j++)
+ {
+ TInt pos = aName[i].Find(iRegisterNotifyArray[j]);
+ if(pos != KErrNotFound)
+ {
+ CMDnsPtrParamSet* responseParam = CMDnsPtrParamSet::NewL(pnpFamily);
+ responseParam->SetInstanceNameL(iRegisterNotifyArray[j]);
+ responseParam->SetDomainNameL(aName[i]);
+ // have to fill up the ttl field, query the cache
+ RPointerArray <CCacheEntry> aEntries;
+ iServer.MessageHandler().DnsCache().FindServiceL(aEntries,aName[i],EDnsType_SRV);
+ responseParam->SetTtlL(0);
+ if(aEntries.Count()==0)
+ {
+ // already deleted from cache
+ responseParam->SetTtlL(0);
+ }
+ else if(aEntries[0]->PtrRecord()!=NULL)
+ {
+ responseParam->SetTtlL(aEntries[0]->PtrRecord()->Ttl());
+ }
+ aEntries.ResetAndDestroy();
+ aEntries.Close();
+ break;
+ }
+ }
+ }
+ HBufC8* buffer = HBufC8::NewLC(KDnsBufferlength);
+ TPtr8 bufferPointer(buffer->Des());
+ publishBundle.Store(bufferPointer);
+ iNotifyMessageRequest.Write(0,bufferPointer);
+ iNotifyMessageRequest.Complete(KErrNone);
+ CleanupStack::PopAndDestroy(buffer);//buffer
+ publishBundle.Close();
+ }
+ __FLOG(_L8("CMdnsServerSession::NewServiceL - Exit"));
+ }
+
+
+void CMdnsServerSession::CreateAnyQueryResponseL(CCacheEntry& aEntry)
+ {
+ RParameterFamily ptrFamily = iResponseBundle.CreateFamilyL (EMdnsPtrParamset);
+ RParameterFamily srvFamily = iResponseBundle.CreateFamilyL (EMdnsSrvParamset);
+ RParameterFamily txtFamily = iResponseBundle.CreateFamilyL (EMdnsTxtParamset);
+ RParameterFamily AFamily = iResponseBundle.CreateFamilyL (EMdnsAddrParamset);
+ if(aEntry.AddressRecord()!= NULL)
+ {
+ CMDnsAddrParamSet* responseParam = CMDnsAddrParamSet::NewL(AFamily);
+ responseParam->SetDomainNameL(aEntry.AddressRecord()->Name());
+ responseParam->SetAddress(aEntry.AddressRecord()->Address());
+ }
+ if(aEntry.ServiceRecord()!= NULL)
+ {
+ CMDnsSrvParamSet* responseParam = CMDnsSrvParamSet::NewL(srvFamily);
+ responseParam->SetDomainNameL(aEntry.ServiceRecord()->Name());
+ responseParam->SetTargetL(aEntry.ServiceRecord()->Target());
+ responseParam->SetPriority(aEntry.ServiceRecord()->Priority());
+ responseParam->SetWeight(aEntry.ServiceRecord()->Weight());
+ responseParam->SetPort(aEntry.ServiceRecord()->Port());
+ }
+ if(aEntry.PtrRecord()!= NULL)
+ {
+ CMDnsPtrParamSet* responseParam = CMDnsPtrParamSet::NewL(ptrFamily);
+ responseParam->SetInstanceNameL(aEntry.PtrRecord()->Name());
+ responseParam->SetDomainNameL(aEntry.PtrRecord()->DomainName());
+ //responseParam->SetTtlL(aEntry.PtrRecord()->Ttl());
+ }
+ if(aEntry.TxtRecord()!= NULL)
+ {
+ CMDnsTxtParamSet* responseParam = CMDnsTxtParamSet::NewL(txtFamily);
+ responseParam->SetDomainNameL(aEntry.TxtRecord()->Name());
+ RArray<RBuf8> txtData = aEntry.TxtRecord()->Text();
+ for(TInt txtCount = 0 ;txtCount < txtData.Count();txtCount++)
+ {
+ responseParam->AppendTxtData(txtData[txtCount]);
+ }
+ }
+
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/server/src/shutdowntimer.cpp Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2008 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+/**
+@file
+@internalTechnology
+*/
+
+//User Include
+#include "shutdowntimer.h"
+#include "mdnsserver.h"
+__FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
+
+CShutdownTimer* CShutdownTimer::NewL(CMdnsServer& aServer)
+ {
+
+ CShutdownTimer* self = CShutdownTimer::NewLC(aServer);
+ CleanupStack::Pop(self);
+
+ return self;
+ }
+
+
+CShutdownTimer* CShutdownTimer::NewLC(CMdnsServer& aServer)
+ {
+
+ CShutdownTimer* self = new (ELeave) CShutdownTimer(aServer);
+ CleanupStack::PushL(self);
+ self->ConstructL();
+
+ return self;
+ }
+
+void CShutdownTimer::Start()
+ {
+ TTimeIntervalMicroSeconds32 interval(KShutdownDelay);
+ //After(interval);
+ After(1000000);
+ }
+
+
+void CShutdownTimer::RunL()
+ {
+ // tell the server to begin the shutdown process
+ iServer.BeginShutdownL();
+ }
+
+TInt CShutdownTimer::RunError(TInt /*aError*/)
+ {
+ CActiveScheduler::Stop();
+ return KErrNone;
+ }
+
+CShutdownTimer::CShutdownTimer(CMdnsServer& aServer)
+ : CTimer(EPriorityStandard), iServer(aServer)
+ {
+ CActiveScheduler::Add(this);
+ }
+
+CShutdownTimer::~CShutdownTimer()
+ {
+
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/sis/bonjour.pkg Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,37 @@
+;
+; Copyright (c) 2010 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"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+;Language - standard language definitions
+&EN
+
+; SIS file header
+#{"ZeroConf"},(0x2000D154),0,1,0
+
+;Localised Vendor name
+%{"Nokia"}
+
+;Unique Vendor name
+:"Nokia"
+
+;Supports Series 60
+[0x101F7961], *, *, *, {"Series60ProductID"}
+
+
+; reference files
+"\epoc32\release\armv5\urel\mdnscachemanager.dll" - "!:\Sys\Bin\mdnscachemanager.dll"
+"\epoc32\release\armv5\urel\dnsparser.dll" - "!:\Sys\Bin\dnsparser.dll"
+"\epoc32\release\armv5\urel\mdnsclient.dll" - "!:\Sys\Bin\mdnsclient.dll"
+"\epoc32\data\z\resource\plugins\mdnsclient.rsc" - "!:\resource\plugins\mdnsclient.rsc"
+"\epoc32\release\armv5\urel\zeroconf_20008AD8.exe" - "!:\Sys\Bin\zeroconf_20008AD8.exe"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/sis/distribution.policy.s60 Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/sis/rd-key.pem Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXAIBAAKBgQDLRF+r1FGGkCwTrb420kbnAps7gi1yYUcXYUdWeFTuBeQe5eW4
+6Y+LWaA8HMlDdoHRB0FgASisYcFagwno9+oFf4AJka4H1gWEs5XTGwAA1s0d8XGh
+7W7Dt9F5FZij8F7/9Pi6+FhhxZFIf1DD+yry9D7+Sp+BgdNALe4XOpf25QIBAwKB
+gQCHgupyjYuvCsgNHn7PNtnvVxInrB5MQNoPli+O+uNJWUK/Q+57Rl+yO8AoEzDX
+pFaLWiuVVhsdloDnAgabT/FXzYncs6uOHyEUV+dSXb78vtLPJqAX+Fg2i3hOXreB
+yskcZ13/OsKVOu5wgrJkx2baZufkqMwOSytf5y9nwjEIKwJBAP+inobagVNrN62j
+KQva3cC+UN/6XnKdTc0CA6bHyLOaJoH1xiMwG/VS2PGjHI0tiSMNtLn/QPpHJ003
+iabGhdUCQQDLjp/9UjFT6K6CF66Chqf30pZXhx+GTSQZmv/gvZiMly7X9fX9BGX3
+2MbJohBC4yI21XKTbisWywkF73Hwh+TRAkEAqmxprzxWN5zPyRdwspHpKymLP/w+
+9xOJM1atGdqFzRFvAU6EF3Vn+OHl9my9s3OwwgkjJqorUYTE3iUGby8D4wJBAIe0
+aqjhdjfwdFa6dFcEb/qMZDpaFQQzbWZnVUB+ZbMPdI/5TqitmU/l2dvBYCyXbCSO
+TGJJcg8yBgP09qBamIsCQFL7j1tM0XPVQJQ89WpKCld7O9ORxRGVj1eG0tWijrH8
+mGbYh8SGCVoWV3vrKSS8GBrFVgQnqUaHuEdtM7tpCAQ=
+-----END RSA PRIVATE KEY-----
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/zeroconf/sis/rd.cer Thu Jun 24 19:09:47 2010 +0530
@@ -0,0 +1,17 @@
+-----BEGIN CERTIFICATE-----
+MIICzDCCAjWgAwIBAgIBADANBgkqhkiG9w0BAQUFADArMRAwDgYDVQQKEwdSRCBD
+ZXJ0MRcwFQYDVQQDEw5SRCBDZXJ0aWZpY2F0ZTAeFw0wNDExMTUxMjQyMDZaFw0z
+NzA5MjMxMjQyMDZaMCsxEDAOBgNVBAoTB1JEIENlcnQxFzAVBgNVBAMTDlJEIENl
+cnRpZmljYXRlMIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDLRF+r1FGGkCwT
+rb420kbnAps7gi1yYUcXYUdWeFTuBeQe5eW46Y+LWaA8HMlDdoHRB0FgASisYcFa
+gwno9+oFf4AJka4H1gWEs5XTGwAA1s0d8XGh7W7Dt9F5FZij8F7/9Pi6+FhhxZFI
+f1DD+yry9D7+Sp+BgdNALe4XOpf25QIBA6OCAQAwgf0wDAYDVR0TBAUwAwEB/zAL
+BgNVHQ8EBAMCAoQwHQYDVR0OBBYEFFi/kuGzxhVpjGxe9ZwlxC3fH9jFMFMGA1Ud
+IwRMMEqAFFi/kuGzxhVpjGxe9ZwlxC3fH9jFoS+kLTArMRAwDgYDVQQKEwdSRCBD
+ZXJ0MRcwFQYDVQQDEw5SRCBDZXJ0aWZpY2F0ZYIBADBsBgNVHSAEZTBjMGEGBFUd
+IAAwWTATBggrBgEFBQcCARYHaHR0cDovLzBCBggrBgEFBQcCAjA2GjRGb3IgUiZE
+IHVzYWdlIG9ubHkuIFRoaXMgY2VydGlmaWNhdGUgaXMgbm90IHRydXN0ZWQuMA0G
+CSqGSIb3DQEBBQUAA4GBAHGB4RQMAgBdeT2hxfOr6f2nA/dZm+M5yX5daUtZnET9
+Ed0A9sazLawfN2G1KFQT9kxEParAyoAkpbMAsRrnRz/9cM3OHgFm/NiKRnf50DpT
+7oCx0I/65mVD2kt+xXE62/Ii5KPnTufIkPi2uLvURCia1tTS8JmJ8dtxDGyQt8BR
+-----END CERTIFICATE-----