Coverage Report

Created: 2026-01-02 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-3com-xns.c
Line
Count
Source
1
/* packet-xns-llc.c
2
 * Routines for 3Com's encapsulation of XNS over 802.2 LLC
3
 * (and other protocols using DSAP 80)
4
 *
5
 * Wireshark - Network traffic analyzer
6
 * By Gerald Combs <gerald@wireshark.org>
7
 * Copyright 1998 Gerald Combs
8
 *
9
 * SPDX-License-Identifier: GPL-2.0-or-later
10
 */
11
12
#include "config.h"
13
14
#include <epan/packet.h>
15
#include <epan/etypes.h>
16
17
/* Forward declarations */
18
void proto_register_3com_xns(void);
19
void proto_reg_handoff_3com_xns(void);
20
21
static dissector_handle_t our_xns_handle;
22
23
static int proto_3com_xns;
24
25
static int hf_3com_xns_type_ethertype;
26
static int hf_3com_xns_type_retix_bpdu;
27
28
static int ett_3com_xns;
29
30
static const value_string retix_bpdu_type_vals[] = {
31
  { 0x0004, "Retix Spanning Tree" },
32
  { 0, NULL }
33
};
34
35
static dissector_table_t ethertype_subdissector_table;
36
37
static dissector_handle_t retix_bpdu_handle;
38
39
/*
40
 * Apparently 3Com had some scheme for encapsulating XNS in 802.2 LLC,
41
 * using a DSAP and SSAP of 0x80, and putting a 2-byte field that appeared
42
 * to contain, at least for IPP, the Ethertype value for IPP.
43
 *
44
 * We assume that the value there is an Ethertype value, except for
45
 * the Retix spanning tree protocol, which also uses a DSAP and SSAP
46
 * of 0x80 but has, at least in one capture, 0x0004 as the type
47
 * field.  We handle that specially.
48
 *
49
 * XXX - I've also seen packets on 802.11 with a DSAP and SSAP of 0x80,
50
 * but with random stuff that appears neither to be XNS nor Retix
51
 * spanning tree.
52
 */
53
static int
54
dissect_3com_xns(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
55
15
{
56
15
  proto_tree *subtree;
57
15
  proto_tree *ti;
58
15
  uint16_t type;
59
15
  tvbuff_t *next_tvb;
60
61
15
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "3Com XNS");
62
15
  col_clear(pinfo->cinfo, COL_INFO);
63
64
15
  ti = proto_tree_add_item(tree, proto_3com_xns, tvb, 0, 4, ENC_NA);
65
15
  subtree = proto_item_add_subtree(ti, ett_3com_xns);
66
67
15
  type = tvb_get_ntohs(tvb, 0);
68
15
  next_tvb = tvb_new_subset_remaining(tvb, 2);
69
15
  if (type == 0x0004) {
70
1
    proto_tree_add_uint(subtree, hf_3com_xns_type_retix_bpdu,
71
1
        tvb, 0, 2, type);
72
1
    call_dissector(retix_bpdu_handle, next_tvb, pinfo, tree);
73
14
  } else {
74
14
    proto_tree_add_uint(subtree, hf_3com_xns_type_ethertype,
75
14
        tvb, 0, 2, type);
76
14
    if (!dissector_try_uint(ethertype_subdissector_table,
77
14
        type, next_tvb, pinfo, tree))
78
5
      call_data_dissector(next_tvb, pinfo, tree);
79
14
  }
80
15
  return tvb_captured_length(tvb);
81
15
}
82
83
void
84
proto_register_3com_xns(void)
85
14
{
86
14
  static hf_register_info hf[] = {
87
    /* registered here but handled in ethertype.c */
88
14
    { &hf_3com_xns_type_ethertype,
89
14
    { "Type", "3comxns.type", FT_UINT16, BASE_HEX,
90
14
      VALS(etype_vals), 0x0, NULL, HFILL }},
91
92
14
    { &hf_3com_xns_type_retix_bpdu,
93
14
    { "Type", "3comxns.type", FT_UINT16, BASE_HEX,
94
14
      VALS(retix_bpdu_type_vals), 0x0, NULL, HFILL }},
95
14
  };
96
97
14
  static int *ett[] ={
98
14
    &ett_3com_xns,
99
14
  };
100
101
14
  proto_3com_xns = proto_register_protocol("3Com XNS Encapsulation", "3COMXNS", "3comxns");
102
14
  proto_register_field_array(proto_3com_xns, hf, array_length(hf));
103
14
  proto_register_subtree_array(ett, array_length(ett));
104
105
14
  our_xns_handle = register_dissector("3comxns", dissect_3com_xns, proto_3com_xns);
106
14
}
107
108
void
109
proto_reg_handoff_3com_xns(void)
110
14
{
111
14
  retix_bpdu_handle = find_dissector_add_dependency("rbpdu", proto_3com_xns);
112
14
  ethertype_subdissector_table = find_dissector_table("ethertype");
113
14
  dissector_add_uint("llc.dsap", 0x80, our_xns_handle);
114
14
}
115
116
/*
117
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
118
 *
119
 * Local variables:
120
 * c-basic-offset: 8
121
 * tab-width: 8
122
 * indent-tabs-mode: t
123
 * End:
124
 *
125
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
126
 * :indentSize=8:tabSize=8:noTabs=false:
127
 */