2 * Routines for RX packet dissection
3 * Copyright 1999, Nathan Neulinger <nneul@umr.edu>
4 * Based on routines from tcpdump patches by
5 * Ken Hornstein <kenh@cmf.nrl.navy.mil>
7 * $Id: packet-rx.c,v 1.4 1999/11/16 11:42:53 guy Exp $
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@unicom.net>
11 * Copyright 1998 Gerald Combs
13 * Copied from packet-tftp.c
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #ifdef HAVE_SYS_TYPES_H
37 # include <sys/types.h>
40 #ifdef HAVE_NETINET_IN_H
41 # include <netinet/in.h>
47 #include "packet-rx.h"
50 static const value_string rx_types[] = {
51 { RX_PACKET_TYPE_DATA, "data" },
52 { RX_PACKET_TYPE_ACK, "ack" },
53 { RX_PACKET_TYPE_BUSY, "busy" },
54 { RX_PACKET_TYPE_ABORT, "abort" },
55 { RX_PACKET_TYPE_ACKALL, "ackall" },
56 { RX_PACKET_TYPE_CHALLENGE, "challenge" },
57 { RX_PACKET_TYPE_RESPONSE, "response" },
58 { RX_PACKET_TYPE_DEBUG, "debug" },
59 { RX_PACKET_TYPE_PARAMS, "params" },
60 { RX_PACKET_TYPE_VERSION, "version" },
64 static const value_string rx_flags[] = {
65 { RX_CLIENT_INITIATED, "client-init" },
66 { RX_REQUEST_ACK, "req-ack" },
67 { RX_LAST_PACKET, "last-pckt" },
68 { RX_MORE_PACKETS, "more-pckts" },
69 { RX_FREE_PACKET, "free-pckt" }
72 static int proto_rx = -1;
74 static int hf_rx_epoch = -1;
75 static int hf_rx_cid = -1;
76 static int hf_rx_seq = -1;
77 static int hf_rx_serial = -1;
78 static int hf_rx_callnumber = -1;
79 static int hf_rx_type = -1;
80 static int hf_rx_flags = -1;
81 static int hf_rx_flags_clientinit = -1;
82 static int hf_rx_flags_request_ack = -1;
83 static int hf_rx_flags_last_packet = -1;
84 static int hf_rx_flags_more_packets = -1;
85 static int hf_rx_flags_free_packet = -1;
86 static int hf_rx_userstatus = -1;
87 static int hf_rx_securityindex = -1;
88 static int hf_rx_spare = -1;
89 static int hf_rx_serviceid = -1;
91 static gint ett_rx = -1;
92 static gint ett_rx_flags = -1;
95 dissect_rx(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
97 proto_tree *rx_tree, *rx_tree_flags, *rx_flags, *ti;
98 struct rx_header *rxh;
101 rxh = (struct rx_header *) &pd[offset];
103 /* get at least a full packet structure */
104 if ( !BYTES_ARE_IN_FRAME(offset, sizeof(struct rx_header)) )
107 if (check_col(fd, COL_PROTOCOL))
108 col_add_str(fd, COL_PROTOCOL, "RX");
112 ti = proto_tree_add_item(tree, proto_rx, offset,
113 sizeof(struct rx_header), NULL);
114 rx_tree = proto_item_add_subtree(ti, ett_rx);
116 proto_tree_add_item(rx_tree, hf_rx_epoch,
117 offset, 4, ntohl(rxh->epoch));
118 proto_tree_add_item(rx_tree, hf_rx_cid,
119 offset+4, 4, ntohl(rxh->cid));
120 proto_tree_add_item(rx_tree, hf_rx_callnumber,
121 offset+8, 4, ntohl(rxh->callNumber));
122 proto_tree_add_item(rx_tree, hf_rx_seq,
123 offset+12, 4, ntohl(rxh->seq));
124 proto_tree_add_item(rx_tree, hf_rx_serial,
125 offset+16, 4, ntohl(rxh->serial));
127 proto_tree_add_item(rx_tree, hf_rx_type,
128 offset+20, 1, rxh->type);
130 rx_flags = proto_tree_add_item(rx_tree, hf_rx_flags,
131 offset+21, 1, rxh->flags);
132 rx_tree_flags = proto_item_add_subtree(rx_flags, ett_rx_flags);
133 proto_tree_add_item(rx_tree_flags, hf_rx_flags_free_packet,
134 offset+21, 1, rxh->flags);
135 proto_tree_add_item(rx_tree_flags, hf_rx_flags_more_packets,
136 offset+21, 1, rxh->flags);
137 proto_tree_add_item(rx_tree_flags, hf_rx_flags_last_packet,
138 offset+21, 1, rxh->flags);
139 proto_tree_add_item(rx_tree_flags, hf_rx_flags_request_ack,
140 offset+21, 1, rxh->flags);
141 proto_tree_add_item(rx_tree_flags, hf_rx_flags_clientinit,
142 offset+21, 1, rxh->flags);
144 proto_tree_add_item(rx_tree, hf_rx_userstatus,
145 offset+22, 1, rxh->userStatus);
146 proto_tree_add_item(rx_tree, hf_rx_securityindex,
147 offset+23, 1, rxh->securityIndex);
148 proto_tree_add_item(rx_tree, hf_rx_spare,
149 offset+24, 2, ntohs(rxh->spare));
150 proto_tree_add_item(rx_tree, hf_rx_serviceid,
151 offset+26, 2, ntohs(rxh->serviceId));
154 if (check_col(fd, COL_INFO))
155 col_add_fstr(fd, COL_INFO,
160 "Destination Port: %s ",
161 val_to_str(rxh->type, rx_types, "%d"),
162 (unsigned long)ntohl(rxh->seq),
163 (unsigned long)ntohl(rxh->callNumber),
164 get_udp_port(pi.srcport),
165 get_udp_port(pi.destport)
168 reply = (rxh->flags & RX_CLIENT_INITIATED) == 0;
169 if ( (rxh->type == RX_PACKET_TYPE_ABORT && reply) ||
170 rxh->type == RX_PACKET_TYPE_DATA )
172 dissect_afs(pd,offset,fd,tree);
177 proto_register_rx(void)
179 static hf_register_info hf[] = {
181 "Epoch", "rx.epoch", FT_UINT32, BASE_DEC,
184 "CID", "rx.cid", FT_UINT32, BASE_DEC,
186 { &hf_rx_callnumber, {
187 "Call Number", "rx.callnumber", FT_UINT32, BASE_DEC,
188 NULL, 0, "Call Number" }},
190 "Sequence Number", "rx.seq", FT_UINT32, BASE_DEC,
191 NULL, 0, "Sequence Number" }},
193 "Serial", "rx.serial", FT_UINT32, BASE_DEC,
194 NULL, 0, "Serial" }},
196 "Type", "rx.type", FT_UINT8, BASE_DEC,
197 VALS(rx_types), 0, "Type" }},
199 "Flags", "rx.flags", FT_UINT8, BASE_HEX,
201 { &hf_rx_flags_clientinit, {
202 "Client Initiated", "rx.flags.client_init", FT_UINT8, BASE_BIN,
203 NULL, RX_CLIENT_INITIATED, "Client Initiated" }},
204 { &hf_rx_flags_request_ack, {
205 "Request Ack", "rx.flags.request_ack", FT_UINT8, BASE_BIN,
206 NULL, RX_REQUEST_ACK, "Request Ack" }},
207 { &hf_rx_flags_last_packet, {
208 "Last Packet", "rx.flags.last_packet", FT_UINT8, BASE_BIN,
209 NULL, RX_LAST_PACKET, "Last Packet" }},
210 { &hf_rx_flags_more_packets, {
211 "More Packets", "rx.flags.more_packets", FT_UINT8, BASE_BIN,
212 NULL, RX_MORE_PACKETS, "More Packets" }},
213 { &hf_rx_flags_free_packet, {
214 "Free Packet", "rx.flags.free_packet", FT_UINT8, BASE_BIN,
215 NULL, RX_FREE_PACKET, "Free Packet" }},
216 { &hf_rx_userstatus, {
217 "User Status", "rx.userstatus", FT_UINT32, BASE_DEC,
218 NULL, 0, "User Status" }},
219 { &hf_rx_securityindex, {
220 "Security Index", "rx.securityindex", FT_UINT32, BASE_DEC,
221 NULL, 0, "Security Index" }},
223 "Spare/Checksum", "rx.spare", FT_UINT16, BASE_DEC,
224 NULL, 0, "Spare/Checksum" }},
225 { &hf_rx_serviceid, {
226 "Service ID", "rx.serviceid", FT_UINT16, BASE_DEC,
227 NULL, 0, "Service ID" }},
229 static gint *ett[] = {
234 proto_rx = proto_register_protocol("RX Protocol", "rx");
235 proto_register_field_array(proto_rx, hf, array_length(hf));
236 proto_register_subtree_array(ett, array_length(ett));