summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorMichael R Sweet <michaelrsweet@gmail.com>2016-10-19 16:04:10 -0400
committerMichael R Sweet <michaelrsweet@gmail.com>2016-10-19 16:04:10 -0400
commit95e00ac365503feeed8de953423601ac13a795f6 (patch)
treede5bc7fe2e0cda0332282b5dac5b5f95825f59b0 /backend
parentf261df73b55efffd40bc628dcc1397b05e0cc0be (diff)
downloadcups-95e00ac365503feeed8de953423601ac13a795f6.tar.gz
Add additional debug information from IPP backend (logging all requests and
responses).
Diffstat (limited to 'backend')
-rw-r--r--backend/ipp.c95
1 files changed, 64 insertions, 31 deletions
diff --git a/backend/ipp.c b/backend/ipp.c
index 67383c71c..de998a5dc 100644
--- a/backend/ipp.c
+++ b/backend/ipp.c
@@ -160,6 +160,7 @@ static void cancel_job(http_t *http, const char *uri, int id,
static ipp_pstate_t check_printer_state(http_t *http, const char *uri,
const char *resource,
const char *user, int version);
+static void debug_attributes(ipp_t *ipp);
static void *monitor_printer(_cups_monitor_t *monitor);
static ipp_t *new_request(ipp_op_t op, int version, const char *uri,
const char *user, const char *title,
@@ -1499,6 +1500,7 @@ main(int argc, /* I - Number of command-line args */
fprintf(stderr, "DEBUG: Validate-Job: %s (%s)\n",
ippErrorString(ipp_status), cupsLastErrorString());
+ debug_attributes(response);
if ((job_auth = ippFindAttribute(response, "job-authorization-uri",
IPP_TAG_URI)) != NULL)
@@ -1669,6 +1671,7 @@ main(int argc, /* I - Number of command-line args */
fprintf(stderr, "DEBUG: %s: %s (%s)\n",
(num_files > 1 || create_job) ? "Create-Job" : "Print-Job",
ippErrorString(ipp_status), cupsLastErrorString());
+ debug_attributes(response);
if (ipp_status > IPP_OK_CONFLICT)
{
@@ -1803,6 +1806,9 @@ main(int argc, /* I - Number of command-line args */
"compression", NULL, compression);
fprintf(stderr, "DEBUG: Sending file %d using chunking...\n", i + 1);
+ fprintf(stderr, "DEBUG: IPP/%d.%d %s #%d\n", version / 10, version % 10, ippOpString(ippGetOperation(request)), ippGetRequestId(request));
+ debug_attributes(request);
+
http_status = cupsSendRequest(http, request, resource, 0);
if (http_status == HTTP_CONTINUE && request->state == IPP_DATA)
{
@@ -1852,11 +1858,13 @@ main(int argc, /* I - Number of command-line args */
fprintf(stderr, "DEBUG: Error writing document data for "
"Send-Document: %s\n", strerror(httpError(http)));
- ippDelete(cupsGetResponse(http, resource));
+ response = cupsGetResponse(http, resource);
ippDelete(request);
fprintf(stderr, "DEBUG: Send-Document: %s (%s)\n",
ippErrorString(cupsLastError()), cupsLastErrorString());
+ debug_attributes(response);
+ ippDelete(response);
if (cupsLastError() > IPP_OK_CONFLICT && !job_canceled)
{
@@ -2023,6 +2031,9 @@ main(int argc, /* I - Number of command-line args */
"requested-attributes", sizeof(jattrs) / sizeof(jattrs[0]),
NULL, jattrs);
+ fprintf(stderr, "DEBUG: IPP/%d.%d %s #%d\n", version / 10, version % 10, ippOpString(ippGetOperation(request)), ippGetRequestId(request));
+ debug_attributes(request);
+
/*
* Do the request...
*/
@@ -2047,6 +2058,7 @@ main(int argc, /* I - Number of command-line args */
fprintf(stderr, "DEBUG: Get-Job-Attributes: %s (%s)\n",
ippErrorString(ipp_status), cupsLastErrorString());
+ debug_attributes(response);
if (ipp_status <= IPP_OK_CONFLICT)
password_tries = 0;
@@ -2323,6 +2335,9 @@ check_printer_state(
"requested-attributes",
(int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
+ fprintf(stderr, "DEBUG: IPP/%d.%d %s #%d\n", version / 10, version % 10, ippOpString(ippGetOperation(request)), ippGetRequestId(request));
+ debug_attributes(request);
+
if ((response = cupsDoRequest(http, request, resource)) != NULL)
{
report_printer_state(response);
@@ -2336,6 +2351,7 @@ check_printer_state(
fprintf(stderr, "DEBUG: Get-Printer-Attributes: %s (%s)\n",
ippErrorString(cupsLastError()), cupsLastErrorString());
+ debug_attributes(response);
/*
* Return the printer-state value...
@@ -2346,6 +2362,51 @@ check_printer_state(
/*
+ * 'debug_attributes()' - Print out the request or response attributes as DEBUG
+ * messages...
+ */
+
+static void
+debug_attributes(ipp_t *ipp) /* I - Request or response message */
+{
+ ipp_tag_t group; /* Current group */
+ ipp_attribute_t *attr; /* Current attribute */
+ char buffer[1024]; /* Value buffer */
+
+
+ for (group = IPP_TAG_ZERO, attr = ippFirstAttribute(ipp);
+ attr;
+ attr = ippNextAttribute(ipp))
+ {
+ const char *name = ippGetName(attr);
+
+ if (!name)
+ {
+ group = IPP_TAG_ZERO;
+ continue;
+ }
+
+ if (group != ippGetGroupTag(attr))
+ {
+ group = ippGetGroupTag(attr);
+ fprintf(stderr, "DEBUG: ---- %s ----\n", ippTagString(group));
+ }
+
+ if (!strcmp(name, "job-password"))
+ strlcpy(buffer, "---", sizeof(buffer));
+ else
+ ippAttributeString(attr, buffer, sizeof(buffer));
+
+ fprintf(stderr, "DEBUG: %s %s%s %s\n", name,
+ ippGetCount(attr) > 1 ? "1setOf " : "",
+ ippTagString(ippGetValueTag(attr)), buffer);
+ }
+
+ fprintf(stderr, "DEBUG: ---- %s ----\n", ippTagString(IPP_TAG_END));
+}
+
+
+/*
* 'monitor_printer()' - Monitor the printer state.
*/
@@ -2646,9 +2707,6 @@ new_request(
{
ipp_t *request; /* Request data */
const char *keyword; /* PWG keyword */
- ipp_tag_t group; /* Current group */
- ipp_attribute_t *attr; /* Current attribute */
- char buffer[1024]; /* Value buffer */
/*
@@ -2772,33 +2830,8 @@ new_request(
ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "copies", copies);
}
- fprintf(stderr, "DEBUG: IPP/%d.%d %s #%d\n", version / 10, version % 10,
- ippOpString(ippGetOperation(request)), ippGetRequestId(request));
- for (group = IPP_TAG_ZERO, attr = ippFirstAttribute(request);
- attr;
- attr = ippNextAttribute(request))
- {
- const char *name = ippGetName(attr);
-
- if (!name)
- {
- group = IPP_TAG_ZERO;
- continue;
- }
-
- if (group != ippGetGroupTag(attr))
- {
- group = ippGetGroupTag(attr);
- fprintf(stderr, "DEBUG: ---- %s ----\n", ippTagString(group));
- }
-
- ippAttributeString(attr, buffer, sizeof(buffer));
- fprintf(stderr, "DEBUG: %s %s%s %s\n", name,
- ippGetCount(attr) > 1 ? "1setOf " : "",
- ippTagString(ippGetValueTag(attr)), buffer);
- }
-
- fprintf(stderr, "DEBUG: ---- %s ----\n", ippTagString(IPP_TAG_END));
+ fprintf(stderr, "DEBUG: IPP/%d.%d %s #%d\n", version / 10, version % 10, ippOpString(ippGetOperation(request)), ippGetRequestId(request));
+ debug_attributes(request);
return (request);
}