DnsProxyListener.h revision 007e987fee7e815e0c4bc820f434a632b7a69a9d
1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 17#ifndef _DNSPROXYLISTENER_H__ 18#define _DNSPROXYLISTENER_H__ 19 20#include <pthread.h> 21#include <sysutils/FrameworkListener.h> 22 23#include "NetdCommand.h" 24 25class DnsProxyListener : public FrameworkListener { 26public: 27 DnsProxyListener(); 28 virtual ~DnsProxyListener() {} 29 30private: 31 class GetAddrInfoCmd : public NetdCommand { 32 public: 33 GetAddrInfoCmd(); 34 virtual ~GetAddrInfoCmd() {} 35 int runCommand(SocketClient *c, int argc, char** argv); 36 }; 37 38 class GetAddrInfoHandler { 39 public: 40 // Note: All of host, service, and hints may be NULL 41 GetAddrInfoHandler(SocketClient *c, 42 char* host, 43 char* service, 44 struct addrinfo* hints) 45 : mClient(c), 46 mHost(host), 47 mService(service), 48 mHints(hints) {} 49 ~GetAddrInfoHandler(); 50 51 static void* threadStart(void* handler); 52 void start(); 53 54 private: 55 void run(); 56 pthread_t mThread; 57 SocketClient* mClient; // not owned 58 char* mHost; // owned 59 char* mService; // owned 60 struct addrinfo* mHints; // owned 61 }; 62}; 63 64#endif 65