xref: /illumos-gate/usr/src/lib/print/libipp-core/common/ipp.h (revision 1da57d551424de5a9d469760be7c4b4d4f10a755)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  *
26  */
27 
28 #ifndef	_IPP_H
29 #define	_IPP_H
30 
31 /* $Id: ipp.h 146 2006-03-24 00:26:54Z njacobs $ */
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #include <stdarg.h>
38 #include <sys/time.h>
39 #include <papi.h>
40 #include <inttypes.h>
41 
42 
43 typedef ssize_t (*ipp_reader_t)(void *fd, void *buffer, size_t buffer_size);
44 typedef ssize_t (*ipp_writer_t)(void *fd, void *buffer, size_t buffer_size);
45 
46 enum {
47 	IPP_TYPE_UNKNOWN  = 0,
48 	IPP_TYPE_REQUEST  = 1,
49 	IPP_TYPE_RESPONSE = 2
50 };
51 
52 /*
53  * How closely do we conform to the spec when parsing?  Do we
54  *   a) Stop parsing only when we encounter an error that prevents us from
55  *      continuing parsing (a server error or ridiculously malformed request)?
56  *   b) Stop parsing when we know the server wouldn't be able to act on the
57  *      response correctly, even if we can make sense of some of the data?
58  *   c) Jawohl, Mein IPP Spec!
59  * The answer will usually be b, though a will be useful for debugging.
60  */
61 enum {
62 	IPP_PARSE_CONFORMANCE_RASH = 0,
63 	IPP_PARSE_CONFORMANCE_LOOSE = 1,
64 	IPP_PARSE_CONFORMANCE_STRICT = 2
65 };
66 
67 
68 /* Operation IDs */
69 enum {
70 	OPID_MIN = 0x0000,			/* 0x0000 */
71 	OPID_RESERVED_0000 = 0x0000,		/* 0x0000 */
72 	OPID_RESERVED_0001,			/* 0x0001 */
73 	OPID_PRINT_JOB,				/* 0x0002 */
74 	OPID_PRINT_URI,				/* 0x0003 */
75 	OPID_VALIDATE_JOB,			/* 0x0004 */
76 	OPID_CREATE_JOB,			/* 0x0005 */
77 	OPID_SEND_DOCUMENT,			/* 0x0006 */
78 	OPID_SEND_URI,				/* 0x0007 */
79 	OPID_CANCEL_JOB,			/* 0x0008 */
80 	OPID_GET_JOB_ATTRIBUTES,		/* 0x0009 */
81 	OPID_GET_JOBS,				/* 0x000a */
82 	OPID_GET_PRINTER_ATTRIBUTES,		/* 0x000b */
83 	OPID_HOLD_JOB,				/* 0x000c */
84 	OPID_RELEASE_JOB,			/* 0x000d */
85 	OPID_RESTART_JOB,			/* 0x000e */
86 	OPID_RESERVED_000F,			/* 0x000f */
87 	OPID_PAUSE_PRINTER,			/* 0x0010 */
88 	OPID_RESUME_PRINTER,			/* 0x0011 */
89 	OPID_PURGE_JOBS,			/* 0x0012 */
90 	OPID_SET_PRINTER_ATTRIBUTES,		/* 0x0013 */
91 	OPID_SET_JOB_ATTRIBUTES,		/* 0x0014 */
92 	OPID_GET_PRINTER_SUPPORTED_VALUES,	/* 0x0015 */
93 	OPID_CREATE_PRINTER_SUBSCRIPTION,	/* 0x0016 */
94 	OPID_CREATE_JOB_SUBSCRIPTION,		/* 0x0017 */
95 	OPID_GET_SUBSCRIPTION_ATTRIBUTES,	/* 0x0018 */
96 	OPID_GET_SUBSCRIPTIONS,			/* 0x0019 */
97 	OPID_RENEW_SUBSCRIPTION,		/* 0x001a */
98 	OPID_CANCEL_SUBSCRIPTION,		/* 0x001b */
99 	OPID_GET_NOTIFICATIONS,			/* 0x001c */
100 	OPID_SEND_NOTIFICATIONS,		/* 0x001d */
101 	OPID_GET_RESOURCE_ATTRIBUTES,		/* 0x001e */
102 	OPID_GET_RESOURCE_DATA,			/* 0x001f */
103 	OPID_GET_RESOURCES,			/* 0x0020 */
104 	OPID_GET_PRINT_SUPPORT_FILES,		/* 0x0021 */
105 	OPID_ENABLE_PRINTER,			/* 0x0022 */
106 	OPID_DISABLE_PRINTER,			/* 0x0023 */
107 	OPID_PAUSE_PRINTER_AFTER_CURRENT_JOB,	/* 0x0024 */
108 	OPID_HOLD_NEW_JOBS,			/* 0x0025 */
109 	OPID_RELEASE_HELD_NEW_JOBS,		/* 0x0026 */
110 	OPID_DEACTIVATE_PRINTER,		/* 0x0027 */
111 	OPID_ACTIVATE_PRINTER,			/* 0x0028 */
112 	OPID_RESTART_PRINTER,			/* 0x0029 */
113 	OPID_SHUTDOWN_PRINTER,			/* 0x002a */
114 	OPID_STARTUP_PRINTER,			/* 0x002b */
115 	OPID_REPROCESS_JOB,			/* 0x002c */
116 	OPID_CANCEL_CURRENT_JOB,		/* 0x002d */
117 	OPID_SUSPEND_CURRENT_JOB,		/* 0x002e */
118 	OPID_RESUME_JOB,			/* 0x002f */
119 	OPID_PROMOTE_JOB,			/* 0x0030 */
120 	OPID_SCHEDULE_JOB_AFTER,		/* 0x0031 */
121 	OPID_RESERVED_MIN,			/* 0x0032 */
122 	OPID_RESERVED_0032 = 0x0032,		/* 0x0032 */
123 	/* ... */
124 	OPID_RESERVED_3FFF = 0x3fff,		/* 0x3fff */
125 	OPID_RESERVED_MAX = 0x3fff,		/* 0x3fff */
126 	OPID_RESERVED_VENDOR_MIN = 0x4000,	/* 0x4000 */
127 	OPID_RESERVED_VENDOR_4000 = 0x4000,	/* 0x4000 */
128 	/* ... */
129 	OPID_RESERVED_VENDOR_8FFF = 0x8fff,	/* 0x8fff */
130 	OPID_RESERVED_VENDOR_MAX = 0x8fff,	/* 0x8fff */
131 	OPID_MAX = 0x8fff			/* 0x8fff */
132 };
133 
134 enum {
135 	/* Delimiter Tags */
136 	DTAG_MIN = 0x00,			/* 0x00 */
137 	DTAG_RESERVED_DELIMITER_00 = 0x00,	/* 0x00 */
138 	DTAG_OPERATION_ATTRIBUTES,		/* 0x01 */
139 	DTAG_JOB_ATTRIBUTES,			/* 0x02 */
140 	DTAG_END_OF_ATTRIBUTES,			/* 0x03 */
141 	DTAG_PRINTER_ATTRIBUTES,		/* 0x04 */
142 	DTAG_UNSUPPORTED_ATTRIBUTES,		/* 0x05 */
143 	DTAG_SUBSCRIPTION_ATTRIBUTES,		/* 0x06 */
144 	DTAG_EVENT_NOTIFICATION_ATTRIBUTES,	/* 0x07 */
145 	DTAG_RESERVED_DELIMITER_08,		/* 0x08 */
146 	DTAG_RESERVED_DELIMITER_09,		/* 0x09 */
147 	DTAG_RESERVED_DELIMITER_0A,		/* 0x0a */
148 	DTAG_RESERVED_DELIMITER_0B,		/* 0x0b */
149 	DTAG_RESERVED_DELIMITER_0C,		/* 0x0c */
150 	DTAG_RESERVED_DELIMITER_0D,		/* 0x0d */
151 	DTAG_RESERVED_DELIMITER_0E,		/* 0x0e */
152 	DTAG_RESERVED_DELIMITER_0F,		/* 0x0f */
153 	DTAG_MAX = 0x0f,			/* 0x0f */
154 
155 	/* Value Tags */
156 	VTAG_MIN = 0x10,			/* 0x10 */
157 	VTAG_UNSUPPORTED = 0x10,		/* 0x10 */
158 	VTAG_RESERVED_DEFAULT,			/* 0x11 */
159 	VTAG_UNKNOWN,				/* 0x12 */
160 	VTAG_NOVALUE,				/* 0x13 */
161 	VTAG_RESERVED_OOB_14,			/* 0x14 */
162 	VTAG_NOT_SETTABLE,			/* 0x15 */
163 	VTAG_DELETE_ATTRIBUTE,			/* 0x16 */
164 	VTAG_ADMIN_DEFINE,			/* 0x17 */
165 	VTAG_RESERVED_OOB_18,			/* 0x18 */
166 	VTAG_RESERVED_OOB_19,			/* 0x19 */
167 	VTAG_RESERVED_OOB_1A,			/* 0x1a */
168 	VTAG_RESERVED_OOB_1B,			/* 0x1b */
169 	VTAG_RESERVED_OOB_1C,			/* 0x1c */
170 	VTAG_RESERVED_OOB_1D,			/* 0x1d */
171 	VTAG_RESERVED_OOB_1E,			/* 0x1e */
172 	VTAG_RESERVED_OOB_1F,			/* 0x1f */
173 	VTAG_RESERVED_INT_GEN,			/* 0x20 */
174 	VTAG_INTEGER,				/* 0x21 */
175 	VTAG_BOOLEAN,				/* 0x22 */
176 	VTAG_ENUM,				/* 0x23 */
177 	VTAG_RESERVED_INT_24,			/* 0x24 */
178 	VTAG_RESERVED_INT_25,			/* 0x25 */
179 	VTAG_RESERVED_INT_26,			/* 0x26 */
180 	VTAG_RESERVED_INT_27,			/* 0x27 */
181 	VTAG_RESERVED_INT_28,			/* 0x28 */
182 	VTAG_RESERVED_INT_29,			/* 0x29 */
183 	VTAG_RESERVED_INT_2A,			/* 0x2a */
184 	VTAG_RESERVED_INT_2B,			/* 0x2b */
185 	VTAG_RESERVED_INT_2C,			/* 0x2c */
186 	VTAG_RESERVED_INT_2D,			/* 0x2d */
187 	VTAG_RESERVED_INT_2E,			/* 0x2e */
188 	VTAG_RESERVED_INT_2F,			/* 0x2f */
189 	VTAG_OCTET_STRING,			/* 0x30 */
190 	VTAG_DATE_TIME,				/* 0x31 */
191 	VTAG_RESOLUTION,			/* 0x32 */
192 	VTAG_RANGE_OF_INTEGER,			/* 0x33 */
193 	VTAG_BEGIN_COLLECTION,			/* 0x34 */
194 	VTAG_TEXT_WITH_LANGUAGE,		/* 0x35 */
195 	VTAG_NAME_WITH_LANGUAGE,		/* 0x36 */
196 	VTAG_END_COLLECTION,			/* 0x37 */
197 	VTAG_RESERVED_STRING_38,		/* 0x38 */
198 	VTAG_RESERVED_STRING_39,		/* 0x39 */
199 	VTAG_RESERVED_STRING_3A,		/* 0x3a */
200 	VTAG_RESERVED_STRING_3B,		/* 0x3b */
201 	VTAG_RESERVED_STRING_3C,		/* 0x3c */
202 	VTAG_RESERVED_STRING_3D,		/* 0x3d */
203 	VTAG_RESERVED_STRING_3E,		/* 0x3e */
204 	VTAG_RESERVED_STRING_3F,		/* 0x3f */
205 	VTAG_RESERVED_CHAR_GEN,			/* 0x40 */
206 	VTAG_TEXT_WITHOUT_LANGUAGE,		/* 0x41 */
207 	VTAG_NAME_WITHOUT_LANGUAGE,		/* 0x42 */
208 	VTAG_RESERVED_43,			/* 0x43 */
209 	VTAG_KEYWORD,				/* 0x44 */
210 	VTAG_URI,				/* 0x45 */
211 	VTAG_URI_SCHEME,			/* 0x46 */
212 	VTAG_CHARSET,				/* 0x47 */
213 	VTAG_NATURAL_LANGUAGE,			/* 0x48 */
214 	VTAG_MIME_MEDIA_TYPE,			/* 0x49 */
215 	VTAG_MEMBER_ATTR_NAME,			/* 0x4a */
216 	VTAG_RESERVED_STRING_4B,		/* 0x4b */
217 	VTAG_RESERVED_STRING_4C,		/* 0x4c */
218 	VTAG_RESERVED_STRING_4D,		/* 0x4d */
219 	VTAG_RESERVED_STRING_4E,		/* 0x4e */
220 	VTAG_RESERVED_STRING_4F,		/* 0x4f */
221 	VTAG_RESERVED_STRING_50,		/* 0x50 */
222 	VTAG_RESERVED_STRING_51,		/* 0x51 */
223 	VTAG_RESERVED_STRING_52,		/* 0x52 */
224 	VTAG_RESERVED_STRING_53,		/* 0x53 */
225 	VTAG_RESERVED_STRING_54,		/* 0x54 */
226 	VTAG_RESERVED_STRING_55,		/* 0x55 */
227 	VTAG_RESERVED_STRING_56,		/* 0x56 */
228 	VTAG_RESERVED_STRING_57,		/* 0x57 */
229 	VTAG_RESERVED_STRING_58,		/* 0x58 */
230 	VTAG_RESERVED_STRING_59,		/* 0x59 */
231 	VTAG_RESERVED_STRING_5A,		/* 0x5a */
232 	VTAG_RESERVED_STRING_5B,		/* 0x5b */
233 	VTAG_RESERVED_STRING_5C,		/* 0x5c */
234 	VTAG_RESERVED_STRING_5D,		/* 0x5d */
235 	VTAG_RESERVED_STRING_5E,		/* 0x5e */
236 	VTAG_RESERVED_STRING_5F,		/* 0x5f */
237 	VTAG_RESERVED_MAX = 0x5f,		/* 0x5f */
238 	VTAG_MAX = 0x5f,			/* 0x5f */
239 	VTAG_EXTEND = 0x7f			/* 0x7f */
240 };
241 
242 /* Response codes */
243 enum {
244 	IPP_OK_MIN = 0x0000,
245 	IPP_OK = 0x0000,			/* 0x0000 */
246 	IPP_OK_IGNORED_ATTRIBUTES,		/* 0x0001 */
247 	IPP_OK_CONFLICTING_ATTRIBUTES,		/* 0x0002 */
248 	IPP_OK_IGNORED_SUBSCRIPTIONS,		/* 0x0003 */
249 	IPP_OK_IGNORED_NOTIFICATIONS,		/* 0x0004 */
250 	IPP_OK_TOO_MANY_EVENTS,			/* 0x0005 */
251 	IPP_OK_BUT_CANCEL_SUBSCRIPTION,		/* 0x0006 */
252 	IPP_OK_MAX = IPP_OK_BUT_CANCEL_SUBSCRIPTION,
253 
254 	IPP_REDIR_MIN = 0x0300,
255 	IPP_REDIR_OTHER_SIZE = 0x0300,		/* 0x0300 */
256 	IPP_REDIR_MAX = 0x0300,
257 
258 	IPP_CERR_MIN = 0x0400,
259 	IPP_CERR_BAD_REQUEST = 0x0400,		/* 0x0400 */
260 	IPP_CERR_FORBIDDEN,			/* 0x0401 */
261 	IPP_CERR_NOT_AUTHENTICATED,		/* 0x0402 */
262 	IPP_CERR_NOT_AUTHORIZED,		/* 0x0403 */
263 	IPP_CERR_NOT_POSSIBLE,			/* 0x0404 */
264 	IPP_CERR_TIMEOUT,			/* 0x0405 */
265 	IPP_CERR_NOT_FOUND,			/* 0x0406 */
266 	IPP_CERR_GONE,				/* 0x0407 */
267 	IPP_CERR_REQUEST_ENTITY,		/* 0x0408 */
268 	IPP_CERR_REQUEST_VALUE,			/* 0x0409 */
269 	IPP_CERR_DOCUMENT_FORMAT,		/* 0x040a */
270 	IPP_CERR_ATTRIBUTES,			/* 0x040b */
271 	IPP_CERR_URI_SCHEME,			/* 0x040c */
272 	IPP_CERR_CHARSET,			/* 0x040d */
273 	IPP_CERR_CONFLICT,			/* 0x040e */
274 	IPP_CERR_COMPRESSION_NOT_SUPPORTED,	/* 0x040f */
275 	IPP_CERR_COMPRESSION_ERROR,		/* 0x0410 */
276 	IPP_CERR_DOCUMENT_FORMAT_ERROR,		/* 0x0411 */
277 	IPP_CERR_DOCUMENT_ACCESS_ERROR,		/* 0x0412 */
278 	IPP_CERR_ATTRIBUTES_NOT_SETTABLE,	/* 0x0413 */
279 	IPP_CERR_IGNORED_ALL_SUBSCRIPTIONS,	/* 0x0414 */
280 	IPP_CERR_TOO_MANY_SUBSCRIPTIONS,	/* 0x0415 */
281 	IPP_CERR_IGNORED_ALL_NOTIFICATIONS,	/* 0x0416 */
282 	IPP_CERR_PRINT_SUPPORT_FILE_NOT_FOUND,	/* 0x0417 */
283 	IPP_CERR_MAX = IPP_CERR_PRINT_SUPPORT_FILE_NOT_FOUND,
284 
285 	IPP_SERR_MIN = 0x0500,
286 	IPP_SERR_INTERNAL = 0x0500,		/* 0x0500 */
287 	IPP_SERR_OPERATION_NOT_SUPPORTED,	/* 0x0501 */
288 	IPP_SERR_SERVICE_UNAVAILABLE,		/* 0x0502 */
289 	IPP_SERR_VERSION_NOT_SUPPORTED,		/* 0x0503 */
290 	IPP_SERR_DEVICE_ERROR,			/* 0x0504 */
291 	IPP_SERR_TEMPORARY_ERROR,		/* 0x0505 */
292 	IPP_SERR_NOT_ACCEPTING,			/* 0x0506 */
293 	IPP_SERR_BUSY,				/* 0x0507 */
294 	IPP_SERR_CANCELLED,			/* 0x0508 */
295 	IPP_SERR_MULTIPLE_DOCS_NOT_SUPPORTED,	/* 0x0509 */
296 	IPP_SERR_PRINTER_IS_DEACTIVATED,	/* 0x050a */
297 	IPP_SERR_MAX = IPP_SERR_PRINTER_IS_DEACTIVATED
298 };
299 
300 /* Job state codes */
301 enum {
302 	IPP_JOB_STATE_PENDING = 3,
303 	IPP_JOB_STATE_PENDING_HELD = 4,
304 	IPP_JOB_STATE_PROCESSING = 5,
305 	IPP_JOB_STATE_PROCESSING_STOPPED = 6,
306 	IPP_JOB_STATE_CANCELED = 7,
307 	IPP_JOB_STATE_ABORTED = 8,
308 	IPP_JOB_STATE_COMPLETED = 9
309 };
310 
311 /* exported functions */
312 extern papi_status_t ipp_read_message(ipp_reader_t iread, void *fd,
313 					papi_attribute_t ***message, char type);
314 
315 extern papi_status_t ipp_write_message(ipp_writer_t iwrite, void *fd,
316 					papi_attribute_t **message);
317 
318 /* internal functions shared between modules */
319 extern void ipp_set_status(papi_attribute_t ***message, papi_status_t status,
320 					char *format, ...);
321 extern papi_status_t ipp_validate_request(papi_attribute_t **request,
322 					papi_attribute_t ***response);
323 
324 extern int ipp_severity(int16_t status);
325 
326 extern int16_t ipp_charset_supported(char *charset);
327 
328 extern void *string_to_ipp_attr_value(int8_t type, char *value);
329 
330 extern char *ipp_uri_to_printer(char *uri);
331 extern void *papi_attribute_to_ipp_attr(int8_t type, papi_attribute_t *attr);
332 
333 extern int8_t name_to_ipp_type(char *name);
334 extern char *job_template[];
335 extern char *job_description[];
336 extern char *printer_description[];
337 extern char *ipp_tag_string(int8_t tag, char *buf, size_t bufsiz);
338 extern size_t min_val_len(int8_t type, char *name);
339 extern size_t max_val_len(int8_t type, char *name);
340 extern int is_keyword(char *value);
341 
342 #ifdef	__cplusplus
343 }
344 #endif
345 
346 #endif	/* _IPP_H */
347