MAC/RLC/PDCP LTE: replace obsolete APIs

Change-Id: I5368cc7b1986c6a87cb70a3fd3cb5e589d73f870
Reviewed-on: https://code.wireshark.org/review/1520
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
This commit is contained in:
Pascal Quantin 2014-05-05 22:32:33 +02:00 committed by Martin Mathieson
parent eecc1353a2
commit 542b4e6742
3 changed files with 47 additions and 47 deletions

View File

@ -2067,7 +2067,7 @@ gboolean dissect_mac_lte_context_fields(struct mac_lte_info *p_mac_lte_info, tv
case MAC_LTE_PAYLOAD_TAG:
/* Have reached data, so set payload length and get out of loop */
/* TODO: this is not correct if there is padding which isn't in frame */
p_mac_lte_info->length= tvb_length_remaining(tvb, offset);
p_mac_lte_info->length= tvb_reported_length_remaining(tvb, offset);
continue;
default:
@ -2107,7 +2107,7 @@ static gboolean dissect_mac_lte_heur(tvbuff_t *tvb, packet_info *pinfo,
- fixed header bytes
- tag for data
- at least one byte of MAC PDU payload */
if (tvb_length_remaining(tvb, offset) < (gint)(strlen(MAC_LTE_START_STRING)+3+2)) {
if (tvb_captured_length_remaining(tvb, offset) < (gint)(strlen(MAC_LTE_START_STRING)+3+2)) {
return FALSE;
}
@ -2608,7 +2608,7 @@ static void dissect_rar(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro
tap_info->number_of_rars += number_of_rars;
/* Padding may follow */
if (tvb_length_remaining(tvb, offset) > 0) {
if (tvb_reported_length_remaining(tvb, offset) > 0) {
proto_tree_add_item(tree, hf_mac_lte_padding_data,
tvb, offset, -1, ENC_NA);
}
@ -2631,7 +2631,7 @@ static void dissect_bch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
write_pdu_label_and_info(pdu_ti, NULL, pinfo,
"BCH PDU (%u bytes, on %s transport) ",
tvb_length_remaining(tvb, offset),
tvb_reported_length_remaining(tvb, offset),
val_to_str_const(p_mac_lte_info->rntiType,
bch_transport_channel_vals,
"Unknown"));
@ -2682,7 +2682,7 @@ static void dissect_pch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
write_pdu_label_and_info(pdu_ti, NULL, pinfo,
"PCH PDU (%u bytes) ",
tvb_length_remaining(tvb, offset));
tvb_reported_length_remaining(tvb, offset));
/****************************************/
/* Whole frame is PCH data */
@ -3000,7 +3000,7 @@ static void TrackReportedULHARQResend(packet_info *pinfo, tvbuff_t *tvb, volatil
lastData = &(ueData->harqid[p_mac_lte_info->detailed_phy_info.ul_info.harq_id]);
if (lastData->inUse) {
/* Compare time, sf, data to see if this looks like a retx */
if ((tvb_length_remaining(tvb, offset) == lastData->length) &&
if ((tvb_reported_length_remaining(tvb, offset) == lastData->length) &&
(p_mac_lte_info->detailed_phy_info.ul_info.ndi == lastData->ndi) &&
tvb_memeql(tvb, offset, lastData->data, MIN(lastData->length, MAX_EXPECTED_PDU_LENGTH)) == 0) {
@ -3050,7 +3050,7 @@ static void TrackReportedULHARQResend(packet_info *pinfo, tvbuff_t *tvb, volatil
/* Store this frame's details in table */
thisData = &(ueData->harqid[p_mac_lte_info->detailed_phy_info.ul_info.harq_id]);
thisData->inUse = TRUE;
thisData->length = tvb_length_remaining(tvb, offset);
thisData->length = tvb_reported_length_remaining(tvb, offset);
tvb_memcpy(tvb, thisData->data, offset, MIN(thisData->length, MAX_EXPECTED_PDU_LENGTH));
thisData->ndi = p_mac_lte_info->detailed_phy_info.ul_info.ndi;
thisData->framenum = pinfo->fd->num;
@ -3860,7 +3860,7 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
/* For DL, see if this is a retx. Use whole PDU present (i.e. ignore padding if not logged) */
if (direction == DIRECTION_DOWNLINK) {
/* Result will be added to context tree */
TrackReportedDLHARQResend(pinfo, tvb, tvb_length_remaining(tvb, 0), context_tree, p_mac_lte_info);
TrackReportedDLHARQResend(pinfo, tvb, tvb_reported_length_remaining(tvb, 0), context_tree, p_mac_lte_info);
tap_info->isPHYRetx = (p_mac_lte_info->dl_retx == dl_retx_yes);
}
@ -4098,7 +4098,7 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
if (pdu_lengths[n] == -1) {
/* Control Element size is the remaining PDU */
pdu_lengths[n] = (gint16)tvb_length_remaining(tvb, curr_offset);
pdu_lengths[n] = (gint16)tvb_reported_length_remaining(tvb, curr_offset);
}
/* Create EPHR root */
@ -4465,7 +4465,7 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
}
/* There might not be any data, if only headers (plus control data) were logged */
is_truncated = ((tvb_length_remaining(tvb, offset) == 0) && expecting_body_data);
is_truncated = ((tvb_reported_length_remaining(tvb, offset) == 0) && expecting_body_data);
truncated_ti = proto_tree_add_uint(tree, hf_mac_lte_sch_header_only, tvb, 0, 0,
is_truncated);
if (is_truncated) {
@ -4496,7 +4496,7 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
/* Work out length */
data_length = (pdu_lengths[n] == -1) ?
tvb_length_remaining(tvb, offset) :
tvb_reported_length_remaining(tvb, offset) :
pdu_lengths[n];
/* Dissect SDU as raw bytes */
@ -4642,7 +4642,7 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
/* Now padding, if present, extends to the end of the PDU */
if (lcids[number_of_headers-1] == PADDING_LCID) {
if (tvb_length_remaining(tvb, offset) > 0) {
if (tvb_reported_length_remaining(tvb, offset) > 0) {
proto_tree_add_item(tree, hf_mac_lte_padding_data,
tvb, offset, -1, ENC_NA);
}
@ -4958,7 +4958,7 @@ static void dissect_mch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro
if (pdu_lengths[n] == -1) {
/* Control Element size is the remaining PDU */
pdu_lengths[n] = (gint16)tvb_length_remaining(tvb, curr_offset);
pdu_lengths[n] = (gint16)tvb_reported_length_remaining(tvb, curr_offset);
}
if (pdu_lengths[n] & 0x01) {
expert_add_info_format(pinfo, sched_info_ti, &ei_mac_lte_context_length,
@ -5001,7 +5001,7 @@ static void dissect_mch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro
/* There might not be any data, if only headers (plus control data) were logged */
is_truncated = ((tvb_length_remaining(tvb, offset) == 0) && expecting_body_data);
is_truncated = ((tvb_reported_length_remaining(tvb, offset) == 0) && expecting_body_data);
truncated_ti = proto_tree_add_uint(tree, hf_mac_lte_mch_header_only, tvb, 0, 0,
is_truncated);
if (is_truncated) {
@ -5030,7 +5030,7 @@ static void dissect_mch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro
/* Work out length */
data_length = (pdu_lengths[n] == -1) ?
tvb_length_remaining(tvb, offset) :
tvb_reported_length_remaining(tvb, offset) :
pdu_lengths[n];
if ((lcids[n] == 0) && global_mac_lte_attempt_mcch_decode) {
@ -5067,7 +5067,7 @@ static void dissect_mch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro
/* Now padding, if present, extends to the end of the PDU */
if (lcids[number_of_headers-1] == PADDING_LCID) {
if (tvb_length_remaining(tvb, offset) > 0) {
if (tvb_reported_length_remaining(tvb, offset) > 0) {
proto_tree_add_item(tree, hf_mac_lte_padding_data,
tvb, offset, -1, ENC_NA);
}
@ -5484,7 +5484,7 @@ int dissect_mac_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
PROTO_ITEM_SET_HIDDEN(hidden_root_ti);
/* Also set total number of bytes (won't be used for UL/DL-SCH) */
tap_info->single_number_of_bytes = tvb_length_remaining(tvb, offset);
tap_info->single_number_of_bytes = tvb_reported_length_remaining(tvb, offset);
/* If we know its predefined data, don't try to decode any further */
if (p_mac_lte_info->isPredefinedData) {
@ -5492,7 +5492,7 @@ int dissect_mac_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
write_pdu_label_and_info(pdu_ti, NULL, pinfo,
"Predefined data (%u bytes%s)",
p_mac_lte_info->length,
(p_mac_lte_info->length > tvb_length_remaining(tvb, offset) ?
(p_mac_lte_info->length > tvb_reported_length_remaining(tvb, offset) ?
" - truncated" :
""));
@ -5510,7 +5510,7 @@ int dissect_mac_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
(p_mac_lte_info->crcStatus != crc_success))) {
proto_tree_add_item(mac_lte_tree, hf_mac_lte_raw_pdu, tvb, offset, -1, ENC_NA);
write_pdu_label_and_info(pdu_ti, NULL, pinfo, "Raw data (%u bytes)", tvb_length_remaining(tvb, offset));
write_pdu_label_and_info(pdu_ti, NULL, pinfo, "Raw data (%u bytes)", tvb_reported_length_remaining(tvb, offset));
/* For uplink grants, update SR status. N.B. only newTx grant should stop SR */
if ((p_mac_lte_info->direction == DIRECTION_UPLINK) && (p_mac_lte_info->reTxCount == 0) &&

View File

@ -1271,7 +1271,7 @@ static gboolean dissect_pdcp_lte_heur(tvbuff_t *tvb, packet_info *pinfo,
- fixed header bytes
- tag for data
- at least one byte of PDCP PDU payload */
if (tvb_length_remaining(tvb, offset) < (gint)(strlen(PDCP_LTE_START_STRING)+3+2)) {
if (tvb_captured_length_remaining(tvb, offset) < (gint)(strlen(PDCP_LTE_START_STRING)+3+2)) {
return FALSE;
}
@ -1531,7 +1531,7 @@ static tvbuff_t *decipher_payload(tvbuff_t *tvb, packet_info *pinfo, int *offset
}
/* Extract the encrypted data into a buffer */
payload_length = tvb_length_remaining(tvb, *offset);
payload_length = tvb_captured_length_remaining(tvb, *offset);
decrypted_data = (guint8 *)g_malloc0(payload_length);
tvb_memcpy(tvb, decrypted_data, *offset, payload_length);
@ -1554,7 +1554,7 @@ static tvbuff_t *decipher_payload(tvbuff_t *tvb, packet_info *pinfo, int *offset
/* SNOW-3G */
if (pdu_security_settings->ciphering == eea1) {
/* Extract the encrypted data into a buffer */
payload_length = tvb_length_remaining(tvb, *offset);
payload_length = tvb_captured_length_remaining(tvb, *offset);
decrypted_data = (guint8 *)g_malloc0(payload_length+4);
tvb_memcpy(tvb, decrypted_data, *offset, payload_length);
@ -1607,7 +1607,7 @@ static guint32 calculate_digest(pdu_security_settings_t *pdu_security_settings,
case eia1:
{
guint8 *mac;
gint message_length = tvb_length_remaining(tvb, offset) - 4;
gint message_length = tvb_captured_length_remaining(tvb, offset) - 4;
guint8 *message_data = (guint8 *)g_malloc0(message_length+5);
message_data[0] = header;
tvb_memcpy(tvb, message_data+1, offset, message_length);
@ -1651,7 +1651,7 @@ static guint32 calculate_digest(pdu_security_settings_t *pdu_security_settings,
}
/* Extract the encrypted data into a buffer */
message_length = tvb_length_remaining(tvb, offset) - 4;
message_length = tvb_captured_length_remaining(tvb, offset) - 4;
message_data = (guint8 *)g_malloc0(message_length+9);
message_data[0] = (pdu_security_settings->count & 0xff000000) >> 24;
message_data[1] = (pdu_security_settings->count & 0x00ff0000) >> 16;
@ -1845,7 +1845,7 @@ static void dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
write_pdu_label_and_info(root_ti, pinfo, " sn=%-2u ", seqnum);
offset++;
if (tvb_length_remaining(tvb, offset) == 0) {
if (tvb_reported_length_remaining(tvb, offset) == 0) {
/* Only PDCP header was captured, stop dissection here */
return;
}
@ -1961,13 +1961,13 @@ static void dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
}
/* Bitmap tree */
if (tvb_length_remaining(tvb, offset) > 0) {
if (tvb_reported_length_remaining(tvb, offset) > 0) {
bitmap_ti = proto_tree_add_item(pdcp_tree, hf_pdcp_lte_bitmap, tvb,
offset, -1, ENC_NA);
bitmap_tree = proto_item_add_subtree(bitmap_ti, ett_pdcp_report_bitmap);
buff = (gchar *)wmem_alloc(wmem_packet_scope(), BUFF_SIZE);
len = tvb_length_remaining(tvb, offset);
len = tvb_reported_length_remaining(tvb, offset);
bit_offset = offset<<3;
/* For each byte... */
for (i=0; i<len; i++) {
@ -2073,8 +2073,8 @@ static void dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
if (rrc_handle != 0) {
/* Call RRC dissector if have one */
tvbuff_t *rrc_payload_tvb = tvb_new_subset(payload_tvb, offset,
tvb_length_remaining(payload_tvb, offset) - 4,
tvb_length_remaining(payload_tvb, offset) - 4);
tvb_captured_length_remaining(payload_tvb, offset) - 4,
tvb_reported_length_remaining(payload_tvb, offset) - 4);
gboolean was_writable = col_get_writable(pinfo->cinfo);
/* We always want to see this in the info column */
@ -2088,7 +2088,7 @@ static void dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
else {
/* Just show data */
proto_tree_add_item(pdcp_tree, hf_pdcp_lte_signalling_data, payload_tvb, offset,
tvb_length_remaining(tvb, offset) - 4, ENC_NA);
tvb_reported_length_remaining(tvb, offset) - 4, ENC_NA);
}
if (!pinfo->fd->flags.visited &&
@ -2103,10 +2103,10 @@ static void dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
else {
/* Just show as unparsed data */
proto_tree_add_item(pdcp_tree, hf_pdcp_lte_signalling_data, payload_tvb, offset,
tvb_length_remaining(tvb, offset) - 4, ENC_NA);
tvb_reported_length_remaining(tvb, offset) - 4, ENC_NA);
}
data_length = tvb_length_remaining(payload_tvb, offset) - 4;
data_length = tvb_reported_length_remaining(payload_tvb, offset) - 4;
offset += data_length;
/* Last 4 bytes are MAC */
@ -2134,7 +2134,7 @@ static void dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
/* If not compressed with ROHC, show as user-plane data */
if (!p_pdcp_info->rohc.rohc_compression) {
gint payload_length = tvb_length_remaining(payload_tvb, offset);
gint payload_length = tvb_reported_length_remaining(payload_tvb, offset);
if (payload_length > 0) {
if (p_pdcp_info->plane == USER_PLANE) {

View File

@ -1510,7 +1510,7 @@ static sequence_analysis_state checkChannelSequenceInfo(packet_info *pinfo, tvbu
if (!last_includes_end &&
((number_of_segments > 1) || first_includes_start)) {
guint16 lastSegmentLength = tvb_length(tvb)-lastSegmentOffset;
guint16 lastSegmentLength = tvb_reported_length(tvb)-lastSegmentOffset;
if (global_rlc_lte_reassembly) {
reassembly_reset(p_channel_status);
@ -1616,7 +1616,7 @@ static sequence_analysis_state checkChannelSequenceInfo(packet_info *pinfo, tvbu
if (!last_includes_end &&
((number_of_segments > 1) || first_includes_start)) {
guint16 lastSegmentLength = tvb_length(tvb)-lastSegmentOffset;
guint16 lastSegmentLength = tvb_reported_length(tvb)-lastSegmentOffset;
if (global_rlc_lte_reassembly) {
reassembly_reset(p_channel_status);
reassembly_add_segment(p_channel_status, sequenceNumber,
@ -1957,7 +1957,7 @@ static void dissect_rlc_lte_tm(tvbuff_t *tvb, packet_info *pinfo,
raw_tm_ti = proto_tree_add_item(tree, hf_rlc_lte_tm_data, tvb, offset, -1, ENC_NA);
if (!global_rlc_lte_call_rrc_for_ccch) {
write_pdu_label_and_info(top_ti, NULL, pinfo,
" [%u-bytes]", tvb_length_remaining(tvb, offset));
" [%u-bytes]", tvb_reported_length_remaining(tvb, offset));
}
if (global_rlc_lte_call_rrc_for_ccch) {
@ -2125,7 +2125,7 @@ static void dissect_rlc_lte_um(tvbuff_t *tvb, packet_info *pinfo,
if (global_rlc_lte_headers_expected) {
/* There might not be any data, if only headers (plus control data) were logged */
is_truncated = (tvb_length_remaining(tvb, offset) == 0);
is_truncated = (tvb_reported_length_remaining(tvb, offset) == 0);
truncated_ti = proto_tree_add_uint(tree, hf_rlc_lte_header_only, tvb, 0, 0,
is_truncated);
if (is_truncated) {
@ -2215,7 +2215,7 @@ static void dissect_rlc_lte_um(tvbuff_t *tvb, packet_info *pinfo,
((s_number_of_extensions == 0) ? first_includes_start : TRUE) && last_includes_end,
(s_number_of_extensions == 0) ? reassembly_info : NULL,
seq_anal_state);
show_PDU_in_info(pinfo, top_ti, (guint16)tvb_length_remaining(tvb, offset),
show_PDU_in_info(pinfo, top_ti, (guint16)tvb_reported_length_remaining(tvb, offset),
(s_number_of_extensions == 0) ? first_includes_start : TRUE,
last_includes_end);
}
@ -2368,11 +2368,11 @@ static void dissect_rlc_lte_am_status_pdu(tvbuff_t *tvb,
/* Check that we've reached the end of the PDU. If not, show malformed */
offset = (bit_offset+7) / 8;
if (tvb_length_remaining(tvb, offset) > 0) {
if (tvb_reported_length_remaining(tvb, offset) > 0) {
expert_add_info_format(pinfo, status_ti, &ei_rlc_lte_bytes_after_status_pdu_complete,
"%cL %u bytes remaining after Status PDU complete",
(p_rlc_lte_info->direction == DIRECTION_UPLINK) ? 'U' : 'D',
tvb_length_remaining(tvb, offset));
tvb_reported_length_remaining(tvb, offset));
}
/* Set selected length of control tree */
@ -2518,7 +2518,7 @@ static void dissect_rlc_lte_am(tvbuff_t *tvb, packet_info *pinfo,
/* There might not be any data, if only headers (plus control data) were logged */
if (global_rlc_lte_headers_expected) {
is_truncated = (tvb_length_remaining(tvb, offset) == 0);
is_truncated = (tvb_reported_length_remaining(tvb, offset) == 0);
truncated_ti = proto_tree_add_uint(tree, hf_rlc_lte_header_only, tvb, 0, 0,
is_truncated);
if (is_truncated) {
@ -2559,7 +2559,7 @@ static void dissect_rlc_lte_am(tvbuff_t *tvb, packet_info *pinfo,
firstSegmentLength = s_lengths[0];
}
else {
firstSegmentLength = tvb_length_remaining(tvb, offset);
firstSegmentLength = tvb_reported_length_remaining(tvb, offset);
}
seq_anal_state = checkChannelSequenceInfo(pinfo, tvb, p_rlc_lte_info, FALSE,
@ -2601,12 +2601,12 @@ static void dissect_rlc_lte_am(tvbuff_t *tvb, packet_info *pinfo,
}
/* Final data element */
if (tvb_length_remaining(tvb, offset) > 0) {
if (tvb_reported_length_remaining(tvb, offset) > 0) {
show_PDU_in_tree(pinfo, tree, tvb, offset, -1, p_rlc_lte_info,
((s_number_of_extensions == 0) ? first_includes_start : TRUE) && last_includes_end,
(s_number_of_extensions == 0) ? reassembly_info : NULL,
seq_anal_state);
show_PDU_in_info(pinfo, top_ti, (guint16)tvb_length_remaining(tvb, offset),
show_PDU_in_info(pinfo, top_ti, (guint16)tvb_reported_length_remaining(tvb, offset),
(s_number_of_extensions == 0) ? first_includes_start : TRUE,
last_includes_end);
}
@ -2651,7 +2651,7 @@ static gboolean dissect_rlc_lte_heur(tvbuff_t *tvb, packet_info *pinfo,
- fixed header bytes
- tag for data
- at least one byte of RLC PDU payload */
if (tvb_length_remaining(tvb, offset) < (gint)(strlen(RLC_LTE_START_STRING)+1+2)) {
if (tvb_captured_length_remaining(tvb, offset) < (gint)(strlen(RLC_LTE_START_STRING)+1+2)) {
return FALSE;
}
@ -2710,7 +2710,7 @@ static gboolean dissect_rlc_lte_heur(tvbuff_t *tvb, packet_info *pinfo,
case RLC_LTE_PAYLOAD_TAG:
/* Have reached data, so set payload length and get out of loop */
p_rlc_lte_info->pduLength= tvb_length_remaining(tvb, offset);
p_rlc_lte_info->pduLength= tvb_reported_length_remaining(tvb, offset);
continue;
default:
@ -2897,7 +2897,7 @@ static void dissect_rlc_lte_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree
/* Predefined data (i.e. not containing a valid RLC header */
proto_tree_add_item(rlc_lte_tree, hf_rlc_lte_predefined_pdu, tvb, offset, -1, ENC_NA);
write_pdu_label_and_info(top_ti, NULL, pinfo, " [%u-bytes]",
tvb_length_remaining(tvb, offset));
tvb_reported_length_remaining(tvb, offset));
break;
default: