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