2 * Anything in Anything protocol
3 * Copyright 2008, Jelmer Vernooij <jelmer@samba.org>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 * ref: http://unfix.org/~jeroen/archive/drafts/draft-massar-v6ops-ayiya-02.html#anchor4
34 #include <epan/packet.h>
35 #include <epan/ipproto.h>
36 #include <epan/strutil.h>
38 static dissector_table_t ip_dissector_table;
40 static int proto_ayiya = -1;
41 static int hf_id_len = -1;
42 static int hf_id_type = -1;
43 static int hf_sig_len = -1;
44 static int hf_hash_method = -1;
45 static int hf_auth_method = -1;
46 static int hf_opcode = -1;
47 static int hf_next_header = -1;
48 static int hf_epoch = -1;
49 static int hf_identity = -1;
50 static int hf_signature = -1;
52 static gint ett_ayiya = -1;
54 static const value_string identity_types[] = {
57 { 0x2, "ASCII string" },
61 static const value_string hash_methods[] = {
68 static const value_string auth_methods[] = {
69 { 0x0, "No authentication" },
70 { 0x1, "Hash using a Shared Secret" },
71 { 0x2, "Hash using a public/private key method" },
75 #define OPCODE_FORWARD 1
77 static const value_string opcodes[] = {
78 { 0x0, "No Operation / Heartbeat" },
80 { 0x2, "Echo Request" },
81 { 0x3, "Echo Request and Forward" },
82 { 0x4, "Echo Response" },
84 { 0x6, "Query Request" },
85 { 0x7, "Query Response" },
89 #define UDP_PORT_AYIYA 5072
92 dissect_ayiya(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
94 proto_tree *ayiya_tree;
96 int idlen, siglen, ayiya_len;
97 guint8 next_header, opcode;
100 idlen = 1 << tvb_get_bits8(tvb, 0, 4);
101 siglen = tvb_get_bits8(tvb, 8, 4) * 4;
102 opcode = tvb_get_bits8(tvb, 20, 4);
103 next_header = tvb_get_guint8(tvb, 3);
105 ayiya_len = 8+idlen+siglen;
107 col_set_str(pinfo->cinfo, COL_PROTOCOL, "AYIYA");
112 ti = proto_tree_add_protocol_format( tree, proto_ayiya, tvb,
113 offset, ayiya_len, "AYIYA" );
114 ayiya_tree = proto_item_add_subtree(ti, ett_ayiya);
116 proto_tree_add_bits_item(ayiya_tree, hf_id_len, tvb, 0, 4, FALSE);
117 proto_tree_add_bits_item(ayiya_tree, hf_id_type, tvb, 4, 4, FALSE);
118 proto_tree_add_bits_item(ayiya_tree, hf_sig_len, tvb, 8, 4, FALSE);
119 proto_tree_add_bits_item(ayiya_tree, hf_hash_method, tvb, 12, 4, FALSE);
120 proto_tree_add_bits_item(ayiya_tree, hf_auth_method, tvb, 16, 4, FALSE);
121 proto_tree_add_bits_item(ayiya_tree, hf_opcode, tvb, 20, 4, FALSE);
122 proto_tree_add_uint_format(ayiya_tree, hf_next_header, tvb,
124 "Next header: %s (0x%02x)",
125 ipprotostr(next_header), next_header);
126 tv.secs = tvb_get_ntohl(tvb, 4);
128 proto_tree_add_time(ayiya_tree, hf_epoch, tvb, 4, 4, &tv);
129 proto_tree_add_item(ayiya_tree, hf_identity, tvb, 8, idlen, FALSE);
130 proto_tree_add_item(ayiya_tree, hf_signature, tvb, 8+idlen, siglen, FALSE);
135 payload = tvb_new_subset_remaining(tvb, offset);
136 dissector_try_port(ip_dissector_table, next_header, payload, pinfo, tree);
142 proto_register_ayiya(void)
144 static hf_register_info hf[] = {
146 { "Identity field length", "ayiya.idlen", FT_UINT8,
147 BASE_HEX, NULL, 0x0, NULL, HFILL
151 { "Identity field type", "ayiya.idtype", FT_UINT8,
152 BASE_HEX, VALS(identity_types), 0x0, NULL, HFILL
156 { "Signature Length", "ayiya.siglen", FT_UINT8,
157 BASE_HEX, NULL, 0x0, NULL, HFILL
161 { "Hash method", "ayiya.hashmethod", FT_UINT8,
162 BASE_HEX, VALS(hash_methods), 0x0, NULL, HFILL
166 { "Authentication method", "ayiya.authmethod", FT_UINT8,
167 BASE_HEX, VALS(auth_methods), 0x0, NULL, HFILL
171 { "Operation Code", "ayiya.opcode", FT_UINT8,
172 BASE_HEX, VALS(opcodes), 0x0, NULL, HFILL
176 { "Next Header", "ayiya.nextheader", FT_UINT8,
177 BASE_HEX, NULL, 0x0, NULL, HFILL
181 { "Epoch", "ayiya.epoch", FT_ABSOLUTE_TIME,
182 ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL
186 { "Identity", "ayiya.identity", FT_BYTES,
187 BASE_NONE, NULL, 0x0, NULL, HFILL
191 { "Signature", "ayiya.signature", FT_BYTES,
192 BASE_NONE, NULL, 0x0, NULL, HFILL
196 static gint *ett[] = {
200 proto_ayiya = proto_register_protocol("Anything in Anything Protocol",
202 register_dissector("ayiya", dissect_ayiya, proto_ayiya);
203 proto_register_field_array(proto_ayiya, hf, array_length(hf));
204 proto_register_subtree_array(ett, array_length(ett));
208 proto_reg_handoff_ayiya(void)
210 dissector_handle_t ayiya_handle;
212 ayiya_handle = find_dissector("ayiya");
213 dissector_add("udp.port", UDP_PORT_AYIYA, ayiya_handle);
215 ip_dissector_table = find_dissector_table("ip.proto");