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
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
;
25 static int hf_ifindex
;
26 static int hf_grifindex
;
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" },
42 static const value_string htype_vals
[] = {
50 dissect_ipnet(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
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 */
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);
84 call_dissector(ip_handle
, next_tvb
, pinfo
, tree
);
86 case SOLARIS_AF_INET6
:
87 call_dissector(ipv6_handle
, next_tvb
, pinfo
, tree
);
92 return tvb_captured_length(tvb
);
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
[] = {
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
);
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
151 * indent-tabs-mode: nil
154 * ex: set shiftwidth=2 tabstop=8 expandtab:
155 * :indentSize=2:tabSize=8:noTabs=true: