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
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" },
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 */
44 static dissector_handle_t swipe_handle
;
45 static dissector_handle_t ipv6_handle
;
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
;
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);
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
);
65 proto_tree_add_item(swipe_tree
, hf_swipe_packet_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
68 proto_tree_add_item(swipe_tree
, hf_swipe_len
, tvb
, offset
+ 1, 1, ENC_BIG_ENDIAN
);
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
);
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 */
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
[] = {
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
));
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
);
130 * indent-tabs-mode: nil
133 * ex: set shiftwidth=4 tabstop=8 expandtab:
134 * :indentSize=4:tabSize=8:noTabs=true: