Coverage Report

Created: 2025-02-15 06:25

/src/wireshark/epan/dissectors/packet-hpext.c
Line
Count
Source
1
/* packet-hpext.c
2
 * Routines for HP extended IEEE 802.2 LLC layer
3
 * Jochen Friedrich <jochen@scram.de>
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
#include "config.h"
12
13
#include <epan/packet.h>
14
#include <epan/llcsaps.h>
15
#include "packet-hpext.h"
16
17
void proto_register_hpext(void);
18
void proto_reg_handoff_hpext(void);
19
20
static dissector_handle_t hpext_handle;
21
22
static dissector_table_t subdissector_table;
23
24
static const value_string xsap_vals[] = {
25
  { HPEXT_DXSAP,  "RBOOT Destination Service Access Point" },
26
  { HPEXT_SXSAP,  "RBOOT Source Service Access Point" },
27
  { HPEXT_HPSW,   "HP Switch Protocol" },
28
  { HPEXT_SNMP,   "SNMP" },
29
  { 0x00,         NULL }
30
};
31
32
static int proto_hpext;
33
34
static int hf_hpext_dxsap;
35
static int hf_hpext_reserved;
36
static int hf_hpext_sxsap;
37
38
static int ett_hpext;
39
40
static int
41
dissect_hpext(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
42
28
{
43
28
  proto_tree  *hpext_tree = NULL;
44
28
  proto_item  *ti = NULL;
45
28
  uint16_t    dxsap, sxsap;
46
28
  tvbuff_t  *next_tvb;
47
48
28
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "HPEXT");
49
50
28
  dxsap = tvb_get_ntohs(tvb, 3);
51
28
  sxsap = tvb_get_ntohs(tvb, 5);
52
53
28
  if (tree) {
54
23
    ti = proto_tree_add_item(tree, proto_hpext, tvb, 0, 7, ENC_NA);
55
23
    hpext_tree = proto_item_add_subtree(ti, ett_hpext);
56
23
    proto_tree_add_item(hpext_tree, hf_hpext_reserved, tvb, 0, 3, ENC_NA);
57
23
    proto_tree_add_uint(hpext_tree, hf_hpext_dxsap, tvb, 3,
58
23
      2, dxsap);
59
23
    proto_tree_add_uint(hpext_tree, hf_hpext_sxsap, tvb, 5,
60
23
      2, sxsap);
61
23
  }
62
63
28
  col_append_fstr(pinfo->cinfo, COL_INFO,
64
28
        "; HPEXT; DXSAP %s, SXSAP %s",
65
28
        val_to_str(dxsap, xsap_vals, "%04x"),
66
28
        val_to_str(sxsap, xsap_vals, "%04x"));
67
68
28
  if (tvb_reported_length_remaining(tvb, 7) > 0) {
69
21
    next_tvb = tvb_new_subset_remaining(tvb, 7);
70
21
    if (!dissector_try_uint(subdissector_table,
71
21
        dxsap, next_tvb, pinfo, tree)) {
72
2
      call_data_dissector(next_tvb, pinfo, tree);
73
2
    }
74
21
  }
75
28
  return tvb_captured_length(tvb);
76
28
}
77
78
void
79
proto_register_hpext(void)
80
14
{
81
14
  static hf_register_info hf[] = {
82
14
    { &hf_hpext_dxsap,
83
14
      { "DXSAP", "hpext.dxsap",
84
14
        FT_UINT16, BASE_HEX, VALS(xsap_vals), 0x0,
85
14
        NULL, HFILL }
86
14
    },
87
14
    { &hf_hpext_sxsap,
88
14
      { "SXSAP", "hpext.sxsap",
89
14
        FT_UINT16, BASE_HEX, VALS(xsap_vals), 0x0,
90
14
        NULL, HFILL }
91
14
    },
92
14
    { &hf_hpext_reserved,
93
14
      { "Reserved", "hpext.reserved",
94
14
        FT_UINT24, BASE_HEX, NULL, 0x0,
95
14
        NULL, HFILL }
96
14
    },
97
14
  };
98
99
14
  static int *ett[] = {
100
14
    &ett_hpext
101
14
  };
102
103
14
  proto_hpext = proto_register_protocol("HP Extended Local-Link Control", "HPEXT", "hpext");
104
14
  proto_register_field_array(proto_hpext, hf, array_length(hf));
105
14
  proto_register_subtree_array(ett, array_length(ett));
106
107
/* subdissector code */
108
14
  subdissector_table = register_dissector_table("hpext.dxsap",
109
14
    "HPEXT XSAP", proto_hpext, FT_UINT16, BASE_HEX);
110
111
14
  hpext_handle = register_dissector("hpext", dissect_hpext, proto_hpext);
112
14
}
113
114
void
115
proto_reg_handoff_hpext(void)
116
14
{
117
14
  dissector_add_uint("llc.dsap", SAP_HPEXT, hpext_handle);
118
14
}
119
120
/*
121
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
122
 *
123
 * Local variables:
124
 * c-basic-offset: 8
125
 * tab-width: 8
126
 * indent-tabs-mode: t
127
 * End:
128
 *
129
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
130
 * :indentSize=8:tabSize=8:noTabs=false:
131
 */