diff options
-rw-r--r-- | file.c | 11 | ||||
-rw-r--r-- | packet-atalk.c | 62 | ||||
-rw-r--r-- | packet-atalk.h | 34 | ||||
-rw-r--r-- | packet.h | 5 |
4 files changed, 93 insertions, 19 deletions
@@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.110 1999/10/22 07:17:28 guy Exp $ + * $Id: file.c,v 1.111 1999/10/22 08:11:39 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -89,6 +89,8 @@ #include "resolv.h" #endif +#include "packet-atalk.h" + #include "packet-ipv6.h" #include "packet-ncp.h" @@ -587,6 +589,7 @@ col_set_addr(frame_data *fd, int col, address *addr, gboolean is_res) { u_int ipv4_addr; struct e_in6_addr ipv6_addr; + struct atalk_ddp_addr ddp_addr; switch (addr->type) { @@ -632,6 +635,12 @@ col_set_addr(frame_data *fd, int col, address *addr, gboolean is_res) } break; + case AT_ATALK: + memcpy(&ddp_addr, addr->data, sizeof ddp_addr); + strncpy(fd->cinfo->col_data[col], atalk_addr_to_str(&ddp_addr), + COL_MAX_LEN); + break; + default: break; } diff --git a/packet-atalk.c b/packet-atalk.c index 28802df5bf..4f190c6dba 100644 --- a/packet-atalk.c +++ b/packet-atalk.c @@ -1,7 +1,7 @@ -/* packet-ddp.c - * Routines for DDP packet disassembly. +/* packet-atalk.c + * Routines for Appletalk packet disassembly (DDP, currently). * - * $Id: packet-atalk.c,v 1.15 1999/10/12 06:20:02 gram Exp $ + * $Id: packet-atalk.c,v 1.16 1999/10/22 08:11:40 guy Exp $ * * Simon Wilkinson <sxw@dcs.ed.ac.uk> * @@ -31,6 +31,7 @@ #include <glib.h> #include "globals.h" #include "packet.h" +#include "packet-atalk.h" #ifdef HAVE_NETINET_IN_H # include <netinet/in.h> @@ -75,19 +76,41 @@ typedef struct _e_ddp { #define DDP_ADSP 0x07 #define DDP_HEADER_SIZE 13 +extern gchar * +atalk_addr_to_str(const struct atalk_ddp_addr *addrp) +{ + static gchar str[3][22]; + static gchar *cur; + + if (cur == &str[0][0]) { + cur = &str[1][0]; + } else if (cur == &str[1][0]) { + cur = &str[2][0]; + } else { + cur = &str[0][0]; + } + + sprintf(cur, "%d.%d:%d", addrp->net, addrp->node, addrp->port); + return cur; +} + +static const value_string op_vals[] = { + {DDP_RTMPDATA, "AppleTalk Routing Table response or data" }, + {DDP_NBP, "AppleTalk Name Binding Protocol packet"}, + {DDP_ATP, "AppleTalk Transaction Protocol packet"}, + {DDP_AEP, "AppleTalk Echo Protocol packet"}, + {DDP_RTMPREQ, "AppleTalk Routing Table request"}, + {DDP_ZIP, "AppleTalk Zone Information Protocol packet"}, + {DDP_ADSP, "AppleTalk Data Stream Protocol"}, + {0, NULL} +}; + void dissect_ddp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { e_ddp ddp; proto_tree *ddp_tree; proto_item *ti; - value_string op_vals[] = { {DDP_RTMPDATA, "AppleTalk Routing Table response or data" }, - {DDP_NBP, "AppleTalk Name Binding Protocol packet"}, - {DDP_ATP, "AppleTalk Transaction Protocol packet"}, - {DDP_AEP, "AppleTalk Echo Protocol packet"}, - {DDP_RTMPREQ, "AppleTalk Routing Table request"}, - {DDP_ZIP, "AppleTalk Zone Information Protocol packet"}, - {DDP_ADSP, "AppleTalk Data Stream Protocol"}, - {0, NULL} }; + static struct atalk_ddp_addr src, dst; if (!BYTES_ARE_IN_FRAME(offset, DDP_HEADER_SIZE)) { dissect_data(pd, offset, fd, tree); @@ -99,10 +122,17 @@ dissect_ddp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { ddp.snet=ntohs(ddp.snet); ddp.sum=ntohs(ddp.sum); - if (check_col(fd, COL_RES_NET_SRC)) - col_add_fstr(fd, COL_RES_NET_SRC, "%d.%d:%d", ddp.snet, ddp.snode, ddp.sport); - if (check_col(fd, COL_RES_NET_DST)) - col_add_fstr(fd, COL_RES_NET_DST, "%d.%d:%d", ddp.dnet, ddp.dnode, ddp.dport); + src.net = ddp.snet; + src.node = ddp.snode; + src.port = ddp.sport; + dst.net = ddp.dnet; + dst.node = ddp.dnode; + dst.port = ddp.dport; + SET_ADDRESS(&pi.net_src, AT_ATALK, sizeof src, (guint8 *)&src); + SET_ADDRESS(&pi.src, AT_ATALK, sizeof src, (guint8 *)&src); + SET_ADDRESS(&pi.net_dst, AT_ATALK, sizeof dst, (guint8 *)&dst); + SET_ADDRESS(&pi.dst, AT_ATALK, sizeof dst, (guint8 *)&dst); + if (check_col(fd, COL_PROTOCOL)) col_add_str(fd, COL_PROTOCOL, "DDP"); if (check_col(fd, COL_INFO)) @@ -171,7 +201,7 @@ proto_register_atalk(void) "" }}, { &hf_ddp_type, - { "Protocol type", "ddp.type", FT_UINT8, BASE_DEC, NULL, 0x0, + { "Protocol type", "ddp.type", FT_UINT8, BASE_DEC, VALS(op_vals), 0x0, "" }}, }; diff --git a/packet-atalk.h b/packet-atalk.h new file mode 100644 index 0000000000..c57a1ea6ef --- /dev/null +++ b/packet-atalk.h @@ -0,0 +1,34 @@ +/* packet-atalk.h + * Definitions for Appletalk packet disassembly (DDP, currently). + * + * $Id: packet-atalk.h,v 1.1 1999/10/22 08:11:40 guy Exp $ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* + * Structure used to represent a DDP address; gives the layout of the + * data pointed to by an AT_ATALK "address" structure. + */ +struct atalk_ddp_addr { + guint16 net; + guint8 node; + guint8 port; +}; + +/* + * Routine to take a DDP address and generate a string. + */ +extern gchar *atalk_addr_to_str(const struct atalk_ddp_addr *addrp); @@ -1,7 +1,7 @@ /* packet.h * Definitions for packet disassembly structures and routines * - * $Id: packet.h,v 1.117 1999/10/22 07:17:47 guy Exp $ + * $Id: packet.h,v 1.118 1999/10/22 08:11:40 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -138,7 +138,8 @@ typedef enum { AT_IPv4, /* IPv4 */ AT_IPv6, /* IPv6 */ AT_IPX, /* IPX */ - AT_SNA /* SNA */ + AT_SNA, /* SNA */ + AT_ATALK /* Appletalk */ } address_type; typedef struct _address { |