New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log connection type to aid in IPv6 testing/verification #2046

Closed
michaelrsweet opened this Issue Oct 21, 2006 · 2 comments

Comments

Projects
None yet
1 participant
@michaelrsweet
Collaborator

michaelrsweet commented Oct 21, 2006

Version: 1.3-current
CUPS.org User: jlovell

It would be nice if the backends logged their connection type to aid in IPv6/IPv4 debugging/testing.

Attached patch does this...
It also adds $LIBOBJS to the clean target in the Makefile.

Thanks!

@michaelrsweet

This comment has been minimized.

Collaborator

michaelrsweet commented Oct 23, 2006

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet

This comment has been minimized.

Collaborator

michaelrsweet commented Oct 23, 2006

"ipv6-logging.patch":

Index: lpd.c

--- lpd.c (revision 6044)
+++ lpd.c (working copy)
@@ -582,6 +582,7 @@
cptr; / Pointer into control file string /
char status; /
Status byte from command /
char portname[255]; /
Port name */

  • char addrname[256]; /* Address name /
    http_addrlist_t *addrlist, /
    Address list /
    *addr; /
    Socket address /
    int copy; /
    Copies written */
    @@ -820,9 +821,19 @@

    fputs("STATE: -connecting-to-device\n", stderr);
    fprintf(stderr, "INFO: Connected to %s...\n", hostname);

  • fprintf(stderr, "DEBUG: Connected on ports %d (local %d)...\n", port,

  •        lport);
    

+#ifdef AF_INET6

  • if (addr->addr.addr.sa_family == AF_INET6)
  •  fprintf(stderr, "DEBUG: Connected to [%s]:%d (IPv6) (local port %d)...\n", 
    
  •         httpAddrString(&addr->addr, addrname, sizeof(addrname)),
    
  •         ntohs(addr->addr.ipv6.sin6_port), lport);
    
  • else
    +#endif /* AF_INET6 */
  •  if (addr->addr.addr.sa_family == AF_INET)
    
  • fprintf(stderr, "DEBUG: Connected to %s:%d (IPv4) (local port %d)...\n",
  •       httpAddrString(&addr->addr, addrname, sizeof(addrname)),
    
  •       ntohs(addr->addr.ipv4.sin_port), lport);
    
    /*
    • Next, open the print file and figure out its size...
      _/
      Index: ipp.c

      --- ipp.c (revision 6044)
      +++ ipp.c (working copy)
      @@ -106,6 +106,7 @@
      hostname[1024], /_ Hostname /
      username[255], /
      Username info /
      resource[1024], /
      Resource info (printer name) */
  •   addrname[256],      /\* Address name _/
    *optptr,        /_ Pointer to URI options _/
    name[255],      /_ Name of option _/
    value[255],     /_ Value of option */
    
    @@ -573,6 +574,18 @@
    fputs("STATE: -connecting-to-device\n", stderr);
    fprintf(stderr, "INFO: Connected to %s...\n", hostname);

+#ifdef AF_INET6

  • if (http->hostaddr->addr.sa_family == AF_INET6)
  • fprintf(stderr, "DEBUG: Connected to [%s]:%d (IPv6)...\n",
  •       httpAddrString(http->hostaddr, addrname, sizeof(addrname)),
    
  •       ntohs(http->hostaddr->ipv6.sin6_port));
    
  • else
    +#endif /* AF_INET6 */
  • if (http->hostaddr->addr.sa_family == AF_INET)
  •  fprintf(stderr, "DEBUG: Connected to %s:%d (IPv4)...\n",
    
  •         httpAddrString(http->hostaddr, addrname, sizeof(addrname)),
    
  •         ntohs(http->hostaddr->ipv4.sin_port));
    
    /*
    • Build a URI for the printer and fill the standard IPP attributes for
    • an IPP_PRINT_FILE request. We can't use the URI in argv[0] because it
      Index: socket.c

      --- socket.c (revision 6044)
      +++ socket.c (working copy)
      @@ -78,7 +78,9 @@
      int delay; /* Delay for retries... /
      int device_fd; /
      AppSocket /
      int error; /
      Error code (if any) */
  • http_addrlist_t addrlist; / Address list */
  • http_addrlist_t addrlist, / Address list */
  •     _addr;        /_ Connected address */
    
  • char addrname[256]; /* Address name /
    ssize_t tbytes; /
    Total number of bytes written /
    struct timeval timeout; /
    Timeout for select() /
    fd_set input; /
    Input set for select() */
    @@ -245,7 +247,7 @@

for (delay = 5;;)
{

  • if (!httpAddrConnect(addrlist, &device_fd))
  • if ((addr = httpAddrConnect(addrlist, &device_fd)) == NULL)
    {
    error = errno;
    device_fd = -1;
    @@ -293,7 +295,20 @@
    }

fputs("STATE: -connecting-to-device\n", stderr);

  • fprintf(stderr, "INFO: Connected to %s...\n", hostname);

+#ifdef AF_INET6

  • if (addr->addr.addr.sa_family == AF_INET6)

  • fprintf(stderr, "DEBUG: Connected to [%s]:%d (IPv6)...\n",

  •       httpAddrString(&addr->addr, addrname, sizeof(addrname)),
    
  •       ntohs(addr->addr.ipv6.sin6_port));
    
  • else
    +#endif /* AF_INET6 */

  • if (addr->addr.addr.sa_family == AF_INET)

  •  fprintf(stderr, "DEBUG: Connected to %s:%d (IPv4)...\n",
    
  •         httpAddrString(&addr->addr, addrname, sizeof(addrname)),
    
  •         ntohs(addr->addr.ipv4.sin_port));
    

    /*

    • Print everything...
      */
      Index: Makefile

      --- Makefile (revision 6044)
      +++ Makefile (working copy)
      @@ -46,7 +46,7 @@

    clean:

  • $(RM) $(OBJS) $(TARGETS) http

  • $(RM) $(OBJS) $(TARGETS) $(LIBOBJS) http

@michaelrsweet michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment