1 /*****************************************************************************\
3 hpmud.h - public definitions for multi-point transport driver
5 (c) 2004-2015 Copyright Hewlett-Packard Development Company, LP
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11 of the Software, and to permit persons to whom the Software is furnished to do
12 so, subject to the following conditions:
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 Author: Naga Samrat Chowdary Narla, Yashwant Sahu, Sarbeswar Meher
25 \*****************************************************************************/
33 HPMUD_R_INVALID_DEVICE = 2,
34 HPMUD_R_INVALID_DESCRIPTOR = 3,
35 HPMUD_R_INVALID_URI = 4,
36 HPMUD_R_INVALID_LENGTH = 8,
37 HPMUD_R_IO_ERROR = 12,
38 HPMUD_R_DEVICE_BUSY = 21,
39 HPMUD_R_INVALID_SN = 28,
40 HPMUD_R_INVALID_CHANNEL_ID = 30,
41 HPMUD_R_INVALID_STATE = 31,
42 HPMUD_R_INVALID_DEVICE_OPEN = 37,
43 HPMUD_R_INVALID_DEVICE_NODE = 38,
44 HPMUD_R_INVALID_IP = 45,
45 HPMUD_R_INVALID_IP_PORT = 46,
46 HPMUD_R_INVALID_TIMEOUT = 47,
47 HPMUD_R_DATFILE_ERROR = 48,
48 HPMUD_R_IO_TIMEOUT = 49,
49 HPMUD_R_INVALID_MDNS = 50,
54 HPMUD_UNI_MODE=0, /* uni-di */
55 HPMUD_RAW_MODE=1, /* bi-di */
57 HPMUD_DOT4_PHOENIX_MODE=4, /* (ie: clj2550, clj2840, lj3050, lj3055, clj4730mfp) */
58 HPMUD_DOT4_BRIDGE_MODE=5, /* (ie: clj2500) not USB compatable, use HPMUD_RAW_MODE, tested on F10 12/10/08 DES */
59 HPMUD_MLC_GUSHER_MODE=6, /* most new devices */
60 HPMUD_MLC_MISER_MODE=7, /* old stuff */
73 HPMUD_SCANTYPE_NA = 0,
74 HPMUD_SCANTYPE_SCL = 1,
75 HPMUD_SCANTYPE_PML = 2,
76 HPMUD_SCANTYPE_SOAP = 3, /* Wookie (ie:ljcm1017) */
77 HPMUD_SCANTYPE_MARVELL = 4, /* (ie: ljm1005) */
78 HPMUD_SCANTYPE_SOAPHT = 5, /* HorseThief (ie: ljm1522) */
79 HPMUD_SCANTYPE_SCL_DUPLEX = 6,
80 HPMUD_SCANTYPE_LEDM = 7,
81 HPMUD_SCANTYPE_MARVELL2 = 8, /* (Tsunami lj 1212 and series) */
87 HPMUD_SCANSRC_FLATBED = 0x1,
88 HPMUD_SCANSRC_ADF= 0x2,
89 HPMUD_SCANSRC_CAMERA = 0x4,
94 HPMUD_STATUSTYPE_NA = 0,
95 HPMUD_STATUSTYPE_VSTATUS = 1, /* device-id vstatus */
96 HPMUD_STATUSTYPE_SFIELD = 2, /* device-id s-field */
97 HPMUD_STATUSTYPE_PML = 3, /* laserjet pml */
98 HPMUD_STATUSTYPE_EWS = 6, /* laserjet hp ews */
99 HPMUD_STATUSTYPE_PJL = 8, /* laserjet pjl */
100 HPMUD_STATUSTYPE_PJLPML = 9, /* laserjet pjl and pml */
103 enum HPMUD_SUPPORT_TYPE
105 HPMUD_SUPPORT_TYPE_NONE = 0, /* not supported */
106 HPMUD_SUPPORT_TYPE_HPIJS = 1, /* supported by hpijs only */
107 HPMUD_SUPPORT_TYPE_HPLIP = 2, /* supported by hpijs and "hp" backend */
110 enum HPMUD_PLUGIN_TYPE
112 HPMUD_PLUGIN_TYPE_NONE = 0,
113 HPMUD_PLUGIN_TYPE_REQUIRED = 1,
114 HPMUD_PLUGIN_TYPE_OPTIONAL = 2,
117 #define HPMUD_S_PRINT_CHANNEL "PRINT"
118 #define HPMUD_S_PML_CHANNEL "HP-MESSAGE"
119 #define HPMUD_S_SCAN_CHANNEL "HP-SCAN"
120 #define HPMUD_S_FAX_SEND_CHANNEL "HP-FAX-SEND"
121 #define HPMUD_S_CONFIG_UPLOAD_CHANNEL "HP-CONFIGURATION-UPLOAD"
122 #define HPMUD_S_CONFIG_DOWNLOAD_CHANNEL "HP-CONFIGURATION-DOWNLOAD"
123 #define HPMUD_S_MEMORY_CARD_CHANNEL "HP-CARD-ACCESS"
124 #define HPMUD_S_EWS_CHANNEL "HP-EWS"
125 #define HPMUD_S_EWS_LEDM_CHANNEL "HP-EWS-LEDM"
126 #define HPMUD_S_SOAP_SCAN "HP-SOAP-SCAN"
127 #define HPMUD_S_SOAP_FAX "HP-SOAP-FAX"
128 #define HPMUD_S_DEVMGMT_CHANNEL "HP-DEVMGMT"
129 #define HPMUD_S_MARVELL_SCAN_CHANNEL "HP-MARVELL-SCAN"
130 #define HPMUD_S_MARVELL_FAX_CHANNEL "HP-MARVELL-FAX"
131 #define HPMUD_S_LEDM_SCAN "HP-LEDM-SCAN"
132 #define HPMUD_S_WIFI_CHANNEL "HP-WIFICONFIG"
134 typedef int HPMUD_DEVICE; /* usb, parallel or jetdirect */
135 #define HPMUD_DEVICE_MAX 2 /* zero is not used */
137 typedef int HPMUD_CHANNEL;
138 #define HPMUD_CHANNEL_MAX HPMUD_MAX_CHANNEL_ID
140 #define HPMUD_LINE_SIZE 256 /* Length of a line. */
141 #define HPMUD_BUFFER_SIZE 16384 /* General Read/Write buffer. */
145 char uri[HPMUD_LINE_SIZE];
146 int client_cnt; /* number of clients that have this device opend */
147 enum HPMUD_IO_MODE io_mode;
148 int channel_cnt; /* number of open channels */
149 int mlc_up; /* 0 = MLC/1284.4 transport up, 1 = MLD/1284.4 transport down */
152 struct hpmud_model_attributes
154 enum HPMUD_IO_MODE prt_mode; /* print only (io_mode) */
155 enum HPMUD_IO_MODE mfp_mode; /* pml | scan | fax (io_mode) */
156 enum HPMUD_SCANTYPE scantype; /* scan protocol i.e. SCL, PML, SOAP, MARVELL, LEDM */
157 enum HPMUD_STATUSTYPE statustype;
158 enum HPMUD_SUPPORT_TYPE support;
159 enum HPMUD_PLUGIN_TYPE plugin;
160 enum HPMUD_SUPPORT_TYPE reserved[5];
161 enum HPMUD_SCANSRC scansrc; /*Flatbed, ADF, Camera or combination of these*/
169 * hpmud_device_open - open specified device, call normally does not block
172 * uri - specifies device to open
173 * io_mode - see enum definition
176 * dd - device descriptor
177 * return value - see enum definition
179 enum HPMUD_RESULT hpmud_open_device(const char *uri, enum HPMUD_IO_MODE io_mode, HPMUD_DEVICE *dd);
182 * hpmud_device_close - close specified device, call does not block
185 * dd - device descriptor
188 * return value - see enum definition
190 enum HPMUD_RESULT hpmud_close_device(HPMUD_DEVICE dd);
193 * hpmud_get_device_id - read IEEE 1284 device ID string, call normally does not block
195 * If the device is busy, a cached copy may be returned.
198 * dd - device descriptor
199 * buf_size - maximum size of buf
202 * buf - zero terminated device ID string
203 * bytes_read - size of device ID string, does not include zero termination
204 * return value - see enum definition
206 enum HPMUD_RESULT hpmud_get_device_id(HPMUD_DEVICE dd, char *buf, int buf_size, int *bytes_read);
209 * hpmud_get_device_status - read 8-bit device status, call normally does not block
212 * dd - device descriptor
215 * status - 3-bit status, supported by inkjets only
216 * return value - see enum definition
218 enum HPMUD_RESULT hpmud_get_device_status(HPMUD_DEVICE dd, unsigned int *status);
221 * hpmud_probe_devices - probe local buses for HP supported devices, call normally does not block
224 * bus - see enum definiton
225 * buf_size - size of read buffer
228 * buf - zero terminated CUPS backend formatted data
229 * cnt - number of HP devices found
230 * bytes_read - number of bytes actually read
231 * return value - see enum definition
233 enum HPMUD_RESULT hpmud_probe_devices(enum HPMUD_BUS_ID bus, char *buf, int buf_size, int *cnt, int *bytes_read);
236 * hpmud_channel_open - open specified channel, call will block
238 * Only EWS channel can be opened by more than one process.
241 * dd - device descriptor
242 * channel_name - requested service name
245 * cd - channel descriptor
246 * return value - see enum definition
248 enum HPMUD_RESULT hpmud_open_channel(HPMUD_DEVICE dd, const char *channel_name, HPMUD_CHANNEL *cd);
251 * hpmud_channel_close - close specified channel, call will block
254 * dd - device descriptor
255 * cd - channel descriptor
258 * return value - see enum definition
260 enum HPMUD_RESULT hpmud_close_channel(HPMUD_DEVICE dd, HPMUD_CHANNEL cd);
263 * hpmud_channel_write - write data to specified channel, call will block
265 * May return with partial bytes written (ie: bytes_wrote < size) with or with-out a timeout.
268 * dd - device descriptor
269 * cd - channel descriptor
270 * buf - data to write
271 * size - number of bytes to write
272 * timeout - in seconds
275 * bytes_wrote - number of bytes actually wrote
276 * return value - see enum definition
278 enum HPMUD_RESULT hpmud_write_channel(HPMUD_DEVICE dd, HPMUD_CHANNEL cd, const void *buf, int size, int timeout, int *bytes_written);
281 * hpmud_channel_read - read data from specified channel, call will block
283 * May return with partial bytes read (ie: bytes_read < size) or zero if timeout occured.
286 * dd - device descriptor
287 * cd - channel descriptor
288 * size - number of bytes to read
289 * timeout - in seconds
292 * buf - read data buffer
293 * bytes_read - number of bytes actually read
294 * return value - see enum definition
296 enum HPMUD_RESULT hpmud_read_channel(HPMUD_DEVICE dd, HPMUD_CHANNEL cd, void *buf, int size, int timeout, int *bytes_read);
299 * hpmud_dstat - get device information
302 * dd - device descriptor
305 * ds - see dstat definition
306 * return value - see enum definition
308 enum HPMUD_RESULT hpmud_get_dstat(HPMUD_DEVICE dd, struct hpmud_dstat *ds);
311 * hpmud_set_pml - set pml object
313 * Set_pml is a high level interface to hpmud. This command calls the hpmud core interface.
314 * This command can be used with local or jetdirect connections. Jetdirect connection will
318 * dd - device descriptor
319 * cc - channel descriptor
320 * snmp_oid - snmp encoded pml oid
321 * type - oid data type
322 * data - data payload
323 * data_size - number of bytes to write
327 * return value - see enum definition
329 enum HPMUD_RESULT hpmud_set_pml(HPMUD_DEVICE device, HPMUD_CHANNEL channel, const char *snmp_oid, int type, void *data, int data_size, int *pml_result);
332 * hpmud_get_pml - get pml object
334 * Get_pml is a high level interface to hpmud. This command calls the hpmud core interface.
335 * This command can be used with local or jetdirect connections. Jetdirect connection will
339 * dd - device descriptor
340 * cc - channel descriptor
341 * snmp_oid - snmp encoded pml oid
342 * data_size - data buffer size in bytes
345 * data - data payload
346 * type - pml data type
348 * return value - see enum definition
350 enum HPMUD_RESULT hpmud_get_pml(HPMUD_DEVICE device, HPMUD_CHANNEL channel, const char *snmp_oid, void *buf, int buf_size, int *bytes_read, int *type, int *pml_result);
353 * hpmud_get_model - parse device model from the IEEE 1284 device id string.
355 * This function is a stateless hpmud helper function.
358 * id - IEEE 1284 device id string
359 * buf_size - size of buf in bytes
362 * buf - device model string (generalized)
363 * return value - length of string in bytes, does not include zero termination
365 int hpmud_get_model(const char *id, char *buf, int buf_size);
368 * hpmud_get_raw_model - parse device model from the IEEE 1284 device id string.
370 * This function is a stateless hpmud helper function.
373 * id - IEEE 1284 device id string
374 * buf_size - size of buf in bytes
377 * buf - device model string (raw)
378 * return value - length of string in bytes, does not include zero termination
380 int hpmud_get_raw_model(char *id, char *raw, int rawSize);
383 * hpmud_get_uri_model - parse device model from uri
385 * This function is a stateless hpmud helper function.
389 * buf_size - size of buf in bytes
392 * buf - device model string
393 * return value - length of string in bytes, does not include zero termination
395 int hpmud_get_uri_model(const char *uri, char *buf, int buf_size);
398 * hpmud_get_uri_datalink - parse the data link from uri
400 * This function is a stateless hpmud helper function.
404 * buf_size - size of buf in bytes
407 * buf - device model string
408 * return value - length of string in bytes, does not include zero termination
410 int hpmud_get_uri_datalink(const char *uri, char *buf, int buf_size);
413 * hpmud_get_model_attributes - get all model attributes for specified device
415 * Reads device model attributes from models.dat file. This function is a
416 * stateless hpmud helper function.
419 * uri - specifies device
420 * buf_size - size of buf in bytes
423 * buf - buffer for all model attributes, key/value pair, one per line
424 * bytes_read - number of bytes actually read
425 * return value - see enum definition
427 enum HPMUD_RESULT hpmud_get_model_attributes(char *uri, char *attr, int attrSize, int *bytes_read);
430 * hpmud_model_query - get model attributes structure for specified device
432 * Reads device model attributes from models.dat file. This function is a
433 * stateless hpmud helper function.
436 * uri - specifies device
439 * ma - see structure definition
440 * return value - see enum definition
442 enum HPMUD_RESULT hpmud_query_model(char *uri, struct hpmud_model_attributes *ma);
445 * hpmud_make_usb_uri - make a usb uri from bus:dev pair
447 * This function is a stateless hpmud helper function. The lsusb command can be used
448 * determine the bus:dev pair.
451 * busnum - specifies usbfs bus number
452 * devnum - specifies usbfs device number
453 * uri_size - size of uri buffer in bytes
456 * uri - zero terminated string
457 * bytes_read - size of uri
458 * return value - see enum definition
460 enum HPMUD_RESULT hpmud_make_usb_uri(const char *busnum, const char *devnum, char *uri, int uri_size, int *bytes_read);
463 * hpmud_make_usb_serial_uri - make a usb uri from product serial number
465 * This function is a stateless hpmud helper function. The lsusb command can be used
466 * determine the product serial number.
469 * sn - specifies product serial number
470 * uri_size - size of uri buffer in bytes
473 * uri - zero terminated string
474 * bytes_read - size of uri
475 * return value - see enum definition
477 enum HPMUD_RESULT hpmud_make_usb_serial_uri(const char *sn, char *uri, int uri_size, int *bytes_read);
480 * hpmud_make_net_uri - make a net uri from IP
482 * This function is a stateless hpmud helper function.
485 * ip - internet address
487 * uri_size - size of uri buffer in bytes
490 * uri - zero terminated string
491 * bytes_read - size of uri
492 * return value - see enum definition
494 enum HPMUD_RESULT hpmud_make_net_uri(const char *ip, int port, char *uri, int uri_size, int *bytes_read);
497 * hpmud_make_par_uri - make a par uri from parallel port
499 * This function is a stateless hpmud helper function.
502 * dnode - device node
503 * uri_size - size of uri buffer in bytes
506 * uri - zero terminated string
507 * bytes_read - size of uri
508 * return value - see enum definition
510 enum HPMUD_RESULT hpmud_make_par_uri(const char *dnode, char *uri, int uri_size, int *bytes_read);
513 * hpmud_get_conf - get key value from hplip.conf
515 * This function is a stateless hpmud helper function.
518 * section - zero terminated string (ie: "[dirs]")
519 * key - zero terminated string (ie: "home")
520 * value_size - size of value buffer in bytes
523 * value - zero terminated string
524 * return value - see enum definition
526 enum HPMUD_RESULT hpmud_get_conf(const char *section, const char *key, char *value, int value_size);
529 * hpmud_get_key_value - get key value from specified file
531 * This function is a stateless hpmud helper function.
534 * file - zero terminated file path
535 * section - zero terminated string (ie: "[dirs]")
536 * key - zero terminated string (ie: "home")
537 * value_size - size of value buffer in bytes
540 * value - zero terminated string
541 * return value - see enum definition
543 enum HPMUD_RESULT hpmud_get_key_value(const char *file, const char *section, const char *key, char *value, int value_size);
546 * hpmud_mdns_lookup - lookup IP for MDNS host name
548 * This function is a stateless hpmud helper function.
551 * host_name - zero terminated string (ie: "npi7c8a3e")
552 * sec_timeout - in seconds
555 * ip - zero terminated string
556 * return value - see enum definition
558 enum HPMUD_RESULT hpmud_mdns_lookup(const char *host_name, int sec_timeout, char *ip);
561 * hpmud_make_mdns_uri - make a network uri from host name
563 * This function is a stateless hpmud helper function. Requires UDP port 5353 to be open.
566 * host - zero terminated string (ie: "npi7c8a3e")
567 * uri_size - size of uri buffer in bytes
570 * uri - zero terminated string
571 * bytes_read - size of uri
572 * return value - see enum definition
574 enum HPMUD_RESULT hpmud_make_mdns_uri(const char *host, int port, char *uri, int uri_size, int *bytes_read);