]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add the ability to force IPv4 or IPv6 connections.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Wed, 10 Nov 2010 06:48:19 +0000 (06:48 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Wed, 10 Nov 2010 06:48:19 +0000 (06:48 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@9354 7a7537e8-13f0-0310-91df-b6672ffda945

backend/ipp.c
cups/adminutil.c
cups/http-private.h
cups/http.c
man/ipptool.man
test/ipptool.c

index ca2a419115762aa6ccabc64feae25d4f953de7df..3dde960e6298041ba618f93874f57384184b8ad4 100644 (file)
@@ -1719,7 +1719,8 @@ monitor_printer(
   * Make a copy of the printer connection...
   */
 
-  http = _httpCreate(monitor->hostname, monitor->port, monitor->encryption);
+  http = _httpCreate(monitor->hostname, monitor->port, monitor->encryption,
+                     AF_UNSPEC);
   cupsSetPasswordCB(password_cb);
 
  /*
index 3e6a54f0773158a9ee835eb0cd34399c5c35680d..094cea7e042aaa5d45813b05292f24b890d2662d 100644 (file)
@@ -902,7 +902,7 @@ cupsAdminGetServerSettings(
     if (!cg->http)
     {
       if ((cg->http = _httpCreate(cupsServer(), ippPort(),
-                                  cupsEncryption())) == NULL)
+                                  cupsEncryption(), AF_UNSPEC)) == NULL)
       {
        if (errno)
          _cupsSetError(IPP_SERVICE_UNAVAILABLE, NULL, 0);
index 17cdb3f23ae1fc58ff2419b6fb53cc165402bce3..ca102594b5f6fba8c1755966cf06ca6b16d361d2 100644 (file)
@@ -311,7 +311,8 @@ extern int          _httpAddrPort(http_addr_t *addr);
 extern http_tls_credentials_t
                        _httpConvertCredentials(cups_array_t *credentials);
 extern http_t          *_httpCreate(const char *host, int port,
-                                    http_encryption_t encryption);
+                                    http_encryption_t encryption,
+                                    int family);
 extern void            _httpDisconnect(http_t *http);
 extern char            *_httpEncodeURI(char *dst, const char *src,
                                        size_t dstsize);
index 747eafc92e2baa78a62032246f537c83e710e022..5f8e00888c4d61a8fc912ec696d0e80c3e10ba4a 100644 (file)
@@ -475,7 +475,7 @@ httpConnectEncrypt(
   * Create the HTTP structure...
   */
 
-  if ((http = _httpCreate(host, port, encryption)) == NULL)
+  if ((http = _httpCreate(host, port, encryption, AF_UNSPEC)) == NULL)
     return (NULL);
 
  /*
@@ -628,7 +628,8 @@ http_t *                            /* O - HTTP connection */
 _httpCreate(
     const char        *host,           /* I - Hostname */
     int               port,            /* I - Port number */
-    http_encryption_t encryption)      /* I - Encryption to use */
+    http_encryption_t encryption,      /* I - Encryption to use */
+    int               family)          /* I - Address family or AF_UNSPEC */
 {
   http_t               *http;          /* New HTTP connection */
   http_addrlist_t      *addrlist;      /* Host address data */
@@ -649,7 +650,7 @@ _httpCreate(
 
   sprintf(service, "%d", port);
 
-  if ((addrlist = httpAddrGetList(host, AF_UNSPEC, service)) == NULL)
+  if ((addrlist = httpAddrGetList(host, family, service)) == NULL)
     return (NULL);
 
  /*
index 31bd93de63096d3085004363989aaa1187086361..7b190031c0c51ecd36abddd4225c2e3f23e89b29 100644 (file)
 .\"   which should have been included with this file.  If this file is
 .\"   file is missing or damaged, see the license at "http://www.cups.org/".
 .\"
-.TH ipptool 1 "CUPS" "17 October 2010" "Apple Inc."
+.TH ipptool 1 "CUPS" "9 November 2010" "Apple Inc."
 .SH NAME
 ipptool - perform internet printing protocol requests
 .SH SYNOPSIS
 .B ipptool
-[ -C ] [ -E ] [ -I ] [ -L ] [ -S ] [ -T
+[ -4 ] [ -6 ] [ -C ] [ -E ] [ -I ] [ -L ] [ -S ] [ -T
 .I seconds
 ] [ -V
 .I version
@@ -39,6 +39,12 @@ ipptool - perform internet printing protocol requests
 .SH OPTIONS
 The following options are recognized by \fIipptool\fR:
 .TP 5
+-4
+Specifies that \fIipptool\fR must connect to the printer or server using IPv4.
+.TP 5
+-6
+Specifies that \fIipptool\fR must connect to the printer or server using IPv6.
+.TP 5
 -C
 Specifies that requests should be sent using the HTTP/1.1 "Transfer-Encoding: chunked" header, which is required for conformance by all versions of IPP. The default is to use "Transfer-Encoding: chunked" for requests with attached files and "Content-Length:" for requests without attached files.
 .TP 5
index 6832f9d34931a104e8c1a53d2285478d15dc4b83..3ea4ec86cf5e4719f1fd6d242c0400d17f0deec8 100644 (file)
@@ -117,6 +117,7 @@ typedef struct _cups_vars_s         /**** Set of variables ****/
   int          port;                   /* Port number from URI */
   http_encryption_t encryption;                /* Encryption for connection? */
   double       timeout;                /* Timeout for connection */
+  int          family;                 /* Address family */
   cups_array_t *vars;                  /* Array of variables */
 } _cups_vars_t;
 
@@ -232,7 +233,8 @@ main(int  argc,                             /* I - Number of command-line args */
   _cupsSetLocale(argv);
 
   memset(&vars, 0, sizeof(vars));
-  vars.vars = cupsArrayNew((cups_array_func_t)compare_vars, NULL);
+  vars.family = AF_UNSPEC;
+  vars.vars   = cupsArrayNew((cups_array_func_t)compare_vars, NULL);
 
  /*
   * We need at least:
@@ -253,6 +255,16 @@ main(int  argc,                            /* I - Number of command-line args */
       {
         switch (*opt)
         {
+         case '4' : /* Connect using IPv4 only */
+             vars.family = AF_INET;
+             break;
+
+#ifdef AF_INET6
+         case '6' : /* Connect using IPv6 only */
+             vars.family = AF_INET6;
+             break;
+#endif /* AF_INET6 */
+
           case 'C' : /* Enable HTTP chunking */
               Transfer = _CUPS_TRANSFER_CHUNKED;
               break;
@@ -644,8 +656,16 @@ do_tests(_cups_vars_t *vars,               /* I - Variables */
   * Connect to the server...
   */
 
-  if ((http = httpConnectEncrypt(vars->hostname, vars->port,
-                                 vars->encryption)) == NULL)
+  if ((http = _httpCreate(vars->hostname, vars->port, vars->encryption,
+                         vars->family)) == NULL)
+  {
+    print_fatal_error("Unable to connect to %s on port %d - %s", vars->hostname,
+                      vars->port, strerror(errno));
+    pass = 0;
+    goto test_exit;
+  }
+
+  if (httpReconnect(http))
   {
     print_fatal_error("Unable to connect to %s on port %d - %s", vars->hostname,
                       vars->port, strerror(errno));
@@ -3743,10 +3763,12 @@ usage(void)
                  "\n"
                  "Options:\n"
                  "\n"
-                 "-C             Send requests using chunking (default)\n"
+                 "-4             Connect using IPv4.\n"
+                 "-6             Connect using IPv6.\n"
+                 "-C             Send requests using chunking (default).\n"
                  "-E             Test with TLS encryption.\n"
-                 "-I             Ignore errors\n"
-                 "-L             Send requests using content-length\n"
+                 "-I             Ignore errors.\n"
+                 "-L             Send requests using content-length.\n"
                  "-S             Test with SSL encryption.\n"
                  "-T             Set the receive/send timeout in seconds.\n"
                  "-V version     Set default IPP version.\n"