2014-12-24 11:42:16 +00:00
|
|
|
/* packet-zvt.c
|
|
|
|
* Routines for ZVT dissection
|
|
|
|
* Copyright 2014-2015, Martin Kaiser <martin@kaiser.cx>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* 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; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* ZVT is a manufacturer-independent protocol between payment terminals and
|
|
|
|
* electronic cash-register systems / vending machines
|
|
|
|
*
|
|
|
|
* the specifications are available from http://www.zvt-kassenschnittstelle.de
|
|
|
|
*
|
|
|
|
* ZVT defines a "serial transport protocol" and a "TCP/IP transport
|
|
|
|
* protocol"
|
|
|
|
*
|
|
|
|
* ZVT can sit on top of USB, either the serial or the TCP/IP protocol
|
|
|
|
* can be used in this case - this is not supported for now
|
|
|
|
*
|
|
|
|
* a dump of ZVT data can be converted to pcap, using a user-defined DLT
|
|
|
|
* we register the dissector by name and try to auto-detect the serial
|
|
|
|
* or TCP/IP protocol
|
|
|
|
*
|
|
|
|
* finally, ZVT can run on top of TCP, the default port is 20007, only
|
|
|
|
* the TCP/IP protocol can be used here
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/addr_resolv.h>
|
2015-06-02 17:54:09 +00:00
|
|
|
#include <epan/expert.h>
|
2014-12-24 11:42:16 +00:00
|
|
|
|
|
|
|
/* special characters of the serial transport protocol */
|
2015-01-10 17:33:32 +00:00
|
|
|
#define STX 0x02
|
|
|
|
#define ETX 0x03
|
2014-12-24 11:42:16 +00:00
|
|
|
#define ACK 0x06
|
2015-01-10 17:33:32 +00:00
|
|
|
#define DLE 0x10
|
2014-12-24 11:42:16 +00:00
|
|
|
#define NAK 0x15
|
|
|
|
|
|
|
|
/* an APDU needs at least a 2-byte control-field and one byte length */
|
|
|
|
#define ZVT_APDU_MIN_LEN 3
|
|
|
|
|
2015-01-11 11:45:39 +00:00
|
|
|
|
2016-12-23 18:06:24 +00:00
|
|
|
static GHashTable *apdu_table = NULL, *bitmap_table = NULL, *tlv_table = NULL;
|
2015-01-11 11:45:39 +00:00
|
|
|
|
2015-05-31 17:02:29 +00:00
|
|
|
static wmem_tree_t *transactions = NULL;
|
|
|
|
|
2015-06-02 18:20:32 +00:00
|
|
|
typedef struct _zvt_transaction_t {
|
|
|
|
guint32 rqst_frame;
|
|
|
|
guint32 resp_frame;
|
|
|
|
guint16 ctrl;
|
|
|
|
} zvt_transaction_t;
|
|
|
|
|
2015-01-11 11:45:39 +00:00
|
|
|
typedef enum _zvt_direction_t {
|
|
|
|
DIRECTION_UNKNOWN,
|
|
|
|
DIRECTION_ECR_TO_PT,
|
|
|
|
DIRECTION_PT_TO_ECR
|
|
|
|
} zvt_direction_t;
|
|
|
|
|
|
|
|
/* source/destination address field */
|
|
|
|
#define ADDR_ECR "ECR"
|
|
|
|
#define ADDR_PT "PT"
|
|
|
|
|
2015-04-17 15:34:14 +00:00
|
|
|
#define CCRC_POS 0x80
|
|
|
|
#define CCRC_NEG 0x84
|
|
|
|
|
2015-06-02 17:54:09 +00:00
|
|
|
/* "don't care" value for min_len_field */
|
|
|
|
#define LEN_FIELD_ANY G_MAXUINT32
|
|
|
|
|
2015-01-11 11:45:39 +00:00
|
|
|
typedef struct _apdu_info_t {
|
|
|
|
guint16 ctrl;
|
|
|
|
guint32 min_len_field;
|
|
|
|
zvt_direction_t direction;
|
2015-06-02 18:20:32 +00:00
|
|
|
void (*dissect_payload)(tvbuff_t *, gint, guint16,
|
|
|
|
packet_info *, proto_tree *, zvt_transaction_t *);
|
2015-01-11 11:45:39 +00:00
|
|
|
} apdu_info_t;
|
|
|
|
|
2015-01-11 10:57:42 +00:00
|
|
|
/* control code 0 is not defined in the specification */
|
2015-01-11 11:45:39 +00:00
|
|
|
#define ZVT_CTRL_NONE 0x0000
|
2015-02-19 21:52:42 +00:00
|
|
|
|
2015-01-11 11:45:39 +00:00
|
|
|
#define CTRL_STATUS 0x040F
|
|
|
|
#define CTRL_INT_STATUS 0x04FF
|
2015-01-11 15:46:36 +00:00
|
|
|
#define CTRL_REGISTRATION 0x0600
|
2015-01-11 11:45:39 +00:00
|
|
|
#define CTRL_AUTHORISATION 0x0601
|
|
|
|
#define CTRL_COMPLETION 0x060F
|
2015-01-11 15:46:36 +00:00
|
|
|
#define CTRL_ABORT 0x061E
|
|
|
|
#define CTRL_END_OF_DAY 0x0650
|
|
|
|
#define CTRL_DIAG 0x0670
|
|
|
|
#define CTRL_INIT 0x0693
|
2015-01-11 11:45:39 +00:00
|
|
|
#define CTRL_PRINT_LINE 0x06D1
|
|
|
|
|
2016-09-04 16:42:03 +00:00
|
|
|
static void dissect_zvt_int_status(tvbuff_t *tvb, gint offset, guint16 len,
|
|
|
|
packet_info *pinfo, proto_tree *tree, zvt_transaction_t *zvt_trans);
|
2015-06-02 18:20:32 +00:00
|
|
|
static void dissect_zvt_reg(tvbuff_t *tvb, gint offset, guint16 len,
|
|
|
|
packet_info *pinfo, proto_tree *tree, zvt_transaction_t *zvt_trans);
|
2016-07-24 17:23:48 +00:00
|
|
|
static void dissect_zvt_bitmap_seq(tvbuff_t *tvb, gint offset, guint16 len,
|
2015-06-02 18:20:32 +00:00
|
|
|
packet_info *pinfo, proto_tree *tree, zvt_transaction_t *zvt_trans);
|
2016-09-04 16:58:35 +00:00
|
|
|
static void dissect_zvt_init(tvbuff_t *tvb, gint offset, guint16 len,
|
|
|
|
packet_info *pinfo, proto_tree *tree, zvt_transaction_t *zvt_trans);
|
2015-01-11 11:45:39 +00:00
|
|
|
|
|
|
|
static const apdu_info_t apdu_info[] = {
|
2016-12-13 23:28:43 +00:00
|
|
|
{ CTRL_STATUS, 0, DIRECTION_PT_TO_ECR, dissect_zvt_bitmap_seq },
|
2016-09-04 16:42:03 +00:00
|
|
|
{ CTRL_INT_STATUS, 0, DIRECTION_PT_TO_ECR, dissect_zvt_int_status },
|
2015-02-19 21:52:42 +00:00
|
|
|
{ CTRL_REGISTRATION, 4, DIRECTION_ECR_TO_PT, dissect_zvt_reg },
|
2015-01-11 11:45:39 +00:00
|
|
|
/* authorisation has at least a 0x04 tag and 6 bytes for the amount */
|
2016-07-24 17:23:48 +00:00
|
|
|
{ CTRL_AUTHORISATION, 7, DIRECTION_ECR_TO_PT, dissect_zvt_bitmap_seq },
|
|
|
|
{ CTRL_COMPLETION, 0, DIRECTION_PT_TO_ECR, dissect_zvt_bitmap_seq },
|
2015-02-19 21:52:42 +00:00
|
|
|
{ CTRL_ABORT, 0, DIRECTION_PT_TO_ECR, NULL },
|
|
|
|
{ CTRL_END_OF_DAY, 0, DIRECTION_ECR_TO_PT, NULL },
|
|
|
|
{ CTRL_DIAG, 0, DIRECTION_ECR_TO_PT, NULL },
|
2016-09-04 16:58:35 +00:00
|
|
|
{ CTRL_INIT, 0, DIRECTION_ECR_TO_PT, dissect_zvt_init },
|
2015-02-19 21:52:42 +00:00
|
|
|
{ CTRL_PRINT_LINE, 0, DIRECTION_PT_TO_ECR, NULL }
|
2015-01-11 11:45:39 +00:00
|
|
|
};
|
2015-01-11 10:57:42 +00:00
|
|
|
|
2016-07-24 16:43:14 +00:00
|
|
|
|
|
|
|
typedef struct _bitmap_info_t {
|
|
|
|
guint8 bmp;
|
|
|
|
guint16 payload_len;
|
|
|
|
gint (*dissect_payload)(tvbuff_t *, gint, packet_info *, proto_tree *);
|
|
|
|
} bitmap_info_t;
|
|
|
|
|
|
|
|
#define BMP_TIMEOUT 0x01
|
|
|
|
#define BMP_MAX_STAT_INFO 0x02
|
2016-12-13 23:28:43 +00:00
|
|
|
#define BMP_SVC_BYTE 0x03
|
2016-07-24 16:43:14 +00:00
|
|
|
#define BMP_AMOUNT 0x04
|
|
|
|
#define BMP_PUMP_NR 0x05
|
|
|
|
#define BMP_TLV_CONTAINER 0x06
|
2016-12-13 23:28:43 +00:00
|
|
|
#define BMP_TRACE_NUM 0x0B
|
|
|
|
#define BMP_TIME 0x0C
|
|
|
|
#define BMP_DATE 0x0D
|
2016-07-24 16:43:14 +00:00
|
|
|
#define BMP_EXP_DATE 0x0E
|
2016-12-13 23:28:43 +00:00
|
|
|
#define BMP_CARD_SEQ_NUM 0x17
|
2016-07-24 16:43:14 +00:00
|
|
|
#define BMP_PAYMENT_TYPE 0x19
|
|
|
|
#define BMP_CARD_NUM 0x22
|
|
|
|
#define BMP_T2_DAT 0x23
|
|
|
|
#define BMP_T3_DAT 0x24
|
2016-12-13 23:28:43 +00:00
|
|
|
#define BMP_RES_CODE 0x27
|
|
|
|
#define BMP_TID 0x29
|
2016-07-24 16:43:14 +00:00
|
|
|
#define BMP_T1_DAT 0x2D
|
|
|
|
#define BMP_CVV_CVC 0x3A
|
|
|
|
#define BMP_ADD_DATA 0x3C
|
|
|
|
#define BMP_CC 0x49
|
2016-12-13 23:28:43 +00:00
|
|
|
#define BMP_RCPT_NUM 0x87
|
|
|
|
#define BMP_CARD_TYPE 0x8A
|
2016-07-24 16:43:14 +00:00
|
|
|
|
|
|
|
#define BMP_PLD_LEN_UNKNOWN 0 /* unknown/variable bitmap payload len */
|
|
|
|
|
|
|
|
static gint dissect_zvt_tlv_container(
|
|
|
|
tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *tree);
|
2016-12-24 13:01:16 +00:00
|
|
|
static inline gint dissect_zvt_res_code(
|
2016-12-16 22:47:02 +00:00
|
|
|
tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *tree);
|
2016-12-24 13:01:16 +00:00
|
|
|
static inline gint dissect_zvt_cc(
|
2016-09-04 16:20:41 +00:00
|
|
|
tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *tree);
|
2016-12-24 13:01:16 +00:00
|
|
|
static inline gint dissect_zvt_card_type(
|
2016-12-16 22:47:02 +00:00
|
|
|
tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *tree);
|
2016-07-24 16:43:14 +00:00
|
|
|
|
|
|
|
static const bitmap_info_t bitmap_info[] = {
|
|
|
|
{ BMP_TIMEOUT, 1, NULL },
|
|
|
|
{ BMP_MAX_STAT_INFO, 1, NULL },
|
2016-12-13 23:28:43 +00:00
|
|
|
{ BMP_SVC_BYTE, 1, NULL },
|
2016-07-24 16:43:14 +00:00
|
|
|
{ BMP_AMOUNT, 6, NULL },
|
|
|
|
{ BMP_PUMP_NR, 1, NULL },
|
|
|
|
{ BMP_TLV_CONTAINER, BMP_PLD_LEN_UNKNOWN, dissect_zvt_tlv_container },
|
2016-12-13 23:28:43 +00:00
|
|
|
{ BMP_TRACE_NUM, 3, NULL },
|
|
|
|
{ BMP_TIME, 3, NULL },
|
|
|
|
{ BMP_DATE, 2, NULL },
|
2016-07-24 16:43:14 +00:00
|
|
|
{ BMP_EXP_DATE, 2, NULL },
|
2016-12-13 23:28:43 +00:00
|
|
|
{ BMP_CARD_SEQ_NUM, 2, NULL },
|
2016-07-24 16:43:14 +00:00
|
|
|
{ BMP_PAYMENT_TYPE, 1, NULL },
|
|
|
|
{ BMP_CARD_NUM, BMP_PLD_LEN_UNKNOWN, NULL },
|
|
|
|
{ BMP_T2_DAT, BMP_PLD_LEN_UNKNOWN, NULL },
|
|
|
|
{ BMP_T3_DAT, BMP_PLD_LEN_UNKNOWN, NULL },
|
2016-12-16 22:47:02 +00:00
|
|
|
{ BMP_RES_CODE, 1, dissect_zvt_res_code },
|
2016-12-13 23:28:43 +00:00
|
|
|
{ BMP_TID, 4, NULL },
|
2016-07-24 16:43:14 +00:00
|
|
|
{ BMP_T1_DAT, BMP_PLD_LEN_UNKNOWN, NULL },
|
|
|
|
{ BMP_CVV_CVC, 2, NULL },
|
|
|
|
{ BMP_ADD_DATA, BMP_PLD_LEN_UNKNOWN, NULL },
|
2016-12-13 23:28:43 +00:00
|
|
|
{ BMP_CC, 2, dissect_zvt_cc },
|
|
|
|
{ BMP_RCPT_NUM, 2, NULL },
|
2016-12-16 22:47:02 +00:00
|
|
|
{ BMP_CARD_TYPE, 1, dissect_zvt_card_type }
|
2016-07-24 16:43:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-12-24 11:42:16 +00:00
|
|
|
void proto_register_zvt(void);
|
|
|
|
void proto_reg_handoff_zvt(void);
|
|
|
|
|
|
|
|
static int proto_zvt = -1;
|
|
|
|
|
|
|
|
static int ett_zvt = -1;
|
|
|
|
static int ett_zvt_apdu = -1;
|
2016-07-24 16:43:14 +00:00
|
|
|
static int ett_zvt_bitmap = -1;
|
2015-04-17 17:14:13 +00:00
|
|
|
static int ett_zvt_tlv_dat_obj = -1;
|
2016-12-23 18:06:24 +00:00
|
|
|
static int ett_zvt_tlv_subseq = -1;
|
2015-07-13 07:47:21 +00:00
|
|
|
static int ett_zvt_tlv_tag = -1;
|
2014-12-24 11:42:16 +00:00
|
|
|
|
2015-05-31 17:02:29 +00:00
|
|
|
static int hf_zvt_resp_in = -1;
|
|
|
|
static int hf_zvt_resp_to = -1;
|
2015-01-10 17:33:32 +00:00
|
|
|
static int hf_zvt_serial_char = -1;
|
|
|
|
static int hf_zvt_crc = -1;
|
2014-12-24 11:42:16 +00:00
|
|
|
static int hf_zvt_ctrl = -1;
|
2015-01-11 10:57:42 +00:00
|
|
|
static int hf_zvt_ccrc = -1;
|
|
|
|
static int hf_zvt_aprc = -1;
|
2014-12-24 11:42:16 +00:00
|
|
|
static int hf_zvt_len = -1;
|
2015-01-11 10:57:42 +00:00
|
|
|
static int hf_zvt_data = -1;
|
2016-09-04 16:42:03 +00:00
|
|
|
static int hf_zvt_int_status = -1;
|
2016-09-04 16:58:35 +00:00
|
|
|
static int hf_zvt_pwd = -1;
|
2015-02-08 19:15:42 +00:00
|
|
|
static int hf_zvt_reg_cfg = -1;
|
2016-12-16 22:47:02 +00:00
|
|
|
static int hf_zvt_res_code = -1;
|
2015-02-17 22:13:00 +00:00
|
|
|
static int hf_zvt_cc = -1;
|
2016-12-16 22:47:02 +00:00
|
|
|
static int hf_zvt_card_type = -1;
|
2015-02-17 22:13:00 +00:00
|
|
|
static int hf_zvt_reg_svc_byte = -1;
|
2016-07-24 16:24:08 +00:00
|
|
|
static int hf_zvt_bmp = -1;
|
2015-06-22 17:23:36 +00:00
|
|
|
static int hf_zvt_tlv_total_len = -1;
|
2015-04-17 17:14:13 +00:00
|
|
|
static int hf_zvt_tlv_tag = -1;
|
2015-07-13 07:47:21 +00:00
|
|
|
static int hf_zvt_tlv_tag_class = -1;
|
|
|
|
static int hf_zvt_tlv_tag_type = -1;
|
2015-04-17 17:14:13 +00:00
|
|
|
static int hf_zvt_tlv_len = -1;
|
2016-12-14 17:50:58 +00:00
|
|
|
static int hf_zvt_text_lines_line = -1;
|
2014-12-24 11:42:16 +00:00
|
|
|
|
2015-06-02 17:54:09 +00:00
|
|
|
static expert_field ei_invalid_apdu_len = EI_INIT;
|
|
|
|
|
2015-01-10 17:33:32 +00:00
|
|
|
static const value_string serial_char[] = {
|
|
|
|
{ STX, "Start of text (STX)" },
|
|
|
|
{ ETX, "End of text (ETX)" },
|
|
|
|
{ ACK, "Acknowledged (ACK)" },
|
|
|
|
{ DLE, "Data line escape (DLE)" },
|
|
|
|
{ NAK, "Not acknowledged (NAK)" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
static value_string_ext serial_char_ext = VALUE_STRING_EXT_INIT(serial_char);
|
|
|
|
|
2015-01-11 11:45:39 +00:00
|
|
|
|
2014-12-24 11:42:16 +00:00
|
|
|
static const value_string ctrl_field[] = {
|
2015-01-11 11:45:39 +00:00
|
|
|
{ CTRL_STATUS, "Status Information" },
|
|
|
|
{ CTRL_INT_STATUS, "Intermediate Status Information" },
|
2015-01-11 15:46:36 +00:00
|
|
|
{ CTRL_REGISTRATION, "Registration" },
|
2015-01-11 11:45:39 +00:00
|
|
|
{ CTRL_AUTHORISATION, "Authorisation" },
|
|
|
|
{ CTRL_COMPLETION, "Completion" },
|
2015-01-11 15:46:36 +00:00
|
|
|
{ CTRL_ABORT, "Abort" },
|
|
|
|
{ CTRL_END_OF_DAY, "End Of Day" },
|
|
|
|
{ CTRL_DIAG, "Diagnosis" },
|
|
|
|
{ CTRL_INIT, "Initialisation" },
|
2015-01-11 11:45:39 +00:00
|
|
|
{ CTRL_PRINT_LINE, "Print Line" },
|
2014-12-24 11:42:16 +00:00
|
|
|
{ 0x06D3, "Print Text Block" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
static value_string_ext ctrl_field_ext = VALUE_STRING_EXT_INIT(ctrl_field);
|
|
|
|
|
2016-09-04 16:20:41 +00:00
|
|
|
static const value_string zvt_cc[] = {
|
|
|
|
{ 0x0978, "EUR" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2016-12-16 22:47:02 +00:00
|
|
|
static const value_string card_type[] = {
|
|
|
|
{ 2, "ec-card" },
|
|
|
|
{ 5, "girocard" },
|
|
|
|
{ 6, "Mastercard" },
|
|
|
|
{ 10, "VISA" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
static value_string_ext card_type_ext = VALUE_STRING_EXT_INIT(card_type);
|
|
|
|
|
2015-02-19 21:52:42 +00:00
|
|
|
static const value_string bitmap[] = {
|
|
|
|
{ BMP_TIMEOUT, "Timeout" },
|
|
|
|
{ BMP_MAX_STAT_INFO, "max. status info" },
|
2016-12-13 23:28:43 +00:00
|
|
|
{ BMP_SVC_BYTE, "Service byte" },
|
2015-02-19 21:52:42 +00:00
|
|
|
{ BMP_AMOUNT, "Amount" },
|
|
|
|
{ BMP_PUMP_NR, "Pump number" },
|
|
|
|
{ BMP_TLV_CONTAINER, "TLV container" },
|
2016-12-13 23:28:43 +00:00
|
|
|
{ BMP_TRACE_NUM, "Trace number" },
|
|
|
|
{ BMP_TIME, "Time" },
|
|
|
|
{ BMP_DATE, "Date" },
|
2015-02-19 21:52:42 +00:00
|
|
|
{ BMP_EXP_DATE, "Exipry date" },
|
2016-12-13 23:28:43 +00:00
|
|
|
{ BMP_CARD_SEQ_NUM, "Card sequence number" },
|
2015-02-19 21:52:42 +00:00
|
|
|
{ BMP_PAYMENT_TYPE, "Payment type" },
|
|
|
|
{ BMP_CARD_NUM, "Card number" },
|
|
|
|
{ BMP_T2_DAT, "Track 2 data" },
|
|
|
|
{ BMP_T3_DAT, "Track 3 data" },
|
2016-12-13 23:28:43 +00:00
|
|
|
{ BMP_RES_CODE, "Result code" },
|
|
|
|
{ BMP_TID, "Transaction ID" },
|
2015-02-19 21:52:42 +00:00
|
|
|
{ BMP_T1_DAT, "Track 1 data" },
|
|
|
|
{ BMP_CVV_CVC, "CVV / CVC" },
|
|
|
|
{ BMP_ADD_DATA, "Additional data" },
|
|
|
|
{ BMP_CC, "Currency code (CC)" },
|
2016-12-13 23:28:43 +00:00
|
|
|
{ BMP_RCPT_NUM, "Receipt number" },
|
|
|
|
{ BMP_CARD_TYPE, "Card type" },
|
2015-01-11 14:14:21 +00:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
2015-02-19 21:52:42 +00:00
|
|
|
static value_string_ext bitmap_ext = VALUE_STRING_EXT_INIT(bitmap);
|
|
|
|
|
2015-07-13 07:47:21 +00:00
|
|
|
static const value_string tlv_tag_class[] = {
|
|
|
|
{ 0x00, "Universal" },
|
|
|
|
{ 0x01, "Application" },
|
|
|
|
{ 0x02, "Context-specific" },
|
|
|
|
{ 0x03, "Private" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
static value_string_ext tlv_tag_class_ext = VALUE_STRING_EXT_INIT(tlv_tag_class);
|
|
|
|
|
2016-12-02 19:13:25 +00:00
|
|
|
#define TLV_TAG_TEXT_LINES 0x07
|
|
|
|
#define TLV_TAG_CHARS_PER_LINE 0x12
|
2016-12-23 18:06:24 +00:00
|
|
|
#define TLV_TAG_DISPLAY_TEXTS 0x24
|
2016-12-02 19:13:25 +00:00
|
|
|
#define TLV_TAG_PERMITTED_ZVT_CMDS 0x26
|
|
|
|
#define TLV_TAG_SUPPORTED_CHARSETS 0x27
|
2016-12-23 18:06:24 +00:00
|
|
|
#define TLV_TAG_PAYMENT_TYPE 0x2F
|
2016-12-02 19:13:25 +00:00
|
|
|
#define TLV_TAG_EMV_CFG_PARAM 0x40
|
|
|
|
#define TLV_TAG_RECEIPT_PARAM 0x1F04
|
|
|
|
#define TLV_TAG_CARDHOLDER_AUTH 0x1F10
|
|
|
|
#define TLV_TAG_ONLINE_FLAG 0x1F11
|
|
|
|
#define TLV_TAG_CARD_TYPE 0x1F12
|
|
|
|
|
2015-07-13 07:47:21 +00:00
|
|
|
|
2016-12-23 18:06:24 +00:00
|
|
|
typedef struct _tlv_seq_info_t {
|
|
|
|
guint txt_enc;
|
|
|
|
} tlv_seq_info_t;
|
|
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
dissect_zvt_tlv_seq(tvbuff_t *tvb, gint offset, guint16 seq_max_len,
|
|
|
|
packet_info *pinfo _U_, proto_tree *tree, tlv_seq_info_t *seq_info);
|
|
|
|
|
|
|
|
typedef struct _tlv_info_t {
|
|
|
|
guint32 tag;
|
|
|
|
gint (*dissect_payload)(tvbuff_t *, gint, gint,
|
|
|
|
packet_info *, proto_tree *, tlv_seq_info_t *);
|
|
|
|
} tlv_info_t;
|
|
|
|
|
2016-12-24 13:01:16 +00:00
|
|
|
static inline gint dissect_zvt_tlv_text_lines(
|
2016-12-14 17:50:58 +00:00
|
|
|
tvbuff_t *tvb, gint offset, gint len,
|
|
|
|
packet_info *pinfo, proto_tree *tree, tlv_seq_info_t *seq_info);
|
|
|
|
|
2016-12-24 13:01:16 +00:00
|
|
|
static inline gint dissect_zvt_tlv_subseq(
|
2016-12-23 18:06:24 +00:00
|
|
|
tvbuff_t *tvb, gint offset, gint len,
|
|
|
|
packet_info *pinfo, proto_tree *tree, tlv_seq_info_t *seq_info);
|
|
|
|
|
|
|
|
static const tlv_info_t tlv_info[] = {
|
2016-12-14 17:50:58 +00:00
|
|
|
{ TLV_TAG_TEXT_LINES, dissect_zvt_tlv_text_lines },
|
2016-12-23 18:06:24 +00:00
|
|
|
{ TLV_TAG_DISPLAY_TEXTS, dissect_zvt_tlv_subseq },
|
|
|
|
{ TLV_TAG_PAYMENT_TYPE, dissect_zvt_tlv_subseq }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string tlv_tags[] = {
|
2016-12-02 19:13:25 +00:00
|
|
|
{ TLV_TAG_TEXT_LINES, "Text lines" },
|
|
|
|
{ TLV_TAG_CHARS_PER_LINE,
|
|
|
|
"Number of characters per line of the printer" },
|
2016-12-23 18:06:24 +00:00
|
|
|
{ TLV_TAG_DISPLAY_TEXTS, "Display texts" },
|
2016-12-02 19:13:25 +00:00
|
|
|
{ TLV_TAG_PERMITTED_ZVT_CMDS, "List of permitted ZVT commands" },
|
|
|
|
{ TLV_TAG_SUPPORTED_CHARSETS, "List of supported character sets" },
|
|
|
|
{ TLV_TAG_PAYMENT_TYPE, "Payment type" },
|
|
|
|
{ TLV_TAG_EMV_CFG_PARAM, "EMV config parameter" },
|
|
|
|
{ TLV_TAG_RECEIPT_PARAM, "Receipt parameter" },
|
|
|
|
{ TLV_TAG_CARDHOLDER_AUTH, "Cardholder authentication" },
|
|
|
|
{ TLV_TAG_ONLINE_FLAG, "Online flag" },
|
|
|
|
{ TLV_TAG_CARD_TYPE, "Card type" },
|
2016-12-23 18:06:24 +00:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
static value_string_ext tlv_tags_ext = VALUE_STRING_EXT_INIT(tlv_tags);
|
|
|
|
|
|
|
|
|
2016-12-24 13:01:16 +00:00
|
|
|
static inline gint dissect_zvt_tlv_text_lines(
|
2016-12-14 17:50:58 +00:00
|
|
|
tvbuff_t *tvb, gint offset, gint len,
|
|
|
|
packet_info *pinfo _U_, proto_tree *tree, tlv_seq_info_t *seq_info)
|
|
|
|
{
|
|
|
|
proto_tree_add_item(tree, hf_zvt_text_lines_line,
|
|
|
|
tvb, offset, len, seq_info->txt_enc | ENC_NA);
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-24 13:01:16 +00:00
|
|
|
static inline gint dissect_zvt_tlv_subseq(
|
2016-12-23 18:06:24 +00:00
|
|
|
tvbuff_t *tvb, gint offset, gint len,
|
|
|
|
packet_info *pinfo, proto_tree *tree, tlv_seq_info_t *seq_info)
|
|
|
|
{
|
|
|
|
proto_tree *subseq_tree;
|
|
|
|
|
|
|
|
subseq_tree = proto_tree_add_subtree(tree,
|
|
|
|
tvb, offset, len, ett_zvt_tlv_subseq, NULL,
|
|
|
|
"Subsequence");
|
|
|
|
|
|
|
|
return dissect_zvt_tlv_seq(tvb, offset, len, pinfo, subseq_tree, seq_info);
|
|
|
|
}
|
2015-07-13 07:47:21 +00:00
|
|
|
|
2015-04-17 17:14:13 +00:00
|
|
|
|
|
|
|
static gint
|
|
|
|
dissect_zvt_tlv_tag(tvbuff_t *tvb, gint offset,
|
|
|
|
packet_info *pinfo _U_, proto_tree *tree, guint32 *tag)
|
|
|
|
{
|
2015-07-13 07:47:21 +00:00
|
|
|
gint offset_start;
|
|
|
|
guint8 one_byte;
|
|
|
|
guint32 _tag;
|
|
|
|
proto_item *tag_ti;
|
|
|
|
proto_tree *tag_tree;
|
2015-04-17 17:14:13 +00:00
|
|
|
|
2015-07-13 07:47:21 +00:00
|
|
|
offset_start = offset;
|
|
|
|
|
|
|
|
one_byte = tvb_get_guint8(tvb, offset);
|
|
|
|
_tag = one_byte;
|
|
|
|
offset++;
|
|
|
|
if ((one_byte & 0x1F) == 0x1F) {
|
|
|
|
do {
|
|
|
|
if ((offset-offset_start)>4) {
|
|
|
|
/* we support tags of <= 4 bytes
|
|
|
|
(the specification defines only 1 and 2-byte tags) */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
one_byte = tvb_get_guint8(tvb, offset);
|
|
|
|
_tag = _tag << 8 | (one_byte&0x7F);
|
|
|
|
offset++;
|
|
|
|
} while (one_byte & 0x80);
|
2015-04-17 17:14:13 +00:00
|
|
|
}
|
|
|
|
|
2015-07-13 07:47:21 +00:00
|
|
|
tag_ti = proto_tree_add_uint_format(tree, hf_zvt_tlv_tag,
|
2016-12-02 18:13:10 +00:00
|
|
|
tvb, offset_start, offset-offset_start, _tag,
|
|
|
|
"Tag: %s (0x%x)",
|
|
|
|
val_to_str_ext(_tag, &tlv_tags_ext, "unknown"), _tag);
|
2015-07-13 07:47:21 +00:00
|
|
|
|
|
|
|
tag_tree = proto_item_add_subtree(tag_ti, ett_zvt_tlv_tag);
|
|
|
|
proto_tree_add_item(tag_tree, hf_zvt_tlv_tag_class,
|
|
|
|
tvb, offset_start, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(tag_tree, hf_zvt_tlv_tag_type,
|
|
|
|
tvb, offset_start, 1, ENC_BIG_ENDIAN);
|
2015-04-17 17:14:13 +00:00
|
|
|
|
|
|
|
if (tag)
|
2015-07-13 07:47:21 +00:00
|
|
|
*tag = _tag;
|
|
|
|
return offset-offset_start;
|
2015-04-17 17:14:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-22 17:23:36 +00:00
|
|
|
static gint
|
|
|
|
dissect_zvt_tlv_len(tvbuff_t *tvb, gint offset,
|
|
|
|
packet_info *pinfo _U_, proto_tree *tree, int hf, guint16 *len)
|
|
|
|
{
|
|
|
|
guint16 _len;
|
|
|
|
gint len_bytes = 1;
|
|
|
|
|
|
|
|
_len = tvb_get_guint8(tvb, offset);
|
|
|
|
if (_len & 0x80) {
|
|
|
|
if ((_len & 0x03) == 1) {
|
|
|
|
len_bytes++;
|
|
|
|
_len = tvb_get_guint8(tvb, offset+1);
|
|
|
|
}
|
|
|
|
else if ((_len & 0x03) == 2) {
|
|
|
|
len_bytes += 2;
|
|
|
|
_len = tvb_get_ntohs(tvb, offset+1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* XXX - expert info */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
proto_tree_add_uint(tree, hf, tvb, offset, len_bytes, _len);
|
|
|
|
if (len)
|
|
|
|
*len = _len;
|
|
|
|
|
|
|
|
return len_bytes;
|
|
|
|
}
|
|
|
|
|
2016-12-23 18:06:24 +00:00
|
|
|
|
2015-04-17 17:14:13 +00:00
|
|
|
static gint
|
2016-12-23 18:06:24 +00:00
|
|
|
dissect_zvt_tlv_seq(tvbuff_t *tvb, gint offset, guint16 seq_max_len,
|
|
|
|
packet_info *pinfo, proto_tree *tree, tlv_seq_info_t *seq_info)
|
2015-04-17 17:14:13 +00:00
|
|
|
{
|
2016-12-23 18:06:24 +00:00
|
|
|
gint offset_start;
|
|
|
|
proto_item *dat_obj_it;
|
|
|
|
proto_tree *dat_obj_tree;
|
|
|
|
gint tag_len;
|
|
|
|
guint32 tag;
|
|
|
|
gint data_len_bytes;
|
|
|
|
guint16 data_len = 0;
|
|
|
|
tlv_info_t *ti;
|
|
|
|
gint ret;
|
|
|
|
|
|
|
|
if (!seq_info) {
|
|
|
|
seq_info = (tlv_seq_info_t *)wmem_alloc(
|
|
|
|
wmem_packet_scope(), sizeof(tlv_seq_info_t));
|
|
|
|
|
|
|
|
/* by default, text lines are using the CP437 charset
|
|
|
|
there's an object to change the encoding
|
|
|
|
(XXX - does this change apply only to the current message?) */
|
|
|
|
seq_info->txt_enc = ENC_CP437;
|
|
|
|
}
|
2015-04-17 17:14:13 +00:00
|
|
|
|
|
|
|
offset_start = offset;
|
|
|
|
|
2016-12-23 18:06:24 +00:00
|
|
|
while (offset-offset_start < seq_max_len) {
|
2015-04-17 17:14:13 +00:00
|
|
|
dat_obj_tree = proto_tree_add_subtree(tree,
|
|
|
|
tvb, offset, -1, ett_zvt_tlv_dat_obj, &dat_obj_it,
|
|
|
|
"TLV data object");
|
|
|
|
|
|
|
|
tag_len = dissect_zvt_tlv_tag(tvb, offset, pinfo, dat_obj_tree, &tag);
|
|
|
|
if (tag_len <= 0)
|
|
|
|
return offset - offset_start;
|
|
|
|
offset += tag_len;
|
|
|
|
|
2015-06-22 17:23:36 +00:00
|
|
|
data_len_bytes = dissect_zvt_tlv_len(tvb, offset, pinfo,
|
2016-12-23 18:06:24 +00:00
|
|
|
dat_obj_tree,hf_zvt_tlv_len, &data_len);
|
2015-06-22 17:23:36 +00:00
|
|
|
if (data_len_bytes > 0)
|
|
|
|
offset += data_len_bytes;
|
2015-04-17 17:14:13 +00:00
|
|
|
|
2016-12-23 18:06:24 +00:00
|
|
|
/* set the sequence length now that we know it
|
|
|
|
this way, we don't have to put the whole switch statement
|
|
|
|
under if (data_len > 0) */
|
2015-04-17 17:14:13 +00:00
|
|
|
proto_item_set_len(dat_obj_it, tag_len + data_len_bytes + data_len);
|
2016-12-23 18:06:24 +00:00
|
|
|
if (data_len == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ti = (tlv_info_t *)g_hash_table_lookup(
|
|
|
|
tlv_table, GUINT_TO_POINTER((guint)tag));
|
|
|
|
if (ti && ti->dissect_payload) {
|
|
|
|
ret = ti->dissect_payload(
|
|
|
|
tvb, offset, (gint)data_len, pinfo, dat_obj_tree, seq_info);
|
|
|
|
if (ret <= 0) {
|
|
|
|
/* XXX - expert info */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += data_len;
|
2015-04-17 17:14:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return offset - offset_start;
|
|
|
|
}
|
|
|
|
|
2015-02-19 21:52:42 +00:00
|
|
|
|
2016-12-23 18:06:24 +00:00
|
|
|
static gint
|
|
|
|
dissect_zvt_tlv_container(tvbuff_t *tvb, gint offset,
|
|
|
|
packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
gint offset_start;
|
|
|
|
gint total_len_bytes, seq_len;
|
2016-12-28 15:22:54 +00:00
|
|
|
guint16 seq_max_len = 0;
|
2016-12-23 18:06:24 +00:00
|
|
|
|
|
|
|
offset_start = offset;
|
|
|
|
|
|
|
|
total_len_bytes = dissect_zvt_tlv_len(tvb, offset, pinfo,
|
|
|
|
tree, hf_zvt_tlv_total_len, &seq_max_len);
|
|
|
|
if (total_len_bytes > 0)
|
|
|
|
offset += total_len_bytes;
|
|
|
|
|
|
|
|
seq_len = dissect_zvt_tlv_seq(
|
|
|
|
tvb, offset, seq_max_len, pinfo, tree, NULL);
|
|
|
|
if (seq_len > 0)
|
|
|
|
offset += seq_len;
|
|
|
|
|
|
|
|
return offset - offset_start;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-24 13:01:16 +00:00
|
|
|
static inline gint dissect_zvt_res_code(
|
2016-12-16 22:47:02 +00:00
|
|
|
tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree *tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_item(tree, hf_zvt_res_code, tvb, offset, 1, ENC_BIG_ENDIAN);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-24 13:01:16 +00:00
|
|
|
static inline gint dissect_zvt_cc(
|
2016-09-04 16:20:41 +00:00
|
|
|
tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree *tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_item(tree, hf_zvt_cc, tvb, offset, 2, ENC_BIG_ENDIAN);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-24 13:01:16 +00:00
|
|
|
static inline gint dissect_zvt_card_type(
|
2016-12-16 22:47:02 +00:00
|
|
|
tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree *tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_item(tree, hf_zvt_card_type, tvb, offset, 1, ENC_BIG_ENDIAN);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-19 21:52:42 +00:00
|
|
|
/* dissect one "bitmap", i.e BMP and the corresponding data */
|
|
|
|
static gint
|
|
|
|
dissect_zvt_bitmap(tvbuff_t *tvb, gint offset,
|
2015-04-17 17:14:13 +00:00
|
|
|
packet_info *pinfo, proto_tree *tree)
|
2015-02-19 21:52:42 +00:00
|
|
|
{
|
2016-07-24 16:43:14 +00:00
|
|
|
gint offset_start;
|
|
|
|
guint8 bmp;
|
|
|
|
proto_item *bitmap_it;
|
|
|
|
proto_tree *bitmap_tree;
|
|
|
|
bitmap_info_t *bi;
|
|
|
|
gint ret;
|
2015-02-19 21:52:42 +00:00
|
|
|
|
|
|
|
offset_start = offset;
|
|
|
|
|
|
|
|
bmp = tvb_get_guint8(tvb, offset);
|
|
|
|
if (try_val_to_str(bmp, bitmap) == NULL)
|
|
|
|
return -1;
|
2015-01-11 14:14:21 +00:00
|
|
|
|
2016-07-24 16:43:14 +00:00
|
|
|
bitmap_tree = proto_tree_add_subtree(tree,
|
|
|
|
tvb, offset, -1, ett_zvt_bitmap, &bitmap_it, "Bitmap");
|
2015-02-19 21:52:42 +00:00
|
|
|
|
2016-07-24 16:43:14 +00:00
|
|
|
proto_tree_add_item(bitmap_tree, hf_zvt_bmp,
|
|
|
|
tvb, offset, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_item_append_text(bitmap_it, ": %s",
|
|
|
|
val_to_str(bmp, bitmap, "unknown"));
|
|
|
|
offset++;
|
2015-02-19 21:52:42 +00:00
|
|
|
|
2016-07-24 16:43:14 +00:00
|
|
|
bi = (bitmap_info_t *)g_hash_table_lookup(
|
|
|
|
bitmap_table, GUINT_TO_POINTER((guint)bmp));
|
|
|
|
if (bi) {
|
|
|
|
if (bi->dissect_payload) {
|
|
|
|
ret = bi->dissect_payload(tvb, offset, pinfo, bitmap_tree);
|
|
|
|
if (ret >= 0)
|
|
|
|
offset += ret;
|
|
|
|
}
|
|
|
|
else if (bi->payload_len != BMP_PLD_LEN_UNKNOWN)
|
|
|
|
offset += bi->payload_len;
|
|
|
|
}
|
2015-02-19 21:52:42 +00:00
|
|
|
|
2016-07-24 16:43:14 +00:00
|
|
|
proto_item_set_len(bitmap_it, offset - offset_start);
|
2015-02-19 21:52:42 +00:00
|
|
|
return offset - offset_start;
|
|
|
|
}
|
2015-01-11 14:14:21 +00:00
|
|
|
|
2016-07-24 16:43:14 +00:00
|
|
|
|
2016-11-27 14:30:48 +00:00
|
|
|
static void dissect_zvt_int_status(tvbuff_t *tvb, gint offset, guint16 len,
|
2016-09-04 16:42:03 +00:00
|
|
|
packet_info *pinfo, proto_tree *tree, zvt_transaction_t *zvt_trans)
|
|
|
|
{
|
|
|
|
proto_tree_add_item(tree, hf_zvt_int_status,
|
|
|
|
tvb, offset, 1, ENC_BIG_ENDIAN);
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
if (len > 1)
|
|
|
|
offset++; /* skip "timeout" */
|
|
|
|
|
|
|
|
if (len > 2)
|
|
|
|
dissect_zvt_bitmap_seq(tvb, offset, len-2, pinfo, tree, zvt_trans);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-08 19:15:42 +00:00
|
|
|
static void
|
|
|
|
dissect_zvt_reg(tvbuff_t *tvb, gint offset, guint16 len _U_,
|
2015-06-02 18:20:32 +00:00
|
|
|
packet_info *pinfo, proto_tree *tree, zvt_transaction_t *zvt_trans)
|
2015-02-08 19:15:42 +00:00
|
|
|
{
|
2016-09-04 16:58:35 +00:00
|
|
|
proto_tree_add_item(tree, hf_zvt_pwd, tvb, offset, 3, ENC_NA);
|
2015-02-08 19:15:42 +00:00
|
|
|
offset += 3;
|
2015-02-17 22:13:00 +00:00
|
|
|
|
2015-02-08 19:15:42 +00:00
|
|
|
proto_tree_add_item(tree, hf_zvt_reg_cfg,
|
2015-02-17 22:13:00 +00:00
|
|
|
tvb, offset, 1, ENC_BIG_ENDIAN);
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
/* check for the optional part CC|0x03|service byte */
|
|
|
|
if (tvb_captured_length_remaining(tvb, offset)>=4 &&
|
|
|
|
tvb_get_guint8(tvb, offset+2)==0x03) {
|
|
|
|
|
2016-09-04 16:20:41 +00:00
|
|
|
offset += dissect_zvt_cc(tvb, offset, pinfo, tree);
|
2015-02-17 22:13:00 +00:00
|
|
|
|
|
|
|
offset++; /* 0x03 */
|
|
|
|
|
|
|
|
proto_tree_add_item(tree, hf_zvt_reg_svc_byte,
|
|
|
|
tvb, offset, 1, ENC_BIG_ENDIAN);
|
|
|
|
offset++;
|
|
|
|
}
|
2015-04-17 17:14:13 +00:00
|
|
|
|
|
|
|
/* it's ok if the remaining len is 0 */
|
2016-07-24 17:23:48 +00:00
|
|
|
dissect_zvt_bitmap_seq(tvb, offset,
|
2015-04-17 17:14:13 +00:00
|
|
|
tvb_captured_length_remaining(tvb, offset),
|
2015-06-02 18:20:32 +00:00
|
|
|
pinfo, tree, zvt_trans);
|
2015-02-08 19:15:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-04 16:58:35 +00:00
|
|
|
static void dissect_zvt_init(
|
|
|
|
tvbuff_t *tvb, gint offset, guint16 len _U_, packet_info *pinfo _U_,
|
|
|
|
proto_tree *tree, zvt_transaction_t *zvt_trans _U_)
|
|
|
|
{
|
|
|
|
proto_tree_add_item(tree, hf_zvt_pwd, tvb, offset, 3, ENC_NA);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-24 17:23:48 +00:00
|
|
|
/* dissect a sequence of bitmaps
|
|
|
|
(which may be the complete APDU payload or a part of it) */
|
2015-01-11 14:14:21 +00:00
|
|
|
static void
|
2016-07-24 17:23:48 +00:00
|
|
|
dissect_zvt_bitmap_seq(tvbuff_t *tvb, gint offset, guint16 len,
|
2015-06-02 18:20:32 +00:00
|
|
|
packet_info *pinfo _U_, proto_tree *tree, zvt_transaction_t *zvt_trans _U_)
|
2015-01-11 14:14:21 +00:00
|
|
|
{
|
2015-02-19 21:52:42 +00:00
|
|
|
gint offset_start, ret;
|
2015-01-11 14:14:21 +00:00
|
|
|
|
|
|
|
offset_start = offset;
|
|
|
|
|
|
|
|
while (offset - offset_start < len) {
|
2015-02-19 21:52:42 +00:00
|
|
|
ret = dissect_zvt_bitmap(tvb, offset, pinfo, tree);
|
|
|
|
if (ret <=0)
|
|
|
|
break;
|
|
|
|
offset += ret;
|
2015-01-11 14:14:21 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-24 11:42:16 +00:00
|
|
|
|
2015-02-19 21:52:42 +00:00
|
|
|
|
2015-01-11 11:45:39 +00:00
|
|
|
static void
|
2015-06-01 11:17:24 +00:00
|
|
|
zvt_set_addresses(packet_info *pinfo, zvt_transaction_t *zvt_trans)
|
2015-01-11 11:45:39 +00:00
|
|
|
{
|
2015-06-01 11:17:24 +00:00
|
|
|
apdu_info_t *ai;
|
|
|
|
zvt_direction_t dir = DIRECTION_UNKNOWN;
|
|
|
|
|
|
|
|
if (!zvt_trans)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ai = (apdu_info_t *)g_hash_table_lookup(
|
|
|
|
apdu_table, GUINT_TO_POINTER((guint)zvt_trans->ctrl));
|
|
|
|
if (!ai)
|
|
|
|
return;
|
|
|
|
|
2016-01-24 03:40:51 +00:00
|
|
|
if (zvt_trans->rqst_frame == pinfo->num) {
|
2015-06-01 11:17:24 +00:00
|
|
|
dir = ai->direction;
|
|
|
|
}
|
2016-01-24 03:40:51 +00:00
|
|
|
else if (zvt_trans->resp_frame == pinfo->num) {
|
2015-06-01 11:17:24 +00:00
|
|
|
if (ai->direction == DIRECTION_ECR_TO_PT)
|
|
|
|
dir = DIRECTION_PT_TO_ECR;
|
|
|
|
else
|
|
|
|
dir = DIRECTION_ECR_TO_PT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dir == DIRECTION_ECR_TO_PT) {
|
2015-10-21 19:04:16 +00:00
|
|
|
set_address(&pinfo->src, AT_STRINGZ,
|
2015-06-01 11:17:24 +00:00
|
|
|
(int)strlen(ADDR_ECR)+1, ADDR_ECR);
|
2015-10-21 19:04:16 +00:00
|
|
|
set_address(&pinfo->dst, AT_STRINGZ,
|
2015-06-01 11:17:24 +00:00
|
|
|
(int)strlen(ADDR_PT)+1, ADDR_PT);
|
2015-01-11 11:45:39 +00:00
|
|
|
}
|
2015-06-01 11:17:24 +00:00
|
|
|
else if (dir == DIRECTION_PT_TO_ECR) {
|
2015-10-21 19:04:16 +00:00
|
|
|
set_address(&pinfo->src, AT_STRINGZ,
|
2015-06-01 11:17:24 +00:00
|
|
|
(int)strlen(ADDR_PT)+1, ADDR_PT);
|
2015-10-21 19:04:16 +00:00
|
|
|
set_address(&pinfo->dst, AT_STRINGZ,
|
2015-06-01 11:17:24 +00:00
|
|
|
(int)strlen(ADDR_ECR)+1, ADDR_ECR);
|
2015-01-11 11:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-24 11:42:16 +00:00
|
|
|
/* dissect a ZVT APDU
|
|
|
|
return -1 if we don't have a complete APDU, 0 if the packet is no ZVT APDU
|
|
|
|
or the length of the ZVT APDU if all goes well */
|
|
|
|
static int
|
2015-01-11 11:45:39 +00:00
|
|
|
dissect_zvt_apdu(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *tree)
|
2014-12-24 11:42:16 +00:00
|
|
|
{
|
2015-05-31 17:02:29 +00:00
|
|
|
gint offset_start;
|
|
|
|
guint8 len_bytes = 1; /* number of bytes for the len field */
|
|
|
|
guint16 ctrl = ZVT_CTRL_NONE;
|
|
|
|
guint16 len;
|
|
|
|
guint8 byte;
|
|
|
|
proto_item *apdu_it;
|
|
|
|
proto_tree *apdu_tree;
|
|
|
|
apdu_info_t *ai;
|
2015-06-01 11:17:24 +00:00
|
|
|
zvt_transaction_t *zvt_trans = NULL;
|
2015-05-31 17:02:29 +00:00
|
|
|
proto_item *it;
|
2014-12-24 11:42:16 +00:00
|
|
|
|
|
|
|
offset_start = offset;
|
|
|
|
|
|
|
|
if (tvb_captured_length_remaining(tvb, offset) < ZVT_APDU_MIN_LEN)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
len = tvb_get_guint8(tvb, offset+2);
|
|
|
|
if (len == 0xFF) {
|
|
|
|
len_bytes = 3;
|
2016-04-06 21:22:13 +00:00
|
|
|
len = tvb_get_letohs(tvb, offset+3);
|
2014-12-24 11:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ZVT_APDU_MIN_LEN already includes one length byte */
|
|
|
|
if (tvb_captured_length_remaining(tvb, offset) <
|
|
|
|
ZVT_APDU_MIN_LEN + (len_bytes-1) + len) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
apdu_tree = proto_tree_add_subtree(tree,
|
|
|
|
tvb, offset, -1, ett_zvt_apdu, &apdu_it, "ZVT APDU");
|
|
|
|
|
2015-04-17 15:34:14 +00:00
|
|
|
byte = tvb_get_guint8(tvb, offset);
|
|
|
|
if (byte == CCRC_POS || byte == CCRC_NEG) {
|
2015-01-11 10:57:42 +00:00
|
|
|
proto_tree_add_item(apdu_tree, hf_zvt_ccrc, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2017-04-02 10:34:44 +00:00
|
|
|
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL,
|
2015-04-17 15:34:14 +00:00
|
|
|
byte == CCRC_POS ? "Positive completion" : "Negative completion");
|
2015-01-11 10:57:42 +00:00
|
|
|
offset++;
|
|
|
|
proto_tree_add_item(apdu_tree, hf_zvt_aprc, tvb, offset, 1, ENC_BIG_ENDIAN);
|
|
|
|
offset++;
|
2015-05-31 17:02:29 +00:00
|
|
|
|
2015-06-23 00:48:54 +00:00
|
|
|
zvt_trans = (zvt_transaction_t *)wmem_tree_lookup32_le(
|
2016-01-24 03:40:51 +00:00
|
|
|
transactions, pinfo->num);
|
2015-06-23 00:48:54 +00:00
|
|
|
if (zvt_trans && zvt_trans->resp_frame==0) {
|
|
|
|
/* there's a pending request, this packet is the response */
|
2016-01-24 03:40:51 +00:00
|
|
|
zvt_trans->resp_frame = pinfo->num;
|
2015-05-31 17:02:29 +00:00
|
|
|
}
|
|
|
|
|
2016-01-24 03:40:51 +00:00
|
|
|
if (zvt_trans && zvt_trans->resp_frame == pinfo->num) {
|
2015-06-23 00:48:54 +00:00
|
|
|
it = proto_tree_add_uint(apdu_tree, hf_zvt_resp_to,
|
|
|
|
NULL, 0, 0, zvt_trans->rqst_frame);
|
|
|
|
PROTO_ITEM_SET_GENERATED(it);
|
|
|
|
}
|
2014-12-24 11:42:16 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-01-11 10:57:42 +00:00
|
|
|
ctrl = tvb_get_ntohs(tvb, offset);
|
2014-12-24 11:42:16 +00:00
|
|
|
proto_tree_add_item(apdu_tree, hf_zvt_ctrl, tvb, offset, 2, ENC_BIG_ENDIAN);
|
2017-04-02 10:34:44 +00:00
|
|
|
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL,
|
2015-01-11 12:41:27 +00:00
|
|
|
val_to_str_const(ctrl, ctrl_field, "Unknown 0x%x"));
|
2014-12-24 11:42:16 +00:00
|
|
|
offset += 2;
|
2015-05-31 17:02:29 +00:00
|
|
|
|
|
|
|
if (PINFO_FD_VISITED(pinfo)) {
|
|
|
|
zvt_trans = (zvt_transaction_t *)wmem_tree_lookup32(
|
2016-01-24 03:40:51 +00:00
|
|
|
transactions, pinfo->num);
|
|
|
|
if (zvt_trans && zvt_trans->rqst_frame==pinfo->num &&
|
2015-05-31 17:02:29 +00:00
|
|
|
zvt_trans->resp_frame!=0) {
|
|
|
|
it = proto_tree_add_uint(apdu_tree, hf_zvt_resp_in,
|
|
|
|
NULL, 0, 0, zvt_trans->resp_frame);
|
|
|
|
PROTO_ITEM_SET_GENERATED(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2015-06-23 00:48:54 +00:00
|
|
|
zvt_trans = wmem_new(wmem_file_scope(), zvt_transaction_t);
|
2016-01-24 03:40:51 +00:00
|
|
|
zvt_trans->rqst_frame = pinfo->num;
|
2015-06-23 00:48:54 +00:00
|
|
|
zvt_trans->resp_frame = 0;
|
|
|
|
zvt_trans->ctrl = ctrl;
|
|
|
|
wmem_tree_insert32(transactions,
|
|
|
|
zvt_trans->rqst_frame, (void *)zvt_trans);
|
2015-05-31 17:02:29 +00:00
|
|
|
}
|
2014-12-24 11:42:16 +00:00
|
|
|
}
|
|
|
|
|
2015-01-11 11:45:39 +00:00
|
|
|
ai = (apdu_info_t *)g_hash_table_lookup(
|
|
|
|
apdu_table, GUINT_TO_POINTER((guint)ctrl));
|
|
|
|
|
2015-06-02 17:54:09 +00:00
|
|
|
it = proto_tree_add_uint(apdu_tree, hf_zvt_len, tvb, offset, len_bytes, len);
|
|
|
|
if (ai && ai->min_len_field!=LEN_FIELD_ANY && len<ai->min_len_field) {
|
|
|
|
expert_add_info_format(pinfo, it, &ei_invalid_apdu_len,
|
|
|
|
"The APDU length is too short. The minimum length is %d",
|
|
|
|
ai->min_len_field);
|
|
|
|
}
|
|
|
|
offset += len_bytes;
|
|
|
|
|
2015-06-01 11:17:24 +00:00
|
|
|
zvt_set_addresses(pinfo, zvt_trans);
|
2015-01-11 10:57:42 +00:00
|
|
|
|
2015-01-11 11:45:39 +00:00
|
|
|
if (len > 0) {
|
|
|
|
if (ai && ai->dissect_payload)
|
2015-06-02 18:20:32 +00:00
|
|
|
ai->dissect_payload(tvb, offset, len, pinfo, apdu_tree, zvt_trans);
|
2015-01-11 11:45:39 +00:00
|
|
|
else
|
2015-06-02 17:54:09 +00:00
|
|
|
proto_tree_add_item(apdu_tree, hf_zvt_data,
|
|
|
|
tvb, offset, len, ENC_NA);
|
2015-01-11 11:45:39 +00:00
|
|
|
}
|
2014-12-24 11:42:16 +00:00
|
|
|
offset += len;
|
|
|
|
|
|
|
|
proto_item_set_len(apdu_it, offset - offset_start);
|
|
|
|
return offset - offset_start;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
dissect_zvt_serial(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree *tree)
|
|
|
|
{
|
|
|
|
gint offset_start;
|
|
|
|
int apdu_len;
|
|
|
|
|
|
|
|
offset_start = offset;
|
|
|
|
|
|
|
|
if (tvb_reported_length_remaining(tvb, offset) == 1) {
|
2015-01-10 17:33:32 +00:00
|
|
|
proto_tree_add_item(tree, hf_zvt_serial_char,
|
|
|
|
tvb, offset, 1, ENC_BIG_ENDIAN);
|
2014-12-24 11:42:16 +00:00
|
|
|
offset++; /* ACK or NAK byte */
|
|
|
|
return offset - offset_start;
|
|
|
|
}
|
|
|
|
|
2015-01-10 17:33:32 +00:00
|
|
|
proto_tree_add_item(tree, hf_zvt_serial_char,
|
|
|
|
tvb, offset, 1, ENC_BIG_ENDIAN);
|
2014-12-24 11:42:16 +00:00
|
|
|
offset ++; /* DLE byte */
|
2015-01-10 17:33:32 +00:00
|
|
|
proto_tree_add_item(tree, hf_zvt_serial_char,
|
|
|
|
tvb, offset, 1, ENC_BIG_ENDIAN);
|
2014-12-24 11:42:16 +00:00
|
|
|
offset ++; /* STX byte */
|
|
|
|
|
|
|
|
apdu_len = dissect_zvt_apdu(tvb, offset, pinfo, tree);
|
|
|
|
if (apdu_len < 0)
|
|
|
|
return apdu_len;
|
|
|
|
|
|
|
|
offset += apdu_len;
|
|
|
|
|
2015-01-10 17:33:32 +00:00
|
|
|
proto_tree_add_item(tree, hf_zvt_serial_char,
|
|
|
|
tvb, offset, 1, ENC_BIG_ENDIAN);
|
2014-12-24 11:42:16 +00:00
|
|
|
offset ++; /* DLE byte */
|
2015-01-10 17:33:32 +00:00
|
|
|
proto_tree_add_item(tree, hf_zvt_serial_char,
|
|
|
|
tvb, offset, 1, ENC_BIG_ENDIAN);
|
2014-12-24 11:42:16 +00:00
|
|
|
offset ++; /* ETX byte */
|
2015-01-10 17:33:32 +00:00
|
|
|
|
|
|
|
/* the CRC is little endian, the other fields are big endian */
|
|
|
|
proto_tree_add_item(tree, hf_zvt_crc,
|
|
|
|
tvb, offset, 2, ENC_LITTLE_ENDIAN);
|
2014-12-24 11:42:16 +00:00
|
|
|
offset += 2; /* CRC bytes */
|
|
|
|
|
|
|
|
return offset - offset_start;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
valid_ctrl_field(tvbuff_t *tvb, gint offset)
|
|
|
|
{
|
|
|
|
if (tvb_get_guint8(tvb, offset) == 0x80 ||
|
|
|
|
tvb_get_guint8(tvb, offset) == 0x84 ||
|
|
|
|
try_val_to_str_ext(tvb_get_ntohs(tvb, offset), &ctrl_field_ext)) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
dissect_zvt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
|
|
|
{
|
|
|
|
gint zvt_len = 0;
|
|
|
|
proto_item *zvt_ti;
|
|
|
|
proto_tree *zvt_tree;
|
|
|
|
gboolean is_serial; /* serial or TCP/IP protocol? */
|
|
|
|
|
|
|
|
if (tvb_captured_length(tvb) == 1 &&
|
|
|
|
(tvb_get_guint8(tvb, 0) == ACK ||
|
|
|
|
tvb_get_guint8(tvb, 0) == NAK)) {
|
|
|
|
is_serial = TRUE;
|
|
|
|
}
|
|
|
|
else if (tvb_captured_length(tvb) >= 2 &&
|
|
|
|
tvb_get_guint8(tvb, 0) == DLE &&
|
|
|
|
tvb_get_guint8(tvb, 1) == STX) {
|
|
|
|
is_serial = TRUE;
|
|
|
|
}
|
|
|
|
else if (tvb_captured_length(tvb) >= ZVT_APDU_MIN_LEN &&
|
|
|
|
valid_ctrl_field(tvb, 0)) {
|
|
|
|
is_serial = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ZVT");
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
|
|
|
zvt_ti = proto_tree_add_protocol_format(tree, proto_zvt,
|
|
|
|
tvb, 0, -1,
|
|
|
|
"ZVT Kassenschnittstelle: %s", is_serial ?
|
|
|
|
"Serial Transport Protocol" : "Transport Protocol TCP/IP");
|
|
|
|
zvt_tree = proto_item_add_subtree(zvt_ti, ett_zvt);
|
|
|
|
|
|
|
|
if (is_serial)
|
|
|
|
zvt_len = dissect_zvt_serial(tvb, 0, pinfo, zvt_tree);
|
|
|
|
else
|
|
|
|
zvt_len = dissect_zvt_apdu(tvb, 0, pinfo, zvt_tree);
|
|
|
|
|
|
|
|
/* zvt_len < 0 means that we have an incomplete APDU
|
|
|
|
we can't do any reassembly here, so let's consume all bytes */
|
|
|
|
if (zvt_len < 0)
|
|
|
|
zvt_len = tvb_captured_length(tvb);
|
|
|
|
|
|
|
|
proto_item_set_len(zvt_ti, zvt_len);
|
|
|
|
return zvt_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
dissect_zvt_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
|
|
|
{
|
|
|
|
gint offset = 0, zvt_len = 0, ret;
|
|
|
|
proto_item *zvt_ti;
|
|
|
|
proto_tree *zvt_tree;
|
|
|
|
|
|
|
|
if (tvb_captured_length(tvb) < ZVT_APDU_MIN_LEN) {
|
|
|
|
if (pinfo->can_desegment) {
|
|
|
|
pinfo->desegment_offset = offset;
|
|
|
|
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
|
2016-05-01 16:23:52 +00:00
|
|
|
return -1;
|
2014-12-24 11:42:16 +00:00
|
|
|
}
|
|
|
|
return zvt_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!valid_ctrl_field(tvb, 0))
|
|
|
|
return 0; /* reject the packet */
|
|
|
|
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ZVT");
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
|
|
|
zvt_ti = proto_tree_add_protocol_format(tree, proto_zvt,
|
|
|
|
tvb, 0, -1,
|
|
|
|
"ZVT Kassenschnittstelle: Transport Protocol TCP/IP");
|
|
|
|
zvt_tree = proto_item_add_subtree(zvt_ti, ett_zvt);
|
|
|
|
|
|
|
|
while (tvb_captured_length_remaining(tvb, offset) > 0) {
|
|
|
|
ret = dissect_zvt_apdu(tvb, offset, pinfo, zvt_tree);
|
|
|
|
if (ret == 0) {
|
|
|
|
/* not a valid APDU
|
|
|
|
mark the bytes that we consumed and exit, give
|
|
|
|
other dissectors a chance to try the remaining
|
|
|
|
bytes */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (ret < 0) {
|
|
|
|
/* not enough data - ask the TCP layer for more */
|
|
|
|
|
|
|
|
if (pinfo->can_desegment) {
|
|
|
|
pinfo->desegment_offset = offset;
|
|
|
|
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
offset += ret;
|
|
|
|
zvt_len += ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
proto_item_set_len(zvt_ti, zvt_len);
|
|
|
|
return zvt_len;
|
|
|
|
}
|
|
|
|
|
2017-01-20 15:12:49 +00:00
|
|
|
static void
|
|
|
|
zvt_shutdown(void)
|
|
|
|
{
|
|
|
|
g_hash_table_destroy(tlv_table);
|
|
|
|
g_hash_table_destroy(apdu_table);
|
|
|
|
g_hash_table_destroy(bitmap_table);
|
|
|
|
}
|
2014-12-24 11:42:16 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_zvt(void)
|
|
|
|
{
|
2015-01-11 11:45:39 +00:00
|
|
|
guint i;
|
2015-06-02 17:54:09 +00:00
|
|
|
expert_module_t* expert_zvt;
|
2015-01-11 11:45:39 +00:00
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_zvt,
|
2015-04-17 17:14:13 +00:00
|
|
|
&ett_zvt_apdu,
|
2016-07-24 16:43:14 +00:00
|
|
|
&ett_zvt_bitmap,
|
2015-07-13 07:47:21 +00:00
|
|
|
&ett_zvt_tlv_dat_obj,
|
2016-12-23 18:06:24 +00:00
|
|
|
&ett_zvt_tlv_subseq,
|
2015-07-13 07:47:21 +00:00
|
|
|
&ett_zvt_tlv_tag
|
2015-01-11 11:45:39 +00:00
|
|
|
};
|
2014-12-24 11:42:16 +00:00
|
|
|
static hf_register_info hf[] = {
|
2015-05-31 17:02:29 +00:00
|
|
|
{ &hf_zvt_resp_in,
|
|
|
|
{ "Response In", "zvt.resp_in",
|
|
|
|
FT_FRAMENUM, BASE_NONE, NULL, 0x0, NULL, HFILL } },
|
|
|
|
{ &hf_zvt_resp_to,
|
|
|
|
{ "Response To", "zvt.resp_to",
|
|
|
|
FT_FRAMENUM, BASE_NONE, NULL, 0x0, NULL, HFILL } },
|
|
|
|
{ &hf_zvt_serial_char,
|
2015-01-10 17:33:32 +00:00
|
|
|
{ "Serial character", "zvt.serial_char", FT_UINT8,
|
|
|
|
BASE_HEX|BASE_EXT_STRING, &serial_char_ext, 0, NULL, HFILL } },
|
|
|
|
{ &hf_zvt_crc,
|
|
|
|
{ "CRC", "zvt.crc", FT_UINT16,
|
|
|
|
BASE_HEX, NULL, 0, NULL, HFILL } },
|
2014-12-24 11:42:16 +00:00
|
|
|
{ &hf_zvt_ctrl,
|
|
|
|
{ "Control-field", "zvt.control_field", FT_UINT16,
|
|
|
|
BASE_HEX|BASE_EXT_STRING, &ctrl_field_ext, 0, NULL, HFILL } },
|
2015-01-11 10:57:42 +00:00
|
|
|
{ &hf_zvt_ccrc,
|
|
|
|
{ "CCRC", "zvt.ccrc",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } },
|
|
|
|
{ &hf_zvt_aprc,
|
|
|
|
{ "APRC", "zvt.aprc",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } },
|
2014-12-24 11:42:16 +00:00
|
|
|
{ &hf_zvt_len,
|
|
|
|
{ "Length-field", "zvt.length_field",
|
2015-01-11 10:57:42 +00:00
|
|
|
FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL } },
|
|
|
|
{ &hf_zvt_data,
|
|
|
|
{ "APDU data", "zvt.data",
|
2015-01-11 14:14:21 +00:00
|
|
|
FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
|
2016-09-04 16:42:03 +00:00
|
|
|
{ &hf_zvt_int_status,
|
|
|
|
{ "Intermediate status", "zvt.int_status",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } },
|
2016-09-04 16:58:35 +00:00
|
|
|
{ &hf_zvt_pwd,
|
|
|
|
{ "Password", "zvt.password",
|
2015-02-08 19:15:42 +00:00
|
|
|
FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
|
|
|
|
{ &hf_zvt_reg_cfg,
|
|
|
|
{ "Config byte", "zvt.reg.config_byte",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } },
|
2016-12-16 22:47:02 +00:00
|
|
|
{ &hf_zvt_res_code,
|
|
|
|
{ "Result Code", "zvt.result_code",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } },
|
2015-02-17 22:13:00 +00:00
|
|
|
/* we don't call the filter zvt.reg.cc, the currency code
|
|
|
|
appears in several apdus */
|
|
|
|
{ &hf_zvt_cc,
|
2016-09-04 16:20:41 +00:00
|
|
|
{ "Currency Code", "zvt.cc",
|
|
|
|
FT_UINT16, BASE_HEX, VALS(zvt_cc), 0, NULL, HFILL } },
|
2016-12-16 22:47:02 +00:00
|
|
|
{ &hf_zvt_card_type,
|
|
|
|
{ "Card Type", "zvt.card_type", FT_UINT8,
|
|
|
|
BASE_DEC|BASE_EXT_STRING, &card_type_ext, 0, NULL, HFILL } },
|
2015-02-17 22:13:00 +00:00
|
|
|
{ &hf_zvt_reg_svc_byte,
|
|
|
|
{ "Service byte", "zvt.reg.service_byte",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } },
|
2016-07-24 16:24:08 +00:00
|
|
|
{ &hf_zvt_bmp,
|
|
|
|
{ "BMP", "zvt.bmp", FT_UINT8,
|
2015-04-17 17:14:13 +00:00
|
|
|
BASE_HEX|BASE_EXT_STRING, &bitmap_ext, 0, NULL, HFILL } },
|
2015-06-22 17:23:36 +00:00
|
|
|
{ &hf_zvt_tlv_total_len,
|
|
|
|
{ "Total length", "zvt.tlv.total_len",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
|
2015-04-17 17:14:13 +00:00
|
|
|
{ &hf_zvt_tlv_tag,
|
|
|
|
{ "Tag", "zvt.tlv.tag", FT_UINT32,
|
|
|
|
BASE_HEX|BASE_EXT_STRING, &tlv_tags_ext, 0, NULL, HFILL } },
|
2015-07-13 07:47:21 +00:00
|
|
|
{ &hf_zvt_tlv_tag_class,
|
|
|
|
{ "Class", "zvt.tlv.tag.class", FT_UINT8,
|
|
|
|
BASE_HEX|BASE_EXT_STRING, &tlv_tag_class_ext,
|
|
|
|
0xC0, NULL, HFILL } },
|
|
|
|
{ &hf_zvt_tlv_tag_type,
|
|
|
|
{ "Type", "zvt.tlv.tag.type", FT_BOOLEAN,
|
|
|
|
8, TFS(&tfs_constructed_primitive), 0x20, NULL, HFILL } },
|
2015-04-17 17:14:13 +00:00
|
|
|
{ &hf_zvt_tlv_len,
|
|
|
|
{ "Length", "zvt.tlv.len",
|
2016-12-14 17:50:58 +00:00
|
|
|
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
|
|
|
|
{ &hf_zvt_text_lines_line,
|
|
|
|
{ "Text line", "zvt.tlv.text_lines.line",
|
|
|
|
FT_STRING, STR_UNICODE, NULL, 0, NULL, HFILL } }
|
2014-12-24 11:42:16 +00:00
|
|
|
};
|
|
|
|
|
2015-06-02 17:54:09 +00:00
|
|
|
static ei_register_info ei[] = {
|
|
|
|
{ &ei_invalid_apdu_len,
|
|
|
|
{ "zvt.apdu_len.invalid", PI_PROTOCOL, PI_WARN,
|
|
|
|
"The APDU length is too short. The minimum length is %d",
|
|
|
|
EXPFILL }}
|
|
|
|
};
|
2015-01-11 11:45:39 +00:00
|
|
|
|
|
|
|
apdu_table = g_hash_table_new(g_direct_hash, g_direct_equal);
|
|
|
|
for(i=0; i<array_length(apdu_info); i++) {
|
|
|
|
g_hash_table_insert(apdu_table,
|
|
|
|
GUINT_TO_POINTER((guint)apdu_info[i].ctrl),
|
2016-01-05 12:06:36 +00:00
|
|
|
(gpointer)(&apdu_info[i]));
|
2015-01-11 11:45:39 +00:00
|
|
|
}
|
2014-12-24 11:42:16 +00:00
|
|
|
|
2016-07-24 16:43:14 +00:00
|
|
|
bitmap_table = g_hash_table_new(g_direct_hash, g_direct_equal);
|
|
|
|
for(i=0; i<array_length(bitmap_info); i++) {
|
|
|
|
g_hash_table_insert(bitmap_table,
|
|
|
|
GUINT_TO_POINTER((guint)bitmap_info[i].bmp),
|
|
|
|
(gpointer)(&bitmap_info[i]));
|
|
|
|
}
|
2016-12-23 18:06:24 +00:00
|
|
|
|
|
|
|
tlv_table = g_hash_table_new(g_direct_hash, g_direct_equal);
|
|
|
|
for(i=0; i<array_length(tlv_info); i++) {
|
|
|
|
g_hash_table_insert(tlv_table,
|
|
|
|
GUINT_TO_POINTER((guint)tlv_info[i].tag),
|
|
|
|
(gpointer)(&tlv_info[i]));
|
|
|
|
}
|
2016-07-24 16:43:14 +00:00
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
proto_zvt = proto_register_protocol("ZVT Kassenschnittstelle", "ZVT", "zvt");
|
|
|
|
|
2014-12-24 11:42:16 +00:00
|
|
|
proto_register_field_array(proto_zvt, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2015-06-02 17:54:09 +00:00
|
|
|
expert_zvt = expert_register_protocol(proto_zvt);
|
|
|
|
expert_register_field_array(expert_zvt, ei, array_length(ei));
|
2014-12-24 11:42:16 +00:00
|
|
|
|
2015-05-31 17:02:29 +00:00
|
|
|
transactions = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
|
2016-10-07 20:25:01 +00:00
|
|
|
|
|
|
|
/* register by name to allow mapping to a user DLT */
|
|
|
|
register_dissector("zvt", dissect_zvt, proto_zvt);
|
2017-01-20 15:12:49 +00:00
|
|
|
|
|
|
|
register_shutdown_routine(zvt_shutdown);
|
2014-12-24 11:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_zvt(void)
|
|
|
|
{
|
2016-10-07 20:25:01 +00:00
|
|
|
dissector_handle_t zvt_tcp_handle;
|
2014-12-24 11:42:16 +00:00
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
zvt_tcp_handle = create_dissector_handle(dissect_zvt_tcp, proto_zvt);
|
2014-12-24 11:42:16 +00:00
|
|
|
|
2016-10-07 20:25:01 +00:00
|
|
|
dissector_add_for_decode_as_with_preference("tcp.port", zvt_tcp_handle);
|
2014-12-24 11:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|