#include "config.h"
#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/conversation.h>
#include <epan/dissectors/packet-tcp.h>
#include <epan/expert.h>
-#include <epan/crc32.h>
+#include <wsutil/crc32.h>
/* DEFINES */
guint32 num_markers, guint32 orig_length)
{
guint8 *mfree_buff = NULL;
- const guint8 *raw_data_ptr = NULL;
guint32 mfree_buff_length, tot_copy, cur_copy;
+ guint32 source_offset;
tvbuff_t *mfree_tvb = NULL;
DISSECTOR_ASSERT(num_markers > 0);
mfree_buff_length = orig_length - (MPA_MARKER_LEN * num_markers);
mfree_buff = g_malloc(mfree_buff_length);
- if (!mfree_buff)
- THROW(OutOfMemoryError);
-
- raw_data_ptr = tvb_get_ptr(tvb, 0, -1);
tot_copy = 0;
+ source_offset = 0;
cur_copy = marker_offset;
while (tot_copy < mfree_buff_length) {
- memcpy(mfree_buff+tot_copy, raw_data_ptr, cur_copy);
+ tvb_memcpy(tvb, mfree_buff+tot_copy, source_offset, cur_copy);
tot_copy += cur_copy;
- raw_data_ptr += cur_copy + MPA_MARKER_LEN;
+ source_offset += cur_copy + MPA_MARKER_LEN;
cur_copy = MIN(MPA_MARKER_INTERVAL, (mfree_buff_length - tot_copy));
}
mfree_tvb = tvb_new_child_real_data(tvb, mfree_buff, mfree_buff_length,
|| tvb_get_ntoh64(tvb, 8) != MPA_ID_REQ_FRAME)
return FALSE;
- conversation = find_conversation(pinfo->fd->num, &pinfo->src,
- &pinfo->dst, pinfo->ptype, pinfo->srcport,
- pinfo->destport, 0);
-
- if (!conversation) {
- conversation = conversation_new(pinfo->fd->num, &pinfo->src,
- &pinfo->dst, pinfo->ptype, pinfo->srcport,
- pinfo->destport, 0);
- }
+ conversation = find_or_create_conversation(pinfo);
if (!get_mpa_state(conversation)) {
if (tree) {
mpa_item = proto_tree_add_item(tree, proto_iwarp_mpa, tvb, 0,
- -1, FALSE);
+ -1, ENC_NA);
mpa_tree = proto_item_add_subtree(mpa_item, ett_mpa);
if (message_type == MPA_REQUEST_FRAME) {
mpa_header_item = proto_tree_add_item(mpa_tree,
- hf_mpa_req, tvb, offset, -1, FALSE);
+ hf_mpa_req, tvb, offset, -1, ENC_NA);
mpa_header_tree = proto_item_add_subtree(
mpa_header_item, ett_mpa);
proto_tree_add_item(mpa_header_tree, hf_mpa_key_req,
- tvb, offset, MPA_REQ_REP_KEY_LEN, FALSE);
+ tvb, offset, MPA_REQ_REP_KEY_LEN, ENC_NA);
}
if (message_type == MPA_REPLY_FRAME) {
mpa_header_item = proto_tree_add_item(mpa_tree,
- hf_mpa_rep, tvb, offset, -1, FALSE);
+ hf_mpa_rep, tvb, offset, -1, ENC_NA);
mpa_header_tree = proto_item_add_subtree(
mpa_header_item, ett_mpa);
proto_tree_add_item(mpa_header_tree, hf_mpa_key_rep,
- tvb, offset, MPA_REQ_REP_KEY_LEN, FALSE);
+ tvb, offset, MPA_REQ_REP_KEY_LEN, ENC_NA);
}
offset += MPA_REQ_REP_KEY_LEN;
proto_tree_add_item(mpa_header_tree, hf_mpa_flag_m, tvb,
- offset, MPA_REQ_REP_FLAG_LEN, FALSE);
+ offset, MPA_REQ_REP_FLAG_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(mpa_header_tree, hf_mpa_flag_c, tvb,
- offset, MPA_REQ_REP_FLAG_LEN, FALSE);
+ offset, MPA_REQ_REP_FLAG_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(mpa_header_tree, hf_mpa_flag_r, tvb,
- offset, MPA_REQ_REP_FLAG_LEN, FALSE);
+ offset, MPA_REQ_REP_FLAG_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(mpa_header_tree, hf_mpa_flag_res, tvb,
- offset, MPA_REQ_REP_FLAG_LEN, FALSE);
+ offset, MPA_REQ_REP_FLAG_LEN, ENC_BIG_ENDIAN);
offset += MPA_REQ_REP_FLAG_LEN;
proto_tree_add_item(mpa_header_tree, hf_mpa_rev, tvb,
- offset, MPA_REQ_REP_REV_LEN, FALSE);
+ offset, MPA_REQ_REP_REV_LEN, ENC_BIG_ENDIAN);
offset += MPA_REQ_REP_REV_LEN;
/* check whether the Private Data Length conforms to RFC 5044 */
if (pd_length) {
proto_tree_add_item(mpa_header_tree,
hf_mpa_private_data, tvb, offset,
- pd_length, FALSE);
+ pd_length, ENC_NA);
}
}
return TRUE;
}
} else {
proto_tree_add_item(tree, hf_mpa_crc, tvb, offset, MPA_CRC_LEN,
- FALSE);
+ ENC_BIG_ENDIAN);
}
}
guint32 offset, i;
mpa_marker_item = proto_tree_add_item(tree, hf_mpa_marker, tvb,
- 0, -1, FALSE);
+ 0, -1, ENC_NA);
mpa_marker_tree = proto_item_add_subtree(mpa_marker_item, ett_mpa);
offset = get_first_marker_offset(state, tcpinfo, endpoint);
for (i=0; i<number_of_markers(state, tcpinfo, endpoint); i++) {
proto_tree_add_item(mpa_marker_tree, hf_mpa_marker_res, tvb,
- offset, MPA_MARKER_RSVD_LEN, FALSE);
+ offset, MPA_MARKER_RSVD_LEN, ENC_BIG_ENDIAN);
fpduptr = (guint16) tvb_get_ntohs(tvb, offset+MPA_MARKER_RSVD_LEN);
proto_tree_add_uint_format_value(mpa_marker_tree,
hf_mpa_marker_fpduptr, tvb,
}
mpa_item = proto_tree_add_item(tree, proto_iwarp_mpa, tvb, 0,
- -1, FALSE);
+ -1, ENC_NA);
mpa_tree = proto_item_add_subtree(mpa_item, ett_mpa);
mpa_header_item = proto_tree_add_item(mpa_tree, hf_mpa_fpdu,
- tvb, offset, -1, FALSE);
+ tvb, offset, -1, ENC_NA);
mpa_header_tree = proto_item_add_subtree(mpa_header_item,
ett_mpa);
tvb, pad_offset(tcpinfo,
total_length,
pad_length),
- pad_length, FALSE);
+ pad_length, ENC_NA);
}
dissect_fpdu_crc(tvb, mpa_header_tree, state,
if (pad_length > 0) {
proto_tree_add_item(mpa_header_tree, hf_mpa_pad, tvb, offset,
- pad_length, FALSE);
+ pad_length, ENC_NA);
offset += pad_length;
}
}
/* Markers are used by either the Initiator or the Responder or both. */
- if (state->ini_exp_m_res || state->res_exp_m_ini) {
+ if ((state->ini_exp_m_res || state->res_exp_m_ini) && endpoint <= MPA_RESPONDER) {
/* find the TCP sequence number of the first FPDU */
if (!state->minfo[endpoint].valid) {
return FALSE;
/* removes Markers if any and prepares new tvbuff for next dissector */
- if (state->minfo[endpoint].valid
+ if (endpoint <= MPA_RESPONDER && state->minfo[endpoint].valid
&& number_of_markers(state, tcpinfo, endpoint) > 0) {
next_tvb = tvb_new_subset(remove_markers(tvb, pinfo,
get_first_marker_offset(state, tcpinfo, endpoint),