2015-01-15 10:19:41 +00:00
|
|
|
/* packet-cattp.c
|
|
|
|
* Routines for packet dissection of
|
|
|
|
* ETSI TS 102 127 v6.13.0 (Release 6 / 2009-0r45)
|
|
|
|
* Card Application Toolkit - Transport Protocol over UDP
|
|
|
|
*
|
|
|
|
* Copyright 2014-2014 by Sebastian Kloeppel <sk [at] nakedape.net>
|
|
|
|
* Cristina E. Vintila <cristina.vintila [at] gmail.com>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-12 11:23:27 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2015-01-15 10:19:41 +00:00
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
2015-01-20 17:51:08 +00:00
|
|
|
#include <epan/prefs.h>
|
2016-07-21 14:21:25 +00:00
|
|
|
#include <epan/expert.h>
|
2015-01-15 10:19:41 +00:00
|
|
|
#include <epan/in_cksum.h>
|
|
|
|
|
|
|
|
#define CATTP_SHORTNAME "CAT-TP"
|
|
|
|
#define CATTP_HBLEN 18
|
|
|
|
|
|
|
|
#define F_SYN 0x80
|
|
|
|
#define F_ACK 0x40
|
|
|
|
#define F_EAK 0x20
|
|
|
|
#define F_RST 0x10
|
|
|
|
#define F_NUL 0x08
|
|
|
|
#define F_SEG 0x04
|
|
|
|
|
|
|
|
/* bit masks for the first header byte. */
|
2015-01-20 17:51:08 +00:00
|
|
|
#define M_FLAGS 0xFC /* flags only, no version */
|
|
|
|
#define M_PDU_SYN 0xB8 /* SYN (ACK, SEG dont care) without version */
|
|
|
|
#define M_PDU_ACK 0xD0 /* ACK (EAK, SEG, NUL dont care) without version */
|
2015-01-15 10:19:41 +00:00
|
|
|
#define M_PDU_RST 0xBC /* RST (ACK dont care) without version */
|
|
|
|
#define M_VERSION 0x03 /* only Version */
|
|
|
|
|
|
|
|
#define ICCID_PREFIX 0x98
|
|
|
|
|
|
|
|
static int proto_cattp = -1;
|
|
|
|
|
|
|
|
static gint ett_cattp = -1;
|
|
|
|
static gint ett_cattp_id = -1;
|
|
|
|
static gint ett_cattp_flags = -1;
|
|
|
|
static gint ett_cattp_eaks = -1;
|
|
|
|
|
|
|
|
static int hf_cattp_flags = -1;
|
|
|
|
|
|
|
|
/* flag components */
|
|
|
|
static int hf_cattp_flag_syn = -1;
|
|
|
|
static int hf_cattp_flag_ack = -1;
|
|
|
|
static int hf_cattp_flag_eak = -1;
|
|
|
|
static int hf_cattp_flag_rst = -1;
|
|
|
|
static int hf_cattp_flag_nul = -1;
|
|
|
|
static int hf_cattp_flag_seg = -1;
|
|
|
|
static int hf_cattp_version = -1;
|
|
|
|
|
|
|
|
/* structure of flag components */
|
|
|
|
static const int *cattp_flags[] = {
|
|
|
|
&hf_cattp_flag_syn,
|
|
|
|
&hf_cattp_flag_ack,
|
|
|
|
&hf_cattp_flag_eak,
|
|
|
|
&hf_cattp_flag_rst,
|
|
|
|
&hf_cattp_flag_nul,
|
|
|
|
&hf_cattp_flag_seg,
|
|
|
|
&hf_cattp_version,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static int hf_cattp_hlen = -1;
|
|
|
|
static int hf_cattp_srcport = -1;
|
|
|
|
static int hf_cattp_dstport = -1;
|
|
|
|
static int hf_cattp_datalen = -1;
|
|
|
|
static int hf_cattp_seq = -1;
|
|
|
|
static int hf_cattp_ack = -1;
|
|
|
|
static int hf_cattp_windowsize = -1;
|
|
|
|
static int hf_cattp_checksum = -1;
|
2016-07-11 03:47:28 +00:00
|
|
|
static int hf_cattp_checksum_status = -1;
|
2015-01-15 10:19:41 +00:00
|
|
|
static int hf_cattp_identification = -1;
|
|
|
|
static int hf_cattp_iccid = -1;
|
|
|
|
static int hf_cattp_idlen = -1;
|
|
|
|
static int hf_cattp_maxpdu = -1;
|
|
|
|
static int hf_cattp_maxsdu = -1;
|
|
|
|
static int hf_cattp_rc = -1;
|
|
|
|
static int hf_cattp_eaklen = -1;
|
|
|
|
static int hf_cattp_eaks = -1;
|
|
|
|
|
2016-07-21 14:21:25 +00:00
|
|
|
static expert_field ei_cattp_checksum = EI_INIT;
|
|
|
|
|
2015-01-15 10:19:41 +00:00
|
|
|
/* Preference to control whether to check the CATTP checksum */
|
|
|
|
static gboolean cattp_check_checksum = TRUE;
|
|
|
|
|
|
|
|
/* Reason code mapping */
|
|
|
|
static const value_string cattp_reset_reason[] = {
|
|
|
|
{ 0, "Normal Ending" },
|
|
|
|
{ 1, "Connection set-up failed, illegal parameters" },
|
|
|
|
{ 2, "Temporarily unable to set up this connection" },
|
|
|
|
{ 3, "Requested Port not available" },
|
|
|
|
{ 4, "Unexpected PDU received" },
|
|
|
|
{ 5, "Maximum retries exceeded" },
|
|
|
|
{ 6, "Version not supported" },
|
|
|
|
{ 7, "RFU" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2016-12-13 19:26:27 +00:00
|
|
|
static const unit_name_string units_pdu = { "PDU", "PDUs" };
|
|
|
|
|
2015-01-15 10:19:41 +00:00
|
|
|
/* Forward declartion due to use of heuristic dissection preference. */
|
|
|
|
void proto_reg_handoff_cattp(void);
|
2015-01-26 07:17:06 +00:00
|
|
|
void proto_register_cattp(void);
|
2015-01-15 10:19:41 +00:00
|
|
|
|
|
|
|
/* Dissection of SYN PDUs */
|
|
|
|
static guint32
|
|
|
|
dissect_cattp_synpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *cattp_tree, guint32 offset)
|
|
|
|
{
|
|
|
|
proto_item *idi, *id_tree;
|
2015-01-20 17:51:08 +00:00
|
|
|
guint8 idlen;
|
2015-01-15 10:19:41 +00:00
|
|
|
|
|
|
|
proto_tree_add_item(cattp_tree, hf_cattp_maxpdu, tvb, offset, 2, ENC_BIG_ENDIAN);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
proto_tree_add_item(cattp_tree, hf_cattp_maxsdu, tvb, offset, 2, ENC_BIG_ENDIAN);
|
|
|
|
offset += 2;
|
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
idlen = tvb_get_guint8(tvb, offset);
|
2015-01-15 10:19:41 +00:00
|
|
|
idi = proto_tree_add_uint(cattp_tree, hf_cattp_idlen, tvb, offset, 1, idlen);
|
2015-01-20 17:51:08 +00:00
|
|
|
offset += 1;
|
2015-01-15 10:19:41 +00:00
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " IdLen=%u ", idlen);
|
2015-01-15 10:19:41 +00:00
|
|
|
|
|
|
|
id_tree = proto_item_add_subtree(idi, ett_cattp_id);
|
|
|
|
|
|
|
|
if (idlen > 0) {
|
|
|
|
guint8 first_id_byte;
|
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
first_id_byte = tvb_get_guint8(tvb, offset);
|
2015-01-15 10:19:41 +00:00
|
|
|
proto_tree_add_item(id_tree, hf_cattp_identification, tvb, offset, idlen, ENC_NA);
|
|
|
|
|
|
|
|
/* Optional code. Checks whether identification field may be an ICCID.
|
|
|
|
* It has to be considered to move this logic to another layer / dissector.
|
|
|
|
* However it is common to send ICCID as Identification for OTA download. */
|
|
|
|
if (idlen <= 10 && idlen >= 9 && ICCID_PREFIX == first_id_byte) {
|
|
|
|
wmem_strbuf_t *buf;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
buf = wmem_strbuf_new(wmem_packet_scope(), "");
|
|
|
|
|
|
|
|
/* switch nibbles */
|
|
|
|
for (i = 0; i < idlen; i++) {
|
|
|
|
guint8 c, n;
|
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
c = tvb_get_guint8(tvb, offset + i);
|
2015-01-15 10:19:41 +00:00
|
|
|
n = ((c & 0xF0) >> 4) + ((c & 0x0F) << 4);
|
2015-01-20 17:51:08 +00:00
|
|
|
wmem_strbuf_append_printf(buf, "%02X", n);
|
2015-01-15 10:19:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
proto_tree_add_string(id_tree, hf_cattp_iccid, tvb, offset,
|
|
|
|
idlen, wmem_strbuf_get_str(buf));
|
|
|
|
}
|
|
|
|
offset += idlen;
|
|
|
|
}
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Dissection of Extended Acknowledgement PDUs */
|
|
|
|
static guint32
|
|
|
|
dissect_cattp_eakpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *cattp_tree, guint32 offset, guint8 hlen)
|
|
|
|
{
|
|
|
|
proto_item *eaki;
|
2015-01-20 17:51:08 +00:00
|
|
|
guint8 eak_count;
|
2015-01-15 10:19:41 +00:00
|
|
|
|
|
|
|
eak_count = (hlen - offset) >> 1;
|
2016-12-13 19:26:27 +00:00
|
|
|
eaki = proto_tree_add_uint(cattp_tree, hf_cattp_eaklen, tvb, offset, eak_count * 2, eak_count);
|
2015-01-15 10:19:41 +00:00
|
|
|
|
|
|
|
if (eak_count > 0) {
|
|
|
|
proto_item *eak_tree;
|
|
|
|
int i;
|
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " EAKs=%u", eak_count);
|
|
|
|
eak_tree = proto_item_add_subtree(eaki, ett_cattp_eaks);
|
2015-01-15 10:19:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < eak_count; i++) {
|
|
|
|
proto_tree_add_item(eak_tree, hf_cattp_eaks, tvb, offset, 2, ENC_BIG_ENDIAN);
|
|
|
|
offset += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Dissection of Extended Acknowledgement PDUs */
|
|
|
|
static guint32
|
|
|
|
dissect_cattp_rstpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *cattp_tree, guint32 offset)
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
guint8 rc;
|
|
|
|
const gchar *rc_str;
|
2015-01-15 10:19:41 +00:00
|
|
|
|
|
|
|
rc = tvb_get_guint8(tvb, offset); /* reason code of RST */
|
2015-01-20 17:51:08 +00:00
|
|
|
rc_str = val_to_str(rc, cattp_reset_reason, "Unknown reason code: 0x%02x");
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " Reason=\"%s\" ", rc_str);
|
2015-01-15 10:19:41 +00:00
|
|
|
|
|
|
|
proto_tree_add_item(cattp_tree, hf_cattp_rc, tvb, offset, 1, ENC_BIG_ENDIAN);
|
|
|
|
return ++offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Dissection of the base header */
|
2015-11-15 13:00:10 +00:00
|
|
|
static int
|
|
|
|
dissect_cattp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2015-01-15 10:19:41 +00:00
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
const char *pdutype = "[Unknown PDU]";
|
2015-01-15 10:19:41 +00:00
|
|
|
proto_item *ti, *cattp_tree;
|
2015-01-20 17:51:08 +00:00
|
|
|
guint32 offset;
|
|
|
|
vec_t cksum_vec[1];
|
|
|
|
int header_offset;
|
|
|
|
guint cksum_data_len;
|
|
|
|
guint8 flags, first_byte, hlen, ver;
|
2016-07-11 03:47:28 +00:00
|
|
|
guint16 plen, ackno, seqno, wsize, sport, dport;
|
2015-01-20 17:51:08 +00:00
|
|
|
|
2015-01-15 10:19:41 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, CATTP_SHORTNAME);
|
|
|
|
|
|
|
|
/* Clear out stuff in the info column */
|
2015-01-20 17:51:08 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2015-01-15 10:19:41 +00:00
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
hlen = tvb_get_guint8(tvb, 3); /* lookahead header len. */
|
2015-01-15 10:19:41 +00:00
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
ti = proto_tree_add_protocol_format(tree, proto_cattp, tvb, offset, hlen,
|
|
|
|
"Card Application Toolkit Transport Protocol");
|
|
|
|
|
|
|
|
cattp_tree = proto_item_add_subtree(ti, ett_cattp);
|
|
|
|
|
|
|
|
/* render flags tree */
|
2015-01-20 17:51:08 +00:00
|
|
|
first_byte = tvb_get_guint8(tvb, offset);
|
|
|
|
flags = first_byte & M_FLAGS; /* discard version from first byte for flags */
|
|
|
|
ver = first_byte & M_VERSION; /* discard flags for version */
|
|
|
|
proto_tree_add_bitmask(cattp_tree, tvb, offset, hf_cattp_flags, ett_cattp_flags, cattp_flags, ENC_BIG_ENDIAN);
|
2015-01-15 10:19:41 +00:00
|
|
|
offset += 3; /* skip RFU and header len */
|
|
|
|
|
|
|
|
/* Header length, varies for SYN(identification) and EAKs */
|
|
|
|
proto_tree_add_uint(cattp_tree, hf_cattp_hlen, tvb, offset, 1, hlen);
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
/* Parse cattp source port. */
|
2015-01-20 17:51:08 +00:00
|
|
|
sport = tvb_get_ntohs(tvb, offset);
|
2015-01-15 10:19:41 +00:00
|
|
|
proto_tree_add_uint(cattp_tree, hf_cattp_srcport, tvb, offset, 2, sport);
|
|
|
|
offset += 2;
|
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
/* Parse cattp destination port. */
|
|
|
|
dport = tvb_get_ntohs(tvb, offset);
|
2015-01-15 10:19:41 +00:00
|
|
|
proto_tree_add_uint(cattp_tree, hf_cattp_dstport, tvb, offset, 2, dport);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
proto_item_append_text(ti, " (v%u, Src Port: %u, Dst Port: %u)", ver, sport, dport);
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "%u > %u ", sport, dport);
|
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
/* Parse length of payload. */
|
|
|
|
plen = tvb_get_ntohs(tvb, offset);
|
2015-01-15 10:19:41 +00:00
|
|
|
proto_tree_add_uint(cattp_tree, hf_cattp_datalen, tvb, offset, 2, plen);
|
|
|
|
offset += 2;
|
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
/* Parse sequence number. */
|
|
|
|
seqno = tvb_get_ntohs(tvb, offset);
|
2015-01-15 10:19:41 +00:00
|
|
|
proto_tree_add_uint(cattp_tree, hf_cattp_seq, tvb, offset, 2, seqno);
|
|
|
|
offset += 2;
|
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
/* Parse acknowledgement number. */
|
|
|
|
ackno = tvb_get_ntohs(tvb, offset);
|
2015-01-15 10:19:41 +00:00
|
|
|
proto_tree_add_uint(cattp_tree, hf_cattp_ack, tvb, offset, 2, ackno);
|
|
|
|
offset += 2;
|
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
/* Parse window size. */
|
|
|
|
wsize = tvb_get_ntohs(tvb, offset);
|
2015-01-15 10:19:41 +00:00
|
|
|
proto_tree_add_uint(cattp_tree, hf_cattp_windowsize, tvb, offset, 2, wsize);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
if (flags & F_SYN)
|
|
|
|
pdutype = "[SYN PDU]";
|
|
|
|
else if (flags & F_ACK)
|
|
|
|
pdutype = "[ACK PDU]";
|
|
|
|
else if (flags & F_RST)
|
|
|
|
pdutype = "[RST PDU]";
|
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, "%s Flags=0x%02X Ack=%u Seq=%u WSize=%u", pdutype, flags, ackno, seqno, wsize);
|
2015-01-15 10:19:41 +00:00
|
|
|
|
|
|
|
/* Parse and verify checksum */
|
2015-01-20 17:51:08 +00:00
|
|
|
header_offset = 0;
|
2015-01-15 10:19:41 +00:00
|
|
|
cksum_data_len = hlen + plen;
|
|
|
|
if (!cattp_check_checksum) {
|
|
|
|
/* We have turned checksum checking off; we do NOT checksum it. */
|
2016-07-21 14:21:25 +00:00
|
|
|
proto_tree_add_checksum(cattp_tree, tvb, offset, hf_cattp_checksum, hf_cattp_checksum_status, &ei_cattp_checksum,
|
|
|
|
pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
|
2015-01-15 10:19:41 +00:00
|
|
|
} else {
|
|
|
|
/* We haven't turned checksum checking off; checksum it. */
|
|
|
|
|
|
|
|
/* Unlike TCP, CATTP does not make use of a pseudo-header for checksum */
|
|
|
|
SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, header_offset, cksum_data_len);
|
2016-07-21 14:21:25 +00:00
|
|
|
proto_tree_add_checksum(cattp_tree, tvb, offset, hf_cattp_checksum, hf_cattp_checksum_status, &ei_cattp_checksum,
|
|
|
|
pinfo, in_cksum(cksum_vec, 1), ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
|
2015-01-15 10:19:41 +00:00
|
|
|
} /* End of checksum code */
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
if (flags & F_SYN)
|
2015-01-20 17:51:08 +00:00
|
|
|
offset = dissect_cattp_synpdu(tvb, pinfo, cattp_tree, offset);
|
2015-01-15 10:19:41 +00:00
|
|
|
else if (flags & F_EAK)
|
|
|
|
offset = dissect_cattp_eakpdu(tvb, pinfo, cattp_tree, offset, hlen);
|
|
|
|
else if (flags & F_RST)
|
|
|
|
offset = dissect_cattp_rstpdu(tvb, pinfo, cattp_tree, offset);
|
2015-01-20 17:51:08 +00:00
|
|
|
/* for other PDU types nothing special to be displayed in detail tree. */
|
2015-01-15 10:19:41 +00:00
|
|
|
|
|
|
|
if (plen > 0) { /* Call generic data handle if data exists. */
|
2015-01-20 17:51:08 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " DataLen=%u", plen);
|
2015-01-15 10:19:41 +00:00
|
|
|
tvb = tvb_new_subset_remaining(tvb, offset);
|
2016-03-20 00:33:14 +00:00
|
|
|
call_data_dissector(tvb, pinfo, tree);
|
2015-01-15 10:19:41 +00:00
|
|
|
}
|
2015-11-15 13:00:10 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2015-01-15 10:19:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The heuristic dissector function checks if the UDP packet may be a cattp packet */
|
|
|
|
static gboolean
|
2016-03-28 19:02:17 +00:00
|
|
|
dissect_cattp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
2015-01-15 10:19:41 +00:00
|
|
|
{
|
|
|
|
if (tvb_captured_length(tvb) >= CATTP_HBLEN) { /* check of data is big enough for base header. */
|
2018-12-08 14:30:26 +00:00
|
|
|
guint8 flags, ver, hlen;
|
2015-01-15 10:19:41 +00:00
|
|
|
guint16 plen;
|
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
hlen = tvb_get_guint8(tvb, 3); /* header len */
|
|
|
|
plen = tvb_get_ntohs(tvb, 8); /* payload len */
|
2015-01-15 10:19:41 +00:00
|
|
|
|
|
|
|
if (hlen+plen != tvb_reported_length(tvb)) /* check if data length is ok. */
|
|
|
|
return FALSE;
|
|
|
|
|
2018-12-08 14:30:26 +00:00
|
|
|
/* ETSI TS 102 127 V15.0.0 and earlier releases say explicitly that
|
|
|
|
the version bits must be 0. */
|
|
|
|
ver = tvb_get_guint8(tvb, 0) & M_VERSION;
|
|
|
|
if (ver != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
flags = tvb_get_guint8(tvb, 0) & M_FLAGS;
|
2015-01-15 10:19:41 +00:00
|
|
|
if ( (flags & M_PDU_SYN) == F_SYN ||
|
|
|
|
(flags & M_PDU_RST) == F_RST ||
|
|
|
|
(flags & M_PDU_ACK) == F_ACK ) { /* check if flag combi is valid */
|
2015-11-15 13:00:10 +00:00
|
|
|
dissect_cattp(tvb, pinfo, tree, data);
|
2015-01-15 10:19:41 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-01-20 17:51:08 +00:00
|
|
|
/* Function to register the dissector, called by infrastructure. */
|
2015-01-15 10:19:41 +00:00
|
|
|
void
|
|
|
|
proto_register_cattp(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{
|
|
|
|
&hf_cattp_flags,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Flags", "cattp.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_flag_syn,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Synchronize Flag", "cattp.flags.syn", FT_UINT8, BASE_DEC, NULL, F_SYN,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_flag_ack,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Acknowledge Flag", "cattp.flags.ack", FT_UINT8, BASE_DEC, NULL, F_ACK,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_flag_eak,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Extended Acknowledge Flag", "cattp.flags.eak", FT_UINT8, BASE_DEC, NULL, F_EAK,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_flag_rst,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Reset Flag", "cattp.flags.rst", FT_UINT8, BASE_DEC, NULL, F_RST,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_flag_nul,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"NULL Flag", "cattp.flags.nul", FT_UINT8, BASE_DEC, NULL, F_NUL,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_flag_seg,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Segmentation Flag", "cattp.flags.seg", FT_UINT8, BASE_DEC, NULL, F_SEG,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_version,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Version", "cattp.version", FT_UINT8, BASE_HEX, NULL, M_VERSION,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_hlen,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Header Length", "cattp.hlen", FT_UINT8, BASE_DEC, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_srcport,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Source Port", "cattp.srcport", FT_UINT16, BASE_DEC, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_dstport,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Destination Port", "cattp.dstport", FT_UINT16, BASE_DEC, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_datalen,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Data Length", "cattp.datalen", FT_UINT16, BASE_DEC, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_seq,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Sequence Number", "cattp.seq", FT_UINT16, BASE_DEC, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_ack,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Acknowledgement Number", "cattp.ack", FT_UINT16, BASE_DEC, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_windowsize,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Window Size", "cattp.windowsize", FT_UINT16, BASE_DEC, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_checksum,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Checksum", "cattp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
2016-07-11 03:47:28 +00:00
|
|
|
{
|
|
|
|
&hf_cattp_checksum_status,
|
|
|
|
{
|
|
|
|
"Checksum Status", "cattp.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
|
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
2015-01-15 10:19:41 +00:00
|
|
|
{
|
|
|
|
&hf_cattp_identification,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Identification", "cattp.identification", FT_BYTES, BASE_NONE, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_iccid,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"ICCID", "cattp.iccid", FT_STRING, BASE_NONE, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_maxpdu,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Maxpdu", "cattp.maxpdu", FT_UINT16, BASE_DEC, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_maxsdu,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Maxsdu", "cattp.maxsdu", FT_UINT16, BASE_DEC, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_rc,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Reason Code", "cattp.rc", FT_UINT8, BASE_DEC, VALS(cattp_reset_reason), 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_idlen,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Identification Length", "cattp.idlen", FT_UINT8, BASE_DEC, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_eaks,
|
|
|
|
{
|
2015-01-20 17:51:08 +00:00
|
|
|
"Acknowledgement Number", "cattp.eak", FT_UINT16, BASE_DEC, NULL, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_cattp_eaklen,
|
|
|
|
{
|
2016-12-13 19:26:27 +00:00
|
|
|
"Extended Acknowledgement Numbers", "cattp.eaks", FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_pdu, 0x0,
|
2015-01-15 10:19:41 +00:00
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Setup protocol subtree array */
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_cattp,
|
|
|
|
&ett_cattp_flags,
|
|
|
|
&ett_cattp_id,
|
|
|
|
&ett_cattp_eaks
|
|
|
|
};
|
|
|
|
|
2016-07-21 14:21:25 +00:00
|
|
|
static ei_register_info ei[] = {
|
|
|
|
{ &ei_cattp_checksum, { "cattp.bad_checksum", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
|
|
|
|
};
|
|
|
|
|
2015-01-15 10:19:41 +00:00
|
|
|
module_t *cattp_module;
|
2016-07-21 14:21:25 +00:00
|
|
|
expert_module_t* expert_cattp;
|
2015-01-15 10:19:41 +00:00
|
|
|
|
|
|
|
proto_cattp = proto_register_protocol (
|
|
|
|
"ETSI Card Application Toolkit Transport Protocol", /* name */
|
|
|
|
CATTP_SHORTNAME, /* short name */
|
2015-01-20 17:51:08 +00:00
|
|
|
"cattp" /* abbrev */
|
2015-01-15 10:19:41 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
proto_register_field_array(proto_cattp, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2016-07-21 14:21:25 +00:00
|
|
|
expert_cattp = expert_register_protocol(proto_cattp);
|
|
|
|
expert_register_field_array(expert_cattp, ei, array_length(ei));
|
2015-01-15 10:19:41 +00:00
|
|
|
|
2016-10-05 20:33:54 +00:00
|
|
|
cattp_module = prefs_register_protocol(proto_cattp, NULL);
|
2015-01-15 10:19:41 +00:00
|
|
|
prefs_register_bool_preference(cattp_module, "checksum",
|
|
|
|
"Validate checksum of all messages",
|
|
|
|
"Whether the checksum of all messages should be validated or not",
|
|
|
|
&cattp_check_checksum);
|
|
|
|
|
2015-07-13 00:40:31 +00:00
|
|
|
prefs_register_obsolete_preference(cattp_module, "enable");
|
2015-01-15 10:19:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Handoff */
|
|
|
|
void
|
|
|
|
proto_reg_handoff_cattp(void)
|
|
|
|
{
|
2016-10-05 20:33:54 +00:00
|
|
|
dissector_handle_t cattp_handle;
|
2015-01-15 10:19:41 +00:00
|
|
|
|
2016-10-05 20:33:54 +00:00
|
|
|
/* Create dissector handle */
|
|
|
|
cattp_handle = create_dissector_handle(dissect_cattp, proto_cattp);
|
2015-01-20 17:51:08 +00:00
|
|
|
|
2016-10-05 20:33:54 +00:00
|
|
|
heur_dissector_add("udp", dissect_cattp_heur, "CAT-TP over UDP", "cattp_udp", proto_cattp, HEURISTIC_ENABLE);
|
|
|
|
dissector_add_for_decode_as_with_preference("udp.port", cattp_handle);
|
2015-01-15 10:19:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
2015-01-20 17:51:08 +00:00
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
2015-01-15 10:19:41 +00:00
|
|
|
* End:
|
|
|
|
*
|
2015-01-20 17:51:08 +00:00
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
2015-01-15 10:19:41 +00:00
|
|
|
*/
|