|
1 // Copyright (c) 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 // dnsserverconfig.h |
|
15 // Source file for the DNS Proxy client side implementation. |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 */ |
|
24 |
|
25 #include "dnsproxyclientconfigparams.h" |
|
26 #include "dnsproxyclient.h" |
|
27 |
|
28 // Runs client-side and starts the separate server process |
|
29 static TInt StartTheServer() |
|
30 { |
|
31 _LIT(KServerExecutableName,"DNSProxy.exe"); |
|
32 |
|
33 RProcess server; |
|
34 |
|
35 TInt err = server.Create(KServerExecutableName, KNullDesC); |
|
36 if (err != KErrNone) |
|
37 return err; |
|
38 |
|
39 TRequestStatus stat; |
|
40 server.Rendezvous(stat); |
|
41 if (stat!=KRequestPending) |
|
42 //abort startup |
|
43 server.Kill(0); |
|
44 else |
|
45 //logon OK - start the server |
|
46 server.Resume(); |
|
47 |
|
48 // wait for start or death |
|
49 User::WaitForRequest(stat); |
|
50 |
|
51 err = server.ExitType(); |
|
52 if (EExitPanic == err) |
|
53 err = KErrGeneral; |
|
54 else |
|
55 err = stat.Int(); |
|
56 |
|
57 // This is no longer needed |
|
58 server.Close(); |
|
59 return err; |
|
60 } |
|
61 |
|
62 |
|
63 EXPORT_C TInt RDNSClient::Connect() |
|
64 /** |
|
65 * This method is used to connect to the server |
|
66 * @return TInt |
|
67 * |
|
68 * @internalTechnology |
|
69 **/ |
|
70 { |
|
71 TInt retry=2; |
|
72 |
|
73 for (;;) |
|
74 { |
|
75 // Uses system-pool message slots |
|
76 TInt r=CreateSession(KServerName,TVersion(1,0,0)); |
|
77 if ( (KErrNotFound!=r) && (KErrServerTerminated!=r) ) |
|
78 return (r); |
|
79 if (--retry==0) |
|
80 return (r); |
|
81 r=StartTheServer(); |
|
82 if ( (KErrNone!=r) && (KErrAlreadyExists!=r) ) |
|
83 return (r); |
|
84 } |
|
85 } |
|
86 |
|
87 EXPORT_C void RDNSClient::ConfigureDnsProxyServer(const TDes8& aInfo, TRequestStatus& aStatus) |
|
88 /** |
|
89 * Client side message to configure DNS Proxy Server. |
|
90 * @param aInfo of type TDes8& which represents connection info |
|
91 * |
|
92 * @internalTechnology |
|
93 **/ |
|
94 { |
|
95 SendReceive(EProxyConfigure, TIpcArgs(&aInfo),aStatus); |
|
96 } |
|
97 |
|
98 /** |
|
99 * Client side message to Add dns db |
|
100 * @param aAddress of type TDes& which represents IP address of the connected hosts. |
|
101 * @param aName of type TDes& which represents host name of the connected hosts. |
|
102 * |
|
103 * @internalTechnology |
|
104 **/ |
|
105 EXPORT_C void RDNSClient::AddDbEntry(const TDes8& aHostName, const TDes& aIpAddress, TRequestStatus& aStatus) |
|
106 { |
|
107 SendReceive(EProxyAddDb,TIpcArgs(&aIpAddress,&aHostName),aStatus); |
|
108 } |
|
109 |
|
110 /** |
|
111 * Client side message to Remove dns db |
|
112 * @param aAddress of type TDes& which represents IP address of the connected hosts. |
|
113 * @param aName of type TDes& which represents host name of the connected hosts. |
|
114 * |
|
115 * @internalTechnology |
|
116 **/ |
|
117 EXPORT_C void RDNSClient::RemoveDbEntry(const TDes& aIpAddress, TRequestStatus& aStatus) |
|
118 { |
|
119 SendReceive(EProxyRemoveDb,TIpcArgs(&aIpAddress),aStatus); |
|
120 } |
|
121 |
|
122 EXPORT_C void RDNSClient::UpdateDomainName(const TDes8& aName, TRequestStatus& aStatus) |
|
123 /** |
|
124 * Client side message to set domain name in the Dns proxy server |
|
125 * @param aAddress of type TDes& which represents IP address of the connected hosts. |
|
126 * @param aName of type TDes& which represents host name of the connected hosts. |
|
127 * |
|
128 * @internalTechnology |
|
129 **/ |
|
130 { |
|
131 SendReceive(EProxyUpdateDomainName,TIpcArgs(&aName),aStatus); |
|
132 } |
|
133 |
|
134 EXPORT_C void RDNSClient::ConfigureUplinkInfo(const TDes8& aName, TRequestStatus& aStatus) |
|
135 /** |
|
136 * Client side message to set the Uplink information |
|
137 * @param aInfo of type TDes8& which represents connection info |
|
138 * |
|
139 * @internalTechnology |
|
140 **/ |
|
141 { |
|
142 SendReceive(EProxyConfigureUplink,TIpcArgs(&aName),aStatus); |
|
143 } |