shill: Add http_proxy class

The http_proxy adds a device/connection based proxy that guarantees
to the caller that its HTTP request will go out a particular device's
connection.  DNS requests occur through a bound socket to this device
and goes to DNS servers configured on this connection.  HTTP requests
will also be bound to this interface.  This facility will be used by
a number of peripheral bits including portal detection, activation and
cashew.

BUG=chromium-os:21664
TEST=New unit test.  New (disabled) functional test, against which I
can run "curl -x" and Chrome with manual proxy settings.

Change-Id: I0d59bf0ae27d3538ef359f786742f5c2f1d6fef9
Reviewed-on: https://gerrit.chromium.org/gerrit/10165
Reviewed-by: Thieu Le <thieule@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
Commit-Ready: Paul Stewart <pstew@chromium.org>
diff --git a/sockets.h b/sockets.h
index 31d718e..e0cc70b 100644
--- a/sockets.h
+++ b/sockets.h
@@ -5,6 +5,8 @@
 #ifndef SHILL_SOCKETS_H_
 #define SHILL_SOCKETS_H_
 
+#include <string>
+
 #include <sys/socket.h>
 #include <sys/types.h>
 
@@ -17,15 +19,41 @@
  public:
   virtual ~Sockets();
 
+  // accept
+  virtual int Accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+
   // bind
   virtual int Bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
 
+  // setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE ...)
+  virtual int BindToDevice(int sockfd, const std::string &device);
+
   // close
   virtual int Close(int fd);
 
+  // connect
+  virtual int Connect(int sockfd, const struct sockaddr *addr,
+                      socklen_t addrlen);
+
+  // errno
+  virtual int Error();
+
+  // errno
+  virtual std::string ErrorString();
+
+  // getsockname
+  virtual int GetSockName(int sockfd, struct sockaddr *addr,
+                          socklen_t *addrlen);
+
+  // getsockopt(sockfd, SOL_SOCKET, SO_ERROR, ...)
+  virtual int GetSocketError(int sockfd);
+
   // ioctl
   virtual int Ioctl(int d, int request, void *argp);
 
+  // listen
+  virtual int Listen(int sockfd, int backlog);
+
   // send
   virtual ssize_t Send(int sockfd, const void *buf, size_t len, int flags);
 
@@ -33,6 +61,9 @@
   virtual ssize_t SendTo(int sockfd, const void *buf, size_t len, int flags,
                          const struct sockaddr *dest_addr, socklen_t addrlen);
 
+  // fcntl(sk, F_SETFL, fcntl(sk, F_GETFL) | O_NONBLOCK)
+  virtual int SetNonBlocking(int sockfd);
+
   // socket
   virtual int Socket(int domain, int type, int protocol);
 };