epan/dissectors/pidl/ C99 drsuapi
[wireshark-sm.git] / epan / dissectors / packet-sscf-nni.c
blobf2e17b780d89b9617148a107c15bfa335baf9ccd
1 /* packet-sscf-nni.c
2 * Routines for SSCF-NNI (Q.2140) frame disassembly
3 * Jeff Morriss <jeff.morriss.ws [AT] gmail.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998
9 * Copied from packet-sscop.c
11 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include "config.h"
16 #include <epan/packet.h>
18 void proto_register_sscf(void);
19 void proto_reg_handoff_sscf(void);
21 static int proto_sscf;
23 static int ett_sscf;
25 static dissector_handle_t mtp3_handle;
27 #define SSCF_PDU_LENGTH 4
28 #define SSCF_STATUS_OFFSET 3
29 #define SSCF_STATUS_LENGTH 1
30 #define SSCF_SPARE_OFFSET 0
31 #define SSCF_SPARE_LENGTH 3
33 static int hf_status;
34 static int hf_spare;
36 #define SSCF_STATUS_OOS 0x01
37 #define SSCF_STATUS_PO 0x02
38 #define SSCF_STATUS_IS 0x03
39 #define SSCF_STATUS_NORMAL 0x04
40 #define SSCF_STATUS_EMERGENCY 0x05
41 #define SSCF_STATUS_ALIGNMENT_NOT_SUCCESSFUL 0x7
42 #define SSCF_STATUS_MANAGEMENT_INITIATED 0x08
43 #define SSCF_STATUS_PROTOCOL_ERROR 0x09
44 #define SSCF_STATUS_PROVING_NOT_SUCCESSFUL 0x0a
46 static const value_string sscf_status_vals[] = {
47 { SSCF_STATUS_OOS, "Out of Service" },
48 { SSCF_STATUS_PO, "Processor Outage" },
49 { SSCF_STATUS_IS, "In Service" },
50 { SSCF_STATUS_NORMAL, "Normal" },
51 { SSCF_STATUS_EMERGENCY, "Emergency" },
52 { SSCF_STATUS_ALIGNMENT_NOT_SUCCESSFUL, "Alignment Not Successful" },
53 { SSCF_STATUS_MANAGEMENT_INITIATED, "Management Initiated" },
54 { SSCF_STATUS_PROTOCOL_ERROR, "Protocol Error" },
55 { SSCF_STATUS_PROVING_NOT_SUCCESSFUL, "Proving Not Successful" },
56 { 0, NULL }
59 static int
60 dissect_sscf_nni(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
62 unsigned reported_length;
63 proto_item *sscf_item = NULL;
64 proto_tree *sscf_tree = NULL;
65 uint8_t sscf_status;
67 reported_length = tvb_reported_length(tvb); /* frame length */
69 if (tree) {
70 sscf_item = proto_tree_add_item(tree, proto_sscf, tvb, 0, -1, ENC_NA);
71 sscf_tree = proto_item_add_subtree(sscf_item, ett_sscf);
74 if (reported_length > SSCF_PDU_LENGTH)
76 call_dissector(mtp3_handle, tvb, pinfo, tree);
78 } else {
80 sscf_status = tvb_get_uint8(tvb, SSCF_STATUS_OFFSET);
82 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SSCF-NNI");
83 col_add_fstr(pinfo->cinfo, COL_INFO, "STATUS (%s) ",
84 val_to_str_const(sscf_status, sscf_status_vals, "Unknown"));
87 proto_tree_add_item(sscf_tree, hf_status, tvb, SSCF_STATUS_OFFSET,
88 SSCF_STATUS_LENGTH, ENC_BIG_ENDIAN);
89 proto_tree_add_item(sscf_tree, hf_spare, tvb, SSCF_SPARE_OFFSET,
90 SSCF_SPARE_LENGTH, ENC_BIG_ENDIAN);
93 return tvb_captured_length(tvb);
96 void
97 proto_register_sscf(void)
99 static hf_register_info hf[] =
100 { { &hf_status, { "Status", "sscf-nni.status", FT_UINT8, BASE_HEX,
101 VALS(sscf_status_vals), 0x0, NULL, HFILL} },
102 { &hf_spare, { "Spare", "sscf-nni.spare", FT_UINT24, BASE_HEX,
103 NULL, 0x0, NULL, HFILL} }
106 static int *ett[] = {
107 &ett_sscf,
110 proto_sscf = proto_register_protocol("SSCF-NNI", "SSCF-NNI", "sscf-nni");
112 proto_register_field_array(proto_sscf, hf, array_length(hf));
113 proto_register_subtree_array(ett, array_length(ett));
115 register_dissector("sscf-nni", dissect_sscf_nni, proto_sscf);
119 void
120 proto_reg_handoff_sscf(void)
122 mtp3_handle = find_dissector_add_dependency("mtp3", proto_sscf);
126 * Editor modelines - https://www.wireshark.org/tools/modelines.html
128 * Local Variables:
129 * c-basic-offset: 2
130 * tab-width: 8
131 * indent-tabs-mode: nil
132 * End:
134 * ex: set shiftwidth=2 tabstop=8 expandtab:
135 * :indentSize=2:tabSize=8:noTabs=true: