Coverage Report

Created: 2026-09-28 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-swipe.c
Line
Count
Source
1
/* packet-swipe.c
2
 * swIPe IP Security Protocol
3
 *
4
 * http://www.crypto.com/papers/swipe.id.txt
5
 *
6
 * Copyright 2014 by Michael Mann
7
 *
8
 * Wireshark - Network traffic analyzer
9
 * By Gerald Combs <gerald@wireshark.org>
10
 * Copyright 1998 Gerald Combs
11
 *
12
 * SPDX-License-Identifier: GPL-2.0-or-later
13
 */
14
15
#include "config.h"
16
17
#include <epan/packet.h>
18
#include <epan/iana-info.h>
19
20
void proto_register_swipe(void);
21
void proto_reg_handoff_swipe(void);
22
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 }
30
};
31
32
/* Initialize the protocol and registered fields */
33
static int proto_swipe;
34
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;
40
41
/* Initialize the subtree pointers */
42
static int ett_swipe;
43
44
static dissector_handle_t swipe_handle;
45
static dissector_handle_t ipv6_handle;
46
47
static int
48
dissect_swipe(tvbuff_t *tvb, packet_info * pinfo, proto_tree *tree, void* data _U_)
49
17
{
50
17
    int             header_len, offset = 0;
51
17
    proto_tree      *swipe_tree;
52
17
    proto_item      *ti;
53
17
    tvbuff_t        *next_tvb;
54
55
17
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "swIPe");
56
17
    col_clear(pinfo->cinfo, COL_INFO);
57
58
17
    header_len = tvb_get_uint8(tvb, offset + 1);
59
17
    if (tree)
60
16
    {
61
16
        ti = proto_tree_add_item(tree, proto_swipe, tvb, offset, header_len, ENC_NA);
62
16
        swipe_tree = proto_item_add_subtree(ti, ett_swipe);
63
64
        /* Packet Type */
65
16
        proto_tree_add_item(swipe_tree, hf_swipe_packet_type, tvb, offset, 1, ENC_BIG_ENDIAN);
66
67
        /* Header Length */
68
16
        proto_tree_add_item(swipe_tree, hf_swipe_len, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
69
70
        /* Policy ID */
71
16
        proto_tree_add_item(swipe_tree, hf_swipe_policy_id, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
72
73
        /* Packet Sequence Number */
74
16
        proto_tree_add_item(swipe_tree, hf_swipe_packet_seq, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
75
76
16
        if (header_len > 8)
77
11
            proto_tree_add_item(swipe_tree, hf_swipe_authenticator, tvb, offset + 8, header_len - 8, ENC_NA);
78
16
    }
79
80
17
    next_tvb = tvb_new_subset_remaining(tvb, header_len);
81
17
    call_dissector(ipv6_handle, next_tvb, pinfo, tree);
82
83
17
    return tvb_captured_length(tvb);
84
17
}
85
86
/* Register the protocol with Wireshark */
87
void
88
proto_register_swipe(void)
89
16
{
90
91
    /* Setup list of header fields */
92
16
    static hf_register_info hf[] = {
93
16
        { &hf_swipe_packet_type,      { "Packet type",      "swipe.packet_type",      FT_UINT8, BASE_DEC, VALS(swipe_packet_type_vals), 0x0, NULL, HFILL } },
94
16
        { &hf_swipe_len,     { "Header Length",     "swipe.len",     FT_UINT8,  BASE_DEC, NULL,                      0x0, NULL, HFILL } },
95
16
        { &hf_swipe_policy_id,    { "Policy identifier",    "swipe.policy_id",    FT_UINT16, BASE_DEC, NULL,                      0x0, NULL, HFILL } },
96
16
        { &hf_swipe_packet_seq,     { "Packet sequence number",     "swipe.packet_seq",     FT_UINT32, BASE_DEC, NULL,                      0x0, NULL, HFILL } },
97
16
        { &hf_swipe_authenticator,   { "Authenticator",   "swipe.authenticator",   FT_BYTES, BASE_NONE, NULL,                      0x0, NULL, HFILL } },
98
16
    };
99
100
    /* Setup protocol subtree array */
101
16
    static int *ett[] = {
102
16
        &ett_swipe
103
16
    };
104
105
    /* Register the protocol name and description */
106
16
    proto_swipe = proto_register_protocol("swIPe IP Security Protocol", "swIPe", "swipe");
107
108
    /* Register the dissector handle */
109
16
    swipe_handle = register_dissector("swipe", dissect_swipe, proto_swipe);
110
111
    /* Required function calls to register the header fields and subtrees used */
112
16
    proto_register_field_array(proto_swipe, hf, array_length(hf));
113
16
    proto_register_subtree_array(ett, array_length(ett));
114
16
}
115
116
void
117
proto_reg_handoff_swipe(void)
118
16
{
119
16
    dissector_add_uint("ip.proto", IP_PROTO_SWIPE_DEPRECATED, swipe_handle);
120
121
16
    ipv6_handle = find_dissector_add_dependency("ipv6", proto_swipe );
122
16
}
123
124
/*
125
 * Editor modelines
126
 *
127
 * Local Variables:
128
 * c-basic-offset: 4
129
 * tab-width: 8
130
 * indent-tabs-mode: nil
131
 * End:
132
 *
133
 * ex: set shiftwidth=4 tabstop=8 expandtab:
134
 * :indentSize=4:tabSize=8:noTabs=true:
135
 */