Coverage Report

Created: 2025-12-27 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 "packet-iana-data.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
11
{
50
11
    int             header_len, offset = 0;
51
11
    proto_tree      *swipe_tree;
52
11
    proto_item      *ti;
53
11
    tvbuff_t        *next_tvb;
54
55
11
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "swIPe");
56
11
    col_clear(pinfo->cinfo, COL_INFO);
57
58
11
    header_len = tvb_get_uint8(tvb, offset + 1);
59
11
    if (tree)
60
10
    {
61
10
        ti = proto_tree_add_item(tree, proto_swipe, tvb, offset, header_len, ENC_NA);
62
10
        swipe_tree = proto_item_add_subtree(ti, ett_swipe);
63
64
        /* Packet Type */
65
10
        proto_tree_add_item(swipe_tree, hf_swipe_packet_type, tvb, offset, 1, ENC_BIG_ENDIAN);
66
67
        /* Header Length */
68
10
        proto_tree_add_item(swipe_tree, hf_swipe_len, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
69
70
        /* Policy ID */
71
10
        proto_tree_add_item(swipe_tree, hf_swipe_policy_id, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
72
73
        /* Packet Sequence Number */
74
10
        proto_tree_add_item(swipe_tree, hf_swipe_packet_seq, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
75
76
10
        if (header_len > 8)
77
5
            proto_tree_add_item(swipe_tree, hf_swipe_authenticator, tvb, offset + 8, header_len - 8, ENC_NA);
78
10
    }
79
80
11
    next_tvb = tvb_new_subset_remaining(tvb, header_len);
81
11
    call_dissector(ipv6_handle, next_tvb, pinfo, tree);
82
83
11
    return tvb_captured_length(tvb);
84
11
}
85
86
/* Register the protocol with Wireshark */
87
void
88
proto_register_swipe(void)
89
14
{
90
91
    /* Setup list of header fields */
92
14
    static hf_register_info hf[] = {
93
14
        { &hf_swipe_packet_type,      { "Packet type",      "swipe.packet_type",      FT_UINT8, BASE_DEC, VALS(swipe_packet_type_vals), 0x0, NULL, HFILL } },
94
14
        { &hf_swipe_len,     { "Header Length",     "swipe.len",     FT_UINT8,  BASE_DEC, NULL,                      0x0, NULL, HFILL } },
95
14
        { &hf_swipe_policy_id,    { "Policy identifier",    "swipe.policy_id",    FT_UINT16, BASE_DEC, NULL,                      0x0, NULL, HFILL } },
96
14
        { &hf_swipe_packet_seq,     { "Packet sequence number",     "swipe.packet_seq",     FT_UINT32, BASE_DEC, NULL,                      0x0, NULL, HFILL } },
97
14
        { &hf_swipe_authenticator,   { "Authenticator",   "swipe.authenticator",   FT_BYTES, BASE_NONE, NULL,                      0x0, NULL, HFILL } },
98
14
    };
99
100
    /* Setup protocol subtree array */
101
14
    static int *ett[] = {
102
14
        &ett_swipe
103
14
    };
104
105
    /* Register the protocol name and description */
106
14
    proto_swipe = proto_register_protocol("swIPe IP Security Protocol", "swIPe", "swipe");
107
108
    /* Register the dissector handle */
109
14
    swipe_handle = register_dissector("swipe", dissect_swipe, proto_swipe);
110
111
    /* Required function calls to register the header fields and subtrees used */
112
14
    proto_register_field_array(proto_swipe, hf, array_length(hf));
113
14
    proto_register_subtree_array(ett, array_length(ett));
114
14
}
115
116
void
117
proto_reg_handoff_swipe(void)
118
14
{
119
14
    dissector_add_uint("ip.proto", IP_PROTO_SWIPE_DEPRECATED, swipe_handle);
120
121
14
    ipv6_handle = find_dissector_add_dependency("ipv6", proto_swipe );
122
14
}
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
 */