summaryrefslogtreecommitdiff
path: root/bjnp-protocol.h
diff options
context:
space:
mode:
authorTill Kamppeter <till.kamppeter@gmail.com>2016-02-13 22:22:24 -0200
committerTill Kamppeter <till.kamppeter@gmail.com>2016-02-13 22:22:24 -0200
commitaa40a1e8fe0c4ed29d21c5f79e682ac7bef1c33f (patch)
tree66996e1a8b1ad790b09c0890ac7986873b7d435a /bjnp-protocol.h
parent879e6db06338166657609930768f76d8d7e7afbb (diff)
Imported Upstream version 2.0
Diffstat (limited to 'bjnp-protocol.h')
-rw-r--r--bjnp-protocol.h223
1 files changed, 104 insertions, 119 deletions
diff --git a/bjnp-protocol.h b/bjnp-protocol.h
index f55792b..7f2ba3a 100644
--- a/bjnp-protocol.h
+++ b/bjnp-protocol.h
@@ -1,18 +1,19 @@
/*
- * BJNP protocol definitions for the
- * bjnp backend for the Common UNIX Printing System (CUPS).
- * Copyright 2008 - 2012 by Louis Lagendijk
+ * BJNP protocol definitions for the
+ * bjnp backend for the Common UNIX Printing System (CUPS).
+ * Copyright 2008-2014 by Louis Lagendijk
*
- * These coded instructions, statements, and computer programs are the
- * property of Louis Lagendijk and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * "LICENSE" which should have been included with this file. If this
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 only.
*
- * This file is subject to the Apple OS-Developed Software exception.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Contents:
- * <to be added>
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CUPS_BJNP_PROTOCOL_H_
#define _CUPS_BJNP_PROTOCOL_H_
@@ -25,140 +26,124 @@
#define BJNP_METHOD "bjnp"
/* commands */
-typedef enum bjnp_cmd_e
-{
- CMD_UDP_DISCOVER = 0x01, /* discover if service type is listening at
- this port */
- CMD_UDP_PRINT_JOB_DET = 0x10, /* send print job owner details */
- CMD_UDP_CLOSE = 0x11, /* request connection closure */
- CMD_TCP_PRINT = 0x21, /* print */
- CMD_UDP_GET_STATUS = 0x20, /* get printer status */
- CMD_UDP_GET_ID = 0x30, /* get printer identity */
- CMD_UDP_SCAN_JOB = 0x32 /* send scan job owner details */
+typedef enum bjnp_cmd_t {
+ CMD_UDP_DISCOVER = 0x01, /* discover if service type is listening at
+ this port */
+ CMD_UDP_PRINT_JOB_DET = 0x10, /* send print job owner details */
+ CMD_UDP_CLOSE = 0x11, /* request connection closure */
+ CMD_TCP_PRINT = 0x21, /* print */
+ CMD_UDP_GET_STATUS = 0x20, /* get printer status */
+ CMD_UDP_GET_ID = 0x30, /* get printer identity */
+ CMD_UDP_SCAN_JOB = 0x32 /* send scan job owner details */
} bjnp_cmd_t;
/* command type */
-typedef enum uint8_t
-{
- BJNP_CMD_PRINT = 0x1, /* printer command */
- BJNP_CMD_SCAN = 0x2, /* scanner command */
- BJNP_RES_PRINT = 0x81, /* printer response */
- BJNP_RES_SCAN = 0x82 /* scanner response */
-} bjnp_cmd_type_t;
+typedef enum bjnp_device_t {
+ BJNP_CMD_PRINT = 0x1, /* printer command */
+ BJNP_CMD_SCAN = 0x2, /* scanner command */
+ BJNP_RES_PRINT = 0x81, /* printer response */
+ BJNP_RES_SCAN = 0x82 /* scanner response */
+} bjnp_device_type_t;
/* the bjnp header, used for commands and responses */
-struct __attribute__ ((__packed__)) bjnp_header
-{
- char BJNP_id[4]; /* string: BJNP */
- uint8_t dev_type; /* 1 = printer, 2 = scanner */
- uint8_t cmd_code; /* command code/response code */
- uint16_t unknown1; /* unknown, always 0? */
- uint16_t seq_no; /* sequence number */
- uint16_t session_id; /* session id for printing */
- uint32_t payload_len; /* length of command buffer */
+struct __attribute__((__packed__)) bjnp_header {
+ char BJNP_id[4]; /* string: BJNP */
+ uint8_t dev_type; /* 1 = printer, 2 = scanner */
+ uint8_t cmd_code; /* command code/response code */
+ uint16_t unknown1; /* unknown, always 0? */
+ uint16_t seq_no; /* sequence number */
+ uint16_t session_id; /* session id for printing */
+ uint32_t payload_len; /* length of command buffer */
};
#define bjnp_header_size sizeof(struct bjnp_header)
/* command definition */
-typedef union __attribute__ ((__packed__)) bjnp_command_u
- {
+union __attribute__((__packed__)) bjnp_command_u {
struct bjnp_header header;
- struct __attribute__ ((__packed__))
- {
+ struct __attribute__((__packed__)) {
struct bjnp_header header;
- } udp_discover;
- struct __attribute__ ((__packed__))
- {
+ } udp_discover;
+ struct __attribute__((__packed__)) {
struct bjnp_header header;
- char unknown[8]; /* don't know what these are for */
- char hostname[64]; /* hostname of sender */
- char username[64]; /* username */
- char jobtitle[256]; /* job title */
- } udp_job_details;
- struct __attribute__ ((__packed__))
- {
+ char unknown[8]; /* don't know what these are for */
+ char hostname[64]; /* hostname of sender */
+ char username[64]; /* username */
+ char jobtitle[256]; /* job title */
+ } udp_job_details;
+ struct __attribute__((__packed__)) {
struct bjnp_header header;
- } udp_close;
- struct __attribute__ ((__packed__))
- {
+ } udp_close;
+ struct __attribute__((__packed__)) {
struct bjnp_header header;
char data [BJNP_PRINTBUF_MAX];
- /* data to be printer */
- } tcp_print;
- struct __attribute__ ((__packed__))
- {
+ /* data to be printer */
+ } tcp_print;
+ struct __attribute__((__packed__)) {
struct bjnp_header header;
- } udp_get_status;
- struct __attribute__ ((__packed__))
- {
+ } udp_get_status;
+ struct __attribute__((__packed__)) {
struct bjnp_header header;
- } udp_get_id;
- } bjnp_command_u;
-
-typedef union __attribute__ ((__packed__)) bjnp_response_u
-{
- struct bjnp_header header;
- struct __attribute__ ((__packed__))
- {
- struct bjnp_header header;
- char unknown1[4]; /* 00 01 08 00 */
- char mac_len; /* length of mac address */
- char addr_len; /* length od address field */
- unsigned char mac_addr[6];/* printers mac address */
- union __attribute__ ((__packed__) )
- {
- struct __attribute__ ((__packed__))
- {
- unsigned char ipv4_addr[4];
- /* a single IPv4 address */
- } ipv4;
- struct __attribute__ ((__packed__))
- {
+ } udp_get_id;
+} bjnp_command_u;
+
+
+typedef union __attribute__((__packed__)) bjnp_response_u {
+ struct bjnp_header header;
+ struct __attribute__((__packed__)) {
+ struct bjnp_header header;
+ char unknown1[4]; /* 00 01 08 00 */
+ char mac_len; /* length of mac address */
+ char addr_len; /* length od address field */
+ unsigned char mac_addr[6];/* printers mac address */
+ union __attribute__((__packed__)) {
+ struct __attribute__((__packed__)) {
+ unsigned char ipv4_addr[4];
+ /* a single IPv4 address */
+ }
+ ipv4;
+ struct __attribute__((__packed__)) {
unsigned char ipv6_addr[8][16];
- /* array of IPv6 address */
- } ipv6;
- } addresses;
+ /* array of IPv6 address */
+ }
+ ipv6;
+ }
+ addresses;
} udp_discover_response;
-
- struct __attribute__ ((__packed__))
- {
- struct bjnp_header header;
- } udp_print_job_details_response;
-
- struct __attribute__ ((__packed__))
- {
- struct bjnp_header header;
+
+ struct __attribute__((__packed__)) {
+ struct bjnp_header header;
+ } udp_print_job_details_response;
+
+ struct __attribute__((__packed__)) {
+ struct bjnp_header header;
} udp_close_response;
-
- struct __attribute__ ((__packed__))
- {
- struct bjnp_header header;
- uint32_t accepted; /* nr of bytes accepted by printer */
- } tcp_print_response;
-
- struct __attribute__ ((__packed__))
- {
- struct bjnp_header header;
- uint16_t status_len; /* length of status field */
- char status[2048];
+
+ struct __attribute__((__packed__)) {
+ struct bjnp_header header;
+ uint32_t accepted; /* nr of bytes accepted by printer */
+ } tcp_print_response;
+
+ struct __attribute__((__packed__)) {
+ struct bjnp_header header;
+ uint16_t status_len; /* length of status field */
+ char status[BJNP_UDP_MAX];
} udp_status_response;
-
- struct __attribute__ ((__packed__))
- {
- struct bjnp_header header;
- uint16_t id_len; /* length of identity field */
- char id[2048]; /* identity */
+
+ struct __attribute__((__packed__)) {
+ struct bjnp_header header;
+ char status[BJNP_UDP_MAX];
+ } udp_status_response_v2;
+
+ struct __attribute__((__packed__)) {
+ struct bjnp_header header;
+ uint16_t id_len; /* length of identity field */
+ char id[2048]; /* identity */
} udp_identity_response;
- char fillers[4096];
+ char fillers[65536];
} bjnp_response_u;
-#define BST_PRINTING 0x80
-#define BST_BUSY 0x20
-#define BST_OPCALL 0x08
-#define STR_BST "BST:"
-
#endif /* _CUPS_BJNP_PROTOCOL_H_ */