14
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#ifndef CMDNSPROBEMANAGER_H_
|
|
18 |
#define CMDNSPROBEMANAGER_H_
|
|
19 |
|
|
20 |
#include <e32base.h>
|
|
21 |
#include <in_sock.h>
|
|
22 |
|
|
23 |
class CMDNSProbeManager : public CTimer
|
|
24 |
{
|
|
25 |
public:
|
|
26 |
|
|
27 |
/*Conflict can happen in 2 cases ,
|
|
28 |
* Case 1: When the Address Record (Type A) is inconsistent, i.e., same
|
|
29 |
* host name for different Ip addresses
|
|
30 |
* Case 2: When the Service Record (Type SRV), is conflicting, two hosts try to
|
|
31 |
* acquire the same service name with the same service type., and same
|
|
32 |
|
|
33 |
/*Case 1:To get Unique Host Name ; to handle Host name conflict,
|
|
34 |
* we need the acquired host name & IPAddress*/
|
|
35 |
static CMDNSProbeManager* NewL(RBuf& aHostName, TInetAddr aAddr);
|
|
36 |
static CMDNSProbeManager* NewLC(RBuf& aHostName, TInetAddr aAddr);
|
|
37 |
|
|
38 |
/*To get Unique Service Name; to handle service name conflict,
|
|
39 |
* we need acquired service name & host name*/
|
|
40 |
static CMDNSProbeManager* NewL(RBuf& aServiceName,RBuf& aHostName);
|
|
41 |
static CMDNSProbeManager* NewLC(RBuf& aServiceName,RBuf& aHostName);
|
|
42 |
|
|
43 |
~CMDNSProbeManager();
|
|
44 |
|
|
45 |
private:
|
|
46 |
|
|
47 |
void RunL();
|
|
48 |
TInt RunError(TInt aError);
|
|
49 |
|
|
50 |
private:
|
|
51 |
|
|
52 |
TBool CheckForUniqueness();
|
|
53 |
|
|
54 |
void DefensiveResponseReceived();//Get a unique name (DNS Label)
|
|
55 |
|
|
56 |
void SendProbeL(); //Probe for Unique name , Create Probe and Send
|
|
57 |
void SendAnnouncementL();//Send out Gratitous mDNS Announcement , Create Announcement and Send
|
|
58 |
void Schedule(); //Self-Complete, To be called when moved to Probe State.
|
|
59 |
|
|
60 |
void Delay(TUint32 aDelayTime/*In Milliseconds*/); //To introduce Delay between Probes.
|
|
61 |
|
|
62 |
CMDNSProbeManager (RBuf& aHostName, TInetAddr aAddr);
|
|
63 |
CMDNSProbeManager (RBuf& aServiceName,RBuf& aHostName);
|
|
64 |
void ConstructL();
|
|
65 |
|
|
66 |
private:
|
|
67 |
|
|
68 |
enum TProbeStates
|
|
69 |
{
|
|
70 |
EIdle,
|
|
71 |
EProbeBegin,
|
|
72 |
EProbeFirstUnicast,
|
|
73 |
EProbeSecondUnicast,
|
|
74 |
EProbeMulticast,
|
|
75 |
EProbeComplete,
|
|
76 |
EFirstAnnouncement,//First gratuitous mDNS announcement
|
|
77 |
ESecondAnnouncement//Second gratuitous mDNS announcement
|
|
78 |
};
|
|
79 |
|
|
80 |
|
|
81 |
TInetAddr iAddr;
|
|
82 |
|
|
83 |
TProbeStates iCurrentProbeState;
|
|
84 |
|
|
85 |
//MDNSCacheInterface* iCache;
|
|
86 |
|
|
87 |
};
|
|
88 |
|
|
89 |
#endif /*CMDNSPROBEMANAGER_H_*/
|