diff options
-rw-r--r-- | packet-vines.c | 189 | ||||
-rw-r--r-- | packet-vines.h | 8 |
2 files changed, 125 insertions, 72 deletions
diff --git a/packet-vines.c b/packet-vines.c index 23889a993f..278c2a64dd 100644 --- a/packet-vines.c +++ b/packet-vines.c @@ -1,7 +1,7 @@ /* packet-vines.c * Routines for Banyan VINES protocol packet disassembly * - * $Id: packet-vines.c,v 1.17 2000/08/07 03:21:18 guy Exp $ + * $Id: packet-vines.c,v 1.18 2000/08/25 18:46:10 deniel Exp $ * * Don Lafontaine <lafont02@cn.ca> * @@ -26,7 +26,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> @@ -43,6 +45,9 @@ #include "packet-vines.h" #include "packet-ip.h" +static int proto_vines = -1; +static int hf_vines_protocol = -1; + static gint ett_vines = -1; static gint ett_vines_frp = -1; static gint ett_vines_spp = -1; @@ -74,7 +79,7 @@ dissect_vines_frp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree gchar frp_flags_str[32]; /* To do: Check for {cap len,pkt len} < struct len */ - /* Avoids alignment problems on many architectures. */ + vines_frp_ctrl = pd[offset]; vines_frp_seqno = pd[offset+1]; @@ -104,10 +109,14 @@ dissect_vines_frp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree } if (tree) { - ti = proto_tree_add_text(tree, NullTVB, offset, 2, "Vines Fragmentation Protocol"); + ti = proto_tree_add_text(tree, NullTVB, offset, 2, + "Vines Fragmentation Protocol"); vines_frp_tree = proto_item_add_subtree(ti, ett_vines_frp); - proto_tree_add_text(vines_frp_tree, NullTVB, offset, 1, "Control Flags: 0x%02x = %s fragment", vines_frp_ctrl, frp_flags_str); - proto_tree_add_text(vines_frp_tree, NullTVB, offset + 1, 1, "Sequence Number: 0x%02x", vines_frp_seqno); + proto_tree_add_text(vines_frp_tree, NullTVB, offset, 1, + "Control Flags: 0x%02x = %s fragment", + vines_frp_ctrl, frp_flags_str); + proto_tree_add_text(vines_frp_tree, NullTVB, offset + 1, 1, + "Sequence Number: 0x%02x", vines_frp_seqno); } /* Skip over header */ @@ -136,8 +145,7 @@ vines_addr_to_str(const guint8 *addrp) } static void -dissect_vines(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) - { +dissect_vines(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { e_vip viph; proto_tree *vip_tree; proto_item *ti; @@ -145,8 +153,11 @@ dissect_vines(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) int is_broadcast = 0; int hops = 0; - /* To do: check for runts, errs, etc. */ - /* Avoids alignment problems on many architectures. */ + OLD_CHECK_DISPLAY_AS_DATA(proto_vines, pd, offset, fd, tree); + + /* To do: check for runts, errs, etc. */ + + /* Avoids alignment problems on many architectures. */ memcpy(&viph, &pd[offset], sizeof(e_vip)); viph.vip_chksum = pntohs(&pd[offset]); @@ -191,13 +202,14 @@ dissect_vines(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) if (check_col(fd, COL_PROTOCOL)) col_add_str(fd, COL_PROTOCOL, "Vines IP"); if (check_col(fd, COL_INFO)) - col_add_fstr(fd, COL_INFO, "Unknown VIP protocol (%02x)", viph.vip_proto); + col_add_fstr(fd, COL_INFO, "Unknown VIP protocol (%02x)", + viph.vip_proto); } - SET_ADDRESS(&pi.net_src, AT_VINES, 6, &pd[offset+12]); - SET_ADDRESS(&pi.src, AT_VINES, 6, &pd[offset+12]); - SET_ADDRESS(&pi.net_dst, AT_VINES, 6, &pd[offset+6]); - SET_ADDRESS(&pi.dst, AT_VINES, 6, &pd[offset+6]); + SET_ADDRESS(&pi.net_src, AT_VINES, VINES_ADDR_LEN, &pd[offset+12]); + SET_ADDRESS(&pi.src, AT_VINES, VINES_ADDR_LEN, &pd[offset+12]); + SET_ADDRESS(&pi.net_dst, AT_VINES, VINES_ADDR_LEN, &pd[offset+6]); + SET_ADDRESS(&pi.dst, AT_VINES, VINES_ADDR_LEN, &pd[offset+6]); /* helpers to decode flags */ /* FIXME: Not used yet */ @@ -206,10 +218,9 @@ dissect_vines(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) } hops = viph.vip_tctl & 0xf; - /* + /* viph.ip_tos = IPTOS_TOS(viph.ip_tos); - switch (viph.ip_tos) - { + switch (viph.ip_tos) { case IPTOS_NONE: strcpy(tos_str, "None"); break; @@ -228,41 +239,57 @@ dissect_vines(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) default: strcpy(tos_str, "Unknon. Malformed?"); break; - } - */ - if (tree) - { - ti = proto_tree_add_text(tree, NullTVB, offset, (viph.vip_pktlen), "Vines IP"); - vip_tree = proto_item_add_subtree(ti, ett_vines); - proto_tree_add_text(vip_tree, NullTVB, offset, 2, "Packet checksum: 0x%04x", viph.vip_chksum); - proto_tree_add_text(vip_tree, NullTVB, offset + 2, 2, "Packet length: 0x%04x (%d)", viph.vip_pktlen, viph.vip_pktlen); - proto_tree_add_text(vip_tree, NullTVB, offset + 4, 1, "Transport control: 0x%02x", - viph.vip_tctl); - proto_tree_add_text(vip_tree, NullTVB, offset + 5, 1, "Protocol: 0x%02x", viph.vip_proto); - } + } + */ + if (tree) { + ti = proto_tree_add_protocol_format(tree, proto_vines, NullTVB, + offset, (viph.vip_pktlen), + "Vines IP"); + vip_tree = proto_item_add_subtree(ti, ett_vines); + proto_tree_add_text(vip_tree, NullTVB, offset, 2, + "Packet checksum: 0x%04x", + viph.vip_chksum); + proto_tree_add_text(vip_tree, NullTVB, offset + 2, 2, + "Packet length: 0x%04x (%d)", + viph.vip_pktlen, viph.vip_pktlen); + proto_tree_add_text(vip_tree, NullTVB, offset + 4, 1, + "Transport control: 0x%02x", + viph.vip_tctl); + proto_tree_add_uint(vip_tree, hf_vines_protocol, NullTVB, + offset + 5, 1, + viph.vip_proto); + proto_tree_add_text(vip_tree, NullTVB, offset + 6, + VINES_ADDR_LEN, + "Destination: %s", + vines_addr_to_str(&pd[offset + 6])); + proto_tree_add_text(vip_tree, NullTVB, offset + 12, + VINES_ADDR_LEN, + "Source: %s", + vines_addr_to_str(&pd[offset + 12])); + + } offset += 18; - switch (viph.vip_proto) - { + switch (viph.vip_proto) { case VIP_PROTO_SPP: dissect_vines_spp(pd, offset, fd, tree); break; default: old_dissect_data(pd, offset, fd, tree); break; - } } -#define VINES_VSPP_DATA 1 -#define VINES_VSPP_ACK 5 -void dissect_vines_spp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) - { - e_vspp viph; +} + +void dissect_vines_spp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { + + e_vspp viph; proto_tree *vspp_tree; proto_item *ti; - /* To do: check for runts, errs, etc. */ - /* Avoids alignment problems on many architectures. */ + /* To do: check for runts, errs, etc. */ + + /* Avoids alignment problems on many architectures. */ memcpy(&viph, &pd[offset], sizeof(e_vspp)); viph.vspp_sport = ntohs(viph.vspp_sport); @@ -270,36 +297,38 @@ void dissect_vines_spp(const u_char *pd, int offset, frame_data *fd, proto_tree viph.vspp_lclid = ntohs(viph.vspp_lclid); viph.vspp_rmtid = ntohs(viph.vspp_rmtid); - switch (viph.vspp_pkttype) - { + switch (viph.vspp_pkttype) { case VSPP_PKTTYPE_DATA: - if (check_col(fd, COL_PROTOCOL)) + if (check_col(fd, COL_PROTOCOL)) col_add_str(fd, COL_PROTOCOL, "VSPP Data"); break; case VSPP_PKTTYPE_DISC: - if (check_col(fd, COL_PROTOCOL)) + if (check_col(fd, COL_PROTOCOL)) col_add_str(fd, COL_PROTOCOL, "VSPP Disconnect"); break; case VSPP_PKTTYPE_PROBE: - if (check_col(fd, COL_PROTOCOL)) + if (check_col(fd, COL_PROTOCOL)) col_add_str(fd, COL_PROTOCOL, "VSPP Probe"); break; case VSPP_PKTTYPE_ACK: - if (check_col(fd, COL_PROTOCOL)) + if (check_col(fd, COL_PROTOCOL)) col_add_str(fd, COL_PROTOCOL, "VSPP Ack"); break; default: - if (check_col(fd, COL_PROTOCOL)) + if (check_col(fd, COL_PROTOCOL)) col_add_str(fd, COL_PROTOCOL, "VSPP Unknown"); } + if (check_col(fd, COL_INFO)) - col_add_fstr(fd, COL_INFO, "NS=%04x NR=%04x Window=%04x RID=%04x LID=%04x D=%04x S=%04x", - viph.vspp_seqno, viph.vspp_ack, viph.vspp_win, viph.vspp_rmtid, - viph.vspp_lclid, viph.vspp_dport, viph.vspp_sport); - /* + col_add_fstr(fd, COL_INFO, + "NS=%04x NR=%04x Window=%04x RID=%04x LID=%04x D=%04x S=%04x", + viph.vspp_seqno, viph.vspp_ack, viph.vspp_win, + viph.vspp_rmtid, viph.vspp_lclid, viph.vspp_dport, + viph.vspp_sport); + + /* iph.ip_tos = IPTOS_TOS(iph.ip_tos); - switch (iph.ip_tos) - { + switch (iph.ip_tos) { case IPTOS_NONE: strcpy(tos_str, "None"); break; @@ -318,25 +347,38 @@ void dissect_vines_spp(const u_char *pd, int offset, frame_data *fd, proto_tree default: strcpy(tos_str, "Unknon. Malformed?"); break; - } -*/ - if (tree) - { - ti = proto_tree_add_text(tree, NullTVB, offset, sizeof(viph), "Vines SPP"); - vspp_tree = proto_item_add_subtree(ti, ett_vines_spp); - proto_tree_add_text(vspp_tree, NullTVB, offset, 2, "Source port: 0x%04x", viph.vspp_sport); - proto_tree_add_text(vspp_tree, NullTVB, offset+2, 2, "Destination port: 0x%04x", viph.vspp_dport); - proto_tree_add_text(vspp_tree, NullTVB, offset+4, 1, "Packet type: 0x%02x", viph.vspp_pkttype); - proto_tree_add_text(vspp_tree, NullTVB, offset+5, 1, "Control: 0x%02x", viph.vspp_control); - proto_tree_add_text(vspp_tree, NullTVB, offset+6, 2, "Local Connection ID: 0x%04x", viph.vspp_lclid); - proto_tree_add_text(vspp_tree, NullTVB, offset+8, 2, "Remote Connection ID: 0x%04x", viph.vspp_rmtid); - proto_tree_add_text(vspp_tree, NullTVB, offset+10, 2, "Sequence number: 0x%04x", viph.vspp_seqno); - proto_tree_add_text(vspp_tree, NullTVB, offset+12, 2, "Ack number: 0x%04x", viph.vspp_ack); - proto_tree_add_text(vspp_tree, NullTVB, offset+14, 2, "Window: 0x%04x", viph.vspp_win); - } + } + */ + + if (tree) { + ti = proto_tree_add_text(tree, NullTVB, offset, sizeof(viph), "Vines SPP"); + vspp_tree = proto_item_add_subtree(ti, ett_vines_spp); + proto_tree_add_text(vspp_tree, NullTVB, offset, 2, + "Source port: 0x%04x", viph.vspp_sport); + proto_tree_add_text(vspp_tree, NullTVB, offset+2, 2, + "Destination port: 0x%04x", + viph.vspp_dport); + proto_tree_add_text(vspp_tree, NullTVB, offset+4, 1, + "Packet type: 0x%02x", viph.vspp_pkttype); + proto_tree_add_text(vspp_tree, NullTVB, offset+5, 1, + "Control: 0x%02x", viph.vspp_control); + proto_tree_add_text(vspp_tree, NullTVB, offset+6, 2, + "Local Connection ID: 0x%04x", + viph.vspp_lclid); + proto_tree_add_text(vspp_tree, NullTVB, offset+8, 2, + "Remote Connection ID: 0x%04x", + viph.vspp_rmtid); + proto_tree_add_text(vspp_tree, NullTVB, offset+10, 2, + "Sequence number: 0x%04x", + viph.vspp_seqno); + proto_tree_add_text(vspp_tree, NullTVB, offset+12, 2, + "Ack number: 0x%04x", viph.vspp_ack); + proto_tree_add_text(vspp_tree, NullTVB, offset+14, 2, + "Window: 0x%04x", viph.vspp_win); + } offset += 16; /* sizeof SPP */ old_dissect_data(pd, offset, fd, tree); - } +} void proto_register_vines(void) @@ -347,6 +389,15 @@ proto_register_vines(void) &ett_vines_spp, }; + static hf_register_info hf[] = { + { &hf_vines_protocol, + { "Protocol", "vines.protocol", + FT_UINT8, BASE_HEX, NULL, 0x0, + "Vines protocol" }} + }; + + proto_vines = proto_register_protocol("Banyan Vines", "vines"); + proto_register_field_array(proto_vines, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } diff --git a/packet-vines.h b/packet-vines.h index ec0fb9c88a..504cbac4b9 100644 --- a/packet-vines.h +++ b/packet-vines.h @@ -1,7 +1,7 @@ /* packet-vines.h * Definitions for packet disassembly structures and routines * - * $Id: packet-vines.h,v 1.5 2000/04/16 21:37:07 guy Exp $ + * $Id: packet-vines.h,v 1.6 2000/08/25 18:46:11 deniel Exp $ * * Don Lafontaine <lafont02@cn.ca> * @@ -38,8 +38,7 @@ #ifndef __PACKETVINES_H__ #define __PACKETVINES_H__ -void capture_vines(const u_char *, int, packet_counts *); -void dissect_vines_frp(const u_char *, int, frame_data *, proto_tree *); +#define VINES_ADDR_LEN 6 /* VINES IP structs and definitions */ @@ -108,6 +107,9 @@ typedef struct _e_vsmb { guint32 vsmb_ttw; } e_vsmb; +void capture_vines(const u_char *, int, packet_counts *); +void dissect_vines_frp(const u_char *, int, frame_data *, proto_tree *); + /* * Routine to take a Vines address and generate a string. */ |