|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // cmdnsprobemanager.h |
|
15 // |
|
16 // |
|
17 #ifndef CMDNSPROBEMANAGER_H_ |
|
18 #define CMDNSPROBEMANAGER_H_ |
|
19 |
|
20 #include <e32base.h> |
|
21 #include <in_sock.h> |
|
22 #include "mdnscachemgr.h" |
|
23 #include "cmessagehandler.h" |
|
24 #include "mmessagehandler.h" |
|
25 #include "mdnsdebug.h" |
|
26 |
|
27 const TUint32 KProbeDelay = 250; |
|
28 |
|
29 const TUint32 KMaxFailures = 15; |
|
30 |
|
31 const TUint16 KMaxLength = 255; |
|
32 |
|
33 /*Maximum Length allocated for the service name part of the ServiceInstanceName |
|
34 excluding the service type*/ |
|
35 const TUint16 KMaxNameLength = 128; |
|
36 enum TConflictResolveState |
|
37 { |
|
38 ESuccess=0, |
|
39 EConflictWithAutoReslove, |
|
40 EConflictWithoutAutoResolve, |
|
41 EFail, |
|
42 }; |
|
43 enum TProbeStates |
|
44 { |
|
45 EIdle, |
|
46 EStart, |
|
47 EProbeBegin, |
|
48 EProbeFirstUnicast, |
|
49 EProbeSecondUnicast, |
|
50 EProbeMulticast, |
|
51 EProbeComplete, |
|
52 EFirstAnnouncement,//First gratuitous mDNS announcement |
|
53 ESecondAnnouncement//Second gratuitous mDNS announcement |
|
54 }; |
|
55 |
|
56 class CMDNSProbeManager : public CTimer,public MMessageHandler |
|
57 { |
|
58 public: |
|
59 |
|
60 /*Probe Handler to probe for Unique Host Name*/ |
|
61 static CMDNSProbeManager* NewL(MDNSCacheMgr& aCache,CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled); |
|
62 /*Probe Handler to probe for Service Instance Name*/ |
|
63 static CMDNSProbeManager* NewLC(MDNSCacheMgr& aCache,CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled); |
|
64 |
|
65 ~CMDNSProbeManager(); |
|
66 |
|
67 //From MMessageHandler |
|
68 void OnPacketSendL(TInt aError); |
|
69 |
|
70 |
|
71 TInt StartNameProbeL(const TDesC8&aHostName,TInetAddr aAddr); |
|
72 TInt StartServiceProbeL(const TDesC8& aServiceName,const TDesC8& aTargetMachine,TUint16 aPort); |
|
73 |
|
74 //Called if Auto Resolve Enabled,Probe Manager would have obtained new name |
|
75 const TDesC8& GetUniqueName(); |
|
76 |
|
77 private: |
|
78 |
|
79 void RunL(); |
|
80 TInt RunError(TInt aError); |
|
81 |
|
82 private: |
|
83 |
|
84 CRdTypeA* FormAddressRecordL(); |
|
85 CRdTypeSrv* FormServiceRecordL(); |
|
86 |
|
87 void InsertInCache(); |
|
88 |
|
89 TInt GenerateNonConflictingName(); |
|
90 |
|
91 TBool DefensiveResponseL();//Get a unique name (DNS Label) |
|
92 |
|
93 void Schedule(); |
|
94 |
|
95 void SendProbeL(TBool aUnicast); //Probe for Unique name , Create Probe and Send |
|
96 void SendAnnouncementL();//Send out Gratitous mDNS Announcement , Create Announcement and Send |
|
97 |
|
98 CMDNSProbeManager (MDNSCacheMgr& aCache,CMessageHandler& aMessageHandler,TBool aAutoResolveEnabled); |
|
99 |
|
100 void ConstructL(); |
|
101 |
|
102 |
|
103 private: |
|
104 |
|
105 |
|
106 |
|
107 TProbeStates iCurrentProbeState; |
|
108 TConflictResolveState iConflict; |
|
109 |
|
110 TInt iProbeCounter; |
|
111 |
|
112 MDNSCacheMgr& iCache; |
|
113 |
|
114 TBool iAutoResolveEnabled; |
|
115 |
|
116 CMessageHandler& iMessageHandler; |
|
117 |
|
118 TDnsType iType; |
|
119 RBuf8 iName; |
|
120 RBuf8 iProbeName; |
|
121 RBuf8 iProbeType; |
|
122 TInetAddr iAddr; |
|
123 TUint16 iPort; |
|
124 RBuf8 iTarget; |
|
125 /** |
|
126 *FLOGGER debug trace member variable. |
|
127 */ |
|
128 __FLOG_DECLARATION_MEMBER_MUTABLE; |
|
129 |
|
130 }; |
|
131 |
|
132 #endif /*CMDNSPROBEMANAGER_H_*/ |