Remove iplen and iphdrlen from struct _packet_info.

Dissectors should just use (reported) tvb length and taps have other ways to get the data.

svn path=/trunk/; revision=52899
This commit is contained in:
Michael Mann 2013-10-27 20:38:42 +00:00
parent 63ff652b8e
commit 8c64c5da89
11 changed files with 14 additions and 21 deletions

View File

@ -786,7 +786,7 @@ dissect_coap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
/* initialize the CoAP length and the content-Format */
/*
* the length of CoAP message is not specified in the CoAP header.
* It has to be from the lower layer. the iplen of packet_info is not accurate.
* It has to be from the lower layer.
* Currently, the length is just copied from the reported length of the tvbuffer.
*/
coap_length = tvb_reported_length(tvb);

View File

@ -867,7 +867,7 @@ aoslos_data_zone_dissector ( proto_tree* ehs_tree, tvbuff_t* tvb, int* offset, p
proto_tree *ehs_data_zone_tree;
/* create the data zone tree */
ehs_data_zone = proto_tree_add_text ( ehs_tree, tvb, *offset, pinfo->iplen - IP_HEADER_LENGTH - *offset, "AOS/LOS Data Zone" );
ehs_data_zone = proto_tree_add_text ( ehs_tree, tvb, *offset, tvb_reported_length(tvb) - *offset, "AOS/LOS Data Zone" );
ehs_data_zone_tree = proto_item_add_subtree ( ehs_data_zone, ett_ehs_data_zone );
/* since the aos/los EHS packet data zone is well known, format it for display as well
@ -902,7 +902,7 @@ udsm_data_zone_dissector ( proto_tree* ehs_tree, tvbuff_t* tvb, int* offset, pac
int year, jday, hour, minute, second;
/* create the data zone tree */
ehs_data_zone = proto_tree_add_text ( ehs_tree, tvb, *offset, pinfo->iplen - IP_HEADER_LENGTH - *offset, "UDSM Data Zone" );
ehs_data_zone = proto_tree_add_text ( ehs_tree, tvb, *offset, tvb_reported_length(tvb) - *offset, "UDSM Data Zone" );
ehs_data_zone_tree = proto_item_add_subtree ( ehs_data_zone, ett_ehs_data_zone );
proto_tree_add_item ( ehs_data_zone_tree, hf_ehs_dz_udsm_ccsds_vs_bpdu, tvb, *offset, 1, ENC_BIG_ENDIAN );

View File

@ -909,7 +909,7 @@ dissect_igmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
switch (type) {
case IGMP_V1_HOST_MEMBERSHIP_QUERY: /* 0x11 v1/v2/v3 */
if ( (pinfo->iplen-pinfo->iphdrlen)>=12 ) {
if ( tvb_reported_length(tvb)>=12 ) {
/* version 3 */
offset = dissect_igmp_v3_query(tvb, pinfo, tree, type, offset);
} else {
@ -967,7 +967,7 @@ dissect_igmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
break;
case IGMP_TYPE_0x25:
if ( (pinfo->iplen-pinfo->iphdrlen)>=8 ) {
if ( tvb_reported_length(tvb)>=8 ) {
/* if len of igmp packet>=8 we assume it is MSNIP */
offset = dissect_msnip(tvb, pinfo, parent_tree, offset);
} else {

View File

@ -2314,8 +2314,6 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
}
pinfo->ipproto = iph->ip_p;
pinfo->iplen = iph->ip_len;
pinfo->iphdrlen = hlen;
tap_queue_packet(ip_tap, pinfo, iph);
/* Skip over header + options */
@ -2328,14 +2326,14 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
*/
save_fragmented = pinfo->fragmented;
if (ip_defragment && (iph->ip_off & (IP_MF|IP_OFFSET)) &&
tvb_bytes_exist(tvb, offset, pinfo->iplen - pinfo->iphdrlen) &&
tvb_bytes_exist(tvb, offset, iph->ip_len - hlen) &&
ipsum == 0) {
ipfd_head = fragment_add_check(&ip_reassembly_table, tvb, offset,
pinfo,
iph->ip_p ^ iph->ip_id ^ src32 ^ dst32,
NULL,
(iph->ip_off & IP_OFFSET) * 8,
pinfo->iplen - pinfo->iphdrlen,
iph->ip_len - hlen,
iph->ip_off & IP_MF);
next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled IPv4",

View File

@ -2093,8 +2093,6 @@ again:
/* collect packet info */
pinfo->ipproto = nxt;
pinfo->iplen = (int)sizeof(ipv6) + plen + offset;
pinfo->iphdrlen = offset;
tap_queue_packet(ipv6_tap, pinfo, &ipv6);
if (offlg & IP6F_OFF_MASK || (ipv6_reassemble && offlg & IP6F_MORE_FRAG)) {

View File

@ -485,7 +485,7 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
}
}
} else {
udph->uh_ulen = pinfo->iplen - pinfo->iphdrlen;
udph->uh_ulen = tvb_reported_length(tvb);
udph->uh_sum_cov = tvb_get_ntohs(tvb, offset+4);
if (((udph->uh_sum_cov > 0) && (udph->uh_sum_cov < 8)) || (udph->uh_sum_cov > udph->uh_ulen)) {
/* Bogus length - it includes the header, so it must be >= 8, and no larger then the IP payload size. */

View File

@ -402,7 +402,7 @@ dissect_vcdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
new_offset = offset + 2 + new_ptr;
packet_boundary =
pinfo->iplen - IP_HEADER_LENGTH - VCDU_HEADER_LENGTH
tvb_reported_length(tvb) - VCDU_HEADER_LENGTH
- CCSDS_PRIMARY_HEADER_LENGTH - CCSDS_SECONDARY_HEADER_LENGTH;
while ( ((new_offset-offset+2) < packet_boundary) && ((new_offset-offset+2) >= 4) )

View File

@ -136,9 +136,6 @@ typedef struct _packet_info {
*/
guint32 bytes_until_next_pdu;
int iplen; /**< total length of IP packet */
int iphdrlen; /**< length of IP header */
guint8 ip_ttl; /**< IP time to live */
int p2p_dir; /**< Packet was captured as an
outbound (P2P_DIR_SENT)

View File

@ -131,7 +131,7 @@ comparestat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const
cksum_vec[2].ptr=(const guint8 *)ci->ip_dst.data;
cksum_vec[2].ptr=cksum_vec[2].ptr+ci->ip_dst.len;
/* dynamic computation */
cksum_vec[2].len=pinfo->iphdrlen-20;
cksum_vec[2].len=ci->ip_len-20;
computed_cksum=in_cksum(&cksum_vec[0], 3);
/* collect all packet infos */

View File

@ -206,7 +206,7 @@ comparestat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const
cksum_vec[2].ptr=(guint8 *)ci->ip_dst.data;
cksum_vec[2].ptr=cksum_vec[2].ptr+ci->ip_dst.len;
/* dynamic computation */
cksum_vec[2].len=pinfo->iphdrlen-20;
cksum_vec[2].len=ci->ip_len-20;
computed_cksum=in_cksum(&cksum_vec[0], 3);
/* Set up the new order to create the zebra effect */

View File

@ -651,8 +651,8 @@ int rtp_packet_analyse(tap_rtp_stat_t *statinfo,
statinfo->sumtTS += 1.0 * current_time * nominaltime;
}
/* Calculate the BW in Kbps adding the IP+UDP header to the RTP -> IP header+8bytes(UDP) */
statinfo->bw_history[statinfo->bw_index].bytes = rtpinfo->info_data_len + pinfo->iphdrlen + 8;
/* Calculate the BW in Kbps adding the IP+UDP header to the RTP -> 20bytes(IP) + 8bytes(UDP) */
statinfo->bw_history[statinfo->bw_index].bytes = rtpinfo->info_data_len + 28;
statinfo->bw_history[statinfo->bw_index].time = current_time;
/* Check if there are more than 1sec in the history buffer to calculate BW in bps. If so, remove those for the calculation */
@ -662,7 +662,7 @@ int rtp_packet_analyse(tap_rtp_stat_t *statinfo,
if (statinfo->bw_start_index == BUFF_BW) statinfo->bw_start_index=0;
};
/* IP hdr + UDP + RTP */
statinfo->total_bytes += rtpinfo->info_data_len + pinfo->iphdrlen + 8;
statinfo->total_bytes += rtpinfo->info_data_len + 28;
statinfo->bandwidth = (double)(statinfo->total_bytes*8)/1000;
statinfo->bw_index++;
if (statinfo->bw_index == BUFF_BW) statinfo->bw_index = 0;