From 25c4bc9379996f934e7648f2ab8b8db3857439f6 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 11 Sep 2005 21:25:37 +0000 Subject: Replace tvb_memcpy() calls that extract IPv4 addresses into a guint32, and that extract IPv6 addresses into a "struct e_in6_addr", with tvb_get_ipv4() and tvb_get_ipv6() calls - except for some that we remove, by using proto_tree_add_item(), rather than replacing. Have epan/tvbuff.h include epan/ipv6-utils.h, to define "struct e_in6_addr" (not necessary to declare the tvbuff routines, but including it there means "struct e_in6_addr" is guaranteed to be defined before those declarations, so we don't get compiler complaints if we define it *after* those declarations). svn path=/trunk/; revision=15758 --- asn1/h225/h225.cnf | 2 +- asn1/h245/h245.cnf | 6 ++--- epan/addr_and_mask.c | 1 - epan/dissectors/packet-aodv.c | 25 +++++++++--------- epan/dissectors/packet-arp.c | 4 +-- epan/dissectors/packet-auto_rp.c | 4 +-- epan/dissectors/packet-bgp.c | 6 ++--- epan/dissectors/packet-bootp.c | 2 +- epan/dissectors/packet-cdp.c | 4 +-- epan/dissectors/packet-chdlc.c | 2 +- epan/dissectors/packet-cops.c | 13 +++++----- epan/dissectors/packet-dhcpv6.c | 27 ++++++++++---------- epan/dissectors/packet-dns.c | 1 - epan/dissectors/packet-gsm_a.c | 9 +++---- epan/dissectors/packet-gtp.c | 44 +++++++++++++++---------------- epan/dissectors/packet-h225.c | 2 +- epan/dissectors/packet-h245.c | 6 ++--- epan/dissectors/packet-h245.h | 2 +- epan/dissectors/packet-icmpv6.c | 10 ++++---- epan/dissectors/packet-igmp.c | 2 +- epan/dissectors/packet-ip.c | 6 ++--- epan/dissectors/packet-isakmp.c | 5 ++-- epan/dissectors/packet-isis-lsp.c | 2 +- epan/dissectors/packet-isup.c | 5 ++-- epan/dissectors/packet-ldp.c | 2 +- epan/dissectors/packet-manolito.c | 4 +-- epan/dissectors/packet-msdp.c | 4 +-- epan/dissectors/packet-msnip.c | 4 +-- epan/dissectors/packet-msproxy.c | 4 +-- epan/dissectors/packet-nbns.c | 2 +- epan/dissectors/packet-netflow.c | 54 +++++++++++++-------------------------- epan/dissectors/packet-nsip.c | 13 +++------- epan/dissectors/packet-ntp.c | 2 +- epan/dissectors/packet-olsr.c | 49 +++++++++-------------------------- epan/dissectors/packet-quake3.c | 2 +- epan/dissectors/packet-skinny.c | 4 +-- epan/dissectors/packet-socks.c | 5 ++-- epan/dissectors/packet-teredo.c | 42 ++++++++++++++++++------------ epan/dissectors/packet-uma.c | 6 ++--- epan/dissectors/packet-wccp.c | 2 +- epan/dissectors/packet-wsp.c | 9 +++---- epan/packet.c | 1 - epan/proto.c | 1 - epan/tvbuff.c | 1 - epan/tvbuff.h | 1 + plugins/opsi/packet-opsi.c | 2 +- plugins/profinet/packet-pn-dcp.c | 2 +- 47 files changed, 177 insertions(+), 229 deletions(-) diff --git a/asn1/h225/h225.cnf b/asn1/h225/h225.cnf index 8b34881265..b746a1d88e 100644 --- a/asn1/h225/h225.cnf +++ b/asn1/h225/h225.cnf @@ -231,7 +231,7 @@ CallIdentifier/guid guid ipv4_address = 0; %(DEFAULT_BODY)s if (value_tvb) - tvb_memcpy(value_tvb, (guint8*)&ipv4_address, 0, 4); + ipv4_address = tvb_get_ipv4(value_tvb, 0); #.END #---------------------------------------------------------------------------------------- #.FN_PARS H245TransportAddress/h245ipAddress/h245ipv4port diff --git a/asn1/h245/h245.cnf b/asn1/h245/h245.cnf index 1b7f77e942..d6722364ca 100644 --- a/asn1/h245/h245.cnf +++ b/asn1/h245/h245.cnf @@ -280,10 +280,10 @@ OpenLogicalChannel %(DEFAULT_BODY)s if ( media_channel ) - tvb_memcpy(value_tvb, (guint8*)&ipv4_address, 0, 4); + ipv4_address = tvb_get_ipv4(value_tvb, 0); if ( media_control_channel ) - tvb_memcpy(value_tvb, (guint8*)&rtcp_ipv4_address, 0, 4); + rtcp_ipv4_address = tvb_get_ipv4(value_tvb, 0); #.END #---------------------------------------------------------------------------------------- @@ -815,4 +815,4 @@ VendorIdentification/versionNumber TYPE = FT_STRING DISPLAY = BASE_HEX STRINGS = #---------------------------------------------------------------------------------------- #.FIELD_ATTR AlternativeCapabilitySet/_item NAME = "alternativeCapability" -#---------------------------------------------------------------------------------------- \ No newline at end of file +#---------------------------------------------------------------------------------------- diff --git a/epan/addr_and_mask.c b/epan/addr_and_mask.c index 2e3eaf2588..3dd2941034 100644 --- a/epan/addr_and_mask.c +++ b/epan/addr_and_mask.c @@ -31,7 +31,6 @@ #include #include "tvbuff.h" -#include "ipv6-utils.h" #include "addr_and_mask.h" /* diff --git a/epan/dissectors/packet-aodv.c b/epan/dissectors/packet-aodv.c index 5f38393be7..f2f705e402 100644 --- a/epan/dissectors/packet-aodv.c +++ b/epan/dissectors/packet-aodv.c @@ -35,7 +35,6 @@ #include #include -#include #ifndef offsetof #define offsetof(type, member) ((size_t)(&((type *)0)->member)) @@ -265,7 +264,7 @@ dissect_aodv_rreq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *aodv_tree, offset += 4; if (is_ipv6) { - tvb_memcpy(tvb, (guint8 *)&dest_addr_v6, offset, INET6_ADDRLEN); + tvb_get_ipv6(tvb, offset, &dest_addr_v6); if (aodv_tree) { proto_tree_add_ipv6(aodv_tree, hf_aodv_dest_ipv6, tvb, offset, INET6_ADDRLEN, (guint8 *)&dest_addr_v6); @@ -277,7 +276,7 @@ dissect_aodv_rreq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *aodv_tree, ip6_to_str(&dest_addr_v6)); offset += INET6_ADDRLEN; } else { - tvb_memcpy(tvb, (guint8 *)&dest_addr_v4, offset, 4); + dest_addr_v4 = tvb_get_ipv4(tvb, offset); if (aodv_tree) { proto_tree_add_ipv4(aodv_tree, hf_aodv_dest_ip, tvb, offset, 4, dest_addr_v4); @@ -297,7 +296,7 @@ dissect_aodv_rreq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *aodv_tree, offset += 4; if (is_ipv6) { - tvb_memcpy(tvb, (guint8 *)&orig_addr_v6, offset, INET6_ADDRLEN); + tvb_get_ipv6(tvb, offset, &orig_addr_v6); if (aodv_tree) { proto_tree_add_ipv6(aodv_tree, hf_aodv_orig_ipv6, tvb, offset, INET6_ADDRLEN, (guint8 *)&orig_addr_v6); @@ -309,7 +308,7 @@ dissect_aodv_rreq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *aodv_tree, ip6_to_str(&orig_addr_v6)); offset += INET6_ADDRLEN; } else { - tvb_memcpy(tvb, (guint8 *)&orig_addr_v4, offset, 4); + orig_addr_v4 = tvb_get_ipv4(tvb, offset); if (aodv_tree) { proto_tree_add_ipv4(aodv_tree, hf_aodv_orig_ip, tvb, offset, 4, orig_addr_v4); @@ -387,7 +386,7 @@ dissect_aodv_rrep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *aodv_tree, offset += 1; if (is_ipv6) { - tvb_memcpy(tvb, (guint8 *)&dest_addr_v6, offset, INET6_ADDRLEN); + tvb_get_ipv6(tvb, offset, &dest_addr_v6); if (aodv_tree) { proto_tree_add_ipv6(aodv_tree, hf_aodv_dest_ipv6, tvb, offset, INET6_ADDRLEN, (guint8 *)&dest_addr_v6); @@ -399,7 +398,7 @@ dissect_aodv_rrep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *aodv_tree, ip6_to_str(&dest_addr_v6)); offset += INET6_ADDRLEN; } else { - tvb_memcpy(tvb, (guint8 *)&dest_addr_v4, offset, 4); + dest_addr_v4 = tvb_get_ipv4(tvb, offset); if (aodv_tree) { proto_tree_add_ipv4(aodv_tree, hf_aodv_dest_ip, tvb, offset, 4, dest_addr_v4); @@ -419,7 +418,7 @@ dissect_aodv_rrep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *aodv_tree, offset += 4; if (is_ipv6) { - tvb_memcpy(tvb, (guint8 *)&orig_addr_v6, offset, INET6_ADDRLEN); + tvb_get_ipv6(tvb, offset, &orig_addr_v6); if (aodv_tree) { proto_tree_add_ipv6(aodv_tree, hf_aodv_orig_ipv6, tvb, offset, INET6_ADDRLEN, (guint8 *)&orig_addr_v6); @@ -431,7 +430,7 @@ dissect_aodv_rrep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *aodv_tree, ip6_to_str(&orig_addr_v6)); offset += INET6_ADDRLEN; } else { - tvb_memcpy(tvb, (guint8 *)&orig_addr_v4, offset, 4); + orig_addr_v4 = tvb_get_ipv4(tvb, offset); if (aodv_tree) { proto_tree_add_ipv4(aodv_tree, hf_aodv_orig_ip, tvb, offset, 4, orig_addr_v4); @@ -592,7 +591,7 @@ dissect_aodv_draft_01_v6_rreq(tvbuff_t *tvb, packet_info *pinfo, orig_seqno); offset += 4; - tvb_memcpy(tvb, (guint8 *)&dest_addr_v6, offset, INET6_ADDRLEN); + tvb_get_ipv6(tvb, offset, &dest_addr_v6); if (aodv_tree) { proto_tree_add_ipv6(aodv_tree, hf_aodv_dest_ipv6, tvb, offset, INET6_ADDRLEN, (guint8 *)&dest_addr_v6); @@ -604,7 +603,7 @@ dissect_aodv_draft_01_v6_rreq(tvbuff_t *tvb, packet_info *pinfo, ip6_to_str(&dest_addr_v6)); offset += INET6_ADDRLEN; - tvb_memcpy(tvb, (guint8 *)&orig_addr_v6, offset, INET6_ADDRLEN); + tvb_get_ipv6(tvb, offset, &orig_addr_v6); if (aodv_tree) { proto_tree_add_ipv6(aodv_tree, hf_aodv_orig_ipv6, tvb, offset, INET6_ADDRLEN, (guint8 *)&orig_addr_v6); @@ -677,7 +676,7 @@ dissect_aodv_draft_01_v6_rrep(tvbuff_t *tvb, packet_info *pinfo, dest_seqno); offset += 4; - tvb_memcpy(tvb, (guint8 *)&dest_addr_v6, offset, INET6_ADDRLEN); + tvb_get_ipv6(tvb, offset, &dest_addr_v6); if (aodv_tree) { proto_tree_add_ipv6(aodv_tree, hf_aodv_dest_ipv6, tvb, offset, INET6_ADDRLEN, (guint8 *)&dest_addr_v6); @@ -689,7 +688,7 @@ dissect_aodv_draft_01_v6_rrep(tvbuff_t *tvb, packet_info *pinfo, ip6_to_str(&dest_addr_v6)); offset += INET6_ADDRLEN; - tvb_memcpy(tvb, (guint8 *)&orig_addr_v6, offset, INET6_ADDRLEN); + tvb_get_ipv6(tvb, offset, &orig_addr_v6); if (aodv_tree) { proto_tree_add_ipv6(aodv_tree, hf_aodv_orig_ipv6, tvb, offset, INET6_ADDRLEN, (guint8 *)&orig_addr_v6); diff --git a/epan/dissectors/packet-arp.c b/epan/dissectors/packet-arp.c index 63588aa153..a223bf8723 100644 --- a/epan/dissectors/packet-arp.c +++ b/epan/dissectors/packet-arp.c @@ -713,7 +713,7 @@ dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Add sender address if sender MAC address is neither a broadcast/ multicast address nor an all-zero address and if sender IP address isn't all zeroes. */ - tvb_memcpy(tvb, (guint8 *)&ip, spa_offset, sizeof(ip)); + ip = tvb_get_ipv4(tvb, spa_offset); mac = tvb_get_ptr(tvb, sha_offset, 6); if ((mac[0] & 0x01) == 0 && memcmp(mac, mac_allzero, 6) != 0 && ip != 0) add_ether_byip(ip, mac); @@ -725,7 +725,7 @@ dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Do not add target address if the packet is a Request. According to the RFC, target addresses in requests have no meaning */ - tvb_memcpy(tvb, (guint8 *)&ip, tpa_offset, sizeof(ip)); + ip = tvb_get_ipv4(tvb, tpa_offset); mac = tvb_get_ptr(tvb, tha_offset, 6); if ((mac[0] & 0x01) == 0 && memcmp(mac, mac_allzero, 6) != 0 && ip != 0 && ar_op != ARPOP_REQUEST) diff --git a/epan/dissectors/packet-auto_rp.c b/epan/dissectors/packet-auto_rp.c index 8033fac6f9..1064b1b648 100644 --- a/epan/dissectors/packet-auto_rp.c +++ b/epan/dissectors/packet-auto_rp.c @@ -252,7 +252,7 @@ static int do_auto_rp_map(tvbuff_t *tvb, int offset, proto_tree *auto_rp_tree) guint32 rp_addr; /* In network byte order */ int i; - tvb_memcpy(tvb, (guint8 *)&rp_addr, offset, 4); + rp_addr = tvb_get_ipv4(tvb, offset); group_count = tvb_get_guint8(tvb, offset + 5); /* sizeof map header + n * sizeof encoded group addresses */ @@ -276,7 +276,7 @@ static int do_auto_rp_map(tvbuff_t *tvb, int offset, proto_tree *auto_rp_tree) sign = tvb_get_guint8(tvb, offset); mask_len = tvb_get_guint8(tvb, offset + 1); - tvb_memcpy(tvb, (guint8 *)&group_addr, offset + 2, 4); + group_addr = tvb_get_ipv4(tvb, offset + 2); gi = proto_tree_add_text(map_tree, tvb, offset, 6, "Group %s/%u (%s)", ip_to_str((void *)&group_addr), mask_len, val_to_str(sign&AUTO_RP_SIGN_MASK, auto_rp_mask_sign_vals, "")); diff --git a/epan/dissectors/packet-bgp.c b/epan/dissectors/packet-bgp.c index b106121f88..ae47708b74 100644 --- a/epan/dissectors/packet-bgp.c +++ b/epan/dissectors/packet-bgp.c @@ -573,7 +573,7 @@ mp_addr_to_str (guint16 afi, guint8 safi, tvbuff_t *tvb, gint offset, char *buf, case SAFNUM_MPLS_LABEL: case SAFNUM_TUNNEL: length = 16 ; - tvb_memcpy(tvb, ip6addr.u6_addr.u6_addr8,offset, 16); + tvb_get_ipv6(tvb, offset, &ip6addr); strptr += g_snprintf(strptr, buf_len-(strptr-buf), "%s", ip6_to_str(&ip6addr)); break; case SAFNUM_LAB_VPNUNICAST: @@ -583,7 +583,7 @@ mp_addr_to_str (guint16 afi, guint8 safi, tvbuff_t *tvb, gint offset, char *buf, switch (rd_type) { case FORMAT_AS2_LOC: length = 8 + 16; - tvb_memcpy(tvb, ip6addr.u6_addr.u6_addr8, offset + 8, 16); /* Next Hop */ + tvb_get_ipv6(tvb, offset + 8, &ip6addr); /* Next Hop */ strptr += g_snprintf(strptr, buf_len-(strptr-buf), "Empty Label Stack RD=%u:%u IPv6=%s", tvb_get_ntohs(tvb, offset + 2), tvb_get_ntohl(tvb, offset + 4), @@ -592,7 +592,7 @@ mp_addr_to_str (guint16 afi, guint8 safi, tvbuff_t *tvb, gint offset, char *buf, case FORMAT_IP_LOC: length = 8 + 16; tvb_memcpy(tvb, ip4addr, offset + 2, sizeof(ip4addr)); /* IP part of the RD */ - tvb_memcpy(tvb, ip6addr.u6_addr.u6_addr8, offset + 8, 16); /* Next Hop */ + tvb_get_ipv6(tvb, offset + 8, &ip6addr); /* Next Hop */ strptr += g_snprintf(strptr, buf_len-(strptr-buf), "Empty Label Stack RD=%s:%u IPv6=%s", ip_to_str(ip4addr), tvb_get_ntohs(tvb, offset + 6), diff --git a/epan/dissectors/packet-bootp.c b/epan/dissectors/packet-bootp.c index 782fd2553a..a839da93e9 100644 --- a/epan/dissectors/packet-bootp.c +++ b/epan/dissectors/packet-bootp.c @@ -2843,7 +2843,7 @@ dissect_bootp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (tvb_bytes_exist(tvb, voff, 4)) { if (tvb_get_ntohl(tvb, voff) == 0x63825363) { if (tree) { - tvb_memcpy(tvb, (void *)&ip_addr, voff, sizeof(ip_addr)); + ip_addr = tvb_get_ipv4(tvb, voff); proto_tree_add_ipv4_format(bp_tree, hf_bootp_cookie, tvb, voff, 4, ip_addr, "Magic cookie: (OK)"); diff --git a/epan/dissectors/packet-cdp.c b/epan/dissectors/packet-cdp.c index ffcbf816ac..a24e485058 100644 --- a/epan/dissectors/packet-cdp.c +++ b/epan/dissectors/packet-cdp.c @@ -360,10 +360,10 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* proto_tree_add_text(tlv_tree, tvb, offset+9, length - 9, "Cluster Management"); */ - tvb_memcpy(tvb, (guint8 *)&ip_addr, offset+9, 4); + ip_addr = tvb_get_ipv4(tvb, offset+9); proto_tree_add_text(tlv_tree, tvb, offset+9, 4, "Cluster Master IP: %s",ip_to_str((guint8 *)&ip_addr)); - tvb_memcpy(tvb, (guint8 *)&ip_addr, offset+13, 4); + ip_addr = tvb_get_ipv4(tvb, offset+13); proto_tree_add_text(tlv_tree, tvb, offset+13, 4, "UNKNOWN (IP?): 0x%08X (%s)", ip_addr, ip_to_str((guint8 *)&ip_addr)); diff --git a/epan/dissectors/packet-chdlc.c b/epan/dissectors/packet-chdlc.c index 9550544704..c000e0310e 100644 --- a/epan/dissectors/packet-chdlc.c +++ b/epan/dissectors/packet-chdlc.c @@ -298,7 +298,7 @@ dissect_slarp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case SLARP_REQUEST: case SLARP_REPLY: if (check_col(pinfo->cinfo, COL_INFO)) { - tvb_memcpy(tvb, (guint8 *)&address, 4, 4); + address = tvb_get_ipv4(tvb, 4); col_add_fstr(pinfo->cinfo, COL_INFO, "%s, from %s, mask %s", match_strval(code, slarp_ptype_vals), get_hostname(address), diff --git a/epan/dissectors/packet-cops.c b/epan/dissectors/packet-cops.c index 0c9402692c..ad115dd402 100644 --- a/epan/dissectors/packet-cops.c +++ b/epan/dissectors/packet-cops.c @@ -1096,7 +1096,7 @@ static void dissect_cops_object_data(tvbuff_t *tvb, packet_info *pinfo, guint32 case COPS_OBJ_IN_INT: case COPS_OBJ_OUT_INT: if (c_type == 1) { /* IPv4 */ - tvb_memcpy(tvb, (guint8 *)&ipv4addr, offset, 4); + ipv4addr = tvb_get_ipv4(tvb, offset); ifindex = tvb_get_ntohl(tvb, offset + 4); ti = proto_tree_add_text(tree, tvb, offset, 8, "Contents: IPv4 address %s, ifIndex: %u", ip_to_str((guint8 *)&ipv4addr), ifindex); @@ -1106,7 +1106,7 @@ static void dissect_cops_object_data(tvbuff_t *tvb, packet_info *pinfo, guint32 tvb, offset, 4, ipv4addr); offset += 4; } else if (c_type == 2) { /* IPv6 */ - tvb_memcpy(tvb, (guint8 *)&ipv6addr, offset, sizeof ipv6addr); + tvb_get_ipv6(tvb, offset, &ipv6addr); ifindex = tvb_get_ntohl(tvb, offset + sizeof ipv6addr); ti = proto_tree_add_text(tree, tvb, offset, 20, "Contents: IPv6 address %s, ifIndex: %u", ip6_to_str(&ipv6addr), ifindex); @@ -1232,7 +1232,7 @@ static void dissect_cops_object_data(tvbuff_t *tvb, packet_info *pinfo, guint32 case COPS_OBJ_PDPREDIRADDR: case COPS_OBJ_LASTPDPADDR: if (c_type == 1) { /* IPv4 */ - tvb_memcpy(tvb, (guint8 *)&ipv4addr, offset, 4); + ipv4addr = tvb_get_ipv4(tvb, offset); tcp_port = tvb_get_ntohs(tvb, offset + 4 + 2); ti = proto_tree_add_text(tree, tvb, offset, 8, "Contents: IPv4 address %s, TCP Port Number: %u", ip_to_str((guint8 *)&ipv4addr), tcp_port); @@ -1242,7 +1242,7 @@ static void dissect_cops_object_data(tvbuff_t *tvb, packet_info *pinfo, guint32 tvb, offset, 4, ipv4addr); offset += 4; } else if (c_type == 2) { /* IPv6 */ - tvb_memcpy(tvb, (guint8 *)&ipv6addr, offset, sizeof ipv6addr); + tvb_get_ipv6(tvb, offset, &ipv6addr); tcp_port = tvb_get_ntohs(tvb, offset + sizeof ipv6addr + 2); ti = proto_tree_add_text(tree, tvb, offset, 20, "Contents: IPv6 address %s, TCP Port Number: %u", ip6_to_str(&ipv6addr), tcp_port); @@ -2493,6 +2493,7 @@ info_to_display(tvbuff_t *tvb, proto_item *stt, int offset, int octets, const ch proto_item *pi = NULL; guint8 code8 = 0; guint16 code16 = 0; + guint32 codeipv4 = 0; guint32 code32 = 0; float codefl = 0.0; @@ -2558,7 +2559,7 @@ info_to_display(tvbuff_t *tvb, proto_item *stt, int offset, int octets, const ch switch (mode) { case FMT_FLT: codefl = tvb_get_ntohieee_float(tvb,offset); break; - case FMT_IPv4: tvb_memcpy(tvb, (guint8 *)&code32, offset, 4); + case FMT_IPv4: codeipv4 = tvb_get_ipv4(tvb, offset); break; default: code32 = tvb_get_ntohl(tvb,offset); } @@ -2572,7 +2573,7 @@ info_to_display(tvbuff_t *tvb, proto_item *stt, int offset, int octets, const ch } /* Ip address format*/ if (mode==FMT_IPv4) { - pi = proto_tree_add_ipv4(stt, *hf_proto_parameter,tvb, offset, octets, code32); + pi = proto_tree_add_ipv4(stt, *hf_proto_parameter,tvb, offset, octets, codeipv4); break; } /* Ieee float format */ diff --git a/epan/dissectors/packet-dhcpv6.c b/epan/dissectors/packet-dhcpv6.c index f969cd14f9..589bf78b3a 100644 --- a/epan/dissectors/packet-dhcpv6.c +++ b/epan/dissectors/packet-dhcpv6.c @@ -47,7 +47,6 @@ #include #include #include -#include #include "packet-arp.h" static int proto_dhcpv6 = -1; @@ -461,7 +460,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, optlen, "IAADDR: malformed option"); break; } - tvb_memcpy(tvb, (guint8 *)&in6, off, sizeof(in6)); + tvb_get_ipv6(tvb, off, &in6); proto_tree_add_text(subtree, tvb, off, sizeof(in6), "IPv6 address: %s", ip6_to_str(&in6)); @@ -563,7 +562,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, optlen, "UNICAST: malformed option"); break; } - tvb_memcpy(tvb, (guint8 *)&in6, off, sizeof(in6)); + tvb_get_ipv6(tvb, off, &in6); proto_tree_add_text(subtree, tvb, off, sizeof(in6), "IPv6 address: %s", ip6_to_str(&in6)); @@ -649,7 +648,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, break; } for (i = 0; i < optlen; i += 16) { - tvb_memcpy(tvb, (guint8 *)&in6, off + i, sizeof(in6)); + tvb_get_ipv6(tvb, off + i, &in6); proto_tree_add_text(subtree, tvb, off + i, sizeof(in6), "SIP servers address: %s", ip6_to_str(&in6)); @@ -662,7 +661,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, break; } for (i = 0; i < optlen; i += 16) { - tvb_memcpy(tvb, (guint8 *)&in6, off + i, sizeof(in6)); + tvb_get_ipv6(tvb, off + i, &in6); proto_tree_add_text(subtree, tvb, off + i, sizeof(in6), "DNS servers address: %s", ip6_to_str(&in6)); @@ -681,7 +680,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, break; } for (i = 0; i < optlen; i += 16) { - tvb_memcpy(tvb, (guint8 *)&in6, off + i, sizeof(in6)); + tvb_get_ipv6(tvb, off + i, &in6); proto_tree_add_text(subtree, tvb, off + i, sizeof(in6), "NIS servers address: %s", ip6_to_str(&in6)); @@ -694,7 +693,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, break; } for (i = 0; i < optlen; i += 16) { - tvb_memcpy(tvb, (guint8 *)&in6, off + i, sizeof(in6)); + tvb_get_ipv6(tvb, off + i, &in6); proto_tree_add_text(subtree, tvb, off + i, sizeof(in6), "NISP servers address: %s", ip6_to_str(&in6)); @@ -719,7 +718,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, break; } for (i = 0; i < optlen; i += 16) { - tvb_memcpy(tvb, (guint8 *)&in6, off + i, sizeof(in6)); + tvb_get_ipv6(tvb, off + i, &in6); proto_tree_add_text(subtree, tvb, off + i, sizeof(in6), "SNTP servers address: %s", ip6_to_str(&in6)); @@ -793,7 +792,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, } proto_tree_add_text(subtree, tvb, off + 8, 1, "Prefix length: %d", prefix_length); - tvb_memcpy(tvb, (guint8 *)&in6, off + 9 , sizeof(in6)); + tvb_get_ipv6(tvb, off + 9, &in6); proto_tree_add_text(subtree, tvb, off + 9, 16, "Prefix address: %s", ip6_to_str(&in6)); @@ -816,7 +815,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, break; } - tvb_memcpy(tvb, (guint8 *)&in6, off , sizeof(in6)); + tvb_get_ipv6(tvb, off, &in6); proto_tree_add_text(subtree, tvb, off, 16, "Home Agent: %s", ip6_to_str(&in6)); break; @@ -827,7 +826,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, break; } - tvb_memcpy(tvb, (guint8 *)&in6, off , sizeof(in6)); + tvb_get_ipv6(tvb, off, &in6); proto_tree_add_text(subtree, tvb, off, 16, "Home Address: %s", ip6_to_str(&in6)); break; @@ -882,11 +881,11 @@ dissect_dhcpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, hop_count = tvb_get_guint8(tvb, off+1); proto_tree_add_text(bp_tree, tvb, off+1, 1, "Hop count: %d", hop_count); - tvb_memcpy(tvb, (guint8 *)&in6, off+2, sizeof(in6)); + tvb_get_ipv6(tvb, off+2, &in6); proto_tree_add_text(bp_tree, tvb, off+2, sizeof(in6), "Link-address: %s",ip6_to_str(&in6)); - tvb_memcpy(tvb, (guint8 *)&in6, off+18, sizeof(in6)); + tvb_get_ipv6(tvb, off+18, &in6); proto_tree_add_text(bp_tree, tvb, off+18, sizeof(in6), "Peer-address: %s",ip6_to_str(&in6)); @@ -909,7 +908,7 @@ dissect_dhcpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, msgtype); proto_tree_add_text(bp_tree, tvb, off+1, 3, "Transaction-ID: 0x%08x", xid); #if 0 - tvb_memcpy(tvb, (guint8 *)&in6, 4, sizeof(in6)); + tvb_get_ipv6(tvb, 4, &in6); proto_tree_add_text(bp_tree, tvb, 4, sizeof(in6), "Server address: %s", ip6_to_str(&in6)); #endif diff --git a/epan/dissectors/packet-dns.c b/epan/dissectors/packet-dns.c index 3f6b2af089..0fa5ce15e8 100644 --- a/epan/dissectors/packet-dns.c +++ b/epan/dissectors/packet-dns.c @@ -35,7 +35,6 @@ #include #include -#include #include #include #include diff --git a/epan/dissectors/packet-gsm_a.c b/epan/dissectors/packet-gsm_a.c index a2a6e21b70..70419b8aa3 100644 --- a/epan/dissectors/packet-gsm_a.c +++ b/epan/dissectors/packet-gsm_a.c @@ -94,7 +94,6 @@ #include #include -#include #include #include @@ -11098,7 +11097,7 @@ de_sm_pco(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add proto_tree_add_text(tree,tvb, curr_offset-3, 2, "Parameter: (%u) P-CSCF Address" , prot ); proto_tree_add_text(tree,tvb, curr_offset-1, 1, "Length: 0x%02x (%u)", e_len , e_len); - tvb_memcpy(tvb, (guint8 *)&ipv6_addr, curr_offset, 16); + tvb_get_ipv6(tvb, curr_offset, &ipv6_addr); proto_tree_add_text(tree, tvb, curr_offset, 16, "IPv6: %s", ip6_to_str(&ipv6_addr)); @@ -11113,7 +11112,7 @@ de_sm_pco(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add proto_tree_add_text(tree,tvb, curr_offset-3, 2, "Parameter: (%u) DNS Server Address" , prot ); proto_tree_add_text(tree,tvb, curr_offset-1, 1, "Length: 0x%02x (%u)", e_len , e_len); - tvb_memcpy(tvb, (guint8 *)&ipv6_addr, curr_offset, 16); + tvb_get_ipv6(tvb, curr_offset, &ipv6_addr); proto_tree_add_text(tree, tvb, curr_offset, 16, "IPv6: %s", ip6_to_str(&ipv6_addr)); @@ -11285,7 +11284,7 @@ de_sm_pdp_addr(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar tvb, curr_offset+2, 0, "IPv6: length is wrong"); } else { - tvb_memcpy(tvb, (guint8 *)&ipv6_addr, curr_offset+2, 16); + tvb_get_ipv6(tvb, curr_offset+2, &ipv6_addr); proto_tree_add_text(tree, tvb, curr_offset+2, len-2, "IPv6: %s", ip6_to_str(&ipv6_addr)); @@ -12203,7 +12202,7 @@ de_sm_tflow_temp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gch { struct e_in6_addr ipv6_addr; - tvb_memcpy(tvb, (guint8 *)&ipv6_addr, curr_offset, 16); + tvb_get_ipv6(tvb, curr_offset, &ipv6_addr); proto_tree_add_text(tree, tvb, curr_offset+2, len-2, "Packet filter content: IPv6 %s", ip6_to_str(&ipv6_addr)); diff --git a/epan/dissectors/packet-gtp.c b/epan/dissectors/packet-gtp.c index 1be5079616..a39481be25 100644 --- a/epan/dissectors/packet-gtp.c +++ b/epan/dissectors/packet-gtp.c @@ -2667,12 +2667,12 @@ decode_gtp_user_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tr } else if (length > 2) { switch (pdp_typ) { case 0x21: - tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+5, sizeof addr_ipv4); + addr_ipv4 = tvb_get_ipv4(tvb, offset+5); proto_tree_add_ipv4(ext_tree_user, hf_gtp_user_ipv4, tvb, offset+5, 4, addr_ipv4); proto_item_append_text(te, " : %s", ip_to_str((guint8 *)&addr_ipv4)); break; case 0x57: - tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+5, sizeof addr_ipv6); + tvb_get_ipv6(tvb, offset+5, &addr_ipv6); proto_tree_add_ipv6 (ext_tree_user, hf_gtp_user_ipv6, tvb, offset+5, 16, (guint8 *)&addr_ipv6); proto_item_append_text(te, " : %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6)); break; @@ -3245,11 +3245,11 @@ decode_gtp_pdp_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tr if (pdp_addr_len > 0) { switch (pdp_type_num) { case 0x21: - tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4); + addr_ipv4 = tvb_get_ipv4(tvb, offset+3); proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 4, "PDP address: %s", ip_to_str((guint8 *)&addr_ipv4)); break; case 0x57: - tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6); + tvb_get_ipv6(tvb, offset+3, &addr_ipv6); proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 16, "PDP address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6)); break; default: @@ -3264,11 +3264,11 @@ decode_gtp_pdp_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tr switch (ggsn_addr_len) { case 4: - tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+1, sizeof addr_ipv4); + addr_ipv4 = tvb_get_ipv4(tvb, offset+1); proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 4, "GGSN address: %s", ip_to_str((guint8 *)&addr_ipv4)); break; case 16: - tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+1, sizeof addr_ipv6); + tvb_get_ipv6(tvb, offset+1, &addr_ipv6); proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 16, "GGSN address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6)); break; default: @@ -3284,11 +3284,11 @@ decode_gtp_pdp_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tr switch (ggsn_addr_len) { case 4: - tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+1, sizeof addr_ipv4); + addr_ipv4 = tvb_get_ipv4(tvb, offset+1); proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 4, "GGSN 2 address: %s", ip_to_str((guint8 *)&addr_ipv4)); break; case 16: - tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+1, sizeof addr_ipv6); + tvb_get_ipv6(tvb, offset+1, &addr_ipv6); proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 16, "GGSN 2 address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6)); break; default: @@ -3427,7 +3427,7 @@ decode_gtp_gsn_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tre switch (length) { case 4: proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address length : %u", length); - tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4); + addr_ipv4 = tvb_get_ipv4(tvb, offset+3); proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4)); proto_tree_add_ipv4(ext_tree_gsn_addr, hf_gtp_gsn_ipv4, tvb, offset+3, 4, addr_ipv4); break; @@ -3437,13 +3437,13 @@ decode_gtp_gsn_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tre proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_type, tvb, offset+3, 1, addr_type); addr_len = tvb_get_guint8(tvb, offset+3) & 0x3F; proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_len, tvb, offset+3, 1, addr_len); - tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+4, sizeof addr_ipv4); + addr_ipv4 = tvb_get_ipv4(tvb, offset+4); proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4)); proto_tree_add_ipv4(ext_tree_gsn_addr, hf_gtp_gsn_ipv4, tvb, offset+4, 4, addr_ipv4); break; case 16: proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address length : %u", length); - tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6); + tvb_get_ipv6(tvb, offset+3, &addr_ipv6); proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6)); proto_tree_add_ipv6(ext_tree_gsn_addr, hf_gtp_gsn_ipv6, tvb, offset+3, 16, (guint8*)&addr_ipv6); break; @@ -3453,7 +3453,7 @@ decode_gtp_gsn_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tre proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_type, tvb, offset+3, 1, addr_type); addr_len = tvb_get_guint8(tvb, offset+3) & 0x3F; proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_len, tvb, offset+3, 1, addr_len); - tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+4, sizeof addr_ipv6); + tvb_get_ipv6(tvb, offset+4, &addr_ipv6); proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6)); proto_tree_add_ipv6(ext_tree_gsn_addr, hf_gtp_gsn_ipv6, tvb, offset+4, 16, (guint8*)&addr_ipv6); break; @@ -3604,15 +3604,15 @@ decode_gtp_tft(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tr switch (pf_content_id) { /* address IPv4 and mask = 8 bytes*/ case 0x10: - tvb_memcpy (tvb, (guint8 *)&addr_ipv4, offset + pf_offset + 1, sizeof addr_ipv4); - tvb_memcpy (tvb, (guint8 *)&mask_ipv4, offset + pf_offset + 5, sizeof mask_ipv4); + addr_ipv4 = tvb_get_ipv4 (tvb, offset + pf_offset + 1); + mask_ipv4 = tvb_get_ipv4 (tvb, offset + pf_offset + 5); proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 9, "ID 0x10: IPv4/mask: %s/%s", ip_to_str ((guint8 *)&addr_ipv4), ip_to_str ((guint8 *)&mask_ipv4)); pf_offset = pf_offset + 9; break; /* address IPv6 and mask = 32 bytes*/ case 0x20: - tvb_memcpy (tvb, (guint8 *)&addr_ipv6, offset+pf_offset+1, sizeof addr_ipv6); - tvb_memcpy (tvb, (guint8 *)&mask_ipv6, offset+pf_offset+17, sizeof mask_ipv6); + tvb_get_ipv6 (tvb, offset+pf_offset+1, &addr_ipv6); + tvb_get_ipv6 (tvb, offset+pf_offset+17, &mask_ipv6); proto_tree_add_text (ext_tree_tft_pf, tvb, offset+pf_offset, 33, "ID 0x20: IPv6/mask: %s/%s", ip6_to_str ((struct e_in6_addr*)&addr_ipv6), ip6_to_str ((struct e_in6_addr*)&mask_ipv6)); pf_offset = pf_offset + 33; break; @@ -3745,11 +3745,11 @@ decode_gtp_rab_setup(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tr switch (length) { case 12: - tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+8, sizeof addr_ipv4); + addr_ipv4 = tvb_get_ipv4(tvb, offset+8); proto_tree_add_ipv4(ext_tree_rab_setup, hf_gtp_rnc_ipv4, tvb, offset+8, 4, addr_ipv4); break; case 24: - tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+8, sizeof addr_ipv6); + tvb_get_ipv6(tvb, offset+8, &addr_ipv6); proto_tree_add_ipv6(ext_tree_rab_setup, hf_gtp_rnc_ipv6, tvb, offset+8, 16, (guint8 *)&addr_ipv6); break; default: @@ -3843,12 +3843,12 @@ decode_gtp_chrg_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tr switch (length) { case 4: - tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4); + addr_ipv4 = tvb_get_ipv4(tvb, offset+3); proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4)); proto_tree_add_ipv4 (ext_tree_chrg_addr, hf_gtp_chrg_ipv4, tvb, offset+3, 4, addr_ipv4); break; case 16: - tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6); + tvb_get_ipv6(tvb, offset+3, &addr_ipv6); proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6)); proto_tree_add_ipv6 (ext_tree_chrg_addr, hf_gtp_chrg_ipv6, tvb, offset+3, 16, (guint8*)&addr_ipv6); break; @@ -3998,12 +3998,12 @@ decode_gtp_node_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tr switch (length) { case 4: - tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4); + addr_ipv4 = tvb_get_ipv4(tvb, offset+3); proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4)); proto_tree_add_ipv4 (ext_tree_node_addr, hf_gtp_node_ipv4, tvb, offset+3, 4, addr_ipv4); break; case 16: - tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6); + tvb_get_ipv6(tvb, offset+3, &addr_ipv6); proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6)); proto_tree_add_ipv6 (ext_tree_node_addr, hf_gtp_node_ipv6, tvb, offset+3, 16, (guint8*)&addr_ipv6); break; diff --git a/epan/dissectors/packet-h225.c b/epan/dissectors/packet-h225.c index 44f189f628..edd7ae8134 100644 --- a/epan/dissectors/packet-h225.c +++ b/epan/dissectors/packet-h225.c @@ -1219,7 +1219,7 @@ dissect_h225_T_h245ipv4(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto 4, 4, &value_tvb); if (value_tvb) - tvb_memcpy(value_tvb, (guint8*)&ipv4_address, 0, 4); + ipv4_address = tvb_get_ipv4(value_tvb, 0); return offset; } diff --git a/epan/dissectors/packet-h245.c b/epan/dissectors/packet-h245.c index 748b175f65..f868b88ea2 100644 --- a/epan/dissectors/packet-h245.c +++ b/epan/dissectors/packet-h245.c @@ -1,6 +1,6 @@ /* Do not modify this file. */ /* It is created automatically by the ASN.1 to Ethereal dissector compiler */ -/* .\packet-h245.c */ +/* ./packet-h245.c */ /* ../../tools/asn2eth.py -X -e -p h245 -c h245.cnf -s packet-h245-template h245.asn */ /* Input file: packet-h245-template.c */ @@ -9593,10 +9593,10 @@ dissect_h245_Ipv4_network(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, pro 4, 4, &value_tvb); if ( media_channel ) - tvb_memcpy(value_tvb, (guint8*)&ipv4_address, 0, 4); + ipv4_address = tvb_get_ipv4(value_tvb, 0); if ( media_control_channel ) - tvb_memcpy(value_tvb, (guint8*)&rtcp_ipv4_address, 0, 4); + rtcp_ipv4_address = tvb_get_ipv4(value_tvb, 0); return offset; diff --git a/epan/dissectors/packet-h245.h b/epan/dissectors/packet-h245.h index 96951d500c..3b425f0062 100644 --- a/epan/dissectors/packet-h245.h +++ b/epan/dissectors/packet-h245.h @@ -1,6 +1,6 @@ /* Do not modify this file. */ /* It is created automatically by the ASN.1 to Ethereal dissector compiler */ -/* .\packet-h245.h */ +/* ./packet-h245.h */ /* ../../tools/asn2eth.py -X -e -p h245 -c h245.cnf -s packet-h245-template h245.asn */ /* Input file: packet-h245-template.h */ diff --git a/epan/dissectors/packet-icmpv6.c b/epan/dissectors/packet-icmpv6.c index 2dc9601120..b68a747dcb 100644 --- a/epan/dissectors/packet-icmpv6.c +++ b/epan/dissectors/packet-icmpv6.c @@ -613,7 +613,7 @@ dissect_nodeinfo(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree p = offset + sizeof *ni; for (i = 0; i < n; i++) { struct e_in6_addr e_in6_addr; - tvb_memcpy(tvb, (guint8 *)&e_in6_addr, p, sizeof e_in6_addr); + tvb_get_ipv6(tvb, p, &e_in6_addr); proto_tree_add_text(field_tree, tvb, p, sizeof(struct e_in6_addr), "%s", ip6_to_str(&e_in6_addr)); @@ -728,7 +728,7 @@ dissect_nodeinfo(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree struct e_in6_addr e_in6_addr; gint32 ttl; ttl = (gint32)tvb_get_ntohl(tvb, p); - tvb_memcpy(tvb, (guint8 *)&e_in6_addr, p + sizeof ttl, sizeof e_in6_addr); + tvb_get_ipv6(tvb, p + sizeof ttl, &e_in6_addr); proto_tree_add_text(field_tree, tvb, p, sizeof(struct e_in6_addr) + sizeof(gint32), "%s (TTL %d)", ip6_to_str(&e_in6_addr), ttl); @@ -955,7 +955,7 @@ dissect_mldrv2( tvbuff_t *tvb, guint32 offset, guint16 count, proto_tree *tree ) localOffset += 2; recordSize = 4 + 16 + (16 * sourceNb) + (auxDataLen * 4); - tvb_memcpy(tvb, (guint8 *)&addr, localOffset, sizeof(addr) ); + tvb_get_ipv6(tvb, localOffset, &addr); tf = proto_tree_add_text( tree, tvb, offset, recordSize, #ifdef INET6 "%s: %s (%s)", val_to_str(recordType, mldrv2ModesNames,"Unknown mode"), @@ -974,7 +974,7 @@ dissect_mldrv2( tvbuff_t *tvb, guint32 offset, guint16 count, proto_tree *tree ) localOffset += 16; for( ; sourceNb; sourceNb--, localOffset += 16 ) { - tvb_memcpy(tvb, (guint8 *)&addr, localOffset, sizeof(addr) ); + tvb_get_ipv6(tvb, localOffset, &addr); proto_tree_add_text( sub_tree, tvb, localOffset, 16, #ifdef INET6 "Source Address: %s (%s)", get_hostname6(&addr), ip6_to_str(&addr) ); @@ -991,7 +991,7 @@ dissect_mldqv2(tvbuff_t *tvb, guint32 offset, guint16 count, proto_tree *tree) struct e_in6_addr addr; for ( ; count; count--, offset += 16) { - tvb_memcpy(tvb, (guint8 *)&addr, offset, sizeof(addr)); + tvb_get_ipv6(tvb, offset, &addr); proto_tree_add_text(tree, tvb, offset, 16, "Source Address: %s (%s)", get_hostname6(&addr), ip6_to_str(&addr)); } diff --git a/epan/dissectors/packet-igmp.c b/epan/dissectors/packet-igmp.c index 0a06e89a3f..dcc31cfdd0 100644 --- a/epan/dissectors/packet-igmp.c +++ b/epan/dissectors/packet-igmp.c @@ -446,7 +446,7 @@ dissect_v3_group_record(tvbuff_t *tvb, proto_tree *parent_tree, int offset) guint16 num; guint32 ip; - tvb_memcpy(tvb, (guint8 *)&ip, offset+4, 4); + ip = tvb_get_ipv4(tvb, offset+4); item = proto_tree_add_text(parent_tree, tvb, offset, -1, "Group Record : %s %s", ip_to_str((guint8*)&ip), diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c index f40e0af37c..a9af75f16a 100644 --- a/epan/dissectors/packet-ip.c +++ b/epan/dissectors/packet-ip.c @@ -489,9 +489,7 @@ dissect_ipopt_route(const ip_tcp_opt *optp, tvbuff_t *tvb, int offset, break; } - /* Avoids alignment problems on many architectures. */ - tvb_memcpy(tvb, (guint8 *)&addr, offset + optoffset, sizeof(addr)); - + addr = tvb_get_ipv4(tvb, offset + optoffset); proto_tree_add_text(field_tree, tvb, offset + optoffset, 4, "%s%s", ((addr == 0) ? "-" : (char *)get_hostname(addr)), @@ -559,7 +557,7 @@ dissect_ipopt_timestamp(const ip_tcp_opt *optp, tvbuff_t *tvb, "(suboption would go past end of option)"); break; } - tvb_memcpy(tvb, (guint8 *)&addr, offset + optoffset, sizeof(addr)); + addr = tvb_get_ipv4(tvb, offset + optoffset); ts = tvb_get_ntohl(tvb, offset + optoffset + 4); optlen -= 8; proto_tree_add_text(field_tree, tvb, offset + optoffset, 8, diff --git a/epan/dissectors/packet-isakmp.c b/epan/dissectors/packet-isakmp.c index eb5ce61fed..bac3a7bb6c 100644 --- a/epan/dissectors/packet-isakmp.c +++ b/epan/dissectors/packet-isakmp.c @@ -39,7 +39,6 @@ #include #include -#include #include #include #include @@ -1671,7 +1670,7 @@ dissect_nat_original_address(tvbuff_t *tvb, int offset, int length, proto_tree * case 1: /* ID_IPV4_ADDR */ if (length == 4) { - tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset, length); + addr_ipv4 = tvb_get_ipv4(tvb, offset); proto_tree_add_text(tree, tvb, offset, length, "Original address: %s", ip_to_str((guint8 *)&addr_ipv4)); @@ -1684,7 +1683,7 @@ dissect_nat_original_address(tvbuff_t *tvb, int offset, int length, proto_tree * case 5: /* ID_IPV6_ADDR */ if (length == 16) { - tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset, length); + tvb_get_ipv6(tvb, offset, &addr_ipv6); proto_tree_add_text(tree, tvb, offset, length, "Original address: %s", ip6_to_str(&addr_ipv6)); diff --git a/epan/dissectors/packet-isis-lsp.c b/epan/dissectors/packet-isis-lsp.c index 27b90968df..a88d6d8b01 100644 --- a/epan/dissectors/packet-isis-lsp.c +++ b/epan/dissectors/packet-isis-lsp.c @@ -542,7 +542,7 @@ dissect_lsp_ip_reachability_clv(tvbuff_t *tvb, proto_tree *tree, int offset, * Gotta build a sub-tree for all our pieces */ if ( tree ) { - tvb_memcpy(tvb, (guint8 *)&src, offset+4, 4); + src = tvb_get_ipv4(tvb, offset+4); mask = tvb_get_ntohl(tvb, offset+8); /* find out if the mask matches one of 33 possible prefix lengths */ diff --git a/epan/dissectors/packet-isup.c b/epan/dissectors/packet-isup.c index a83f58b88b..8e8e20ca14 100644 --- a/epan/dissectors/packet-isup.c +++ b/epan/dissectors/packet-isup.c @@ -47,7 +47,6 @@ #include #include -#include #include #include #include "packet-q931.h" @@ -1970,7 +1969,7 @@ dissect_nsap(tvbuff_t *parameter_tvb,gint offset,gint len, proto_tree *parameter icp = tvb_get_ntohs(parameter_tvb, offset); proto_tree_add_uint(parameter_tree, hf_iana_icp, parameter_tvb, offset, 1, icp ); if ( icp == 0 ){ /* IPv6 addr */ - tvb_memcpy(parameter_tvb, (guint8 *)&ipv6_addr,( offset + 2 ), 16); + tvb_get_ipv6(parameter_tvb, ( offset + 2 ), &ipv6_addr); proto_tree_add_text(parameter_tree, parameter_tvb, offset + 2 , 3, "DSP = %s", tvb_bytes_to_str(parameter_tvb, offset + 2, 17)); proto_tree_add_ipv6(parameter_tree, hf_nsap_ipv6_addr, parameter_tvb, offset, @@ -1978,7 +1977,7 @@ dissect_nsap(tvbuff_t *parameter_tvb,gint offset,gint len, proto_tree *parameter } else { /* IPv4 addr */ - tvb_memcpy(parameter_tvb,(guint8 *) &addr, ( offset + 2 ), 4); + addr = tvb_get_ipv4(parameter_tvb, ( offset + 2 )); proto_tree_add_text(parameter_tree, parameter_tvb, offset + 2 , 3, "DSP = %s", tvb_bytes_to_str(parameter_tvb, offset + 2, 17)); proto_tree_add_ipv4(parameter_tree, hf_nsap_ipv4_addr, parameter_tvb, offset + 2, 4, addr); diff --git a/epan/dissectors/packet-ldp.c b/epan/dissectors/packet-ldp.c index cef613ad32..bb3ec4ae2e 100644 --- a/epan/dissectors/packet-ldp.c +++ b/epan/dissectors/packet-ldp.c @@ -1126,7 +1126,7 @@ dissect_tlv_path_vector(tvbuff_t *tvb, guint offset, proto_tree *tree, int rem) if(val_tree == NULL) return; for(ix=1; rem >= 4; ix++, offset += 4, rem -= 4) { - tvb_memcpy(tvb, (guint8 *)&addr, offset, 4); + addr = tvb_get_ipv4(tvb, offset); proto_tree_add_ipv4_format(val_tree, hf_ldp_tlv_pv_lsrid, tvb, offset, 4, addr, "LSR Id %u: %s", ix, diff --git a/epan/dissectors/packet-manolito.c b/epan/dissectors/packet-manolito.c index 96e6927237..86212bcc42 100644 --- a/epan/dissectors/packet-manolito.c +++ b/epan/dissectors/packet-manolito.c @@ -80,8 +80,8 @@ dissect_manolito(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* MANOLITO packet header (network byte order) */ header.checksum = tvb_get_ntohl(tvb, 0); header.seqno = tvb_get_ntohl(tvb, 4); - tvb_memcpy(tvb, (guint8 *)&header.src, 8, 4); - tvb_memcpy(tvb, (guint8 *)&header.dest, 12, 4); + header.src = tvb_get_ipv4(tvb, 8); + header.dest = tvb_get_ipv4(tvb, 12); if (tvb_reported_length(tvb) == 19) { header.options = (tvb_get_ntohs(tvb, 16) << 8) + diff --git a/epan/dissectors/packet-msdp.c b/epan/dissectors/packet-msdp.c index dc0234356b..88838ca09e 100644 --- a/epan/dissectors/packet-msdp.c +++ b/epan/dissectors/packet-msdp.c @@ -246,7 +246,6 @@ static void dissect_msdp_sa(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset, int length) { guint8 entries; - guint32 rp_addr; if (length < 1) return; @@ -260,7 +259,6 @@ static void dissect_msdp_sa(tvbuff_t *tvb, packet_info *pinfo, length = 0; return; } - tvb_memcpy(tvb, (guint8 *)&rp_addr, *offset, 4); proto_tree_add_item(tree, hf_msdp_sa_rp_addr, tvb, *offset, 4, FALSE); *offset += 4; length -= 4; @@ -343,7 +341,7 @@ static void add_notification_data_ipv4addr(tvbuff_t *tvb, proto_tree *tree, int proto_tree_add_item(tree, hf_msdp_not_res, tvb, *offset, 3, FALSE); *offset += 3; - tvb_memcpy(tvb, (guint8 *)&ipaddr, *offset, 4); + ipaddr = tvb_get_ipv4(tvb, *offset); proto_tree_add_ipv4_format(tree, hf_msdp_not_ipv4, tvb, *offset, 4, ipaddr, "%s: %s", addrtype, ip_to_str((guint8 *)&ipaddr)); *offset += 4; diff --git a/epan/dissectors/packet-msnip.c b/epan/dissectors/packet-msnip.c index e0ec3f0c85..dd00fc5f70 100644 --- a/epan/dissectors/packet-msnip.c +++ b/epan/dissectors/packet-msnip.c @@ -117,7 +117,7 @@ dissect_msnip_rmr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, in offset += 3; /* multicast group */ - tvb_memcpy(tvb, (guint8 *)&maddr, offset, 4); + maddr = tvb_get_ipv4(tvb, offset); proto_tree_add_ipv4(tree, hf_maddr, tvb, offset, 4, maddr); offset += 4; @@ -188,7 +188,7 @@ dissect_msnip_gm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int tree = proto_item_add_subtree(item, ett_groups); /* multicast group */ - tvb_memcpy(tvb, (guint8 *)&maddr, offset, 4); + maddr = tvb_get_ipv4(tvb, offset); proto_tree_add_ipv4(tree, hf_maddr, tvb, offset, 4, maddr); offset += 4; diff --git a/epan/dissectors/packet-msproxy.c b/epan/dissectors/packet-msproxy.c index c843fbf486..6522592ae9 100644 --- a/epan/dissectors/packet-msproxy.c +++ b/epan/dissectors/packet-msproxy.c @@ -503,7 +503,7 @@ static void dissect_request_connect(tvbuff_t *tvb, int offset, proto_tree_add_item( tree, hf_msproxy_dstaddr, tvb, offset, 4, FALSE); - tvb_memcpy( tvb, (guint8 *)&conv_info->dst_addr, offset, sizeof( guint32)); + conv_info->dst_addr = tvb_get_ipv4( tvb, offset); offset += 12; @@ -908,7 +908,7 @@ static void dissect_bind_info( tvbuff_t *tvb, int offset, packet_info *pinfo, conv_info->dst_port); offset += 2; - tvb_memcpy( tvb, (guint8 *)&conv_info->dst_addr, offset, sizeof( guint32)); + conv_info->dst_addr = tvb_get_ipv4( tvb, offset); if ( tree) proto_tree_add_item( tree, hf_msproxy_dstaddr, tvb, offset, 4, FALSE); diff --git a/epan/dissectors/packet-nbns.c b/epan/dissectors/packet-nbns.c index 39c7ac922d..146320d444 100644 --- a/epan/dissectors/packet-nbns.c +++ b/epan/dissectors/packet-nbns.c @@ -1225,7 +1225,7 @@ dissect_nbdgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) header.flags.node_type = (flags & 12) >> 2; header.dgm_id = tvb_get_ntohs(tvb, offset+2); - tvb_memcpy(tvb, (guint8 *)&header.src_ip, offset+4, 4); + header.src_ip = tvb_get_ipv4(tvb, offset+4); header.src_port = tvb_get_ntohs(tvb, offset+8); switch (header.msg_type) { diff --git a/epan/dissectors/packet-netflow.c b/epan/dissectors/packet-netflow.c index 0d961a1462..f9fd5a95fa 100644 --- a/epan/dissectors/packet-netflow.c +++ b/epan/dissectors/packet-netflow.c @@ -923,8 +923,6 @@ dissect_v9_pdu(proto_tree * pdutree, tvbuff_t * tvb, int offset, int i; for (i = 0; i < template->count; i++) { - guint32 ipv4addr; - guint8 ipv6addr[16]; guint16 type, length; nstime_t ts; @@ -993,15 +991,11 @@ dissect_v9_pdu(proto_tree * pdutree, tvbuff_t * tvb, int offset, case 8: /* source IP */ if (length == 4) { - tvb_memcpy(tvb, (guint8 *)&ipv4addr, offset, - sizeof(ipv4addr)); - proto_tree_add_ipv4(pdutree, hf_cflow_srcaddr, - tvb, offset, length, ipv4addr); + proto_tree_add_item(pdutree, hf_cflow_srcaddr, + tvb, offset, length, FALSE); } else if (length == 16) { - tvb_memcpy(tvb, ipv6addr, offset, - sizeof(ipv6addr)); - proto_tree_add_ipv6(pdutree, hf_cflow_srcaddr_v6, - tvb, offset, length, ipv6addr); + proto_tree_add_item(pdutree, hf_cflow_srcaddr_v6, + tvb, offset, length, FALSE); } else { proto_tree_add_text(pdutree, tvb, offset, length, @@ -1026,15 +1020,11 @@ dissect_v9_pdu(proto_tree * pdutree, tvbuff_t * tvb, int offset, case 12: /* dest IP */ if (length == 4) { - tvb_memcpy(tvb, (guint8 *)&ipv4addr, offset, - sizeof(ipv4addr)); - proto_tree_add_ipv4(pdutree, hf_cflow_dstaddr, - tvb, offset, length, ipv4addr); + proto_tree_add_item(pdutree, hf_cflow_dstaddr, + tvb, offset, length, FALSE); } else if (length == 16) { - tvb_memcpy(tvb, ipv6addr, offset, - sizeof(ipv6addr)); - proto_tree_add_ipv6(pdutree, hf_cflow_dstaddr_v6, - tvb, offset, length, ipv6addr); + proto_tree_add_item(pdutree, hf_cflow_dstaddr_v6, + tvb, offset, length, FALSE); } else { proto_tree_add_text(pdutree, tvb, offset, length, @@ -1054,15 +1044,11 @@ dissect_v9_pdu(proto_tree * pdutree, tvbuff_t * tvb, int offset, case 15: /* nexthop IP */ if (length == 4) { - tvb_memcpy(tvb, (guint8 *)&ipv4addr, offset, - sizeof(ipv4addr)); - proto_tree_add_ipv4(pdutree, hf_cflow_nexthop, - tvb, offset, length, ipv4addr); + proto_tree_add_item(pdutree, hf_cflow_nexthop, + tvb, offset, length, FALSE); } else if (length == 16) { - tvb_memcpy(tvb, ipv6addr, offset, - sizeof(ipv6addr)); - proto_tree_add_ipv6(pdutree, hf_cflow_nexthop_v6, - tvb, offset, length, ipv6addr); + proto_tree_add_item(pdutree, hf_cflow_nexthop_v6, + tvb, offset, length, FALSE); } else { proto_tree_add_text(pdutree, tvb, offset, length, @@ -1082,15 +1068,11 @@ dissect_v9_pdu(proto_tree * pdutree, tvbuff_t * tvb, int offset, case 18: /* BGP nexthop IP */ if (length == 4) { - tvb_memcpy(tvb, (guint8 *)&ipv4addr, offset, - sizeof(ipv4addr)); - proto_tree_add_ipv4(pdutree, hf_cflow_bgpnexthop, - tvb, offset, length, ipv4addr); + proto_tree_add_item(pdutree, hf_cflow_bgpnexthop, + tvb, offset, length, FALSE); } else if (length == 16) { - tvb_memcpy(tvb, ipv6addr, offset, - sizeof(ipv6addr)); - proto_tree_add_ipv6(pdutree, hf_cflow_bgpnexthop_v6, - tvb, offset, length, ipv6addr); + proto_tree_add_item(pdutree, hf_cflow_bgpnexthop_v6, + tvb, offset, length, FALSE); } else { proto_tree_add_text(pdutree, tvb, offset, length, @@ -1407,12 +1389,12 @@ dissect_pdu(proto_tree * pdutree, tvbuff_t * tvb, int offset, int ver) /* * memcpy so we can use the values later to calculate a prefix */ - tvb_memcpy(tvb, (guint8 *) & srcaddr, offset, 4); + srcaddr = tvb_get_ipv4(tvb, offset); proto_tree_add_ipv4(pdutree, hf_cflow_srcaddr, tvb, offset, 4, srcaddr); offset += 4; - tvb_memcpy(tvb, (guint8 *) & dstaddr, offset, 4); + dstaddr = tvb_get_ipv4(tvb, offset); proto_tree_add_ipv4(pdutree, hf_cflow_dstaddr, tvb, offset, 4, dstaddr); offset += 4; diff --git a/epan/dissectors/packet-nsip.c b/epan/dissectors/packet-nsip.c index 526a985a2f..d7bb036d56 100644 --- a/epan/dissectors/packet-nsip.c +++ b/epan/dissectors/packet-nsip.c @@ -36,7 +36,6 @@ #include #include -#include #include #define NSIP_DEBUG 0 @@ -393,8 +392,7 @@ decode_ip_element(nsip_ip_element_info_t *element, build_info_t *bi, proto_tree /* IP address */ switch (element->version) { case NSIP_IP_VERSION_4: - tvb_memcpy(bi->tvb, (guint8 *)&ip4_addr, bi->offset, - element->address_length); + ip4_addr = tvb_get_ipv4(bi->tvb, bi->offset); proto_tree_add_item(field_tree, hf_nsip_ip_address_ipv4, bi->tvb, bi->offset, element->address_length, NSIP_LITTLE_ENDIAN); @@ -403,8 +401,7 @@ decode_ip_element(nsip_ip_element_info_t *element, build_info_t *bi, proto_tree break; case NSIP_IP_VERSION_6: - tvb_memcpy(bi->tvb, (guint8 *)&ip6_addr, bi->offset, - sizeof(struct e_in6_addr)); + tvb_get_ipv6(bi->tvb, bi->offset, &ip6_addr); proto_tree_add_item(field_tree, hf_nsip_ip_address_ipv6, bi->tvb, bi->offset, element->address_length, NSIP_LITTLE_ENDIAN); @@ -530,8 +527,7 @@ decode_iei_ip_address(nsip_ie_t *ie, build_info_t *bi, int ie_start_offset) { switch (address_type) { case NSIP_IP_ADDRESS_TYPE_IPV4: ie->total_length = 2 + ipv4_element.address_length; - tvb_memcpy(bi->tvb, (guint8 *)&ip4_addr, bi->offset, - ipv4_element.address_length); + ip4_addr = tvb_get_ipv4(bi->tvb, bi->offset); if (bi->nsip_tree) { proto_tree_add_ipv4(bi->nsip_tree, hf_nsip_ip_address_ipv4, bi->tvb, ie_start_offset, ie->total_length, @@ -540,8 +536,7 @@ decode_iei_ip_address(nsip_ie_t *ie, build_info_t *bi, int ie_start_offset) { break; case NSIP_IP_ADDRESS_TYPE_IPV6: ie->total_length = 2 + ipv6_element.address_length; - tvb_memcpy(bi->tvb, (guint8 *)&ip6_addr, bi->offset, - sizeof(struct e_in6_addr)); + tvb_get_ipv6(bi->tvb, bi->offset, &ip6_addr); if (bi->nsip_tree) { proto_tree_add_ipv6(bi->nsip_tree, hf_nsip_ip_address_ipv4, bi->tvb, ie_start_offset, ie->total_length, diff --git a/epan/dissectors/packet-ntp.c b/epan/dissectors/packet-ntp.c index aa13cfc9de..9430099d33 100644 --- a/epan/dissectors/packet-ntp.c +++ b/epan/dissectors/packet-ntp.c @@ -558,7 +558,7 @@ dissect_ntp_std(tvbuff_t *tvb, proto_tree *ntp_tree, guint8 flags) } } else { buff[sizeof(buff) - 1] = '\0'; - tvb_memcpy(tvb, (guint8 *)&refid_addr, 12, 4); + refid_addr = tvb_get_ipv4(tvb, 12); strncpy (buff, get_hostname (refid_addr), sizeof(buff)); if (buff[sizeof(buff) - 1] != '\0') diff --git a/epan/dissectors/packet-olsr.c b/epan/dissectors/packet-olsr.c index 7d28d34138..74ee3c7933 100644 --- a/epan/dissectors/packet-olsr.c +++ b/epan/dissectors/packet-olsr.c @@ -48,7 +48,6 @@ #include #include -#include #define UDP_PORT_OLSR 698 #define HELLO 1 @@ -111,18 +110,6 @@ dissect_olsr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint16 packet_len; - guint32 origin_addr; - guint32 neighbor_addr; - guint32 interface_addr; - guint32 network_addr; - guint32 netmask; - struct e_in6_addr origin6_addr, *origin=&origin6_addr; - struct e_in6_addr neighbor6_addr, *neighbor=&neighbor6_addr; - struct e_in6_addr interface6_addr, *theinterface=&interface6_addr; - struct e_in6_addr network6_addr, *network=&network6_addr; - struct e_in6_addr netmask6, *netmask_v6=&netmask6; - - /* Does this packet have a valid message type at the beginning? */ if (!tvb_bytes_exist(tvb, 0, 2)) return 0; /* not enough bytes for the packet length */ @@ -202,8 +189,7 @@ dissect_olsr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /*-----------------Dissecting: Origin Addr, TTL, Hop Count, and Message Seq Number*/ if(message_size > 0) { - tvb_memcpy(tvb, (guint8*)&origin_addr, offset, 4); - proto_tree_add_ipv4(olsr_tree, hf_olsr_origin_addr, tvb, offset, 4, origin_addr); + proto_tree_add_item(olsr_tree, hf_olsr_origin_addr, tvb, offset, 4, FALSE); message_size--; packet_size--; offset+=4; @@ -228,8 +214,7 @@ dissect_olsr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) packet_size--; while(message_size>0) { - tvb_memcpy(tvb, (guint8*)&neighbor_addr, offset, 4); - proto_tree_add_ipv4(olsr_tree, hf_olsr_neighbor_addr, tvb, offset, 4, neighbor_addr); + proto_tree_add_item(olsr_tree, hf_olsr_neighbor_addr, tvb, offset, 4, FALSE); message_size--; offset+=4; packet_size--; @@ -308,8 +293,7 @@ dissect_olsr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /*-------------------Dissect Neighbor Addresses--------------------*/ while(link_message_size>0) { - tvb_memcpy(tvb, (guint8*)&neighbor_addr, offset, 4); - proto_tree_add_ipv4(olsr_tree, hf_olsr_neighbor_addr, tvb, offset, 4, neighbor_addr); + proto_tree_add_item(olsr_tree, hf_olsr_neighbor_addr, tvb, offset, 4, FALSE); offset+=4; message_size--; packet_size--; @@ -321,8 +305,7 @@ dissect_olsr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /*---------------------------------Dissect MID Message----------------------------------*/ else if(message_size>0 && message_type==MID) { while(message_size>0) { - tvb_memcpy(tvb, (guint8*)&interface_addr, offset, 4); - proto_tree_add_ipv4(olsr_tree, hf_olsr_interface_addr, tvb, offset, 4, interface_addr); + proto_tree_add_item(olsr_tree, hf_olsr_interface_addr, tvb, offset, 4, FALSE); message_size--; offset+=4; packet_size--; @@ -332,13 +315,11 @@ dissect_olsr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /*-----------------------------Dissect HNA Message--------------------------------*/ else if(message_size>0 && message_type==HNA) { while(message_size>0) { - tvb_memcpy(tvb, (guint8*)&network_addr, offset, 4); - proto_tree_add_ipv4(olsr_tree, hf_olsr_network_addr, tvb, offset, 4, network_addr); + proto_tree_add_item(olsr_tree, hf_olsr_network_addr, tvb, offset, 4, FALSE); message_size--; packet_size--; offset+=4; - tvb_memcpy(tvb, (guint8*)&netmask, offset, 4); - proto_tree_add_ipv4(olsr_tree, hf_olsr_netmask, tvb, offset, 4, netmask); + proto_tree_add_item(olsr_tree, hf_olsr_netmask, tvb, offset, 4, FALSE); message_size--; packet_size--; offset+=4; @@ -401,8 +382,7 @@ dissect_olsr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /*-----------------Dissecting: Origin Addr, TTL, Hop Count, and Message Seq Number */ if(message_size > 0) { - tvb_memcpy(tvb, (guint8*)&origin6_addr, offset, 16); - proto_tree_add_ipv6(olsr_tree, hf_olsr_origin6_addr, tvb, offset, 16, (guint8*)origin); + proto_tree_add_item(olsr_tree, hf_olsr_origin6_addr, tvb, offset, 16, FALSE); offset+=16; message_size-=4; packet_size-=4; @@ -427,8 +407,7 @@ dissect_olsr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) packet_size--; while(message_size>0) { - tvb_memcpy(tvb, (guint8*)&neighbor6_addr, offset, 16); - proto_tree_add_ipv6(olsr_tree, hf_olsr_neighbor6_addr, tvb, offset, 16, (guint8*)neighbor); + proto_tree_add_item(olsr_tree, hf_olsr_neighbor6_addr, tvb, offset, 16, FALSE); message_size-=4; offset+=16; packet_size-=4; @@ -507,8 +486,7 @@ dissect_olsr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /*--------------------------Dissect Neighbor Addresses---------------------------*/ while(link_message_size>0) { - tvb_memcpy(tvb, (guint8*)&neighbor6_addr, offset, 16); - proto_tree_add_ipv6(olsr_tree, hf_olsr_neighbor6_addr, tvb, offset, 16, (guint8*)neighbor); + proto_tree_add_item(olsr_tree, hf_olsr_neighbor6_addr, tvb, offset, 16, FALSE); offset+=16; message_size-=4; packet_size-=4; @@ -520,8 +498,7 @@ dissect_olsr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /*---------------------------------Dissect MID Message----------------------------------*/ else if(message_size>0 && message_type==MID) { while(message_size>0) { - tvb_memcpy(tvb, (guint8*)&interface6_addr, offset, 16); - proto_tree_add_ipv6(olsr_tree, hf_olsr_interface6_addr, tvb, offset, 16, (guint8*)theinterface); + proto_tree_add_item(olsr_tree, hf_olsr_interface6_addr, tvb, offset, 16, FALSE); message_size-=4; offset+=16; packet_size-=4; @@ -531,13 +508,11 @@ dissect_olsr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /*-----------------------------Dissect HNA Message--------------------------------*/ else if(message_size>0 && message_type==HNA) { while(message_size>0) { - tvb_memcpy(tvb, (guint8*)&network6_addr, offset, 16); - proto_tree_add_ipv6(olsr_tree, hf_olsr_network6_addr, tvb, offset, 16, (guint8*)network); + proto_tree_add_item(olsr_tree, hf_olsr_network6_addr, tvb, offset, 16, FALSE); offset+=16; message_size-=4; packet_size-=4; - tvb_memcpy(tvb, (guint8*)&netmask6, offset, 16); - proto_tree_add_ipv6(olsr_tree, hf_olsr_netmask6, tvb, offset, 16, (guint8*)netmask_v6); + proto_tree_add_item(olsr_tree, hf_olsr_netmask6, tvb, offset, 16, FALSE); message_size-=4; packet_size-=4; offset+=16; diff --git a/epan/dissectors/packet-quake3.c b/epan/dissectors/packet-quake3.c index 85ae3aeee6..34e34f34cb 100644 --- a/epan/dissectors/packet-quake3.c +++ b/epan/dissectors/packet-quake3.c @@ -277,7 +277,7 @@ dissect_quake3_ConnectionlessPacket(tvbuff_t *tvb, packet_info *pinfo _U_, proto_item *server_item = NULL; proto_tree *server_tree = NULL; - tvb_memcpy(tvb, (guint8 *)&ip_addr, base + 1, 4); + ip_addr = tvb_get_ipv4(tvb, base + 1); udp_port = tvb_get_ntohs(tvb, base + 5); /* It may be a good idea to create a conversation for diff --git a/epan/dissectors/packet-skinny.c b/epan/dissectors/packet-skinny.c index fca4ccbc07..ee7bb6c5ae 100644 --- a/epan/dissectors/packet-skinny.c +++ b/epan/dissectors/packet-skinny.c @@ -1393,7 +1393,7 @@ static void dissect_skinny_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr src_addr.type=AT_IPv4; src_addr.len=4; src_addr.data=(guint8 *)&ipv4_address; - tvb_memcpy(tvb, (guint8 *)&ipv4_address, offset+16, 4); + ipv4_address = tvb_get_ipv4(tvb, offset+16); rtp_add_address(pinfo, &src_addr, tvb_get_letohl(tvb, offset+20), 0, "Skinny", pinfo->fd->num, NULL); } break; @@ -1774,7 +1774,7 @@ static void dissect_skinny_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr src_addr.type=AT_IPv4; src_addr.len=4; src_addr.data=(char *)&ipv4_address; - tvb_memcpy(tvb, (char *)&ipv4_address, offset+20, 4); + ipv4_address = tvb_get_ipv4(tvb, offset+20); rtp_add_address(pinfo, &src_addr, tvb_get_letohl(tvb, offset+24), 0, "Skinny", pinfo->fd->num, NULL); } break; diff --git a/epan/dissectors/packet-socks.c b/epan/dissectors/packet-socks.c index 77c12a727c..eeba019bd4 100644 --- a/epan/dissectors/packet-socks.c +++ b/epan/dissectors/packet-socks.c @@ -342,8 +342,7 @@ static int get_address_v5(tvbuff_t *tvb, int offset, if ( a_type == 1){ /* IPv4 address */ if ( hash_info) - tvb_memcpy(tvb, (guint8 *)&hash_info->dst_addr, - offset, 4); + hash_info->dst_addr = tvb_get_ipv4(tvb, offset); offset += 4; } @@ -672,7 +671,7 @@ state_machine_v4( socks_hash_entry_t *hash_info, tvbuff_t *tvb, hash_info->port = tvb_get_ntohs(tvb, offset + 2); /* get remote address */ - tvb_memcpy(tvb, (guint8 *)&hash_info->dst_addr, offset + 4, 4); + hash_info->dst_addr = tvb_get_ipv4(tvb, offset + 4); /* save the packet pointer */ hash_info->connect_row = get_packet_ptr; diff --git a/epan/dissectors/packet-teredo.c b/epan/dissectors/packet-teredo.c index 36b0935849..174fbaff6a 100644 --- a/epan/dissectors/packet-teredo.c +++ b/epan/dissectors/packet-teredo.c @@ -153,35 +153,45 @@ static int parse_teredo_orig(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, e_teredohdr *teredoh) { + proto_item *ti = NULL; + if (check_col(pinfo->cinfo, COL_INFO)) col_append_sep_str (pinfo->cinfo, COL_INFO, ", ", "Origin indication"); if (tree) { - proto_item *ti; - guint16 port; - guint32 addr; - ti = proto_tree_add_item(tree, hf_teredo_orig, tvb, offset, 8, FALSE); tree = proto_item_add_subtree(ti, ett_teredo_orig); - offset += 2; + } + offset += 2; - port = ~tvb_get_ntohs(tvb, offset); + teredoh->th_orgport = tvb_get_ntohs(tvb, offset); + if (tree) { + /* + * The "usual arithmetic conversions" will convert + * "teredoh->th_orgport" to an "int" (because all + * "unsigned short" values will fit in an "int"), + * which will zero-extend it. This means that + * complementing it will turn all the zeroes in + * the upper 16 bits into ones; we just want the + * lower 16 bits (containing the port number) + * complemented, with the result zero-extended. + * + * That's what the cast is for. + */ proto_tree_add_uint(tree, hf_teredo_orig_port, tvb, - offset, 2, port); - offset += 2; + offset, 2, + (guint16)~teredoh->th_orgport); + } + offset += 2; - tvb_memcpy(tvb, (guint8 *)&addr, offset, 4); + teredoh->th_iporgaddr = tvb_get_ipv4(tvb, offset); + if (tree) { proto_tree_add_ipv4(tree, hf_teredo_orig_addr, tvb, - offset, 4, ~addr); - offset += 4; + offset, 4, ~teredoh->th_iporgaddr); } - else - offset += 8; - - teredoh->th_orgport = tvb_get_ntohs(tvb, offset - 6); - tvb_memcpy(tvb, (guint8 *)&teredoh->th_iporgaddr, offset-4, 4); + offset += 4; return offset; } diff --git a/epan/dissectors/packet-uma.c b/epan/dissectors/packet-uma.c index d7e012322c..c0dbe5344a 100644 --- a/epan/dissectors/packet-uma.c +++ b/epan/dissectors/packet-uma.c @@ -938,7 +938,7 @@ dissect_uma_IE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset) if ( octet == 0x57 ){ /* IPv6 */ }else{ /* All other values shall be interpreted as Ipv4 address in this version of the protocol.*/ - tvb_memcpy(tvb, (guint8 *)&sgw_ipv4_address, ie_offset, 4); + sgw_ipv4_address = tvb_get_ipv4(tvb, ie_offset); proto_tree_add_ipv4(urr_ie_tree, hf_uma_urr_sgw_ipv4, tvb, ie_offset, 4, sgw_ipv4_address); } @@ -1339,7 +1339,7 @@ dissect_uma_IE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset) if ( octet == 0x57 ){ /* IPv6 */ }else{ /* All other values shall be interpreted as Ipv4 address in this version of the protocol.*/ - tvb_memcpy(tvb, (guint8 *)&unc_ipv4_address, ie_offset, 4); + unc_ipv4_address = tvb_get_ipv4(tvb, ie_offset); proto_tree_add_ipv4(urr_ie_tree, hf_uma_urr_unc_ipv4, tvb, ie_offset, 4, unc_ipv4_address); rtp_ipv4_address = unc_ipv4_address; @@ -1363,7 +1363,7 @@ dissect_uma_IE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset) if ( octet == 0x57 ){ /* IPv6 */ }else{ /* All other values shall be interpreted as Ipv4 address in this version of the protocol.*/ - tvb_memcpy(tvb, (guint8 *)&GPRS_user_data_ipv4_address, ie_offset, 4); + GPRS_user_data_ipv4_address = tvb_get_ipv4(tvb, ie_offset); proto_tree_add_ipv4(urr_ie_tree, hf_uma_urr_GPRS_user_data_transport_ipv4, tvb, ie_offset, 4, GPRS_user_data_ipv4_address); } diff --git a/epan/dissectors/packet-wccp.c b/epan/dissectors/packet-wccp.c index 9c8adfa2fd..bdae4572e6 100644 --- a/epan/dissectors/packet-wccp.c +++ b/epan/dissectors/packet-wccp.c @@ -270,7 +270,7 @@ dissect_wccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) "Number of Web Caches: %u", cache_count); offset += 4; for (i = 0; i < cache_count; i++) { - tvb_memcpy(tvb, (guint8 *)&ipaddr, offset, 4); + ipaddr = tvb_get_ipv4(tvb, offset); proto_tree_add_ipv4_format(wccp_tree, hf_cache_ip, tvb, offset, 4, ipaddr, diff --git a/epan/dissectors/packet-wsp.c b/epan/dissectors/packet-wsp.c index e644e5bf04..6cd52b9a1d 100644 --- a/epan/dissectors/packet-wsp.c +++ b/epan/dissectors/packet-wsp.c @@ -54,7 +54,6 @@ #include #include #include -#include #include #include "packet-wap.h" @@ -4606,7 +4605,7 @@ dissect_redirect(tvbuff_t *tvb, int offset, packet_info *pinfo, */ goto unknown_address_type; } - tvb_memcpy(tvb, (guint8 *)&address_ipv4, offset, 4); + address_ipv4 = tvb_get_ipv4(tvb, offset); if (tree) { proto_tree_add_ipv4 (addr_tree, hf_address_ipv4_addr, @@ -4642,7 +4641,7 @@ dissect_redirect(tvbuff_t *tvb, int offset, packet_info *pinfo, */ goto unknown_address_type; } - tvb_memcpy(tvb, (guint8 *)&address_ipv6, offset, 16); + tvb_get_ipv6(tvb, offset, &address_ipv6); if (tree) { proto_tree_add_ipv6 (addr_tree, hf_address_ipv6_addr, @@ -4796,7 +4795,7 @@ add_addresses(proto_tree *tree, tvbuff_t *tvb, int hf) */ goto unknown_address_type; } - tvb_memcpy(tvb, (guint8 *)&address_ipv4, offset, 4); + address_ipv4 = tvb_get_ipv4(tvb, offset); proto_tree_add_ipv4 (addr_tree, hf_address_ipv4_addr, tvb, offset, 4, address_ipv4); break; @@ -4811,7 +4810,7 @@ add_addresses(proto_tree *tree, tvbuff_t *tvb, int hf) */ goto unknown_address_type; } - tvb_memcpy(tvb, (guint8 *)&address_ipv6, offset, 16); + tvb_get_ipv6(tvb, offset, &address_ipv6); proto_tree_add_ipv6 (addr_tree, hf_address_ipv6_addr, tvb, offset, 16, (guint8 *)&address_ipv6); break; diff --git a/epan/packet.c b/epan/packet.c index c68c1d04cf..45b073f1fb 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -43,7 +43,6 @@ #include "timestamp.h" #include "atalk-utils.h" -#include "ipv6-utils.h" #include "sna-utils.h" #include "osi-utils.h" #include "to_str.h" diff --git a/epan/proto.c b/epan/proto.c index a7996f4276..b6c9fcf270 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -36,7 +36,6 @@ #include "strutil.h" #include "addr_resolv.h" #include "plugins.h" -#include "ipv6-utils.h" #include "proto.h" #include "epan_dissect.h" #include "slab.h" diff --git a/epan/tvbuff.c b/epan/tvbuff.c index ae767e519c..fd3ee2c45d 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -46,7 +46,6 @@ #endif #include "pint.h" -#include "ipv6-utils.h" #include "tvbuff.h" #include "strutil.h" #include "emem.h" diff --git a/epan/tvbuff.h b/epan/tvbuff.h index f13a39ccd9..01648b0979 100644 --- a/epan/tvbuff.h +++ b/epan/tvbuff.h @@ -36,6 +36,7 @@ #define __TVBUFF_H__ #include +#include #include "exceptions.h" /** @file diff --git a/plugins/opsi/packet-opsi.c b/plugins/opsi/packet-opsi.c index c18d368879..ef36a040e4 100644 --- a/plugins/opsi/packet-opsi.c +++ b/plugins/opsi/packet-opsi.c @@ -359,7 +359,7 @@ void decode_ipv4_attribute(tvbuff_t *tvb, proto_tree *tree, int* hfValue, int of proto_tree_add_text(tree, tvb, offset, length, "Too short attribute!"); return; } - tvb_memcpy(tvb, (guint8 *)&ip_address, offset+4, 4); + ip_address = tvb_get_ipv4(tvb, offset+4); proto_tree_add_ipv4(tree, *hfValue, tvb, offset+4, 4, ip_address); } diff --git a/plugins/profinet/packet-pn-dcp.c b/plugins/profinet/packet-pn-dcp.c index 9fc5d39682..1cbb23f0cb 100644 --- a/plugins/profinet/packet-pn-dcp.c +++ b/plugins/profinet/packet-pn-dcp.c @@ -306,7 +306,7 @@ dissect_pn_ipv4(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, { guint32 data; - tvb_memcpy(tvb, (guint8 *)&data, offset, 4); + data = tvb_get_ipv4(tvb, offset); if(tree) proto_tree_add_ipv4(tree, hfindex, tvb, offset, 4, data); -- cgit v1.2.3