ptg10805159
Section 21.2 The Internet Printing Protocol 791
version number
operation ID (request)/status code (response)
request ID
attributes
end-of-attributes tag
(2 bytes)
(2 bytes)
(4 bytes)
(0-nbytes)
(1 byte)
Figure 21.3 Structure of an IPP header
The next 4 bytes contain an integer identifying the request, which allows requests to
be matched up with responses. Optional attributes follow this, terminated by an end-
of-attributes tag. Any data that might be associated with the request follows
immediately after the end-of-attributes tag.
In the header,integers arestored as signed, two’s-complement, binary values in
big-endian byte order (i.e., network byte order). Attributes arestored in groups. Each
group starts with a single byte identifying the group. Within each group, an attribute is
generally represented as a 1-byte tag, followed by a 2-byte name length, followed by the
name of the attribute, followed by a 2-byte value length, and finally by the value itself.
The value can be encoded as a string, a binary integer, or a morecomplex structure,
such as a date/timestamp.
Figure21.4 shows how theattributes-charsetattribute would be encoded
with a value ofutf-8.
attribute tag = 0x47
size of attribute name = 18
name =attributes-charset
size of attribute value = 5
value =utf-8
(1 byte)
(2 bytes)
(18 bytes)
(2 bytes)
(5 bytes)
Figure 21.4Sample IPP attribute encoding
Depending on the operation requested, some attributes arerequired to be provided
in the request message, whereas others areoptional. For example, Figure21.5 shows
the attributes defined for a print-job request.