diff -uNr curl-7.2.1.orig/docs/FEATURES curl-7.2.1/docs/FEATURES
--- curl-7.2.1.orig/docs/FEATURES	Mon Jul 31 02:37:46 2000
+++ curl-7.2.1/docs/FEATURES	Thu Sep  7 09:13:09 2000
@@ -38,6 +38,7 @@
  - proxy authentication
  - time conditions
  - via http-proxy
+ - specify interface device/port
 
 HTTPS (*1)
  - (all the HTTP features)
diff -uNr curl-7.2.1.orig/docs/README.curl curl-7.2.1/docs/README.curl
--- curl-7.2.1.orig/docs/README.curl	Tue Jun 20 10:34:39 2000
+++ curl-7.2.1/docs/README.curl	Thu Sep  7 09:13:09 2000
@@ -23,6 +23,15 @@
 
         curl http://www.weirdserver.com:8000/
 
+  Get a web page from a server using a specified port
+  for the interface:
+
+	curl --interface eth0:1 http://www.netscape.com/
+
+  or
+
+	curl --interface 192.168.1.10 http://www.netscape.com/
+
   Get a list of the root directory of an FTP site:
 
         curl ftp://ftp.fts.frontec.se/
diff -uNr curl-7.2.1.orig/include/curl/curl.h curl-7.2.1/include/curl/curl.h
--- curl-7.2.1.orig/include/curl/curl.h	Fri Sep  1 04:23:26 2000
+++ curl-7.2.1/include/curl/curl.h	Thu Sep  7 09:13:09 2000
@@ -141,6 +141,8 @@
 
   CURLE_HTTP_POST_ERROR,
 
+  CURLE_HTTP_PORT_FAILED, /* HTTP Interface operation failed */
+
   CURLE_SSL_CONNECT_ERROR, /* something was wrong when connecting with SSL */
 
   CURLE_FTP_BAD_DOWNLOAD_RESUME, /* couldn't resume download */
@@ -373,6 +375,9 @@
 
   /* size of the POST input data, if strlen() is not good to use */
   T(POSTFIELDSIZE, LONG, 60),
+
+  /* Set the interface string */
+  T(INTERFACE, OBJECTPOINT, 61),
 
   CURLOPT_LASTENTRY /* the last unusued */
 } CURLoption;
diff -uNr curl-7.2.1.orig/lib/easy.c curl-7.2.1/lib/easy.c
--- curl-7.2.1.orig/lib/easy.c	Thu Aug 24 09:26:33 2000
+++ curl-7.2.1/lib/easy.c	Thu Sep  7 09:13:09 2000
@@ -109,6 +109,9 @@
     return NULL;
 
   data->interf = CURLI_EASY; /* mark it as an easy one */
+  /* SAC */
+  data->device = NULL;
+
   return data;
 }
 
diff -uNr curl-7.2.1.orig/lib/url.c curl-7.2.1/lib/url.c
--- curl-7.2.1.orig/lib/url.c	Thu Aug 24 09:26:33 2000
+++ curl-7.2.1/lib/url.c	Thu Sep  7 09:13:09 2000
@@ -52,7 +52,6 @@
 
 #include <errno.h>
 
-
 #if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
 #include <winsock.h>
 #include <time.h>
@@ -495,6 +494,9 @@
   case CURLOPT_QUOTE:
     data->quote = va_arg(param, struct curl_slist *);
     break;
+  case CURLOPT_INTERFACE:
+    data->device = va_arg(param, char *);
+    break;
   default:
     /* unknown tag and its companion, just ignore: */
     return CURLE_READ_ERROR; /* correct this */
@@ -1164,6 +1166,133 @@
   conn->serv_addr.sin_family = conn->hp->h_addrtype;
   conn->serv_addr.sin_port = htons(data->port);
 
+/* sck 8/31/2000 add support for specifing device to bind socket to */
+/* #ifdef LINUX */
+/* I am using this, but it may not work everywhere, only tested on RedHat 6.2 */
+#ifdef HAVE_INET_NTOA
+
+  if (data->device) {
+    struct ifreq ifr;
+    struct sockaddr_in sa;
+    struct hostent *h=NULL;
+    size_t size;
+    unsigned short porttouse;
+    char myhost[256] = "";
+    unsigned long in;
+    
+    if(if2ip(data->device, myhost, sizeof(myhost))) {
+      h = GetHost(data, myhost, hostent_buf, sizeof(hostent_buf));
+    }
+    else 
+      {
+	if(strlen(data->device)>1)
+	  {
+	    h = GetHost(data, data->device, hostent_buf, 
+			sizeof(hostent_buf));
+	  }
+	if(h)
+	  {
+	    strcpy(myhost,data->device);
+	  }
+      }
+        
+    if(! *myhost) 
+      {
+	/* need to fix this 
+	   h=GetHost(data, 
+	   getmyhost(*myhost,sizeof(myhost)), 
+	   hostent_buf, 
+	   sizeof(hostent_buf));
+	*/
+	printf("in here\n");
+      }
+    
+    infof(data, "We connect from %s\n", myhost);
+    
+    if ( (in=inet_addr(myhost)) != INADDR_NONE ) {
+
+      if ( h )
+	{
+	  memset((char *)&sa, 0, sizeof(sa));
+	  memcpy((char *)&sa.sin_addr,
+		 h->h_addr,
+		 h->h_length);
+	  sa.sin_family = AF_INET;
+	  sa.sin_addr.s_addr = in;
+	  sa.sin_port = 0; /* get any port */
+	  
+	  if( bind(data->firstsocket, (struct sockaddr *)&sa, sizeof(sa)) >= 0) 
+	    {
+	      /* we succeeded to bind */
+	      struct sockaddr_in add;
+	      
+	      size = sizeof(add);
+	      if(getsockname(data->firstsocket, (struct sockaddr *) &add,
+			     (int *)&size)<0) {
+		failf(data, "getsockname() failed");
+		return CURLE_HTTP_PORT_FAILED;
+	      }
+	    }
+	  else
+	    {
+	      switch(errno) 
+		{
+		case EBADF:
+		  failf(data,"Invalid descriptor: %d",errno);
+		  break;
+		case EINVAL:
+		  failf(data,"Invalid request: %d",errno);
+		  break;
+		case EACCES:
+		  failf(data,"Address is protected, user not superuser: %d",errno);
+		  break;
+		case ENOTSOCK:
+		  failf(data,"Argument is a descriptor for a file, not a socket: %d",errno);
+		  break;
+		case EROFS:
+		  failf(data,"Socket inode would reside on a read-only file system: %d",errno);
+		  break;
+		case EFAULT:
+		  failf(data,"Inaccessable memory error: %d",errno);
+		  break;
+		case ENAMETOOLONG:
+		  failf(data,"Address too long: %d",errno);
+		  break;
+		case ENOENT:
+		  failf(data,"File does not exist: %d",errno);
+		  break;
+		case ENOMEM:
+		  failf(data,"Insufficient kernel memory was available: %d",errno);
+		  break;
+		case ENOTDIR:
+		  failf(data,"Component of path prefix is not a directory: %d",errno);
+		  break;
+		case ELOOP:
+		  failf(data,"Too many symbolic links encountered: %d",errno);
+		  break;
+		default:
+		  failf(data,"errno %d\n");
+		} /* end of switch */
+	      
+	      return CURLE_HTTP_PORT_FAILED;
+	    } /* end of else */
+	  
+	} /* end of if  h */
+      else {
+	failf(data,"could't find my own IP address (%s)", myhost);
+	return CURLE_HTTP_PORT_FAILED;
+      }
+
+    } /* end of inet_addr */
+
+    else {
+      failf(data, "could't find my own IP address (%s)", myhost);
+      return CURLE_HTTP_PORT_FAILED;
+    }
+
+  } /* end of device selection support */
+#endif  /* end of HAVE_INET_NTOA */
+
   if (connect(data->firstsocket,
               (struct sockaddr *) &(conn->serv_addr),
               sizeof(conn->serv_addr)
@@ -1173,6 +1302,43 @@
       /* this should be made nicer */
     case ECONNREFUSED:
       failf(data, "Connection refused");
+      break;
+    case EBADF:
+      failf(data,"File descriptor is not a valid index in descriptor table: %d",errno);
+      break;
+    case EFAULT:
+      failf(data,"Invalid socket address: %d",errno);
+      break;
+    case ENOTSOCK:
+      failf(data,"File descriptor is not a socket: %d",errno);
+      break;
+    case EISCONN:
+      failf(data,"Socket already connected: %d",errno);
+      break;
+    case ETIMEDOUT:
+      failf(data,"Timeout while accepting connection, server busy: %d",errno);
+      break;
+    case ENETUNREACH:
+      failf(data,"Network is unreachable: %d",errno);
+      break;
+    case EADDRINUSE:
+      failf(data,"Local address already in use: %d",errno);
+      break;
+    case EINPROGRESS:
+      failf(data,"Socket is nonblocking and connection can not be completed immediately: %d",errno);
+      break;
+    case EALREADY:
+      failf(data,"Socket is nonblocking and a previous connection attempt not completed: %d",errno);
+      break;
+    case EAGAIN:
+      failf(data,"No more free local ports: %d",errno);
+      break;
+    case EAFNOSUPPORT:
+      failf(data,"Incorrect address family: %d",errno);
+      break;
+    case EACCES:
+    case EPERM:
+      failf(data,"Attempt to connect to broadcast address without socket broadcast flag or local firewall rule violated: %d",errno);
       break;
 #endif
 #ifdef EINTR
diff -uNr curl-7.2.1.orig/lib/urldata.h curl-7.2.1/lib/urldata.h
--- curl-7.2.1.orig/lib/urldata.h	Thu Aug 24 07:33:17 2000
+++ curl-7.2.1/lib/urldata.h	Thu Sep  7 09:13:09 2000
@@ -355,6 +355,7 @@
   char *useragent;   /* User-Agent string */
 
   char *ftpport; /* port to send with the PORT command */
+  char *device;  /* Interface to use */
 
   /* function that stores the output:*/
   curl_write_callback fwrite;
diff -uNr curl-7.2.1.orig/src/main.c curl-7.2.1/src/main.c
--- curl-7.2.1.orig/src/main.c	Thu Aug 24 12:56:20 2000
+++ curl-7.2.1/src/main.c	Thu Sep  7 09:13:09 2000
@@ -243,6 +243,7 @@
        " -H/--header <line> Custom header to pass to server. (H)\n"
        " -i/--include       Include the HTTP-header in the output (H)\n"
        " -I/--head          Fetch document info only (HTTP HEAD/FTP SIZE)\n"
+       "    --interface <interface> Specify the interface to be used\n"
        " -K/--config        Specify which config file to read\n"
        " -l/--list-only     List only names of an FTP directory (F)\n"
        " -L/--location      Follow Location: hints (H)\n"
@@ -301,6 +302,7 @@
   char *headerfile;
   char remotefile;
   char *ftpport;
+  char *interface;
   unsigned short porttouse;
   char *range;
   int low_speed_limit;
@@ -441,6 +443,7 @@
   struct LongShort aliases[]= {
     {"9", "crlf",        FALSE},
     {"8", "stderr",      TRUE},
+    {"7", "interface",   TRUE},
 
     {"2", "sslv2",       FALSE},
     {"3", "sslv3",       FALSE},
@@ -612,6 +615,9 @@
       else
         config->errors = stdout;
       break;
+    case '7': /* there is no short letter for this */
+      /* interface */
+      GetStr(&config->interface, nextarg);
     case '#': /* added 19990617 larsa */
       config->progressmode ^= CURL_PROGRESS_BAR;
       break;
@@ -1479,7 +1485,7 @@
 
     curl_easy_setopt(curl, CURLOPT_REFERER, config.referer);
     curl_easy_setopt(curl, CURLOPT_AUTOREFERER, config.conf&CONF_AUTO_REFERER);
-    curl_easy_setopt(curl, CURLOPT_USERAGENT, config.useragent);
+    curl_easy_setopt(curl, CURLOPT_USERAGENT, config.useragent); 
     curl_easy_setopt(curl, CURLOPT_FTPPORT, config.ftpport);
     curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, config.low_speed_limit);
     curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, config.low_speed_time);
@@ -1501,6 +1507,7 @@
     curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, config.customrequest);
     curl_easy_setopt(curl, CURLOPT_STDERR, config.errors);
     curl_easy_setopt(curl, CURLOPT_WRITEINFO, config.writeout);
+    curl_easy_setopt(curl, CURLOPT_INTERFACE, config.interface);
 
     if((config.progressmode == CURL_PROGRESS_BAR) &&
        !(config.conf&(CONF_NOPROGRESS|CONF_MUTE))) {

