2 * Routines for DDP packet disassembly.
4 * Simon Wilkinson <sxw@dcs.ed.ac.uk>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #ifdef HAVE_SYS_TYPES_H
26 # include <sys/types.h>
32 #ifdef HAVE_NETINET_IN_H
33 # include <netinet/in.h>
36 static int proto_ddp = -1;
38 /* P = Padding, H = Hops, L = Len */
39 #if BYTE_ORDER == BIG_ENDIAN
40 /* PPHHHHLL LLLLLLLL */
41 #define ddp_hops(x) ( ( x >> 10) & 0x3C )
42 #define ddp_len(x) ( x & 0x03ff )
44 /* LLLLLLLL PPHHHHLL*/
45 #define ddp_hops(x) ( x & 0x3C )
46 #define ddp_len(x) ( ntohs(x) & 0x03ff )
48 typedef struct _e_ddp {
49 guint16 hops_len; /* combines pad, hops, and len */
50 guint16 sum,dnet,snet;
56 #define DDP_RTMPDATA 0x01
60 #define DDP_RTMPREQ 0x05
65 dissect_ddp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
69 value_string op_vals[] = { {DDP_RTMPDATA, "AppleTalk Routing Table response or data" },
70 {DDP_NBP, "AppleTalk Name Binding Protocol packet"},
71 {DDP_ATP, "AppleTalk Transaction Protocol packet"},
72 {DDP_AEP, "AppleTalk Echo Protocol packet"},
73 {DDP_RTMPREQ, "AppleTalk Routing Table request"},
74 {DDP_ZIP, "AppleTalk Zone Information Protocol packet"},
75 {DDP_ADSP, "AppleTalk Data Stream Protocol"},
78 memcpy(&ddp, &pd[offset], sizeof(e_ddp));
79 ddp.dnet=ntohs(ddp.dnet);
80 ddp.snet=ntohs(ddp.snet);
81 ddp.sum=ntohs(ddp.sum);
83 if (check_col(fd, COL_RES_NET_SRC))
84 col_add_fstr(fd, COL_RES_NET_SRC, "%d.%d:%d", ddp.snet, ddp.snode, ddp.sport);
85 if (check_col(fd, COL_RES_NET_DST))
86 col_add_fstr(fd, COL_RES_NET_DST, "%d.%d:%d", ddp.dnet, ddp.dnode, ddp.dport);
87 if (check_col(fd, COL_PROTOCOL))
88 col_add_str(fd, COL_PROTOCOL, "DDP");
89 if (check_col(fd, COL_INFO))
90 col_add_str(fd, COL_INFO,
91 val_to_str(ddp.type, op_vals, "Unknown DDP protocol (%02x)"));
94 ti = proto_tree_add_item(tree, proto_ddp, offset, 13, NULL);
95 ddp_tree = proto_item_add_subtree(ti, ETT_IP);
96 proto_tree_add_text(ddp_tree, offset, 1, "Hop count: %d", ddp_hops(ddp.hops_len));
97 proto_tree_add_text(ddp_tree, offset, 2, "Datagram length: %d", ddp_len(ddp.hops_len));
98 proto_tree_add_text(ddp_tree, offset + 2, 2, "Checksum: %d",ddp.sum);
99 proto_tree_add_text(ddp_tree, offset + 4, 2, "Destination Net: %d",ddp.dnet);
100 proto_tree_add_text(ddp_tree, offset + 6, 2, "Source Net: %d",ddp.snet);
101 proto_tree_add_text(ddp_tree, offset + 8, 1, "Destination Node: %d",ddp.dnode);
102 proto_tree_add_text(ddp_tree, offset + 9, 1, "Source Node: %d",ddp.snode);
103 proto_tree_add_text(ddp_tree, offset + 10, 1, "Destination Socket: %d",ddp.dport);
104 proto_tree_add_text(ddp_tree, offset + 11, 1, "Source Socket: %d",ddp.sport);
105 proto_tree_add_text(ddp_tree, offset + 12, 1, "Type: %d",ddp.type);
113 proto_register_atalk(void)
115 /* static hf_register_info hf[] = {
117 { "Name", "ddp.abbreviation", TYPE, VALS_POINTER }},
120 proto_ddp = proto_register_protocol("Datagram Delivery Protocol", "ddp");
121 /* proto_register_field_array(proto_ddp, hf, array_length(hf));*/