DECT-MITEL-ETH: Add Layer field and Mt

This commit is contained in:
Bernhard Dick 2022-11-16 19:02:09 +01:00 committed by Martin Mathieson
parent 534e594a34
commit 15edf3b3ce
1 changed files with 137 additions and 72 deletions

View File

@ -5,6 +5,7 @@
* base stations. * base stations.
* *
* Copyright 2018 by Harald Welte <laforge@gnumonks.org> * Copyright 2018 by Harald Welte <laforge@gnumonks.org>
* Copyright 2022 by Bernhard Dick <bernhard@bdick.de>
* *
* Wireshark - Network traffic analyzer * Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org> * By Gerald Combs <gerald@wireshark.org>
@ -18,6 +19,8 @@
#include <epan/packet.h> #include <epan/packet.h>
#include <epan/packet_info.h> #include <epan/packet_info.h>
#include <epan/value_string.h> #include <epan/value_string.h>
#include <ftypes/ftypes.h>
#include <epan/proto.h>
#include <tvbuff.h> #include <tvbuff.h>
void proto_register_dect_mitel_eth(void); void proto_register_dect_mitel_eth(void);
@ -26,12 +29,17 @@ void proto_reg_handoff_dect_mitelrfp(void);
static int proto_dect_mitel_eth = -1; static int proto_dect_mitel_eth = -1;
static gint hf_dect_mitel_eth_len = -1; static gint hf_dect_mitel_eth_len = -1;
static gint hf_dect_mitel_eth_layer = -1;
static gint hf_dect_mitel_eth_prim_type = -1; static gint hf_dect_mitel_eth_prim_type = -1;
static gint hf_dect_mitel_eth_mcei = -1; static gint hf_dect_mitel_eth_mcei = -1;
static gint hf_dect_mitel_eth_info_string = -1; static gint hf_dect_mitel_eth_info_string = -1;
static gint hf_dect_mitel_eth_pmid = -1; static gint hf_dect_mitel_eth_pmid = -1;
static gint hf_dect_mitel_eth_subfield = -1; static gint hf_dect_mitel_eth_subfield = -1;
static gint hf_dect_mitel_eth_mt_item_key = -1;
static gint hf_dect_mitel_eth_mt_item_length = -1;
static gint hf_dect_mitel_eth_mt_item_value = -1;
static gint ett_dect_mitel_eth = -1; static gint ett_dect_mitel_eth = -1;
static dissector_handle_t data_handle; static dissector_handle_t data_handle;
@ -42,6 +50,14 @@ static dissector_handle_t dlc_handle;
#define DECT_MITEL_ETH_T_VIDEO 0xA003 #define DECT_MITEL_ETH_T_VIDEO 0xA003
#define DECT_MITEL_ETH_T_AUDIOLOG 0xA004 #define DECT_MITEL_ETH_T_AUDIOLOG 0xA004
enum dect_mitel_eth_layer_coding {
DECT_MITEL_ETH_LAYER_RFPC = 0x78,
DECT_MITEL_ETH_LAYER_LC = 0x79,
DECT_MITEL_ETH_LAYER_MAC = 0x7A,
DECT_MITEL_ETH_LAYER_MT = 0x7C,
DECT_MITEL_ETH_LAYER_SYNC = 0x7D,
};
enum dect_mitel_eth_prim_coding { enum dect_mitel_eth_prim_coding {
DECT_MITEL_ETH_MAC_CON_IND = 0x01, DECT_MITEL_ETH_MAC_CON_IND = 0x01,
DECT_MITEL_ETH_MAC_DIS_REQ = 0x02, DECT_MITEL_ETH_MAC_DIS_REQ = 0x02,
@ -72,6 +88,15 @@ enum dect_mitel_eth_prim_coding {
DECT_MITEL_ETH_MAC_GET_CURR_CKEY_ID_CNF = 0x21, DECT_MITEL_ETH_MAC_GET_CURR_CKEY_ID_CNF = 0x21,
}; };
static const value_string dect_mitel_eth_layer_val[] = {
{ DECT_MITEL_ETH_LAYER_RFPC, "RFPc" },
{ DECT_MITEL_ETH_LAYER_LC, "Lc" },
{ DECT_MITEL_ETH_LAYER_MAC, "MAC" },
{ DECT_MITEL_ETH_LAYER_MT, "Mt" },
{ DECT_MITEL_ETH_LAYER_SYNC, "Sync" },
{ 0, NULL }
};
static const value_string dect_mitel_eth_prim_coding_val[] = { static const value_string dect_mitel_eth_prim_coding_val[] = {
{ DECT_MITEL_ETH_MAC_CON_IND, "MAC_CON_IND" }, { DECT_MITEL_ETH_MAC_CON_IND, "MAC_CON_IND" },
{ DECT_MITEL_ETH_MAC_DIS_REQ, "MAC_DIS_REQ" }, { DECT_MITEL_ETH_MAC_DIS_REQ, "MAC_DIS_REQ" },
@ -112,7 +137,7 @@ static const value_string dect_mitel_eth_subfield_val[] = {
static int dissect_dect_mitel_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) static int dissect_dect_mitel_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{ {
guint16 mitel_eth_len, payload_len; guint16 mitel_eth_len, payload_len;
guint8 prim_type, mcei; guint8 prim_type, layer, mcei, mt_item_length;
int offset = 0; int offset = 0;
gboolean ip_encapsulated; gboolean ip_encapsulated;
tvbuff_t *payload_tvb = NULL; tvbuff_t *payload_tvb = NULL;
@ -139,6 +164,8 @@ static int dissect_dect_mitel_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree
offset += 4; offset += 4;
} }
proto_tree_add_item(tree, hf_dect_mitel_eth_layer, tvb, offset, 1, ENC_NA);
layer = tvb_get_guint8(tvb, offset);
offset++; offset++;
prim_type = tvb_get_guint8(tvb, offset); prim_type = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_dect_mitel_eth_prim_type, tvb, offset, 1, ENC_NA); proto_tree_add_item(tree, hf_dect_mitel_eth_prim_type, tvb, offset, 1, ENC_NA);
@ -147,77 +174,95 @@ static int dissect_dect_mitel_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree
val_to_str(prim_type, dect_mitel_eth_prim_coding_val, "Unknown 0x%02x")); val_to_str(prim_type, dect_mitel_eth_prim_coding_val, "Unknown 0x%02x"));
offset++; offset++;
switch (prim_type) { switch (layer) {
case DECT_MITEL_ETH_MAC_PAGE_REQ: case DECT_MITEL_ETH_LAYER_RFPC:
pinfo->p2p_dir = P2P_DIR_SENT; break;
payload_len = tvb_get_guint8(tvb, offset); case DECT_MITEL_ETH_LAYER_MT:
offset++; while ( tvb_reported_length_remaining(tvb, offset) ) {
payload_tvb = tvb_new_subset_length(tvb, offset, payload_len); proto_tree_add_item(tree, hf_dect_mitel_eth_mt_item_key, tvb, offset, 1, ENC_NA);
break; offset++;
case DECT_MITEL_ETH_MAC_CON_IND: proto_tree_add_item(tree, hf_dect_mitel_eth_mt_item_length, tvb, offset, 1, ENC_NA);
pinfo->p2p_dir = P2P_DIR_RECV; mt_item_length = tvb_get_guint8(tvb, offset);
mcei = tvb_get_guint8(tvb, offset); offset++;
conversation_set_elements_by_id(pinfo, CONVERSATION_NONE, mcei); proto_tree_add_item(tree, hf_dect_mitel_eth_mt_item_value, tvb, offset, mt_item_length, ENC_NA);
col_append_fstr(pinfo->cinfo, COL_INFO, "MCEI=%02x ", mcei); offset += mt_item_length;
proto_tree_add_item(tree, hf_dect_mitel_eth_mcei, tvb, offset, 1, ENC_NA); }
offset += 2; break;
proto_tree_add_item(tree, hf_dect_mitel_eth_pmid, tvb, offset, 2, ENC_BIG_ENDIAN); case DECT_MITEL_ETH_LAYER_LC:
break; case DECT_MITEL_ETH_LAYER_MAC:
case DECT_MITEL_ETH_MAC_INFO_IND: switch (prim_type) {
pinfo->p2p_dir = P2P_DIR_RECV; case DECT_MITEL_ETH_MAC_PAGE_REQ:
mcei = tvb_get_guint8(tvb, offset); pinfo->p2p_dir = P2P_DIR_SENT;
conversation_set_elements_by_id(pinfo, CONVERSATION_NONE, mcei); payload_len = tvb_get_guint8(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, "MCEI=%02x ", mcei); offset++;
proto_tree_add_item(tree, hf_dect_mitel_eth_mcei, tvb, offset, 1, ENC_NA); payload_tvb = tvb_new_subset_length(tvb, offset, payload_len);
/* from offset 9 onwards, there's a null-terminated string */ break;
offset += 5; case DECT_MITEL_ETH_MAC_CON_IND:
proto_tree_add_item(tree, hf_dect_mitel_eth_info_string, tvb, offset, pinfo->p2p_dir = P2P_DIR_RECV;
tvb_captured_length_remaining(tvb, offset+9), ENC_ASCII|ENC_NA); mcei = tvb_get_guint8(tvb, offset);
break; conversation_set_elements_by_id(pinfo, CONVERSATION_NONE, mcei);
case DECT_MITEL_ETH_MAC_DIS_REQ: col_append_fstr(pinfo->cinfo, COL_INFO, "MCEI=%02x ", mcei);
case DECT_MITEL_ETH_MAC_DIS_IND: proto_tree_add_item(tree, hf_dect_mitel_eth_mcei, tvb, offset, 1, ENC_NA);
if(prim_type == DECT_MITEL_ETH_MAC_DIS_REQ) { offset += 2;
pinfo->p2p_dir = P2P_DIR_SENT; proto_tree_add_item(tree, hf_dect_mitel_eth_pmid, tvb, offset, 2, ENC_BIG_ENDIAN);
} else { break;
pinfo->p2p_dir = P2P_DIR_RECV; case DECT_MITEL_ETH_MAC_INFO_IND:
} pinfo->p2p_dir = P2P_DIR_RECV;
mcei = tvb_get_guint8(tvb, offset); mcei = tvb_get_guint8(tvb, offset);
conversation_set_elements_by_id(pinfo, CONVERSATION_NONE, mcei); conversation_set_elements_by_id(pinfo, CONVERSATION_NONE, mcei);
col_append_fstr(pinfo->cinfo, COL_INFO, "MCEI=%02x ", mcei); col_append_fstr(pinfo->cinfo, COL_INFO, "MCEI=%02x ", mcei);
proto_tree_add_item(tree, hf_dect_mitel_eth_mcei, tvb, offset, 1, ENC_NA); proto_tree_add_item(tree, hf_dect_mitel_eth_mcei, tvb, offset, 1, ENC_NA);
break; /* from offset 9 onwards, there's a null-terminated string */
case DECT_MITEL_ETH_LC_DTR_IND: offset += 5;
pinfo->p2p_dir = P2P_DIR_RECV; proto_tree_add_item(tree, hf_dect_mitel_eth_info_string, tvb, offset,
mcei = tvb_get_guint8(tvb, offset); tvb_captured_length_remaining(tvb, offset+9), ENC_ASCII|ENC_NA);
conversation_set_elements_by_id(pinfo, CONVERSATION_NONE, mcei); break;
col_append_fstr(pinfo->cinfo, COL_INFO, "MCEI=%02x ", mcei); case DECT_MITEL_ETH_MAC_DIS_REQ:
proto_tree_add_item(tree, hf_dect_mitel_eth_mcei, tvb, offset, 1, ENC_NA); case DECT_MITEL_ETH_MAC_DIS_IND:
offset++; if(prim_type == DECT_MITEL_ETH_MAC_DIS_REQ) {
proto_tree_add_item(tree, hf_dect_mitel_eth_subfield, tvb, offset, 1, ENC_NA); pinfo->p2p_dir = P2P_DIR_SENT;
break; } else {
case DECT_MITEL_ETH_LC_DATA_REQ: pinfo->p2p_dir = P2P_DIR_RECV;
case DECT_MITEL_ETH_LC_DATA_IND: }
if(prim_type == DECT_MITEL_ETH_LC_DATA_REQ) { mcei = tvb_get_guint8(tvb, offset);
pinfo->p2p_dir = P2P_DIR_SENT; conversation_set_elements_by_id(pinfo, CONVERSATION_NONE, mcei);
} else { col_append_fstr(pinfo->cinfo, COL_INFO, "MCEI=%02x ", mcei);
pinfo->p2p_dir = P2P_DIR_RECV; proto_tree_add_item(tree, hf_dect_mitel_eth_mcei, tvb, offset, 1, ENC_NA);
} break;
mcei = tvb_get_guint8(tvb, offset); case DECT_MITEL_ETH_LC_DTR_IND:
conversation_set_elements_by_id(pinfo, CONVERSATION_NONE, mcei); pinfo->p2p_dir = P2P_DIR_RECV;
col_append_fstr(pinfo->cinfo, COL_INFO, "MCEI=%02x ", mcei); mcei = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_dect_mitel_eth_mcei, tvb, offset, 1, ENC_NA); conversation_set_elements_by_id(pinfo, CONVERSATION_NONE, mcei);
offset++; col_append_fstr(pinfo->cinfo, COL_INFO, "MCEI=%02x ", mcei);
proto_tree_add_item(tree, hf_dect_mitel_eth_subfield, tvb, offset, 1, ENC_NA); proto_tree_add_item(tree, hf_dect_mitel_eth_mcei, tvb, offset, 1, ENC_NA);
offset++; offset++;
payload_len = tvb_get_guint8(tvb, offset); proto_tree_add_item(tree, hf_dect_mitel_eth_subfield, tvb, offset, 1, ENC_NA);
offset++; break;
payload_tvb = tvb_new_subset_length(tvb, offset, payload_len); case DECT_MITEL_ETH_LC_DATA_REQ:
if (payload_tvb) case DECT_MITEL_ETH_LC_DATA_IND:
call_dissector(dlc_handle, payload_tvb, pinfo, tree); if(prim_type == DECT_MITEL_ETH_LC_DATA_REQ) {
payload_tvb = NULL; pinfo->p2p_dir = P2P_DIR_SENT;
break; } else {
default: pinfo->p2p_dir = P2P_DIR_RECV;
break; }
mcei = tvb_get_guint8(tvb, offset);
conversation_set_elements_by_id(pinfo, CONVERSATION_NONE, mcei);
col_append_fstr(pinfo->cinfo, COL_INFO, "MCEI=%02x ", mcei);
proto_tree_add_item(tree, hf_dect_mitel_eth_mcei, tvb, offset, 1, ENC_NA);
offset++;
proto_tree_add_item(tree, hf_dect_mitel_eth_subfield, tvb, offset, 1, ENC_NA);
offset++;
payload_len = tvb_get_guint8(tvb, offset);
offset++;
payload_tvb = tvb_new_subset_length(tvb, offset, payload_len);
if (payload_tvb)
call_dissector(dlc_handle, payload_tvb, pinfo, tree);
payload_tvb = NULL;
break;
default:
break;
}
break;
} }
if (payload_tvb) if (payload_tvb)
@ -236,6 +281,11 @@ void proto_register_dect_mitelrfp(void)
NULL, 0x0, NULL, HFILL NULL, 0x0, NULL, HFILL
} }
}, },
{ &hf_dect_mitel_eth_layer,
{ "Interface layer", "dect_mitel_eth.layer", FT_UINT8, BASE_HEX,
VALS(dect_mitel_eth_layer_val), 0x0, NULL, HFILL
}
},
{ &hf_dect_mitel_eth_prim_type, { &hf_dect_mitel_eth_prim_type,
{ "Primitive Type", "dect_mitel_eth.prim", FT_UINT8, BASE_HEX, { "Primitive Type", "dect_mitel_eth.prim", FT_UINT8, BASE_HEX,
VALS(dect_mitel_eth_prim_coding_val), 0x0, NULL, HFILL VALS(dect_mitel_eth_prim_coding_val), 0x0, NULL, HFILL
@ -261,6 +311,21 @@ void proto_register_dect_mitelrfp(void)
VALS(dect_mitel_eth_subfield_val), 0, NULL, HFILL VALS(dect_mitel_eth_subfield_val), 0, NULL, HFILL
} }
}, },
{ &hf_dect_mitel_eth_mt_item_key,
{ "Key", "dect_mitel_eth.mt.item.key", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL
}
},
{ &hf_dect_mitel_eth_mt_item_length,
{ "Length", "dect_mitel_eth.mt.item.length", FT_UINT8, BASE_DEC,
NULL, 0x0, NULL, HFILL
}
},
{ &hf_dect_mitel_eth_mt_item_value,
{ "Value", "dect_mitel_eth.mt.item.value", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL
}
},
}; };
static gint *ett[] = { static gint *ett[] = {