--- /dev/null
+#
+# "$Id$"
+#
+# IPP Everywhere Printer Self-Certification Manual 1.0: Section 5: Bonjour Tests.
+#
+# Copyright 2014 by The Printer Working Group.
+# Copyright 2007-2013 by Apple Inc.
+# Copyright 2001-2006 by Easy Software Products. All rights reserved.
+#
+# These coded instructions, statements, and computer programs are the
+# property of Apple Inc. and are protected by Federal copyright
+# law. Distribution and use rights are outlined in the file "LICENSE.txt"
+# 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/".
+#
+# Usage:
+#
+# ./ipptool -tI printer-uri bonjour-access-tests.test
+#
+
+FILE-ID "org.pwg.ipp-everywhere.bonjour-20140825"
+
+{
+ # The name of the test...
+ NAME "Validate access using Get-Printer-Attributes"
+
+ # The operation to use
+ OPERATION Get-Printer-Attributes
+
+ # Attributes, starting in the operation group...
+ GROUP operation-attributes-tag
+ ATTR charset attributes-charset utf-8
+ ATTR language attributes-natural-language en
+ ATTR uri printer-uri $uri
+
+ # What statuses are OK?
+ STATUS successful-ok
+}
+
+#
+# End of "$Id$".
+#
fi
if test "$2" = _fail4 -o "$2" = _fail5.5; then
- $IPPTOOL -t -d "ADMINURL=$IPPFIND_TXT_ADMINURL" -d "UUID=$IPPFIND_TXT_UUID" $IPPFIND_SERVICE_URI bonjour-tests.test
- $IPPTOOL -t -d "ADMINURL=$IPPFIND_TXT_ADMINURL" -d "UUID=$IPPFIND_TXT_UUID" $IPPFIND_SERVICE_URI bonjour-tests.test | egrep '(GOT|EXPECTED):' | sed -e '1,$s/^[ ]*//' | awk '{print "<string>" $0 "</string>" }' >>"$PLIST"
+ $IPPTOOL -t -d "ADMINURL=$IPPFIND_TXT_ADMINURL" -d "UUID=$IPPFIND_TXT_UUID" $IPPFIND_SERVICE_URI bonjour-value-tests.test
+ $IPPTOOL -t -d "ADMINURL=$IPPFIND_TXT_ADMINURL" -d "UUID=$IPPFIND_TXT_UUID" $IPPFIND_SERVICE_URI bonjour-value-tests.test | egrep '(GOT|EXPECTED):' | sed -e '1,$s/^[ ]*//' | awk '{print "<string>" $0 "</string>" }' >>"$PLIST"
fi
echo "</array>" >>"$PLIST"
# B-4. IPP TXT values test: The IPP TXT record values match the reported IPP attribute values.
start_test "B-4. IPP TXT values test"
-$IPPFIND "$1._ipp._tcp.local." --txt-adminurl '^(http:|https:)//' --txt-pdl 'image/pwg-raster' --txt-pdl 'image/jpeg' --txt-rp '^ipp/(print|print/[^/]+)$' --txt-UUID '^[0-9a-fA-F]{8,8}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{12,12}$' -x $IPPTOOL -q -d 'ADMINURL={txt_adminurl}' -d 'UUID={txt_uuid}' '{}' bonjour-tests.test \;
+$IPPFIND "$1._ipp._tcp.local." --txt-adminurl '^(http:|https:)//' --txt-pdl 'image/pwg-raster' --txt-pdl 'image/jpeg' --txt-rp '^ipp/(print|print/[^/]+)$' --txt-UUID '^[0-9a-fA-F]{8,8}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{12,12}$' -x $IPPTOOL -q -d 'ADMINURL={txt_adminurl}' -d 'UUID={txt_uuid}' '{}' bonjour-value-tests.test \;
if test $? = 0; then
pass=`expr $pass + 1`
end_test PASS
# B-5.1 HTTP Upgrade test: Printer responds to an IPP Get-Printer-Attributes request after doing an HTTP Upgrade to TLS.
start_test "B-5.1 HTTP Upgrade test"
if test $HAVE_TLS = 1; then
- $IPPFIND "$1._ipp._tcp.local." -x $IPPTOOL -E -q -d NO_VALUE_TESTS '{}' bonjour-tests.test \;
+ error=`$IPPFIND "$1._ipp._tcp.local." -x $IPPTOOL -E -q '{}' bonjour-access-tests.test \; 2>&1`
if test $? = 0; then
pass=`expr $pass + 1`
end_test PASS
else
fail=`expr $fail + 1`
+ echo "<key>Errors</key><array><string>$error</string></array>" >>"$PLIST"
+
end_test FAIL
+ echo " $error"
fi
else
skip=`expr $skip + 1`
# B-5.5 IPPS TXT values test: The TXT record values for IPPS match the reported IPPS attribute values.
start_test "B-5.5 IPPS TXT values test"
if test $HAVE_TLS = 1; then
- $IPPFIND "$1._ipps._tcp.local." --txt-adminurl '^(http:|https:)//' --txt-pdl 'image/pwg-raster' --txt-pdl 'image/jpeg' --txt-rp '^ipp/(print|print/[^/]+)$' --txt-UUID '^[0-9a-fA-F]{8,8}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{12,12}$' -x $IPPTOOL -q -d 'ADMINURL={txt_adminurl}' -d 'UUID={txt_uuid}' '{}' bonjour-tests.test \;
+ $IPPFIND "$1._ipps._tcp.local." --txt-adminurl '^(http:|https:)//' --txt-pdl 'image/pwg-raster' --txt-pdl 'image/jpeg' --txt-rp '^ipp/(print|print/[^/]+)$' --txt-UUID '^[0-9a-fA-F]{8,8}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{12,12}$' -x $IPPTOOL -q -d 'ADMINURL={txt_adminurl}' -d 'UUID={txt_uuid}' '{}' bonjour-value-tests.test \;
if test $? = 0; then
pass=`expr $pass + 1`
end_test PASS
#
# Usage:
#
-# ./ipptool -tI printer-uri -d ADMINURL=url -d UUID=uuid bonjour-tests.test
+# ./ipptool -tI printer-uri -d ADMINURL=url -d UUID=uuid bonjour-value-tests.test
#
FILE-ID "org.pwg.ipp-everywhere.bonjour-20140825"
{
- SKIP-IF-DEFINED NO_VALUE_TESTS
-
# The name of the test...
NAME "Validate TXT record values using Get-Printer-Attributes"
EXPECT printer-uuid OF-TYPE uri IN-GROUP printer-attributes-tag COUNT 1 WITH-VALUE "urn:uuid:$UUID"
}
-{
- SKIP-IF-NOT-DEFINED NO_VALUE_TESTS
-
- # The name of the test...
- NAME "Validate Get-Printer-Attributes after HTTP Upgrade"
-
- # The operation to use
- OPERATION Get-Printer-Attributes
-
- # Attributes, starting in the operation group...
- GROUP operation-attributes-tag
- ATTR charset attributes-charset utf-8
- ATTR language attributes-natural-language en
- ATTR uri printer-uri $uri
-
- # What statuses are OK?
- STATUS successful-ok
-}
-
#
# End of "$Id$".
#
NULL)) == NULL)
return (IPPFIND_EXIT_MEMORY);
}
- else if (!strncmp(argv[i], "--txt-", 5))
+ else if (!strncmp(argv[i], "--txt-", 6))
{
- const char *key = argv[i] + 5;/* TXT key */
+ const char *key = argv[i] + 6;/* TXT key */
i ++;
if (i >= argc)
result = !regexec(&(expression->re), val, 0, NULL, 0);
else
result = 0;
+
+ if (getenv("IPPFIND_DEBUG"))
+ printf("TXT_REGEX of \"%s\": %d\n", val, result);
break;
case IPPFIND_OP_URI_REGEX :
result = !regexec(&(expression->re), service->uri, 0, NULL, 0);
strlcpy(tptr, scheme + 22, sizeof(temp) - (size_t)(tptr - temp));
else if (!strncmp(keyword, "txt_", 4))
{
- if ((ptr = (char *)cupsGetOption(keyword + 4, service->num_txt,
- service->txt)) != NULL)
- strlcpy(tptr, strdup(ptr), sizeof(temp) - (size_t)(tptr - temp));
+ const char *txt = cupsGetOption(keyword + 4, service->num_txt, service->txt);
+ if (txt)
+ strlcpy(tptr, txt, sizeof(temp) - (size_t)(tptr - temp));
else
*tptr = '\0';
}
* Return whether the program succeeded or crashed...
*/
+ if (getenv("IPPFIND_DEBUG"))
+ {
+ if (WIFEXITED(status))
+ printf("Exit Status: %d\n", WEXITSTATUS(status));
+ else
+ printf("Terminating Signal: %d\n", WTERMSIG(status));
+ }
+
return (status == 0);
}
static int process_ipp(_ipp_client_t *client);
static void *process_job(_ipp_job_t *job);
#ifdef HAVE_DNSSD
-static int register_printer(_ipp_printer_t *printer,
- const char *location, const char *make,
- const char *model, const char *formats,
- const char *adminurl, int color,
- int duplex, const char *regtype);
+static int register_printer(_ipp_printer_t *printer, const char *location, const char *make, const char *model, const char *formats, const char *adminurl, const char *uuid, int color, int duplex, const char *regtype);
#endif /* HAVE_DNSSD */
static int respond_http(_ipp_client_t *client, http_status_t code,
const char *content_coding,
* Register the printer with Bonjour...
*/
- if (!register_printer(printer, location, make, model, docformats, adminurl,
- ppm_color > 0, duplex, subtype))
+ if (!register_printer(printer, location, make, model, docformats, adminurl, uuid + 9, ppm_color > 0, duplex, subtype))
goto bad_printer;
#endif /* HAVE_DNSSD */
if (recv(httpGetFd(client->http), buf, 1, MSG_PEEK) == 1 && (!buf[0] || !strchr("DGHOPT", buf[0])))
{
- fprintf(stderr, "%s Negotiating TLS session.\n", client->hostname);
+ fprintf(stderr, "%s Starting HTTPS session.\n", client->hostname);
if (httpEncryption(client->http, HTTP_ENCRYPTION_ALWAYS))
{
fprintf(stderr, "%s Unable to encrypt connection: %s\n", client->hostname, cupsLastErrorString());
break;
}
+
+ fprintf(stderr, "%s Connection now encrypted.\n", client->hostname);
}
first_time = 0;
if (httpSeparateURI(HTTP_URI_CODING_MOST, uri, scheme, sizeof(scheme),
userpass, sizeof(userpass),
hostname, sizeof(hostname), &port,
- client->uri, sizeof(client->uri)) < HTTP_URI_STATUS_OK)
+ client->uri, sizeof(client->uri)) < HTTP_URI_STATUS_OK &&
+ (http_state != HTTP_STATE_OPTIONS || strcmp(uri, "*")))
{
fprintf(stderr, "%s Bad URI \"%s\".\n", client->hostname, uri);
respond_http(client, HTTP_STATUS_BAD_REQUEST, NULL, NULL, 0);
if (!strcasecmp(httpGetField(client->http, HTTP_FIELD_CONNECTION),
"Upgrade"))
{
+#ifdef HAVE_SSL
+ if (strstr(httpGetField(client->http, HTTP_FIELD_UPGRADE), "TLS/") != NULL && !httpIsEncrypted(client->http))
+ {
+ if (!respond_http(client, HTTP_STATUS_SWITCHING_PROTOCOLS, NULL, NULL, 0))
+ return (0);
+
+ fprintf(stderr, "%s Upgrading to encrypted connection.\n", client->hostname);
+
+ if (httpEncryption(client->http, HTTP_ENCRYPTION_REQUIRED))
+ {
+ fprintf(stderr, "%s Unable to encrypt connection: %s\n", client->hostname, cupsLastErrorString());
+ return (0);
+ }
+
+ fprintf(stderr, "%s Connection now encrypted.\n", client->hostname);
+ }
+ else
+#endif /* HAVE_SSL */
+
if (!respond_http(client, HTTP_STATUS_NOT_IMPLEMENTED, NULL, NULL, 0))
return (0);
}
{
case HTTP_STATE_OPTIONS :
/*
- * Do HEAD/OPTIONS command...
+ * Do OPTIONS command...
*/
return (respond_http(client, HTTP_STATUS_OK, NULL, NULL, 0));
const char *model, /* I - Model name */
const char *formats, /* I - Supported formats */
const char *adminurl, /* I - Web interface URL */
+ const char *uuid, /* I - Printer UUID */
int color, /* I - 1 = color, 0 = monochrome */
int duplex, /* I - 1 = duplex, 0 = simplex */
const char *subtype) /* I - Service subtype */
make);
TXTRecordSetValue(&(printer->ipp_txt), "usb_MDL", (uint8_t)strlen(model),
model);
+ TXTRecordSetValue(&(printer->ipp_txt), "UUID", (uint8_t)strlen(uuid), uuid);
+# ifdef HAVE_SSL
+ TXTRecordSetValue(&(printer->ipp_txt), "TLS", 3, "1.2");
+# endif /* HAVE_SSL */
/*
* Create a shared service reference for Bonjour...
* Format an error message...
*/
- if (!type && !length && code != HTTP_STATUS_OK)
+ if (!type && !length && code != HTTP_STATUS_OK && code != HTTP_STATUS_SWITCHING_PROTOCOLS)
{
snprintf(message, sizeof(message), "%d - %s\n", code, httpStatus(code));