Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-ipnet.c
blob94cf58067cb39e1d3f6f3f3442c26108701ba3ad
1 /* packet-ipnet.c
2 * Routines for decoding Solaris IPNET packet disassembly
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
11 #include "config.h"
13 #include <epan/packet.h>
14 #include <epan/aftypes.h>
15 #include <wiretap/wtap.h>
17 void proto_register_ipnet(void);
18 void proto_reg_handoff_ipnet(void);
20 static int proto_ipnet;
21 static int hf_version;
22 static int hf_family;
23 static int hf_htype;
24 static int hf_pktlen;
25 static int hf_ifindex;
26 static int hf_grifindex;
27 static int hf_zsrc;
28 static int hf_zdst;
30 static int ett_raw;
32 static dissector_handle_t ipnet_handle;
33 static dissector_handle_t ip_handle;
34 static dissector_handle_t ipv6_handle;
36 static const value_string solaris_family_vals[] = {
37 { SOLARIS_AF_INET, "Solaris AF_INET" },
38 { SOLARIS_AF_INET6, "Solaris AF_INET6" },
39 { 0, NULL }
42 static const value_string htype_vals[] = {
43 { 0, "Inbound" },
44 { 1, "Outbound" },
45 { 2, "Local" },
46 { 0, NULL }
49 static int
50 dissect_ipnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
52 proto_tree *fh_tree;
53 proto_item *ti;
54 tvbuff_t *next_tvb;
55 uint32_t pktlen;
56 uint8_t family;
58 /* load the top pane info. This should be overwritten by
59 the next protocol in the stack */
60 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPNET");
61 col_set_str(pinfo->cinfo, COL_INFO, "Solaris IPNET");
63 /* populate a tree in the second pane with the IPNET header data */
64 if(tree) {
65 ti = proto_tree_add_item (tree, proto_ipnet, tvb, 0, 24, ENC_NA);
66 fh_tree = proto_item_add_subtree(ti, ett_raw);
68 proto_tree_add_item(fh_tree, hf_version, tvb, 0, 1, ENC_BIG_ENDIAN);
69 proto_tree_add_item(fh_tree, hf_family, tvb, 1, 1, ENC_BIG_ENDIAN);
70 proto_tree_add_item(fh_tree, hf_htype, tvb, 2, 2, ENC_BIG_ENDIAN);
71 proto_tree_add_item(fh_tree, hf_pktlen, tvb, 4, 4, ENC_BIG_ENDIAN);
72 proto_tree_add_item(fh_tree, hf_ifindex, tvb, 8, 4, ENC_BIG_ENDIAN);
73 proto_tree_add_item(fh_tree, hf_grifindex, tvb, 12, 4, ENC_BIG_ENDIAN);
74 proto_tree_add_item(fh_tree, hf_zsrc, tvb, 16, 4, ENC_BIG_ENDIAN);
75 proto_tree_add_item(fh_tree, hf_zdst, tvb, 20, 4, ENC_BIG_ENDIAN);
78 pktlen = tvb_get_ntohl(tvb, 4);
79 next_tvb = tvb_new_subset_remaining(tvb, tvb_captured_length(tvb) - pktlen);
81 family = tvb_get_uint8(tvb, 1);
82 switch (family) {
83 case SOLARIS_AF_INET:
84 call_dissector(ip_handle, next_tvb, pinfo, tree);
85 break;
86 case SOLARIS_AF_INET6:
87 call_dissector(ipv6_handle, next_tvb, pinfo, tree);
88 break;
89 default:
90 break;
92 return tvb_captured_length(tvb);
95 void
96 proto_register_ipnet(void)
98 static hf_register_info hf[] = {
99 { &hf_version, { "Header version", "ipnet.version",
100 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
102 { &hf_family, { "Address family", "ipnet.family",
103 FT_UINT8, BASE_DEC, VALS(solaris_family_vals), 0x0, NULL, HFILL }},
105 { &hf_htype, { "Hook type", "ipnet.htype",
106 FT_UINT16, BASE_DEC, VALS(htype_vals), 0x0, NULL, HFILL }},
108 { &hf_pktlen, { "Data length", "ipnet.pktlen",
109 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
111 { &hf_ifindex, { "Interface index", "ipnet.ifindex",
112 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
114 { &hf_grifindex, { "Group interface index", "ipnet.grifindex",
115 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
117 { &hf_zsrc, { "Source Zone ID", "ipnet.zsrc",
118 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
120 { &hf_zdst, { "Destination Zone ID", "ipnet.zdst",
121 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
123 static int *ett[] = {
124 &ett_raw,
127 proto_ipnet = proto_register_protocol("Solaris IPNET", "IPNET", "ipnet");
128 proto_register_field_array(proto_ipnet, hf, array_length(hf));
129 proto_register_subtree_array(ett, array_length(ett));
130 ipnet_handle = register_dissector("ipnet", dissect_ipnet, proto_ipnet);
133 void
134 proto_reg_handoff_ipnet(void)
137 * Get handles for the IP and IPv6 dissectors.
139 ip_handle = find_dissector_add_dependency("ip", proto_ipnet);
140 ipv6_handle = find_dissector_add_dependency("ipv6", proto_ipnet);
142 dissector_add_uint("wtap_encap", WTAP_ENCAP_IPNET, ipnet_handle);
146 * Editor modelines - https://www.wireshark.org/tools/modelines.html
148 * Local Variables:
149 * c-basic-offset: 2
150 * tab-width: 8
151 * indent-tabs-mode: nil
152 * End:
154 * ex: set shiftwidth=2 tabstop=8 expandtab:
155 * :indentSize=2:tabSize=8:noTabs=true: