2 * Copyright (c) 2003 Markus Friedl. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <epan/packet.h>
30 #include <epan/ipproto.h>
31 #include <epan/expert.h>
33 void proto_register_etherip(void);
34 void proto_reg_handoff_etherip(void);
36 static int proto_etherip
= -1;
37 static int hf_etherip_ver
= -1;
38 static int hf_etherip_reserved
= -1;
40 static gint ett_etherip
= -1;
42 static expert_field ei_etherip_ver_3
= EI_INIT
;
43 static expert_field ei_etherip_reserved_0
= EI_INIT
;
45 static dissector_handle_t eth_withoutfcs_handle
;
49 * RFC 3378: EtherIP: Tunneling Ethernet Frames in IP Datagrams
51 * Bits 0-3: Protocol version
52 * Bits 4-15: Reserved for future use
55 #define ETHERIP_VERS_MASK 0xF000
56 #define ETHERIP_RESERVE_MASK 0x0FFF
60 dissect_etherip(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
63 proto_tree
*etherip_tree
;
65 guint16 field
, version
;
67 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "ETHERIP");
69 field
= tvb_get_ntohs(tvb
, 0);
70 version
= (field
& ETHERIP_VERS_MASK
) >> 12;
73 ti
= proto_tree_add_protocol_format(tree
, proto_etherip
, tvb
, 0,
75 "EtherIP, Version %d",
78 etherip_tree
= proto_item_add_subtree(ti
, ett_etherip
);
80 ti
= proto_tree_add_item(etherip_tree
, hf_etherip_ver
, tvb
,
81 0, 2, ENC_BIG_ENDIAN
);
83 expert_add_info(pinfo
, ti
, &ei_etherip_ver_3
);
86 ti
= proto_tree_add_item(etherip_tree
, hf_etherip_reserved
, tvb
,
87 0, 2, ENC_BIG_ENDIAN
);
88 if ((field
& ETHERIP_RESERVE_MASK
) != 0) {
89 expert_add_info(pinfo
, ti
, &ei_etherip_reserved_0
);
93 /* Set the tvbuff for the payload after the header */
94 next_tvb
= tvb_new_subset_remaining(tvb
, 2);
96 call_dissector(eth_withoutfcs_handle
, next_tvb
, pinfo
, tree
);
100 proto_register_etherip(void)
102 static hf_register_info hf_etherip
[] = {
104 { "Version", "etherip.ver", FT_UINT16
, BASE_DEC
, NULL
, ETHERIP_VERS_MASK
,
106 { &hf_etherip_reserved
,
107 { "Reserved", "etherip.reserved", FT_UINT16
, BASE_HEX
, NULL
, ETHERIP_RESERVE_MASK
,
108 "Reserved (must be 0)", HFILL
}},
111 static gint
*ett
[] = {
115 static ei_register_info ei
[] = {
116 { &ei_etherip_ver_3
, { "etherip.ver.not3", PI_PROTOCOL
, PI_WARN
, "Version must be 3", EXPFILL
}},
117 { &ei_etherip_reserved_0
, { "etherip.reserved.not0", PI_PROTOCOL
, PI_WARN
, "Reserved field must be 0", EXPFILL
}},
120 expert_module_t
* expert_etherip
;
122 proto_etherip
= proto_register_protocol("Ethernet over IP",
123 "ETHERIP", "etherip");
124 proto_register_field_array(proto_etherip
, hf_etherip
, array_length(hf_etherip
));
125 proto_register_subtree_array(ett
, array_length(ett
));
126 expert_etherip
= expert_register_protocol(proto_etherip
);
127 expert_register_field_array(expert_etherip
, ei
, array_length(ei
));
129 register_dissector("etherip", dissect_etherip
, proto_etherip
);
133 proto_reg_handoff_etherip(void)
135 dissector_handle_t etherip_handle
;
137 eth_withoutfcs_handle
= find_dissector("eth_withoutfcs");
138 etherip_handle
= find_dissector("etherip");
139 dissector_add_uint("ip.proto", IP_PROTO_ETHERIP
, etherip_handle
);