diff options
author | Michael R Sweet <michaelrsweet@gmail.com> | 2016-11-15 12:12:05 -0500 |
---|---|---|
committer | Michael R Sweet <michaelrsweet@gmail.com> | 2016-11-15 12:12:05 -0500 |
commit | f5cffc18d1c9ca808707dacf7d1d88ba5dab5c02 (patch) | |
tree | 5304d44de86c67b8feaa905aa438d04b44bc71e8 | |
parent | 0fa88e19c45f37d89a7d6451f40d8d47dd2a6eb5 (diff) |
Add address logging to network backends (<rdar://problem/29268474>)
-rw-r--r-- | CHANGES.txt | 4 | ||||
-rw-r--r-- | backend/backend-private.h | 1 | ||||
-rw-r--r-- | backend/ipp.c | 22 | ||||
-rw-r--r-- | backend/lpd.c | 21 | ||||
-rw-r--r-- | backend/network.c | 62 | ||||
-rw-r--r-- | backend/socket.c | 21 | ||||
-rw-r--r-- | xcode/CUPS.xcodeproj/project.pbxproj | 4 |
7 files changed, 75 insertions, 60 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 6594d47a2..00dcd85b6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,4 @@ -CHANGES.txt - 2.2.2 - 2016-11-08 +CHANGES.txt - 2.2.2 - 2016-11-15 -------------------------------- CHANGES IN CUPS V2.2.2 @@ -15,6 +15,8 @@ CHANGES IN CUPS V2.2.2 (<rdar://problem/28332470>) - The ippContainsString function now uses case-insensitive comparisons for mimeMediaType, name, and text values in conformance with RFC 2911. + - The network backends now log the addresses that were found for a + printer (<rdar://problem/29268474>) - Updated documentation (PR #4896) - Updated localizations (PR #4894, PR #4895, PR #4904, PR #4908) diff --git a/backend/backend-private.h b/backend/backend-private.h index 04bf51674..64fbe411c 100644 --- a/backend/backend-private.h +++ b/backend/backend-private.h @@ -312,6 +312,7 @@ extern int backendGetDeviceID(int fd, char *device_id, extern int backendGetMakeModel(const char *device_id, char *make_model, size_t make_model_size); +extern http_addrlist_t *backendLookup(const char *hostname, int port, int *cancel); extern int backendNetworkSideCB(int print_fd, int device_fd, int snmp_fd, http_addr_t *addr, int use_bc); diff --git a/backend/ipp.c b/backend/ipp.c index 180418664..a338577f9 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -223,7 +223,6 @@ main(int argc, /* I - Number of command-line args */ *compatfile = NULL; /* Compatibility filename */ off_t compatsize = 0; /* Size of compatibility file */ int port; /* Port number (not used) */ - char portname[255]; /* Port name */ char uri[HTTP_MAX_URI]; /* Updated URI without user/pass */ char print_job_name[1024]; /* Update job-name for Print-Job */ http_status_t http_status; /* Status of HTTP request */ @@ -664,26 +663,7 @@ main(int argc, /* I - Number of command-line args */ start_time = time(NULL); - sprintf(portname, "%d", port); - - update_reasons(NULL, "+connecting-to-device"); - fprintf(stderr, "DEBUG: Looking up \"%s\"...\n", hostname); - - while ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL) - { - _cupsLangPrintFilter(stderr, "INFO", - _("Unable to locate printer \"%s\"."), hostname); - sleep(10); - - if (getenv("CLASS") != NULL) - { - update_reasons(NULL, "-connecting-to-device"); - return (CUPS_BACKEND_STOP); - } - - if (job_canceled) - return (CUPS_BACKEND_OK); - } + addrlist = backendLookup(hostname, port, &job_canceled); http = httpConnect2(hostname, port, addrlist, AF_UNSPEC, cupsEncryption(), 1, 0, NULL); diff --git a/backend/lpd.c b/backend/lpd.c index 2b811076b..835f9eaee 100644 --- a/backend/lpd.c +++ b/backend/lpd.c @@ -111,7 +111,6 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ *filename, /* File to print */ title[256]; /* Title string */ int port; /* Port number */ - char portname[256]; /* Port name (string) */ http_addrlist_t *addrlist; /* List of addresses for printer */ int snmp_enabled = 1; /* Is SNMP enabled? */ int snmp_fd; /* SNMP socket */ @@ -411,23 +410,11 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ * Find the printer... */ - snprintf(portname, sizeof(portname), "%d", port); + addrlist = backendLookup(hostname, port, NULL); - fputs("STATE: +connecting-to-device\n", stderr); - fprintf(stderr, "DEBUG: Looking up \"%s\"...\n", hostname); - - while ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL) - { - _cupsLangPrintFilter(stderr, "INFO", - _("Unable to locate printer \"%s\"."), hostname); - sleep(10); - - if (getenv("CLASS") != NULL) - { - fputs("STATE: -connecting-to-device\n", stderr); - exit(CUPS_BACKEND_FAILED); - } - } + /* + * See if the printer supports SNMP... + */ if (snmp_enabled) snmp_fd = _cupsSNMPOpen(addrlist->addr.addr.sa_family); diff --git a/backend/network.c b/backend/network.c index 8beced8d2..d2c64a128 100644 --- a/backend/network.c +++ b/backend/network.c @@ -1,7 +1,7 @@ /* * Common backend network APIs for CUPS. * - * Copyright 2007-2014 by Apple Inc. + * Copyright 2007-2016 by Apple Inc. * Copyright 2006-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -26,7 +26,6 @@ * 'backendCheckSideChannel()' - Check the side-channel for pending requests. */ - void backendCheckSideChannel( int snmp_fd, /* I - SNMP socket */ @@ -47,6 +46,65 @@ backendCheckSideChannel( /* + * 'backendLookup()' - Lookup the given host and log addresses. + */ + +http_addrlist_t * /* O - List of addresses or NULL */ +backendLookup(const char *hostname, /* I - Hostname */ + int port, /* I - Port number */ + int *cancel) /* I - Variable to watch for job cancel */ +{ + char portname[32], /* Port number as string */ + addrname[256]; /* Address as string */ + http_addrlist_t *addrlist, /* List of addresses */ + *current; /* Current address */ + + + /* + * Lookup the address for the named host... + */ + + snprintf(portname, sizeof(portname), "%d", port); + + fputs("STATE: +connecting-to-device\n", stderr); + fprintf(stderr, "DEBUG: Looking up \"%s\"...\n", hostname); + + while ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL) + { + _cupsLangPrintFilter(stderr, "INFO", _("Unable to locate printer \"%s\"."), hostname); + sleep(10); + + if (getenv("CLASS") != NULL) + { + fputs("STATE: -connecting-to-device\n", stderr); + exit(CUPS_BACKEND_STOP); + } + + if (cancel && *cancel) + { + fputs("STATE: -connecting-to-device\n", stderr); + exit(CUPS_BACKEND_OK); + } + } + + fputs("STATE: -connecting-to-device\n", stderr); + + /* + * Log the addresses we got... + */ + + for (current = addrlist; current; current = current->next) + fprintf(stderr, "DEBUG: %s=%s\n", hostname, httpAddrString(¤t->addr, addrname, sizeof(addrname))); + + /* + * Return... + */ + + return (addrlist); +} + + +/* * 'backendNetworkSideCB()' - Handle common network side-channel commands. */ diff --git a/backend/socket.c b/backend/socket.c index e51582394..7fc0880f1 100644 --- a/backend/socket.c +++ b/backend/socket.c @@ -1,7 +1,7 @@ /* * AppSocket backend for CUPS. * - * Copyright 2007-2014 by Apple Inc. + * Copyright 2007-2016 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -69,7 +69,6 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ int contimeout; /* Connection timeout */ int waiteof; /* Wait for end-of-file? */ int port; /* Port number */ - char portname[255]; /* Port name */ int delay; /* Delay for retries... */ int device_fd; /* AppSocket */ int error; /* Error code (if any) */ @@ -264,23 +263,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ start_time = time(NULL); - sprintf(portname, "%d", port); - - fputs("STATE: +connecting-to-device\n", stderr); - fprintf(stderr, "DEBUG: Looking up \"%s\"...\n", hostname); - - while ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL) - { - _cupsLangPrintFilter(stderr, "INFO", - _("Unable to locate printer \"%s\"."), hostname); - sleep(10); - - if (getenv("CLASS") != NULL) - { - fputs("STATE: -connecting-to-device\n", stderr); - return (CUPS_BACKEND_STOP); - } - } + addrlist = backendLookup(hostname, port, NULL); /* * See if the printer supports SNMP... diff --git a/xcode/CUPS.xcodeproj/project.pbxproj b/xcode/CUPS.xcodeproj/project.pbxproj index dcff0d52c..3a673f20d 100644 --- a/xcode/CUPS.xcodeproj/project.pbxproj +++ b/xcode/CUPS.xcodeproj/project.pbxproj @@ -10416,6 +10416,8 @@ isa = XCBuildConfiguration; buildSettings = { COMBINE_HIDPI_IMAGES = YES; + DYLIB_COMPATIBILITY_VERSION = 2.0.0; + DYLIB_CURRENT_VERSION = 2.12.0; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/lib; PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups; @@ -10428,6 +10430,8 @@ isa = XCBuildConfiguration; buildSettings = { COMBINE_HIDPI_IMAGES = YES; + DYLIB_COMPATIBILITY_VERSION = 2.0.0; + DYLIB_CURRENT_VERSION = 2.12.0; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/lib; PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups; |