Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-tuxedo.c
blobcb98838b1c97813bc983190323d64f350cca8ea3
1 /* packet-tuxedo.c
2 * Routines for BEA Tuxedo ATMI protocol
4 * metatech <metatech@flashmail.com>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include "config.h"
15 #include <epan/packet.h>
16 #include <epan/conversation.h>
18 void proto_register_tuxedo(void);
19 void proto_reg_handoff_tuxedo(void);
21 static int proto_tuxedo;
22 static int hf_tuxedo_magic;
23 static int hf_tuxedo_opcode;
25 static int ett_tuxedo;
27 static dissector_handle_t tuxedo_handle;
29 #define TUXEDO_MAGIC 0x91039858
30 #define TUXEDO_SMAGIC 0x73903842
32 #define TUXEDO_ATMI_CALL 1
33 #define TUXEDO_ATMI_REPLY 2
34 #define TUXEDO_ATMI_FAILURE 3
35 #define TUXEDO_ATMI_CONNECT 4
36 #define TUXEDO_ATMI_DATA 5
37 #define TUXEDO_ATMI_DISCON 6
38 #define TUXEDO_ATMI_PREPARE 7
39 #define TUXEDO_ATMI_READY 8
40 #define TUXEDO_ATMI_COMMIT 9
41 #define TUXEDO_ATMI_DONE 10
42 #define TUXEDO_ATMI_COMPLETE 11
43 #define TUXEDO_ATMI_ROLLBACK 12
44 #define TUXEDO_ATMI_HEURISTIC 13
45 #define TUXEDO_ATMI_PRE_NW_ACALL1 14
46 #define TUXEDO_ATMI_PRE_NW_ACALL1_RPLY 15
47 #define TUXEDO_ATMI_PRE_NW_ACALL2 16
48 #define TUXEDO_ATMI_PRE_NW_ACALL2_RPLY 17
49 #define TUXEDO_ATMI_PRE_NW_ACALL3 18
50 #define TUXEDO_ATMI_PRE_NW_ACALL3_RPLY 19
51 #define TUXEDO_ATMI_PRE_NW_LLE 20
52 #define TUXEDO_ATMI_PRE_NW_LLE_RPLY 21
53 #define TUXEDO_ATMI_SEC_EXCHG_RQST 22
54 #define TUXEDO_ATMI_SEC_EXCHG_RPLY 23
55 #define TUXEDO_ATMI_SEC_NW_ACALL3 24
56 #define TUXEDO_ATMI_SEC_NW_ACALL3_RPLY 25
59 static const value_string tuxedo_opcode_vals[] = {
60 { TUXEDO_ATMI_CALL, "CALL" },
61 { TUXEDO_ATMI_REPLY, "REPLY" },
62 { TUXEDO_ATMI_FAILURE, "FAILURE" },
63 { TUXEDO_ATMI_CONNECT, "CONNECT" },
64 { TUXEDO_ATMI_DATA, "DATA" },
65 { TUXEDO_ATMI_DISCON, "DISCON" },
66 { TUXEDO_ATMI_PREPARE, "PREPARE" },
67 { TUXEDO_ATMI_READY, "READY" },
68 { TUXEDO_ATMI_COMMIT, "COMMIT" },
69 { TUXEDO_ATMI_DONE, "DONE" },
70 { TUXEDO_ATMI_COMPLETE, "COMPLETE" },
71 { TUXEDO_ATMI_ROLLBACK, "ROLLBACK" },
72 { TUXEDO_ATMI_HEURISTIC, "HEURISTIC" },
73 { TUXEDO_ATMI_PRE_NW_ACALL1, "ACALL1" },
74 { TUXEDO_ATMI_PRE_NW_ACALL1_RPLY, "ACALL1_REPLY" },
75 { TUXEDO_ATMI_PRE_NW_ACALL2, "ACALL2" },
76 { TUXEDO_ATMI_PRE_NW_ACALL2_RPLY, "ACALL2_REPLY" },
77 { TUXEDO_ATMI_PRE_NW_ACALL3, "ACALL3" },
78 { TUXEDO_ATMI_PRE_NW_ACALL3_RPLY, "ACALL3_REPLY" },
79 { TUXEDO_ATMI_PRE_NW_LLE, "LLE" },
80 { TUXEDO_ATMI_PRE_NW_LLE_RPLY, "LLE_REPLY" },
81 { TUXEDO_ATMI_SEC_EXCHG_RQST, "SEC_EXCHANGE" },
82 { TUXEDO_ATMI_SEC_EXCHG_RPLY, "SEC_EXCHANGE_REPLY" },
83 { TUXEDO_ATMI_SEC_NW_ACALL3, "SEC_ACALL3" },
84 { TUXEDO_ATMI_SEC_NW_ACALL3_RPLY, "SEC_ACALL3_REPLY" },
85 { 0, NULL }
89 static int
90 dissect_tuxedo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
92 proto_tree *tuxedoroot_tree = NULL;
93 proto_item *ti;
94 uint32_t magic;
95 uint32_t opcode;
97 col_set_str(pinfo->cinfo, COL_PROTOCOL, "TUXEDO");
99 if (tvb_reported_length(tvb) >= 8)
101 magic = tvb_get_ntohl(tvb, 0);
102 if (magic == TUXEDO_MAGIC || magic == TUXEDO_SMAGIC)
104 opcode = tvb_get_ntohl(tvb, 4);
106 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(opcode, tuxedo_opcode_vals, "Unknown (0x%02x)"));
108 if (tree)
110 ti = proto_tree_add_item(tree, proto_tuxedo, tvb, 0, -1, ENC_NA);
111 tuxedoroot_tree = proto_item_add_subtree(ti, ett_tuxedo);
113 proto_tree_add_item(tuxedoroot_tree, hf_tuxedo_magic, tvb, 0, 4, ENC_BIG_ENDIAN);
114 proto_tree_add_item(tuxedoroot_tree, hf_tuxedo_opcode, tvb, 4, 4, ENC_BIG_ENDIAN);
117 else
119 /* This packet is a continuation */
120 col_set_str(pinfo->cinfo, COL_INFO, "Continuation");
121 if (tree)
123 proto_tree_add_item(tree, proto_tuxedo, tvb, 0, -1, ENC_NA);
127 return tvb_captured_length(tvb);
130 static bool
131 dissect_tuxedo_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
133 if (tvb_captured_length(tvb) >= 8)
135 uint32_t magic;
136 magic = tvb_get_ntohl(tvb, 0);
137 if (magic == TUXEDO_MAGIC || magic == TUXEDO_SMAGIC)
139 /* Register this dissector for this conversation */
140 conversation_t *conversation = NULL;
141 conversation = find_or_create_conversation(pinfo);
142 conversation_set_dissector(conversation, tuxedo_handle);
144 dissect_tuxedo(tvb, pinfo, tree, data);
145 return true;
148 return false;
151 void
152 proto_register_tuxedo(void)
154 static hf_register_info hf[] = {
155 { &hf_tuxedo_magic,
156 { "Magic", "tuxedo.magic", FT_UINT32, BASE_HEX, NULL, 0x0, "TUXEDO magic", HFILL }},
158 { &hf_tuxedo_opcode,
159 { "Opcode", "tuxedo.opcode", FT_UINT32, BASE_HEX, VALS(tuxedo_opcode_vals), 0x0, "TUXEDO opcode", HFILL }}
162 static int *ett[] = {
163 &ett_tuxedo,
166 proto_tuxedo = proto_register_protocol("BEA Tuxedo", "TUXEDO", "tuxedo");
167 proto_register_field_array(proto_tuxedo, hf, array_length(hf));
168 proto_register_subtree_array(ett, array_length(ett));
170 tuxedo_handle = register_dissector("tuxedo", dissect_tuxedo, proto_tuxedo);
173 void
174 proto_reg_handoff_tuxedo(void)
176 dissector_add_for_decode_as_with_preference("tcp.port", tuxedo_handle);
177 heur_dissector_add("tcp", dissect_tuxedo_heur, "Tuxedo over TCP", "tuxedo_tcp", proto_tuxedo, HEURISTIC_ENABLE);
181 * Editor modelines - https://www.wireshark.org/tools/modelines.html
183 * Local variables:
184 * c-basic-offset: 8
185 * tab-width: 8
186 * indent-tabs-mode: t
187 * End:
189 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
190 * :indentSize=8:tabSize=8:noTabs=false: