Wireshark-dev: [Wireshark-dev] Calculating UDP checksum
From: Rayne <hjazz6@xxxxxxxxx>
Date: Wed, 22 Apr 2009 02:32:20 -0700 (PDT)
Hi,

In packet-udp.c, the following code is used to calculate UDP checksum:

/* Set up the fields of the pseudo-header. */
      cksum_vec[0].ptr = pinfo->src.data;
      cksum_vec[0].len = pinfo->src.len;
      cksum_vec[1].ptr = pinfo->dst.data;
      cksum_vec[1].len = pinfo->dst.len;
      cksum_vec[2].ptr = (const guint8 *)&phdr;
      switch (pinfo->src.type) {

      case AT_IPv4:
	phdr[0] = g_htonl((IP_PROTO_UDP<<16) + udph->uh_ulen);
	cksum_vec[2].len = 4;
	break;

      case AT_IPv6:
        phdr[0] = g_htonl(udph->uh_ulen);
        phdr[1] = g_htonl(IP_PROTO_UDP);
        cksum_vec[2].len = 8;
        break;

      default:
        /* UDP runs only atop IPv4 and IPv6.... */
        DISSECTOR_ASSERT_NOT_REACHED();
        break;
      }
      cksum_vec[3].ptr = tvb_get_ptr(tvb, offset, udph->uh_ulen);
      cksum_vec[3].len = udph->uh_ulen;
      computed_cksum = in_cksum(&cksum_vec[0], 4);

Are 

pinfo->src.data;
pinfo->src.len;
pinfo->dst.data;
pinfo->dst.len;

equivalent to 

inet_ntoa(ip->ip_src);
4
inet_ntoa(ip->ip_dst);
4

respectively?

And does cksum_vec[3].ptr point to the beginning of the UDP header?

Thank you.

Regards,
Rayne