2 * Copyright (C) 2010 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef _DNSPROXYLISTENER_H__
18 #define _DNSPROXYLISTENER_H__
20 #include <resolv_netid.h> // struct android_net_context
21 #include <sysutils/FrameworkListener.h>
23 #include "NetdCommand.h"
25 class NetworkController;
27 class DnsProxyListener : public FrameworkListener {
29 explicit DnsProxyListener(const NetworkController* netCtrl);
30 virtual ~DnsProxyListener() {}
33 const NetworkController *mNetCtrl;
34 class GetAddrInfoCmd : public NetdCommand {
36 GetAddrInfoCmd(const DnsProxyListener* dnsProxyListener);
37 virtual ~GetAddrInfoCmd() {}
38 int runCommand(SocketClient *c, int argc, char** argv);
40 const DnsProxyListener* mDnsProxyListener;
43 class GetAddrInfoHandler {
45 // Note: All of host, service, and hints may be NULL
46 GetAddrInfoHandler(SocketClient *c,
49 struct addrinfo* hints,
50 const struct android_net_context& netcontext);
51 ~GetAddrInfoHandler();
53 static void* threadStart(void* handler);
58 SocketClient* mClient; // ref counted
60 char* mService; // owned
61 struct addrinfo* mHints; // owned
62 struct android_net_context mNetContext;
65 /* ------ gethostbyname ------*/
66 class GetHostByNameCmd : public NetdCommand {
68 GetHostByNameCmd(const DnsProxyListener* dnsProxyListener);
69 virtual ~GetHostByNameCmd() {}
70 int runCommand(SocketClient *c, int argc, char** argv);
72 const DnsProxyListener* mDnsProxyListener;
75 class GetHostByNameHandler {
77 GetHostByNameHandler(SocketClient *c,
82 ~GetHostByNameHandler();
83 static void* threadStart(void* handler);
87 SocketClient* mClient; //ref counted
94 /* ------ gethostbyaddr ------*/
95 class GetHostByAddrCmd : public NetdCommand {
97 GetHostByAddrCmd(const DnsProxyListener* dnsProxyListener);
98 virtual ~GetHostByAddrCmd() {}
99 int runCommand(SocketClient *c, int argc, char** argv);
101 const DnsProxyListener* mDnsProxyListener;
104 class GetHostByAddrHandler {
106 GetHostByAddrHandler(SocketClient *c,
112 ~GetHostByAddrHandler();
114 static void* threadStart(void* handler);
119 SocketClient* mClient; // ref counted
120 void* mAddress; // address to lookup; owned
121 int mAddressLen; // length of address to look up
122 int mAddressFamily; // address family