diff options
Diffstat (limited to 'packet-udp.c')
-rw-r--r-- | packet-udp.c | 77 |
1 files changed, 42 insertions, 35 deletions
diff --git a/packet-udp.c b/packet-udp.c index 2ccf2f175c..cd39e75914 100644 --- a/packet-udp.c +++ b/packet-udp.c @@ -1,7 +1,7 @@ /* packet-udp.c * Routines for UDP packet disassembly * - * $Id: packet-udp.c,v 1.77 2000/11/05 09:26:47 oabad Exp $ + * $Id: packet-udp.c,v 1.78 2000/11/18 10:38:25 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -82,14 +82,20 @@ static heur_dissector_list_t heur_subdissector_list; /* can call to it, ie. socks */ void -decode_udp_ports(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, - int uh_sport, int uh_dport) +decode_udp_ports(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *tree, int uh_sport, int uh_dport) { + tvbuff_t *next_tvb; + const u_char *next_pd; + int next_offset; + + next_tvb = tvb_new_subset(tvb, offset, -1, -1); + /* determine if this packet is part of a conversation and call dissector */ /* for the conversation if available */ - if (old_try_conversation_dissector(&pi.src, &pi.dst, PT_UDP, - uh_sport, uh_dport, pd, offset, fd, tree)) + if (try_conversation_dissector(&pinfo->src, &pinfo->dst, PT_UDP, + uh_sport, uh_dport, next_tvb, pinfo, tree)) return; /* try to apply the plugins */ @@ -98,10 +104,11 @@ decode_udp_ports(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, plugin *pt_plug = plugin_list; if (enabled_plugins_number > 0) { + tvb_compat(next_tvb, &next_pd, &next_offset); while (pt_plug) { if (pt_plug->enabled && strstr(pt_plug->protocol, "udp") && - tree && dfilter_apply(pt_plug->filter, tree, pd, fd->cap_len)) { - pt_plug->dissector(pd, offset, fd, tree); + tree && dfilter_apply(pt_plug->filter, tree, next_pd, pinfo->fd->cap_len)) { + pt_plug->dissector(next_pd, next_offset, pinfo->fd, tree); return; } pt_plug = pt_plug->next; @@ -111,77 +118,77 @@ decode_udp_ports(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, #endif /* do lookup with the subdissector table */ - if (old_dissector_try_port(udp_dissector_table, uh_sport, pd, offset, fd, tree) || - old_dissector_try_port(udp_dissector_table, uh_dport, pd, offset, fd, tree)) + if (dissector_try_port(udp_dissector_table, uh_sport, next_tvb, pinfo, tree) || + dissector_try_port(udp_dissector_table, uh_dport, next_tvb, pinfo, tree)) return; /* do lookup with the heuristic subdissector table */ - if (old_dissector_try_heuristic(heur_subdissector_list, pd, offset, fd, tree)) + if (dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, tree)) return; /* XXX - we should do these with the subdissector table as well. */ #define PORT_IS(port) (uh_sport == port || uh_dport == port) if (PORT_IS(UDP_PORT_VINES)) { /* FIXME: AFAIK, src and dst port must be the same */ - dissect_vines_frp(pd, offset, fd, tree); + tvb_compat(next_tvb, &next_pd, &next_offset); + dissect_vines_frp(next_pd, next_offset, pinfo->fd, tree); } else - old_dissect_data(pd, offset, fd, tree); + dissect_data(next_tvb, 0, pinfo, tree); } static void -dissect_udp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { +dissect_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ e_udphdr uh; guint16 uh_sport, uh_dport, uh_ulen, uh_sum; proto_tree *udp_tree; proto_item *ti; + int offset = 0; - OLD_CHECK_DISPLAY_AS_DATA(proto_udp, pd, offset, fd, tree); + CHECK_DISPLAY_AS_DATA(proto_udp, tvb, pinfo, tree); - if (!BYTES_ARE_IN_FRAME(offset, sizeof(e_udphdr))) { - old_dissect_data(pd, offset, fd, tree); - return; - } + pinfo->current_proto = "UDP"; /* Avoids alignment problems on many architectures. */ - memcpy(&uh, &pd[offset], sizeof(e_udphdr)); + tvb_memcpy(tvb, (guint8 *)&uh, offset, sizeof(e_udphdr)); uh_sport = ntohs(uh.uh_sport); uh_dport = ntohs(uh.uh_dport); uh_ulen = ntohs(uh.uh_ulen); uh_sum = ntohs(uh.uh_sum); - if (check_col(fd, COL_PROTOCOL)) - col_add_str(fd, COL_PROTOCOL, "UDP"); - if (check_col(fd, COL_INFO)) - col_add_fstr(fd, COL_INFO, "Source port: %s Destination port: %s", + if (check_col(pinfo->fd, COL_PROTOCOL)) + col_add_str(pinfo->fd, COL_PROTOCOL, "UDP"); + if (check_col(pinfo->fd, COL_INFO)) + col_add_fstr(pinfo->fd, COL_INFO, "Source port: %s Destination port: %s", get_udp_port(uh_sport), get_udp_port(uh_dport)); if (tree) { - ti = proto_tree_add_item(tree, proto_udp, NullTVB, offset, 8, FALSE); + ti = proto_tree_add_item(tree, proto_udp, tvb, offset, 8, FALSE); udp_tree = proto_item_add_subtree(ti, ett_udp); - proto_tree_add_uint_format(udp_tree, hf_udp_srcport, NullTVB, offset, 2, uh_sport, + proto_tree_add_uint_format(udp_tree, hf_udp_srcport, tvb, offset, 2, uh_sport, "Source port: %s (%u)", get_udp_port(uh_sport), uh_sport); - proto_tree_add_uint_format(udp_tree, hf_udp_dstport, NullTVB, offset + 2, 2, uh_dport, + proto_tree_add_uint_format(udp_tree, hf_udp_dstport, tvb, offset + 2, 2, uh_dport, "Destination port: %s (%u)", get_udp_port(uh_dport), uh_dport); - proto_tree_add_uint_hidden(udp_tree, hf_udp_port, NullTVB, offset, 2, uh_sport); - proto_tree_add_uint_hidden(udp_tree, hf_udp_port, NullTVB, offset+2, 2, uh_dport); + proto_tree_add_uint_hidden(udp_tree, hf_udp_port, tvb, offset, 2, uh_sport); + proto_tree_add_uint_hidden(udp_tree, hf_udp_port, tvb, offset+2, 2, uh_dport); - proto_tree_add_uint(udp_tree, hf_udp_length, NullTVB, offset + 4, 2, uh_ulen); - proto_tree_add_uint_format(udp_tree, hf_udp_checksum, NullTVB, offset + 6, 2, uh_sum, + proto_tree_add_uint(udp_tree, hf_udp_length, tvb, offset + 4, 2, uh_ulen); + proto_tree_add_uint_format(udp_tree, hf_udp_checksum, tvb, offset + 6, 2, uh_sum, "Checksum: 0x%04x", uh_sum); } /* Skip over header */ offset += 8; - pi.ptype = PT_UDP; - pi.srcport = uh_sport; - pi.destport = uh_dport; + pinfo->ptype = PT_UDP; + pinfo->srcport = uh_sport; + pinfo->destport = uh_dport; /* call sub-dissectors */ - decode_udp_ports( pd, offset, fd, tree, uh_sport, uh_dport); + decode_udp_ports( tvb, offset, pinfo, tree, uh_sport, uh_dport); } @@ -225,5 +232,5 @@ proto_register_udp(void) void proto_reg_handoff_udp(void) { - old_dissector_add("ip.proto", IP_PROTO_UDP, dissect_udp); + dissector_add("ip.proto", IP_PROTO_UDP, dissect_udp); } |