#ifndef _DNSPROXYLISTENER_H__
#define _DNSPROXYLISTENER_H__
-#include <pthread.h>
#include <sysutils/FrameworkListener.h>
#include "NetdCommand.h"
GetAddrInfoHandler(SocketClient *c,
char* host,
char* service,
- struct addrinfo* hints)
+ struct addrinfo* hints,
+ char* iface,
+ int pid)
: mClient(c),
mHost(host),
mService(service),
- mHints(hints) {}
+ mHints(hints),
+ mIface(iface),
+ mPid(pid) {}
~GetAddrInfoHandler();
static void* threadStart(void* handler);
private:
void run();
- pthread_t mThread;
SocketClient* mClient; // ref counted
char* mHost; // owned
char* mService; // owned
struct addrinfo* mHints; // owned
+ char* mIface; // owned
+ int mPid;
+ };
+
+ /* ------ gethostbyname ------*/
+ class GetHostByNameCmd : public NetdCommand {
+ public:
+ GetHostByNameCmd();
+ virtual ~GetHostByNameCmd() {}
+ int runCommand(SocketClient *c, int argc, char** argv);
+ };
+
+ class GetHostByNameHandler {
+ public:
+ GetHostByNameHandler(SocketClient *c,
+ int pid,
+ char *iface,
+ char *name,
+ int af)
+ : mClient(c),
+ mPid(pid),
+ mIface(iface),
+ mName(name),
+ mAf(af) {}
+ ~GetHostByNameHandler();
+ static void* threadStart(void* handler);
+ void start();
+ private:
+ void run();
+ SocketClient* mClient; //ref counted
+ int mPid;
+ char* mIface; // owned
+ char* mName; // owned
+ int mAf;
};
/* ------ gethostbyaddr ------*/
GetHostByAddrHandler(SocketClient *c,
void* address,
int addressLen,
- int addressFamily)
+ int addressFamily,
+ char* iface,
+ int pid)
: mClient(c),
mAddress(address),
mAddressLen(addressLen),
- mAddressFamily(addressFamily) {}
+ mAddressFamily(addressFamily),
+ mIface(iface),
+ mPid(pid) {}
~GetHostByAddrHandler();
static void* threadStart(void* handler);
private:
void run();
- pthread_t mThread;
SocketClient* mClient; // ref counted
void* mAddress; // address to lookup; owned
int mAddressLen; // length of address to look up
int mAddressFamily; // address family
+ char* mIface; // owned
+ int mPid;
};
};