Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-swipe.c
blobcf22ddb9593835ab91c614deddc99cb6e1696ab1
1 /* packet-swipe.c
2 * swIPe IP Security Protocol
4 * http://www.crypto.com/papers/swipe.id.txt
6 * Copyright 2014 by Michael Mann
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include "config.h"
17 #include <epan/packet.h>
18 #include <epan/ipproto.h>
20 void proto_register_swipe(void);
21 void proto_reg_handoff_swipe(void);
23 /* Routing Header Types */
24 static const value_string swipe_packet_type_vals[] = {
25 { 0, "Plain encapsulation" },
26 { 1, "Packet is authenticated but not encrypted" },
27 { 2, "Packet is encrypted" },
28 { 3, "Packet is both authenticated and encrypted" },
29 { 0, NULL }
32 /* Initialize the protocol and registered fields */
33 static int proto_swipe;
35 static int hf_swipe_packet_type;
36 static int hf_swipe_len;
37 static int hf_swipe_policy_id;
38 static int hf_swipe_packet_seq;
39 static int hf_swipe_authenticator;
41 /* Initialize the subtree pointers */
42 static int ett_swipe;
44 static dissector_handle_t swipe_handle;
45 static dissector_handle_t ipv6_handle;
47 static int
48 dissect_swipe(tvbuff_t *tvb, packet_info * pinfo, proto_tree *tree, void* data _U_)
50 int header_len, offset = 0;
51 proto_tree *swipe_tree;
52 proto_item *ti;
53 tvbuff_t *next_tvb;
55 col_set_str(pinfo->cinfo, COL_PROTOCOL, "swIPe");
56 col_clear(pinfo->cinfo, COL_INFO);
58 header_len = tvb_get_uint8(tvb, offset + 1);
59 if (tree)
61 ti = proto_tree_add_item(tree, proto_swipe, tvb, offset, header_len, ENC_NA);
62 swipe_tree = proto_item_add_subtree(ti, ett_swipe);
64 /* Packet Type */
65 proto_tree_add_item(swipe_tree, hf_swipe_packet_type, tvb, offset, 1, ENC_BIG_ENDIAN);
67 /* Header Length */
68 proto_tree_add_item(swipe_tree, hf_swipe_len, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
70 /* Policy ID */
71 proto_tree_add_item(swipe_tree, hf_swipe_policy_id, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
73 /* Packet Sequence Number */
74 proto_tree_add_item(swipe_tree, hf_swipe_packet_seq, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
76 if (header_len > 8)
77 proto_tree_add_item(swipe_tree, hf_swipe_authenticator, tvb, offset + 8, header_len - 8, ENC_NA);
80 next_tvb = tvb_new_subset_remaining(tvb, header_len);
81 call_dissector(ipv6_handle, next_tvb, pinfo, tree);
83 return tvb_captured_length(tvb);
86 /* Register the protocol with Wireshark */
87 void
88 proto_register_swipe(void)
91 /* Setup list of header fields */
92 static hf_register_info hf[] = {
93 { &hf_swipe_packet_type, { "Packet type", "swipe.packet_type", FT_UINT8, BASE_DEC, VALS(swipe_packet_type_vals), 0x0, NULL, HFILL } },
94 { &hf_swipe_len, { "Header Length", "swipe.len", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
95 { &hf_swipe_policy_id, { "Policy identifier", "swipe.policy_id", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
96 { &hf_swipe_packet_seq, { "Packet sequence number", "swipe.packet_seq", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
97 { &hf_swipe_authenticator, { "Authenticator", "swipe.authenticator", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
100 /* Setup protocol subtree array */
101 static int *ett[] = {
102 &ett_swipe
105 /* Register the protocol name and description */
106 proto_swipe = proto_register_protocol("swIPe IP Security Protocol", "swIPe", "swipe");
108 /* Register the dissector handle */
109 swipe_handle = register_dissector("swipe", dissect_swipe, proto_swipe);
111 /* Required function calls to register the header fields and subtrees used */
112 proto_register_field_array(proto_swipe, hf, array_length(hf));
113 proto_register_subtree_array(ett, array_length(ett));
116 void
117 proto_reg_handoff_swipe(void)
119 dissector_add_uint("ip.proto", IP_PROTO_SWIPE, swipe_handle);
121 ipv6_handle = find_dissector_add_dependency("ipv6", proto_swipe );
125 * Editor modelines
127 * Local Variables:
128 * c-basic-offset: 4
129 * tab-width: 8
130 * indent-tabs-mode: nil
131 * End:
133 * ex: set shiftwidth=4 tabstop=8 expandtab:
134 * :indentSize=4:tabSize=8:noTabs=true: