这篇教程C++ tvb_reported_length函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中tvb_reported_length函数的典型用法代码示例。如果您正苦于以下问题:C++ tvb_reported_length函数的具体用法?C++ tvb_reported_length怎么用?C++ tvb_reported_length使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了tvb_reported_length函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: dissect_wtp_common/* Code to actually dissect the packets */static voiddissect_wtp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ char *szInfo; int offCur = 0; /* current offset from start of WTP data */ gint returned_length, str_index = 0; unsigned char b0; /* continuation flag */ unsigned char fCon; /* Continue flag */ unsigned char fRID; /* Re-transmission indicator*/ unsigned char fTTR = '/0'; /* Transmission trailer */ guint cbHeader = 0; /* Fixed header length */ guint vHeader = 0; /* Variable header length*/ int abortType = 0; /* Set up structures we'll need to add the protocol subtree and manage it */ proto_item *ti = NULL; proto_tree *wtp_tree = NULL; char pdut; char clsTransaction = 3; int numMissing = 0; /* Number of missing packets in a negative ack */ int i; tvbuff_t *wsp_tvb = NULL; guint8 psn = 0; /* Packet sequence number*/ guint16 TID = 0; /* Transaction-Id */ int dataOffset; gint dataLen;#define SZINFO_SIZE 256 szInfo=(char *)wmem_alloc(wmem_packet_scope(), SZINFO_SIZE); b0 = tvb_get_guint8 (tvb, offCur + 0); /* Discover Concatenated PDUs */ if (b0 == 0) { guint c_fieldlen = 0; /* Length of length-field */ guint c_pdulen = 0; /* Length of conc. PDU */ if (tree) { ti = proto_tree_add_item(tree, proto_wtp, tvb, offCur, 1, ENC_NA); wtp_tree = proto_item_add_subtree(ti, ett_wtp_sub_pdu_tree); proto_item_append_text(ti, ", PDU concatenation"); } offCur = 1; i = 1; while (offCur < (int) tvb_reported_length(tvb)) { tvbuff_t *wtp_tvb; /* The length of an embedded WTP PDU is coded as either: * - a 7-bit value contained in one octet with highest bit == 0. * - a 15-bit value contained in two octets (little endian) * if the 1st octet has its highest bit == 1. * This means that this is NOT encoded as an uintvar-integer!!! */ b0 = tvb_get_guint8(tvb, offCur + 0); if (b0 & 0x80) { c_fieldlen = 2; c_pdulen = ((b0 & 0x7f) << 8) | tvb_get_guint8(tvb, offCur + 1); } else { c_fieldlen = 1; c_pdulen = b0; } if (tree) { proto_tree_add_uint(wtp_tree, hf_wtp_header_sub_pdu_size, tvb, offCur, c_fieldlen, c_pdulen); } if (i > 1) { col_append_str(pinfo->cinfo, COL_INFO, ", "); } /* Skip the length field for the WTP sub-tvb */ wtp_tvb = tvb_new_subset_length(tvb, offCur + c_fieldlen, c_pdulen); dissect_wtp_common(wtp_tvb, pinfo, wtp_tree); offCur += c_fieldlen + c_pdulen; i++; } if (tree) { proto_item_append_text(ti, ", PDU count: %u", i); } return; } /* No concatenation */ fCon = b0 & 0x80; fRID = retransmission_indicator(b0); pdut = pdu_type(b0);#ifdef DEBUG printf("WTP packet %u: tree = %p, pdu = %s (%u) length: %u/n", pinfo->fd->num, tree, val_to_str(pdut, vals_wtp_pdu_type, "Unknown PDU type 0x%x"), pdut, tvb_length(tvb));#endif /* Develop the string to put in the Info column */ returned_length = g_snprintf(szInfo, SZINFO_SIZE, "WTP %s", val_to_str(pdut, vals_wtp_pdu_type, "Unknown PDU type 0x%x")); str_index += MIN(returned_length, SZINFO_SIZE-str_index);//.........这里部分代码省略.........
开发者ID:kevincox,项目名称:wireshark,代码行数:101,
示例2: dissect_mac_mgmt_msg_dcd_decoder/* WiMax MAC Management DCD message (table 15) dissector */void dissect_mac_mgmt_msg_dcd_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ guint offset = 0; guint tvb_len, payload_type, length; gint tlv_type, tlv_len, tlv_offset, tlv_value_offset; guint dl_burst_diuc, dl_num_regions; proto_item *dcd_item = NULL; proto_tree *dcd_tree = NULL; proto_tree *tlv_tree = NULL; proto_tree *sub_tree = NULL; tlv_info_t tlv_info; /* Ensure the right payload type */ payload_type = tvb_get_guint8(tvb, offset); if(payload_type != MAC_MGMT_MSG_DCD) { return; } if(tree) { /* we are being asked for details */ /* Get the tvb reported length */ tvb_len = tvb_reported_length(tvb); /* display MAC payload type DCD */ dcd_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_dcd_decoder, tvb, offset, tvb_len, "Downlink Channel Descriptor (DCD) (%u bytes)", tvb_len); /* add MAC DCD subtree */ dcd_tree = proto_item_add_subtree(dcd_item, ett_mac_mgmt_msg_dcd_decoder); /* Decode and display the Downlink Channel Descriptor (DCD) */ /* display the Message Type */ proto_tree_add_item(dcd_tree, hf_dcd_message_type, tvb, offset, 1, ENC_BIG_ENDIAN); /* set the offset for the Downlink Channel ID */ offset++; /* display the Downlink Channel ID */ proto_tree_add_item(dcd_tree, hf_dcd_downlink_channel_id, tvb, offset, 1, ENC_BIG_ENDIAN); /* set the offset for the Configuration Change Count */ offset++; /* display the Configuration Change Count */ proto_tree_add_item(dcd_tree, hf_dcd_config_change_count, tvb, offset, 1, ENC_BIG_ENDIAN); /* set the offset for the TLV Encoded info */ offset++; /* process the DCD TLV Encoded information (table 358) */ while(offset < tvb_len) { /* get the TLV information */ init_tlv_info(&tlv_info, tvb, offset); /* get the TLV type */ tlv_type = get_tlv_type(&tlv_info); /* get the TLV length */ tlv_len = get_tlv_length(&tlv_info); if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1) { /* invalid tlv info */ col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "DCD TLV error"); proto_tree_add_item(dcd_tree, hf_dcd_invalid_tlv, tvb, offset, (tvb_len - offset), ENC_NA); break; } /* get the TLV value offset */ tlv_value_offset = get_tlv_value_offset(&tlv_info);#ifdef DEBUG /* for debug only */ proto_tree_add_protocol_format(dcd_tree, proto_mac_mgmt_msg_dcd_decoder, tvb, offset, (tlv_len + tlv_value_offset), "DCD Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, tlv_len, offset, tvb_len);#endif /* update the offset */ offset += tlv_value_offset; /* process DCD TLVs */ switch (tlv_type) { case DCD_DOWNLINK_BURST_PROFILE: { /* Downlink Burst Profile TLV (table 363)*/ /* get the DIUC */ dl_burst_diuc = (tvb_get_guint8(tvb, offset) & 0x0F); /* display TLV info */ /* add TLV subtree */ tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dcd_decoder, dcd_tree, proto_mac_mgmt_msg_dcd_decoder, tvb, offset, tlv_len, "Downlink_Burst_Profile (DIUC=%u) (%u bytes)", (dl_burst_diuc+1), tlv_len); /* detail display */ proto_tree_add_item(tlv_tree, hf_dcd_dl_burst_profile_rsv, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tlv_tree, hf_dcd_dl_burst_profile_diuc, tvb, offset, 1, ENC_BIG_ENDIAN); /* process subTLVs */ for (tlv_offset = 1; tlv_offset < tlv_len; ) { /* get the TLV information */ init_tlv_info(&tlv_info, tvb, (offset+tlv_offset)); /* get the TLV type */ tlv_type = get_tlv_type(&tlv_info); /* get the TLV length */ length = get_tlv_length(&tlv_info); if(tlv_type == -1 || length > MAX_TLV_LEN || length < 1) { /* invalid tlv info */ col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "DL Burst Profile TLV error"); proto_tree_add_item(tlv_tree, hf_dcd_invalid_tlv, tvb, offset, (tlv_len - offset - tlv_offset), ENC_NA); break; } /* update the offset */ tlv_offset += get_tlv_value_offset(&tlv_info); switch (tlv_type) { case DCD_BURST_FREQUENCY: { proto_item *tlv_item = NULL; sub_tree = add_tlv_subtree(&tlv_info, ett_mac_mgmt_msg_dcd_decoder, tlv_tree, hf_dcd_burst_freq, tvb, (offset+tlv_offset), 1, FALSE); tlv_item = proto_tree_add_item(sub_tree, hf_dcd_burst_freq, tvb, (offset+tlv_offset), 1, ENC_BIG_ENDIAN);//.........这里部分代码省略.........
开发者ID:CTSRD-CHERI,项目名称:wireshark,代码行数:101,
示例3: dissect_file_record/* XXX - "packet comment" is passed into dissector as data, but currently doesn't have a use */static intdissect_file_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data){ proto_item *volatile ti = NULL; guint cap_len = 0, frame_len = 0; proto_tree *volatile fh_tree = NULL; proto_tree *volatile tree; proto_item *item; const gchar *cap_plurality, *frame_plurality; const color_filter_t *color_filter; file_data_t *file_data = (file_data_t*)data; tree=parent_tree; pinfo->current_proto = "File"; /* if FILE is not referenced from any filters we don't need to worry about generating any tree items. */ if(!proto_field_is_referenced(tree, proto_file)) { tree=NULL; } else { gboolean old_visible; /* Put in frame header information. */ cap_len = tvb_captured_length(tvb); frame_len = tvb_reported_length(tvb); cap_plurality = plurality(cap_len, "", "s"); frame_plurality = plurality(frame_len, "", "s"); ti = proto_tree_add_protocol_format(tree, proto_file, tvb, 0, -1, "File record %u: %u byte%s", pinfo->fd->num, frame_len, frame_plurality); proto_item_append_text(ti, ", %u byte%s", cap_len, cap_plurality); fh_tree = proto_item_add_subtree(ti, ett_file); proto_tree_add_int(fh_tree, hf_file_ftap_encap, tvb, 0, 0, pinfo->fd->lnk_t); proto_tree_add_uint(fh_tree, hf_file_record_number, tvb, 0, 0, pinfo->fd->num); proto_tree_add_uint_format(fh_tree, hf_file_record_len, tvb, 0, 0, frame_len, "Record Length: %u byte%s (%u bits)", frame_len, frame_plurality, frame_len * 8); ti = proto_tree_add_boolean(fh_tree, hf_file_marked, tvb, 0, 0,pinfo->fd->flags.marked); PROTO_ITEM_SET_GENERATED(ti); ti = proto_tree_add_boolean(fh_tree, hf_file_ignored, tvb, 0, 0,pinfo->fd->flags.ignored); PROTO_ITEM_SET_GENERATED(ti); if(proto_field_is_referenced(tree, hf_file_protocols)) { /* we are going to be using proto_item_append_string() on * hf_frame_protocols, and we must therefore disable the * TRY_TO_FAKE_THIS_ITEM() optimisation for the tree by * setting it as visible. * * See proto.h for details. */ old_visible = proto_tree_set_visible(fh_tree, TRUE); ti = proto_tree_add_string(fh_tree, hf_file_protocols, tvb, 0, 0, ""); PROTO_ITEM_SET_GENERATED(ti); proto_tree_set_visible(fh_tree, old_visible); } if(pinfo->fd->pfd != 0){ proto_item *ppd_item; guint num_entries = g_slist_length(pinfo->fd->pfd); guint i; ppd_item = proto_tree_add_uint(fh_tree, hf_file_num_p_prot_data, tvb, 0, 0, num_entries); PROTO_ITEM_SET_GENERATED(ppd_item); for(i=0; i<num_entries; i++){ gchar* str = p_get_proto_name_and_key(wmem_file_scope(), pinfo, i); proto_tree_add_string_format(fh_tree, hf_file_proto_name_and_key, tvb, 0, 0, str, "%s", str); } }#if 0 if (show_file_off) { proto_tree_add_int64_format_value(fh_tree, hf_frame_file_off, tvb, 0, 0, pinfo->fd->file_off, "%" G_GINT64_MODIFIER "d (0x%" G_GINT64_MODIFIER "x)", pinfo->fd->file_off, pinfo->fd->file_off); }#endif } if (pinfo->fd->flags.ignored) { /* Ignored package, stop handling here */ col_set_str(pinfo->cinfo, COL_INFO, "<Ignored>"); proto_tree_add_boolean_format(tree, hf_file_ignored, tvb, 0, -1, TRUE, "This record is marked as ignored"); return tvb_captured_length(tvb); } /* Portable Exception Handling to trap Wireshark specific exceptions like BoundsError exceptions */ TRY {#ifdef _MSC_VER /* Win32: Visual-C Structured Exception Handling (SEH) to trap hardware exceptions//.........这里部分代码省略.........
开发者ID:CharaD7,项目名称:wireshark,代码行数:101,
示例4: dissect_waistatic voiddissect_wai(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){/* Format of WAPI protocol packet in WAI authentication system0 2 3 4 6 8 10 11 12-------------------------------------------------------------------------------| Ver. | Type | Subtype | Reserved | Length | packet | fragm. | flag | data || | seq. no | seq. no | ||-----------------------------------------------------------------------------|Figure 18 from [ref:1]*/#define WAI_MESSAGE_LENGTH 12 /*Length of all fields without 'Data' field*/#define WAI_DATA_OFFSET WAI_MESSAGE_LENGTH guint16 version; guint8 subtype; guint16 length; guint16 packet_num; guint8 fragment_num; guint8 flags; fragment_head *frag_msg; proto_tree *wai_tree = NULL; tvbuff_t *next_tvb; tvbuff_t *new_tvb; const gchar *subtype_name = "Unknown type"; length = tvb_get_ntohs(tvb, 6)-WAI_MESSAGE_LENGTH; subtype = tvb_get_guint8(tvb, 3); /* quick sanity check */ if ((length != tvb_reported_length (tvb)-WAI_MESSAGE_LENGTH) || (subtype > WAI_SUB_MULTICAST_ANNOUNCE_RESP)) { return; } col_set_str(pinfo->cinfo, COL_PROTOCOL, "WAI"); col_clear(pinfo->cinfo, COL_INFO); version = tvb_get_ntohs(tvb, 0); if (version == 1) { subtype_name = val_to_str_ext_const(subtype, &wai_subtype_names_ext, "Unknown type"); } col_append_fstr(pinfo->cinfo, COL_INFO, "%s", subtype_name); /* Field lengths and offsets in WAI protocol described above */ packet_num = tvb_get_ntohs(tvb, 8); fragment_num = tvb_get_guint8(tvb, 10); flags = tvb_get_guint8(tvb, 11); if (tree) { proto_item *wai_item; wai_item = proto_tree_add_item(tree, proto_wai, tvb, 0, -1, ENC_NA); proto_item_set_text (wai_item, "WAI Protocol (%s)", val_to_str_ext_const(subtype, &wai_subtype_names_ext, "Unknown type")); wai_tree = proto_item_add_subtree(wai_item, ett_wai); /* Field lengths and offsets in WAI protocol described above */ proto_tree_add_item(wai_tree, hf_wai_version, tvb, 0, 2, ENC_BIG_ENDIAN); proto_tree_add_item(wai_tree, hf_wai_type, tvb, 2, 1, ENC_BIG_ENDIAN); proto_tree_add_item(wai_tree, hf_wai_subtype, tvb, 3, 1, ENC_BIG_ENDIAN); proto_tree_add_item(wai_tree, hf_wai_reserved, tvb, 4, 2, ENC_BIG_ENDIAN); proto_tree_add_item(wai_tree, hf_wai_length, tvb, 6, 2, ENC_BIG_ENDIAN); proto_tree_add_item(wai_tree, hf_wai_seq, tvb, 8, 2, ENC_BIG_ENDIAN); proto_tree_add_item(wai_tree, hf_wai_fragm_seq, tvb, 10, 1, ENC_BIG_ENDIAN); proto_tree_add_item(wai_tree, hf_wai_flag, tvb, 11, 1, ENC_BIG_ENDIAN); } frag_msg = fragment_add_seq_check (&wai_reassembly_table, tvb, WAI_DATA_OFFSET, pinfo, packet_num, NULL, fragment_num, length, flags); next_tvb = tvb_new_subset_remaining(tvb, WAI_DATA_OFFSET); /* Replace INFO column if message is fragmented and call data_handle */ if (flags) { col_add_fstr(pinfo->cinfo, COL_INFO, "Fragment (%d) of message, data not dissected", fragment_num); process_reassembled_data(tvb, WAI_DATA_OFFSET, pinfo, "Reassembled WAI", frag_msg, &wai_frag_items, NULL, wai_tree); call_dissector(data_handle, next_tvb, pinfo, tree); } else { /* If this is the last fragment of fragmented message, then reassamble and dissect otherwise only dissect */ if (fragment_num > 0) { new_tvb = process_reassembled_data(tvb, WAI_DATA_OFFSET, pinfo, "Reassembled WAI", frag_msg, &wai_frag_items, NULL, wai_tree); if (new_tvb) { col_set_str(pinfo->cinfo, COL_INFO, "Last fragment of message, data dissected");//.........这里部分代码省略.........
开发者ID:Nicholas1126,项目名称:wireshark-ex,代码行数:101,
示例5: dissect_brdwlk/* Code to actually dissect the packets */static voiddissect_brdwlk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){/* Set up structures needed to add the protocol subtree and manage it */ proto_item *ti, *hidden_item; proto_tree *brdwlk_tree = NULL; tvbuff_t *next_tvb; guint8 error, eof, sof; int hdrlen = 2, offset = 0; gint len, reported_len, plen; guint16 pkt_cnt; gboolean dropped_packets; /* Make entries in Protocol column and Info column on summary display */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "Boardwalk"); col_clear(pinfo->cinfo, COL_INFO); pinfo->vsan = (tvb_get_ntohs(tvb, offset) & 0xFFF); sof = (tvb_get_guint8(tvb, offset) & 0xF0) >> 4; if ((sof == FCM_DELIM_SOFI3) || (sof == FCM_DELIM_SOFI2) || (sof == FCM_DELIM_SOFI1) || (sof == FCM_DELIM_SOFI4)) { pinfo->sof_eof = PINFO_SOF_FIRST_FRAME; } else if (sof == FCM_DELIM_SOFF) { pinfo->sof_eof = PINFO_SOF_SOFF; } if (tree) { ti = proto_tree_add_protocol_format(tree, proto_brdwlk, tvb, 0, hdrlen, "Boardwalk"); brdwlk_tree = proto_item_add_subtree(ti, ett_brdwlk); proto_tree_add_item(brdwlk_tree, hf_brdwlk_sof, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(brdwlk_tree, hf_brdwlk_vsan, tvb, offset, 2, ENC_BIG_ENDIAN); } /* Locate EOF which is the last 4 bytes of the frame */ len = tvb_length_remaining(tvb, hdrlen); reported_len = tvb_reported_length_remaining(tvb, hdrlen); if (reported_len < 4) { /* * This packet is claimed not to even have enough data for * a 4-byte EOF. * Don't try to process the EOF. */ ; } else if (len < reported_len) { /* * This packet is claimed to have enough data for a 4-byte EOF, * but we didn't capture all of the packet. * Slice off the 4-byte EOF from the reported length, and trim * the captured length so it's no more than the reported length; * that will slice off what of the EOF, if any, is in the * captured length. */ reported_len -= 4; if (len > reported_len) len = reported_len; } else { /* * We have the entire packet, and it includes a 4-byte EOF. * Slice it off, and put it into the tree if we're building * a tree. */ len -= 4; reported_len -= 4; offset = tvb_reported_length(tvb) - 4; pkt_cnt = tvb_get_ntohs(tvb, offset); if (tree) { proto_tree_add_uint(brdwlk_tree, hf_brdwlk_pktcnt, tvb, offset, 2, pkt_cnt); } dropped_packets = FALSE; if (pinfo->fd->flags.visited) { /* * This isn't the first pass, so we can't use the global * "packet_count" variable to determine whether there were * any dropped frames or not. * We therefore attach a non-null pointer as frame data to * any frame preceded by dropped packets. */ if (p_get_proto_data(pinfo->fd, proto_brdwlk, 0) != NULL) dropped_packets = TRUE; } else { /* * This is the first pass, so we have to use the global * "packet_count" variable to determine whether there were * any dropped frames or not. * * XXX - can there be more than one stream of packets, so that * we can't just use a global variable?//.........这里部分代码省略.........
开发者ID:AndresVelasco,项目名称:wireshark,代码行数:101,
示例6: dissect_prp_redundancy_control_trailerdissect_prp_redundancy_control_trailer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_){ proto_item *ti; proto_tree *prp_tree; guint i; guint length; guint offset; guint16 lan_id; guint16 lsdu_size; guint16 prp1_suffix; guint trailer_start; guint trailer_length; trailer_start = 0; trailer_length = 0; length = tvb_reported_length(tvb); if(length < 14) return 0; /* * This is horribly broken. It assumes the frame is an Ethernet * frame, with a type field at an offset of 12 bytes from the header. * That is not guaranteed to be true. * * Ideally, this should be a heuristic dissector registered in * the "eth.trailer" heuristic dissector table (and it can * be registered as "disabled by default" there); unfortunately, * it needs to know the length of the entire frame for the * PRP-0 heuristic, so it'd have to be passed that length * out of band.
开发者ID:DHODoS,项目名称:wireshark,代码行数:31,
示例7: dissect_manolito/* Code to actually dissect the packets */static voiddissect_manolito(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ unsigned int offset; /* Set up structures needed to add the protocol subtree and manage it */ proto_item *ti; proto_tree *manolito_tree; const char* packet_type = 0; /* Make entries in Protocol column and Info column on summary display */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "MANOLITO"); ti = proto_tree_add_item(tree, proto_manolito, tvb, 0, -1, ENC_NA); manolito_tree = proto_item_add_subtree(ti, ett_manolito); /* MANOLITO packet header (network byte order) */ proto_tree_add_item(manolito_tree, hf_manolito_checksum, tvb, 0, 4, ENC_BIG_ENDIAN); proto_tree_add_item(manolito_tree, hf_manolito_seqno, tvb, 4, 4, ENC_BIG_ENDIAN); proto_tree_add_item(manolito_tree, hf_manolito_src, tvb, 8, 4, ENC_BIG_ENDIAN); proto_tree_add_item(manolito_tree, hf_manolito_dest, tvb, 12, 4, ENC_BIG_ENDIAN); if (tvb_reported_length(tvb) == 19) { packet_type = "Ping (truncated)"; proto_tree_add_item(manolito_tree, hf_manolito_options_short, tvb, 16, 3, ENC_BIG_ENDIAN); } else { proto_tree_add_item(manolito_tree, hf_manolito_options, tvb, 16, 4, ENC_BIG_ENDIAN); } if (tvb_reported_length(tvb) <= 20) /* no payload, just headers */ { col_set_str(pinfo->cinfo, COL_INFO, "Ping"); } else { offset = 20; /* fields start here */ /* fields format: 2-byte name, optional NULL, 1-byte lenlen, */ /* that many bytes(len or data), for NI,CN,VL is len, more */ /* (that many bytes) data follows; else is raw data. */ do { guint16 field_name; /* 16-bit field name */ guint8 dtype; /* data-type */ guint8 length; /* length */ guint8* data; /* payload */ int start; /* field starting location */ char field_name_str[3]; /* printable name */ const char* longname; /* human-friendly field name */ start = offset; /* 2-byte field name */ field_name = tvb_get_ntohs(tvb, offset); offset += 2; /* Identify the packet based on existing fields */ /* Maybe using the options fields is a better idea...*/ if (field_name == 0x434b) /* CK */ packet_type = "Search Hit"; if (field_name == 0x4e43) /* NC */ packet_type = "User Information"; if (field_name == 0x464e) /* FN - if only field */ packet_type = "Search Query"; if (field_name == 0x4944) /* ID ?? search by CK? */ packet_type = "Search Query (by hash)"; if (field_name == 0x5054) /* PT */ packet_type = "Download Request"; if (field_name == 0x4d45) /* ME */ packet_type = "Chat"; if (tvb_reported_length(tvb) == 20) /* no fields */ packet_type = "Ping"; /* Find the long name of the field */ switch(field_name) { case 0x5346: longname = "Shared Files"; break; /* SF */ case 0x534b: longname = "Shared Kilobytes";break; /* SK */ case 0x4e49: longname = "Network ID"; break; /* NI */ case 0x4e43: longname = "Num. Connections";break; /* NC */ case 0x4356: longname = "Client Version"; break; /* CV */ case 0x564c: longname = "Velocity"; break; /* VL */ case 0x464e: longname = "Filename"; break; /* FN */ case 0x464c: longname = "File Length"; break; /* FL */ case 0x4252: longname = "Bit Rate"; break; /* BR */ case 0x4643: longname = "Frequency"; break; /* FC */ case 0x5354: longname = "???"; break; /* ST */ case 0x534c: longname = "Song Length (s)"; break; /* SL */ case 0x434b: longname = "Checksum"; break; /* CK */ case 0x4e4e: longname = "Nickname"; break; /* NN */ case 0x434e: longname = "Client Name"; break; /* CN *///.........这里部分代码省略.........
开发者ID:kailiu-bupt2005,项目名称:wireshark,代码行数:101,
示例8: dissect_kdpstatic void dissect_kdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint body_len; guint8 version = 0; guint8 header_len = 0; guint8 packet_flags = 0; guint8 packet_errors = 0; guint32 sequence_number = G_MAXUINT32; guint32 ack_number = G_MAXUINT32; guint32 src_flowid = G_MAXUINT32; int offset; col_set_str(pinfo->cinfo, COL_PROTOCOL, "KDP"); col_clear(pinfo->cinfo, COL_INFO); if (tree) { proto_item *ti; proto_tree *kdp_tree, *flags_tree; ti = NULL; kdp_tree = NULL; flags_tree = NULL; ti = proto_tree_add_item(tree, proto_kdp, tvb, 0, -1, ENC_NA); kdp_tree = proto_item_add_subtree(ti, ett_kdp); version = tvb_get_guint8(tvb, 0); if (version != 2) { /* Version other than 2 is really SDDP in UDP */ proto_tree_add_item(kdp_tree, hf_kdp_version, tvb, 0, 1, ENC_BIG_ENDIAN); proto_tree_add_item(kdp_tree, hf_kdp_xml_body, tvb, 0, -1, ENC_ASCII|ENC_NA); } else { header_len = tvb_get_guint8(tvb, 1) * 4; body_len = tvb_reported_length(tvb); if (header_len > body_len) { body_len = 0; /* malformed packet */ } else { body_len = body_len - header_len; } packet_flags = tvb_get_guint8(tvb, 2); packet_errors = tvb_get_guint8(tvb, 3); proto_tree_add_item(kdp_tree, hf_kdp_version, tvb, 0, 1, ENC_BIG_ENDIAN); proto_tree_add_item(kdp_tree, hf_kdp_headerlen, tvb, 1, 1, ENC_BIG_ENDIAN); ti = proto_tree_add_item(kdp_tree, hf_kdp_flags, tvb, 2, 1, ENC_BIG_ENDIAN); flags_tree = proto_item_add_subtree(ti, ett_kdp_flags); proto_tree_add_item(flags_tree, hf_kdp_drop_flag, tvb, 2, 1, ENC_BIG_ENDIAN); proto_tree_add_item(flags_tree, hf_kdp_syn_flag, tvb, 2, 1, ENC_BIG_ENDIAN); proto_tree_add_item(flags_tree, hf_kdp_ack_flag, tvb, 2, 1, ENC_BIG_ENDIAN); proto_tree_add_item(flags_tree, hf_kdp_rst_flag, tvb, 2, 1, ENC_BIG_ENDIAN); proto_tree_add_item(flags_tree, hf_kdp_bcst_flag, tvb, 2, 1, ENC_BIG_ENDIAN); proto_tree_add_item(flags_tree, hf_kdp_dup_flag, tvb, 2, 1, ENC_BIG_ENDIAN); proto_tree_add_item(kdp_tree, hf_kdp_errors, tvb, 3, 1, ENC_BIG_ENDIAN); if (header_len > 4) { offset = 4; if (packet_flags & KDP_ACK_FLAG) { proto_tree_add_item(kdp_tree, hf_kdp_destflowid, tvb, offset, 4, ENC_BIG_ENDIAN); offset = offset + 4; } if (packet_flags & (KDP_SYN_FLAG | KDP_BCST_FLAG)) { proto_tree_add_item(kdp_tree, hf_kdp_srcflowid, tvb, offset, 4, ENC_BIG_ENDIAN); src_flowid = tvb_get_ntohl(tvb, offset); offset = offset + 4; } proto_tree_add_item(kdp_tree, hf_kdp_sequence, tvb, offset, 4, ENC_BIG_ENDIAN); sequence_number = tvb_get_ntohl(tvb, offset); offset = offset + 4; if (packet_flags & KDP_ACK_FLAG) { proto_tree_add_item(kdp_tree, hf_kdp_ack, tvb, offset, 4, ENC_BIG_ENDIAN); ack_number = tvb_get_ntohl(tvb, offset); offset = offset + 4; } if (packet_flags & KDP_SYN_FLAG) { proto_tree_add_item(kdp_tree, hf_kdp_maxsegmentsize, tvb, offset, 4, ENC_BIG_ENDIAN); offset = offset + 4; } while (offset < ((body_len > 0) ? header_len - 4 : header_len)) { guint8 option_number; guint8 option_len = 0; option_number = tvb_get_guint8(tvb, offset); proto_tree_add_item(kdp_tree, hf_kdp_optionnumber, tvb, offset, 1, ENC_BIG_ENDIAN); offset = offset + 1; if (option_number > 0) { option_len = tvb_get_guint8(tvb, offset); proto_tree_add_item(kdp_tree, hf_kdp_optionlen, tvb, offset, 1, ENC_BIG_ENDIAN); offset = offset + 1; } switch (option_number) { case 0: break; case 1: proto_tree_add_item(kdp_tree, hf_kdp_option1, tvb, offset, 2, ENC_BIG_ENDIAN);//.........这里部分代码省略.........
开发者ID:koyeen,项目名称:wireshark,代码行数:101,
示例9: test/* Tests a tvbuff against the expected pattern/length. * Returns TRUE if all tests succeeed, FALSE if any test fails */gbooleantest(tvbuff_t *tvb, gchar* name, guint8* expected_data, guint expected_length, guint expected_reported_length){ guint length; guint reported_length; guint8 *ptr; volatile gboolean ex_thrown; volatile guint32 val32; guint32 expected32; guint incr, i; length = tvb_length(tvb); if (length != expected_length) { printf("01: Failed TVB=%s Length of tvb=%u while expected length=%u/n", name, length, expected_length); failed = TRUE; return FALSE; } reported_length = tvb_reported_length(tvb); if (reported_length != expected_reported_length) { printf("01: Failed TVB=%s Reported length of tvb=%u while expected reported length=%u/n", name, reported_length, expected_reported_length); failed = TRUE; return FALSE; } /* Test boundary case. A BoundsError exception should be thrown. */ ex_thrown = FALSE; TRY { tvb_get_ptr(tvb, 0, length + 1); } CATCH(BoundsError) { ex_thrown = TRUE; } CATCH(FragmentBoundsError) { printf("02: Caught wrong exception: FragmentBoundsError/n"); } CATCH(ReportedBoundsError) { printf("02: Caught wrong exception: ReportedBoundsError/n"); } CATCH_ALL { printf("02: Caught wrong exception: %lu, exc->except_id.except_code/n"); } ENDTRY; if (!ex_thrown) { printf("02: Failed TVB=%s No BoundsError when retrieving %u bytes/n", name, length + 1); failed = TRUE; return FALSE; } /* Test boundary case with reported_length+1. A ReportedBoundsError exception should be thrown. */ ex_thrown = FALSE; TRY { tvb_get_ptr(tvb, 0, reported_length + 1); } CATCH(BoundsError) { printf("03: Caught wrong exception: BoundsError/n"); } CATCH(FragmentBoundsError) { printf("03: Caught wrong exception: FragmentBoundsError/n"); } CATCH(ReportedBoundsError) { ex_thrown = TRUE; } CATCH_ALL { printf("02: Caught wrong exception: %lu, exc->except_id.except_code/n"); } ENDTRY; if (!ex_thrown) { printf("03: Failed TVB=%s No ReportedBoundsError when retrieving %u bytes/n", name, reported_length + 1); failed = TRUE; return FALSE; } /* Test boundary case. A BoundsError exception should be thrown. */ ex_thrown = FALSE; TRY { tvb_get_ptr(tvb, -1, 2); } CATCH(BoundsError) { ex_thrown = TRUE; } CATCH(FragmentBoundsError) { printf("04: Caught wrong exception: FragmentBoundsError/n"); } CATCH(ReportedBoundsError) { printf("04: Caught wrong exception: ReportedBoundsError/n"); } CATCH_ALL {//.........这里部分代码省略.........
开发者ID:P1sec,项目名称:LTE_monitor_c2xx,代码行数:101,
示例10: dissect_frame//.........这里部分代码省略......... break; default: g_assert_not_reached(); break; } if(pinfo->pkt_comment){ item = proto_tree_add_item(tree, proto_pkt_comment, tvb, 0, 0, ENC_NA); comments_tree = proto_item_add_subtree(item, ett_comments); comment_item = proto_tree_add_string_format(comments_tree, hf_comments_text, tvb, 0, 0, pinfo->pkt_comment, "%s", pinfo->pkt_comment); expert_add_info_format(pinfo, comment_item, &ei_comments_text, "%s", pinfo->pkt_comment); } /* if FRAME is not referenced from any filters we don't need to worry about generating any tree items. */ if(!proto_field_is_referenced(tree, proto_frame)) { tree=NULL; if(pinfo->fd->flags.has_ts) { if(pinfo->fd->abs_ts.nsecs < 0 || pinfo->fd->abs_ts.nsecs >= 1000000000) expert_add_info(pinfo, NULL, &ei_arrive_time_out_of_range); } } else { proto_tree *fh_tree; gboolean old_visible; /* Put in frame header information. */ cap_len = tvb_length(tvb); frame_len = tvb_reported_length(tvb); cap_plurality = plurality(cap_len, "", "s"); frame_plurality = plurality(frame_len, "", "s"); ti = proto_tree_add_protocol_format(tree, proto_frame, tvb, 0, tvb_captured_length(tvb), "Frame %u: %u byte%s on wire", pinfo->fd->num, frame_len, frame_plurality); if (generate_bits_field) proto_item_append_text(ti, " (%u bits)", frame_len * 8); proto_item_append_text(ti, ", %u byte%s captured", cap_len, cap_plurality); if (generate_bits_field) { proto_item_append_text(ti, " (%u bits)", cap_len * 8); } if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) { proto_item_append_text(ti, " on interface %u", pinfo->phdr->interface_id); } if (pinfo->phdr->presence_flags & WTAP_HAS_PACK_FLAGS) { if (pinfo->phdr->pack_flags & 0x00000001) { proto_item_append_text(ti, " (inbound)"); pinfo->p2p_dir = P2P_DIR_RECV; } if (pinfo->phdr->pack_flags & 0x00000002) { proto_item_append_text(ti, " (outbound)"); pinfo->p2p_dir = P2P_DIR_SENT; } } fh_tree = proto_item_add_subtree(ti, ett_frame);
开发者ID:daniel-scs,项目名称:wireshark-tcpcrypt,代码行数:66,
示例11: dissect_mpls_y1711static intdissect_mpls_y1711(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data){ struct mplsinfo *mplsinfo; int offset = 0; proto_item *ti; proto_tree *mpls_y1711_tree; int functype; tvbuff_t *data_tvb; static const guint8 allone[] = { 0xff, 0xff }; static const guint8 allzero[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* Reject the packet if data is NULL */ if (data == NULL) return 0; mplsinfo = (struct mplsinfo *)data; functype = tvb_get_guint8(tvb, offset); col_append_fstr(pinfo->cinfo, COL_INFO, " (Y.1711: %s)", (functype == 0x01) ? "CV" : (functype == 0x02) ? "FDI" : (functype == 0x03) ? "BDI" : (functype == 0x07) ? "FDD" : "reserved/unknown"); /* sanity checks */ if (tvb_reported_length(tvb) < 44) { /* * ITU-T Y.1711, 5.3: PDUs must have a minimum payload length of * 44 bytes */ proto_tree_add_expert(tree, pinfo, &ei_mpls_y1711_minimum_payload, tvb, offset, -1); data_tvb = tvb_new_subset_remaining(tvb, offset); call_dissector(data_handle, data_tvb, pinfo, tree); return tvb_reported_length(tvb); } ti = proto_tree_add_text(tree, tvb, offset, 44, "Y.1711 OAM"); mpls_y1711_tree = proto_item_add_subtree(ti, ett_mpls_y1711); /* checks for exp, bos and ttl encoding */ if (mplsinfo->label != MPLS_LABEL_OAM_ALERT) proto_tree_add_expert_format(mpls_y1711_tree, pinfo, &ei_mpls_y1711_no_OAM_alert_label, tvb, offset - 4, 3, "Warning: Y.1711 but no OAM alert label (%d) ?!", MPLS_LABEL_OAM_ALERT); if (mplsinfo->exp != 0) proto_tree_add_expert(mpls_y1711_tree, pinfo, &ei_mpls_y1711_exp_bits_not_zero, tvb, offset - 2, 1); if (mplsinfo->bos != 1) proto_tree_add_expert(mpls_y1711_tree, pinfo, &ei_mpls_y1711_s_bit_not_one, tvb, offset - 2, 1); if (mplsinfo->ttl != 1) proto_tree_add_expert(mpls_y1711_tree, pinfo, &ei_mpls_y1711_ttl_not_one, tvb, offset - 1, 1); /* starting dissection */ functype = tvb_get_guint8(tvb, offset); proto_tree_add_item(mpls_y1711_tree, hf_mpls_y1711_function_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset++; switch (functype) { case 0x01: /* CV */ { /* 3 octets reserved (all 0x00) */ if (tvb_memeql(tvb, offset, allzero, 3) == -1) { proto_tree_add_expert(mpls_y1711_tree, pinfo, &ei_mpls_y1711_reserved_not_zero, tvb, offset, 3); } offset += 3; /* ttsi (ipv4 flavor as in RFC 2373) */ if (tvb_memeql(tvb, offset, allzero, 10) == -1) { proto_tree_add_expert(mpls_y1711_tree, pinfo, &ei_mpls_y1711_padding_not_zero, tvb, offset, 10); } offset += 10; if (tvb_memeql(tvb, offset, allone, 2) == -1) { proto_tree_add_expert(mpls_y1711_tree, pinfo, &ei_mpls_y1711_padding_not_ff, tvb, offset, 2); } offset += 2; proto_tree_add_item(mpls_y1711_tree, hf_mpls_y1711_lsr_id, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(mpls_y1711_tree, hf_mpls_y1711_lsp_id, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; /* 18 octets of padding (all 0x00) */ if (tvb_memeql(tvb, offset, allzero, 18) == -1) { proto_tree_add_expert(mpls_y1711_tree, pinfo, &ei_mpls_y1711_padding_not_zero, tvb, offset, 18); } offset += 18; } break;//.........这里部分代码省略.........
开发者ID:dot-Sean,项目名称:wireshark-http2,代码行数:101,
示例12: dissect_bvlcstatic intdissect_bvlc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ proto_item *ti; proto_item *ti_bdt; proto_item *ti_fdt; proto_tree *bvlc_tree; proto_tree *bdt_tree; /* Broadcast Distribution Table */ proto_tree *fdt_tree; /* Foreign Device Table */ gint offset; guint8 bvlc_type; guint8 bvlc_function; guint16 bvlc_length; guint16 packet_length; guint npdu_length; guint length_remaining; guint16 bvlc_result; tvbuff_t *next_tvb; offset = 0; bvlc_type = tvb_get_guint8(tvb, offset); /* * Simple sanity check - make sure the type is one we know about. */ if (match_strval(bvlc_type, bvlc_types) == NULL) return 0; col_set_str(pinfo->cinfo, COL_PROTOCOL, "BVLC"); col_set_str(pinfo->cinfo, COL_INFO, "BACnet Virtual Link Control"); bvlc_function = tvb_get_guint8(tvb, offset+1); packet_length = tvb_get_ntohs(tvb, offset+2); length_remaining = tvb_reported_length_remaining(tvb, offset); if (bvlc_function > 0x08) { /* We have a constant header length of BVLC of 4 in every * BVLC-packet forewarding an NPDU. Beware: Changes in the * BACnet-IP-standard may break this. * At the moment, no functions above 0x0b * exist (Addendum 135a to ANSI/ASHRAE 135-1995 - BACnet) */ bvlc_length = 4; } else if(bvlc_function == 0x04) { /* 4 Bytes + 6 Bytes for B/IP Address of Originating Device */ bvlc_length = 10; } else { /* BVLC-packets with function below 0x09 contain * routing-level data (e.g. Broadcast Distribution) * but no NPDU for BACnet, so bvlc_length goes up to the end * of the captured frame. */ bvlc_length = packet_length; } if (tree) { if (bvlc_length < 4) { proto_tree_add_text(tree, tvb, 2, 2, "Bogus length: %d", bvlc_length); return tvb_reported_length(tvb); /* XXX - reject? */ } ti = proto_tree_add_item(tree, proto_bvlc, tvb, 0, bvlc_length, ENC_NA); bvlc_tree = proto_item_add_subtree(ti, ett_bvlc); proto_tree_add_uint(bvlc_tree, hf_bvlc_type, tvb, offset, 1, bvlc_type); offset ++; proto_tree_add_uint(bvlc_tree, hf_bvlc_function, tvb, offset, 1, bvlc_function); offset ++; if (length_remaining != packet_length) proto_tree_add_uint_format_value(bvlc_tree, hf_bvlc_length, tvb, offset, 2, bvlc_length, "%d of %d bytes (invalid length - expected %d bytes)", bvlc_length, packet_length, length_remaining); else proto_tree_add_uint_format_value(bvlc_tree, hf_bvlc_length, tvb, offset, 2, bvlc_length, "%d of %d bytes BACnet packet length", bvlc_length, packet_length); offset += 2; switch (bvlc_function) { case 0x00: /* BVLC-Result */ bvlc_result = tvb_get_ntohs(tvb, offset); /* I dont know why the result code is encoded in 4 nibbles, * but only using one: 0x00r0. Shifting left 4 bits. */ /* We should bitmask the result correctly when we have a * packet to dissect, see README.developer, 1.6.2, FID */ proto_tree_add_uint_format_value(bvlc_tree, hf_bvlc_result, tvb, offset, 2, bvlc_result,"0x%04x (%s)", bvlc_result, val_to_str(bvlc_result, bvlc_result_names, "Unknown")); offset += 2; break; case 0x01: /* Write-Broadcast-Distribution-Table */ case 0x03: /* Read-Broadcast-Distribution-Table-Ack */ /* List of BDT Entries: N*10-octet *///.........这里部分代码省略.........
开发者ID:hubolo,项目名称:wireshark-1.8.0,代码行数:101,
示例13: dissect_smb_directstatic voiddissect_smb_direct(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, enum SMB_DIRECT_HDR_TYPE hdr_type){ proto_tree *tree = NULL; proto_item *item = NULL; proto_tree *neg_req_tree = NULL; proto_tree *neg_rep_tree = NULL; proto_tree *data_tree = NULL; int offset = 0; guint32 status = 0; guint32 remaining_length = 0; guint32 data_offset = 0; guint32 data_length = 0; guint rlen = tvb_reported_length(tvb); gint len = 0; tvbuff_t *next_tvb = NULL; static const int * flags[] = { &hf_smb_direct_flags_response_requested, NULL }; col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMBDirect"); col_clear(pinfo->cinfo, COL_INFO); if (parent_tree != NULL) { item = proto_tree_add_item(parent_tree, proto_smb_direct, tvb, 0, -1, ENC_NA); tree = proto_item_add_subtree(item, ett_smb_direct); } switch (hdr_type) { case SMB_DIRECT_HDR_UNKNOWN: break; case SMB_DIRECT_HDR_NEG_REQ: col_append_str(pinfo->cinfo, COL_INFO, "NegotiateRequest"); if (tree == NULL) { break; } item = proto_tree_add_item(tree, hf_smb_direct_negotiate_request, tvb, 0, -1, ENC_NA); neg_req_tree = proto_item_add_subtree(item, ett_smb_direct_hdr); proto_tree_add_item(neg_req_tree, hf_smb_direct_min_version, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; proto_tree_add_item(neg_req_tree, hf_smb_direct_max_version, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; /* 2 bytes reserved */ offset += 2; proto_tree_add_item(neg_req_tree, hf_smb_direct_credits_requested, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; proto_tree_add_item(neg_req_tree, hf_smb_direct_preferred_send_size, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; proto_tree_add_item(neg_req_tree, hf_smb_direct_max_receive_size, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; proto_tree_add_item(neg_req_tree, hf_smb_direct_max_fragmented_size, tvb, offset, 4, ENC_LITTLE_ENDIAN); /* offset += 4; */ break; case SMB_DIRECT_HDR_NEG_REP: col_append_str(pinfo->cinfo, COL_INFO, "NegotiateResponse"); status = tvb_get_letohl(tvb, 12); if (status != 0) { col_append_fstr( pinfo->cinfo, COL_INFO, ", Error: %s", val_to_str(status, NT_errors, "Unknown (0x%08X)")); } if (tree == NULL) { break; } item = proto_tree_add_item(tree, hf_smb_direct_negotiate_response, tvb, 0, -1, ENC_NA); neg_rep_tree = proto_item_add_subtree(item, ett_smb_direct_hdr); proto_tree_add_item(neg_rep_tree, hf_smb_direct_min_version, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; proto_tree_add_item(neg_rep_tree, hf_smb_direct_max_version, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; proto_tree_add_item(neg_rep_tree, hf_smb_direct_negotiated_version, tvb, offset, 2, ENC_LITTLE_ENDIAN);//.........这里部分代码省略.........
开发者ID:CharaD7,项目名称:wireshark,代码行数:101,
示例14: tvb_get_guint64 case 8: return tvb_get_guint64(tvb, offset, encoding); } return 0;}static intdissect_uds(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void* data _U_){ proto_tree *uds_tree, *subtree; proto_item *ti; guint8 sid, service; guint32 enum_val; const char *service_name; guint32 data_length = tvb_reported_length(tvb); col_set_str(pinfo->cinfo, COL_PROTOCOL, "UDS"); col_clear(pinfo->cinfo,COL_INFO); sid = tvb_get_guint8(tvb, UDS_SID_OFFSET); service = sid & UDS_SID_MASK; service_name = val_to_str(service, uds_services, "Unknown (0x%02x)"); col_add_fstr(pinfo->cinfo, COL_INFO, "%-7s %-36s", (sid & UDS_REPLY_MASK)? "Reply": "Request", service_name); ti = proto_tree_add_item(tree, proto_uds, tvb, 0, -1, ENC_NA); uds_tree = proto_item_add_subtree(ti, ett_uds); proto_tree_add_item(uds_tree, hf_uds_service, tvb, UDS_SID_OFFSET, UDS_SID_LEN, ENC_BIG_ENDIAN); proto_tree_add_item(uds_tree, hf_uds_reply, tvb, UDS_SID_OFFSET, UDS_SID_LEN, ENC_BIG_ENDIAN);
开发者ID:acaceres2176,项目名称:wireshark,代码行数:30,
示例15: dissect_gvrp/* Code to actually dissect the packets */static voiddissect_gvrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ proto_item *ti; proto_tree *gvrp_tree; guint16 protocol_id; guint8 octet; int msg_index, attr_index, offset = 0, length = tvb_reported_length(tvb); col_set_str(pinfo->cinfo, COL_PROTOCOL, "GVRP"); col_set_str(pinfo->cinfo, COL_INFO, "GVRP"); if (tree) { ti = proto_tree_add_item(tree, proto_gvrp, tvb, 0, length, FALSE); gvrp_tree = proto_item_add_subtree(ti, ett_gvrp); /* Read in GARP protocol ID */ protocol_id = tvb_get_ntohs(tvb, GARP_PROTOCOL_ID); proto_tree_add_uint_format(gvrp_tree, hf_gvrp_proto_id, tvb, GARP_PROTOCOL_ID, sizeof(guint16), protocol_id, "Protocol Identifier: 0x%04x (%s)", protocol_id, protocol_id == GARP_DEFAULT_PROTOCOL_ID ? "GARP VLAN Registration Protocol" : "Unknown Protocol"); /* Currently only one protocol ID is supported */ if (protocol_id != GARP_DEFAULT_PROTOCOL_ID) { proto_tree_add_text(gvrp_tree, tvb, GARP_PROTOCOL_ID, sizeof(guint16), " (Warning: this version of Wireshark only knows about protocol id = 1)"); call_dissector(data_handle, tvb_new_subset(tvb, GARP_PROTOCOL_ID + sizeof(guint16), -1, -1), pinfo, tree); return; } offset += sizeof(guint16); length -= sizeof(guint16); msg_index = 0; /* Begin to parse GARP messages */ while (length) { proto_item *msg_item; int msg_start = offset; /* Read in attribute type. */ octet = tvb_get_guint8(tvb, offset); /* Check for end of mark */ if (octet == GARP_END_OF_MARK) { /* End of GARP PDU */ if (msg_index) { proto_tree_add_text(gvrp_tree, tvb, offset, sizeof(guint8), "End of mark"); break; } else { call_dissector(data_handle, tvb_new_subset_remaining(tvb, offset), pinfo, tree); return; } } offset += sizeof(guint8); length -= sizeof(guint8); msg_item = proto_tree_add_text(gvrp_tree, tvb, msg_start, -1, "Message %d", msg_index + 1); proto_tree_add_uint(gvrp_tree, hf_gvrp_attribute_type, tvb, msg_start, sizeof(guint8), octet); /* GVRP only supports one attribute type. */ if (octet != GVRP_ATTRIBUTE_TYPE) { call_dissector(data_handle, tvb_new_subset_remaining(tvb, offset), pinfo, tree); return; } attr_index = 0; while (length) { int attr_start = offset; proto_item *attr_item; /* Read in attribute length. *///.........这里部分代码省略.........
开发者ID:RazZziel,项目名称:wireshark-dplay,代码行数:101,
示例16: dissect_mac_mgmt_msg_ucd_decoder/* UCD dissector */static void dissect_mac_mgmt_msg_ucd_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ guint offset = 0; guint tvb_len, length; gint tlv_type, tlv_len, tlv_offset, tlv_value_offset; tlv_info_t tlv_info; gchar* proto_str; { /* we are being asked for details */ proto_item *ucd_item; proto_tree *ucd_tree; guint ucd_ranging_backoff_start; guint ucd_ranging_backoff_end; guint ucd_request_backoff_start; guint ucd_request_backoff_end; tvb_len = tvb_reported_length(tvb); /* display MAC payload type UCD */ ucd_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_ucd_decoder, tvb, offset, -1, "Uplink Channel Descriptor (UCD)"); ucd_tree = proto_item_add_subtree(ucd_item, ett_mac_mgmt_msg_ucd_decoder); /* Decode and display the Uplink Channel Descriptor (UCD) */ /* display the Configuration Change Count */ proto_tree_add_item(ucd_tree, hf_ucd_config_change_count, tvb, offset, 1, ENC_NA); offset++; /* get the ranging backoff start */ ucd_ranging_backoff_start = tvb_get_guint8(tvb, offset); proto_tree_add_uint_format_value(ucd_tree, hf_ucd_ranging_backoff_start, tvb, offset, 1, (1 << ucd_ranging_backoff_start), "2^%u = %u", ucd_ranging_backoff_start, (1 << ucd_ranging_backoff_start)); offset++; /* get the ranging backoff end */ ucd_ranging_backoff_end = tvb_get_guint8(tvb, offset); proto_tree_add_uint_format_value(ucd_tree, hf_ucd_ranging_backoff_end, tvb, offset, 1, (1 << ucd_ranging_backoff_end), "2^%u = %u", ucd_ranging_backoff_end, (1 << ucd_ranging_backoff_end)); offset++; /* get the request backoff start */ ucd_request_backoff_start = tvb_get_guint8(tvb, offset); proto_tree_add_uint_format_value(ucd_tree, hf_ucd_request_backoff_start, tvb, offset, 1, (1 << ucd_request_backoff_start), "2^%u = %u", ucd_request_backoff_start, (1 << ucd_request_backoff_start)); offset++; /* get the request backoff end */ ucd_request_backoff_end = tvb_get_guint8(tvb, offset); proto_tree_add_uint_format_value(ucd_tree, hf_ucd_request_backoff_end, tvb, offset, 1, (1 << ucd_request_backoff_end), "2^%u = %u", ucd_request_backoff_end, (1 << ucd_request_backoff_end)); offset++; while(offset < tvb_len) { /* get the TLV information */ init_tlv_info(&tlv_info, tvb, offset); /* get the TLV type */ tlv_type = get_tlv_type(&tlv_info); /* get the TLV length */ tlv_len = get_tlv_length(&tlv_info); if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1) { /* invalid tlv info */ col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "UCD TLV error"); proto_tree_add_item(ucd_tree,hf_ucd_invalid_tlv, tvb, offset, (tvb_len - offset), ENC_NA); break; } /* get the TLV value offset */ tlv_value_offset = get_tlv_value_offset(&tlv_info);#ifdef DEBUG /* for debug only */ proto_tree_add_protocol_format(ucd_tree, proto_mac_mgmt_msg_ucd_decoder, tvb, offset, (tlv_len + tlv_value_offset), "UCD Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, tlv_len, offset, tvb_len);#endif /* update the offset */ offset += tlv_value_offset; /* process UCD TLV Encoded information */ if (include_cor2_changes) { switch (tlv_type) { case UCD_TLV_T_203_UL_PUSC_SUBCHANNEL_ROTATION: { add_tlv_subtree(&tlv_info, ucd_tree, hf_ucd_tlv_t_203_ul_pusc_subchannel_rotation, tvb, offset-tlv_value_offset, ENC_BIG_ENDIAN); break; } case UCD_TLV_T_205_RELATIVE_POWER_OFFSET_UL_HARQ_BURST: { add_tlv_subtree(&tlv_info, ucd_tree, hf_ucd_tlv_t_205_relative_power_offset_ul_harq_burst, tvb, offset-tlv_value_offset, ENC_BIG_ENDIAN); break; } case UCD_TLV_T_206_RELATIVE_POWER_OFFSET_UL_BURST_CONTAINING_MAC_MGMT_MSG: { add_tlv_subtree(&tlv_info, ucd_tree, hf_ucd_tlv_t_206_relative_power_offset_ul_burst_containing_mac_mgmt_msg, tvb, offset-tlv_value_offset, ENC_BIG_ENDIAN); break; } case UCD_TLV_T_207_UL_INITIAL_TRANSMIT_TIMING: { add_tlv_subtree(&tlv_info, ucd_tree, hf_ucd_tlv_t_207_ul_initial_transmit_timing, tvb, offset-tlv_value_offset, ENC_BIG_ENDIAN); break; } case UCD_TLV_T_210_FAST_FEEDBACK_REGION: { add_tlv_subtree(&tlv_info, ucd_tree, hf_ucd_tlv_t_210_fast_feedback_region, tvb, offset-tlv_value_offset, ENC_NA); break; } case UCD_TLV_T_211_HARQ_ACK_REGION: {//.........这里部分代码省略.........
开发者ID:MultipathDTLS,项目名称:wireshark,代码行数:101,
示例17: dissect_pgm/* * dissect_pgm - The dissector for Pragmatic General Multicast */static voiddissect_pgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ guint16 pgmhdr_sport; guint16 pgmhdr_dport; guint8 pgmhdr_type; guint8 pgmhdr_opts; guint16 pgmhdr_cksum; guint16 pgmhdr_tsdulen; guint32 sqn; guint16 afi; guint plen = 0; proto_item *ti; const char *pktname; const char *pollstname; char *gsi; gboolean isdata = FALSE; guint pgmlen, reportedlen; col_set_str(pinfo->cinfo, COL_PROTOCOL, "PGM"); col_clear(pinfo->cinfo, COL_INFO); if (tvb_reported_length_remaining(tvb, 0) < 18) { col_set_str(pinfo->cinfo, COL_INFO, "Packet too small"); return; } pinfo->srcport = pgmhdr_sport = tvb_get_ntohs(tvb, 0); pinfo->destport = pgmhdr_dport = tvb_get_ntohs(tvb, 2); pgmhdr_type = tvb_get_guint8(tvb, 4); pktname = val_to_str(pgmhdr_type, type_vals, "Unknown (0x%02x)"); pgmhdr_opts = tvb_get_guint8(tvb, 5); pgmhdr_cksum = tvb_get_ntohs(tvb, 6); gsi = tvb_bytes_to_str(wmem_packet_scope(), tvb, 8, 6); pgmhdr_tsdulen = tvb_get_ntohs(tvb, 14); sqn = tvb_get_ntohl(tvb, 16); switch(pgmhdr_type) { case PGM_SPM_PCKT: case PGM_NAK_PCKT: case PGM_NNAK_PCKT: case PGM_NCF_PCKT: case PGM_POLR_PCKT: case PGM_ACK_PCKT: col_add_fstr(pinfo->cinfo, COL_INFO, "%-5s sqn 0x%x gsi %s", pktname, sqn, gsi); break; case PGM_RDATA_PCKT: case PGM_ODATA_PCKT: col_add_fstr(pinfo->cinfo, COL_INFO, "%-5s sqn 0x%x gsi %s tsdulen %d", pktname, sqn, gsi, pgmhdr_tsdulen); isdata = TRUE; break; case PGM_POLL_PCKT: { guint16 poll_stype = tvb_get_ntohs(tvb, 22); pollstname = val_to_str(poll_stype, poll_subtype_vals, "Unknown (0x%02x)"); col_add_fstr(pinfo->cinfo, COL_INFO, "%-5s sqn 0x%x gsi %s subtype %s", pktname, sqn, gsi, pollstname); } break; default: return; } { proto_tree *pgm_tree = NULL; proto_tree *opt_tree = NULL; proto_tree *type_tree = NULL; proto_item *tf, *hidden_item; ptvcursor_t* cursor; ti = proto_tree_add_protocol_format(tree, proto_pgm, tvb, 0, -1, "Pragmatic General Multicast: Type %s" " Src Port %u, Dst Port %u, GSI %s", pktname, pgmhdr_sport, pgmhdr_dport, gsi); pgm_tree = proto_item_add_subtree(ti, ett_pgm); cursor = ptvcursor_new(pgm_tree, tvb, 0); hidden_item = proto_tree_add_item(pgm_tree, hf_pgm_port, tvb, 0, 2, ENC_BIG_ENDIAN); PROTO_ITEM_SET_HIDDEN(hidden_item); hidden_item = proto_tree_add_item(pgm_tree, hf_pgm_port, tvb, 2, 2, ENC_BIG_ENDIAN); PROTO_ITEM_SET_HIDDEN(hidden_item); ptvcursor_add(cursor, hf_pgm_main_sport, 2, ENC_BIG_ENDIAN); ptvcursor_add(cursor, hf_pgm_main_dport, 2, ENC_BIG_ENDIAN); ptvcursor_add(cursor, hf_pgm_main_type, 1, ENC_BIG_ENDIAN);//.........这里部分代码省略.........
开发者ID:MultipathDTLS,项目名称:wireshark,代码行数:101,
示例18: dissect_wai_data//.........这里部分代码省略......... break; } case WAI_SUB_CERT_AUTH_RESP: { /* Chapter 8.1.4.2.4 Certificate Authentication Response [ref: 1] */ guint16 offset = 0; dissect_addid(tvb, offset, data_tree); offset += 12; offset += dissect_multiple_certificate(tvb, offset, data_tree); offset += dissect_signature(tvb, offset, data_tree, "Server Signature trusted by ASUE"); if (offset < lenx) dissect_signature(tvb, offset, data_tree, "Server Signature trusted by AE"); break; } case WAI_SUB_UNICAST_KEY_REQ: { /* Chapter 8.1.4.3.1 Unicast Key Negotiation Request [ref: 1] */ dissect_flag(tvb, 0, data_tree); dissect_bkid(tvb, 1, data_tree); dissect_uskid(tvb, 17, data_tree); dissect_addid(tvb, 18, data_tree); dissect_challenge(tvb, 30, data_tree , "AE "); break; } case WAI_SUB_UNICAST_KEY_RESP: { /* Chapter 8.1.4.3.2 Unicast Key Negotiation Response [ref: 1] */ tvbuff_t *next_tvb; guint length = 0; dissect_flag(tvb, 0, data_tree); dissect_bkid(tvb, 1, data_tree); dissect_uskid(tvb, 17, data_tree); dissect_addid(tvb, 18, data_tree); dissect_challenge(tvb, 30, data_tree, "ASUE "); dissect_challenge(tvb, 62, data_tree, "AE "); next_tvb = tvb_new_subset_remaining(tvb, 96); length = tvb_reported_length(next_tvb); dissect_wie(next_tvb, 0, length-20, data_tree); dissect_message_auth_code(next_tvb, length-20, data_tree); break; } case WAI_SUB_UNICAST_KEY_CONFIRM: { /* Chapter 8.1.4.3.3 Unicast Key Negotiation Confirmation [ref: 1] */ tvbuff_t *next_tvb; guint length = 0; dissect_flag(tvb, 0, data_tree); dissect_bkid(tvb, 1, data_tree); dissect_uskid(tvb, 17, data_tree); dissect_addid(tvb, 18, data_tree); dissect_challenge(tvb, 30, data_tree, "ASUE "); next_tvb = tvb_new_subset_remaining(tvb, 62); length = tvb_reported_length(next_tvb); dissect_wie(next_tvb, 0, length-20, data_tree); dissect_message_auth_code(next_tvb, length-20, data_tree); break; } case WAI_SUB_MULTICAST_ANNOUNCE: { /* Chapter 8.1.4.4.1 Multicast Key/STAKey Announcement [ref: 1] */ guint16 offset = 0; dissect_flag(tvb, offset, data_tree); offset += 1; dissect_mskid(tvb, offset, data_tree); offset += 1; dissect_uskid(tvb, offset, data_tree); offset += 1; dissect_addid(tvb, offset, data_tree); offset += 12; proto_tree_add_item(data_tree, hf_wai_data_pack_num, tvb, offset, 16, ENC_NA); offset += 16; dissect_key_announcement_identifier(tvb, offset, data_tree); offset += 16; offset += dissect_key_data(tvb, offset, data_tree, NULL); dissect_message_auth_code(tvb, offset, data_tree); break; } case WAI_SUB_MULTICAST_ANNOUNCE_RESP: { /* Chapter 8.1.4.4.2 Multicast Key/STAKey Announcement Response [ref: 1] */ dissect_flag(tvb, 0, data_tree); dissect_mskid(tvb, 1, data_tree); dissect_uskid(tvb, 2, data_tree); dissect_addid(tvb, 3, data_tree); dissect_key_announcement_identifier(tvb, 15, data_tree); dissect_message_auth_code(tvb, 31, data_tree); break; } default: break; }}
开发者ID:Nicholas1126,项目名称:wireshark-ex,代码行数:101,
示例19: dissect_evrc_auxstatic voiddissect_evrc_aux(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, evrc_variant_t evrc_variant){ guint8 oct; guint8 frame_count; guint8 i; guint32 offset, saved_offset; gboolean further_entries; guint32 len; proto_item *item = NULL; proto_tree *evrc_tree = NULL; proto_tree *toc_tree = NULL; int hf_mode_request; int hf_toc_frame_type_high; int hf_toc_frame_type_low; /* * assumed max number of speech frames based on * frame count being 5 bits + 1 */ guint8 speech_data_len[0x20]; col_set_str(pinfo->cinfo, COL_PROTOCOL, "EVRC"); if (!tree) return; offset = 0; memset(speech_data_len, 0, sizeof(speech_data_len)); len = tvb_reported_length(tvb); item = proto_tree_add_item(tree, proto_evrc, tvb, 0, len, ENC_NA); evrc_tree = proto_item_add_subtree(item, ett_evrc); if (evrc_variant == EVRC_VARIANT_EVRC_LEGACY) { /* legacy 'payload type 60' draft-ietf-avt-evrc-07.txt header format */ proto_tree_add_item(evrc_tree, hf_evrc_reserved, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(evrc_tree, hf_evrc_interleave_length, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(evrc_tree, hf_evrc_interleave_index, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; frame_count = 0; further_entries = TRUE; while (further_entries && (frame_count < sizeof(speech_data_len)) && ((len - offset) > 0)) { item = proto_tree_add_text(evrc_tree, tvb, offset, 1, "ToC [%u]", frame_count+1); toc_tree = proto_item_add_subtree(item, ett_toc); proto_tree_add_item(toc_tree, hf_evrc_legacy_toc_fe_ind, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(toc_tree, hf_evrc_legacy_toc_reduc_rate, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(toc_tree, hf_evrc_legacy_toc_frame_type, tvb, offset, 1, ENC_BIG_ENDIAN); oct = tvb_get_guint8(tvb, offset); further_entries = (oct & 0x80) ? TRUE : FALSE; speech_data_len[frame_count] = evrc_frame_type_to_octs((guint8)(oct & 0x7f)); frame_count++; offset++; } } else { /* RFC 3558 header format */ switch (evrc_variant) { default: proto_tree_add_expert(evrc_tree, pinfo, &ei_evrc_unknown_variant, tvb, offset, len); return; case EVRC_VARIANT_EVRC: hf_mode_request = hf_evrc_mode_request; hf_toc_frame_type_high = hf_evrc_toc_frame_type_high; hf_toc_frame_type_low = hf_evrc_toc_frame_type_low; proto_tree_add_item(evrc_tree, hf_evrc_reserved, tvb, offset, 1, ENC_BIG_ENDIAN); break; case EVRC_VARIANT_EVRC_B: hf_mode_request = hf_evrc_b_mode_request; hf_toc_frame_type_high = hf_evrc_b_toc_frame_type_high; hf_toc_frame_type_low = hf_evrc_b_toc_frame_type_low; proto_tree_add_item(evrc_tree, hf_evrc_reserved, tvb, offset, 1, ENC_BIG_ENDIAN); break; case EVRC_VARIANT_EVRC_WB: hf_mode_request = hf_evrc_wb_mode_request; hf_toc_frame_type_high = hf_evrc_b_toc_frame_type_high; hf_toc_frame_type_low = hf_evrc_b_toc_frame_type_low;//.........这里部分代码省略.........
开发者ID:dot-Sean,项目名称:wireshark-http2,代码行数:101,
示例20: dissect_mac_mgmt_msg_reg_rsp_decoder/* Decode REG-RSP messages. */static void dissect_mac_mgmt_msg_reg_rsp_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ guint offset = 0; guint tlv_offset; guint tvb_len; proto_item *reg_rsp_item; proto_tree *reg_rsp_tree; proto_item *tlv_item = NULL; proto_tree *tlv_tree = NULL; proto_tree *sub_tree = NULL; gboolean hmac_found = FALSE; tlv_info_t tlv_info; gint tlv_type; guint tlv_len; guint this_offset = 0; tlv_info_t sub_tlv_info; gint sub_tlv_type; gint sub_tlv_len; guint sub_tlv_offset; { /* we are being asked for details */ /* Get the tvb reported length */ tvb_len = tvb_reported_length(tvb); /* display MAC payload type REG-RSP */ reg_rsp_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_reg_rsp_decoder, tvb, offset, tvb_len, "MAC Management Message, REG-RSP"); /* add MAC REG-RSP subtree */ reg_rsp_tree = proto_item_add_subtree(reg_rsp_item, ett_mac_mgmt_msg_reg_rsp_decoder); proto_tree_add_item(reg_rsp_tree, hf_reg_rsp_status, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; while (offset < tvb_len) { /* Get the TLV data. */ init_tlv_info(&tlv_info, tvb, offset); /* get the TLV type */ tlv_type = get_tlv_type(&tlv_info); /* get the TLV length */ tlv_len = get_tlv_length(&tlv_info); if (tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1) { /* invalid tlv info */ col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "REG-RSP TLV error"); proto_tree_add_item(reg_rsp_tree, hf_reg_invalid_tlv, tvb, offset, (tvb_len - offset), ENC_NA); break; } /* get the offset to the TLV data */ tlv_offset = offset + get_tlv_value_offset(&tlv_info); switch (tlv_type) { case REG_ARQ_PARAMETERS: case REG_SS_MGMT_SUPPORT: case REG_IP_MGMT_MODE: case REG_IP_VERSION: case REG_UL_TRANSPORT_CIDS_SUPPORTED: case REG_IP_PHS_SDU_ENCAP: case REG_MAX_CLASSIFIERS_SUPPORTED: case REG_PHS_SUPPORT: case REG_ARQ_SUPPORT: case REG_DSX_FLOW_CONTROL: case REG_MCA_FLOW_CONTROL: case REG_MCAST_POLLING_CIDS: case REG_NUM_DL_TRANS_CID: case REG_MAC_ADDRESS:#ifdef WIMAX_16E_2005 case REG_TLV_T_20_MAX_MAC_DATA_PER_FRAME_SUPPORT: case REG_TLV_T_21_PACKING_SUPPORT: case REG_TLV_T_22_MAC_EXTENDED_RTPS_SUPPORT: case REG_TLV_T_23_MAX_NUM_BURSTS_TRANSMITTED_CONCURRENTLY_TO_THE_MS: case REG_TLV_T_26_METHOD_FOR_ALLOCATING_IP_ADDR_SECONDARY_MGMNT_CONNECTION: case REG_TLV_T_27_HANDOVER_SUPPORTED: case REG_TLV_T_29_HO_PROCESS_OPTIMIZATION_MS_TIMER: case REG_TLV_T_31_MOBILITY_FEATURES_SUPPORTED: case REG_TLV_T_40_ARQ_ACK_TYPE: case REG_TLV_T_41_MS_HO_CONNECTIONS_PARAM_PROCESSING_TIME: case REG_TLV_T_42_MS_HO_TEK_PROCESSING_TIME: case REG_TLV_T_43_MAC_HEADER_AND_EXTENDED_SUBHEADER_SUPPORT: case REG_POWER_SAVING_CLASS_CAPABILITY:#endif dissect_extended_tlv(reg_rsp_tree, tlv_type, tvb, tlv_offset, tlv_len, pinfo, offset, proto_mac_mgmt_msg_reg_rsp_decoder); break; case REG_RSP_SECONDARY_MGMT_CID: add_tlv_subtree(&tlv_info, reg_rsp_tree, hf_reg_rsp_secondary_mgmt_cid, tvb, offset, ENC_BIG_ENDIAN); break; case REG_RSP_TLV_T_36_TOTAL_PROVISIONED_SERVICE_FLOW_DSAs: add_tlv_subtree(&tlv_info, reg_rsp_tree, hf_reg_total_provisioned_sf, tvb, offset, ENC_BIG_ENDIAN); break; case REG_RSP_TLV_T_24_CID_UPDATE_ENCODINGS: /* Display CID update encodings */ /* add subtree */ sub_tree = add_protocol_subtree(&tlv_info, ett_reg_rsp_message_tree, reg_rsp_tree, proto_mac_mgmt_msg_reg_rsp_decoder, tvb, offset, tlv_len, "CID update encodings"); /* Use a local copy of tlv_offset */ this_offset = tlv_offset; while(this_offset < tlv_len) { /* Get the sub TLV data. */ init_tlv_info(&sub_tlv_info, tvb, this_offset); /* get the sub TLV type */ sub_tlv_type = get_tlv_type(&sub_tlv_info);//.........这里部分代码省略.........
开发者ID:MultipathDTLS,项目名称:wireshark,代码行数:101,
示例21: add_ethernet_trailer/* * Add an Ethernet trailer - which, for some captures, might be the FCS * rather than a pad-to-60-bytes trailer. * * If fcs_len is 0, we assume the frame has no FCS; if it's 4, we assume * it has an FCS; if it's anything else (such as -1, which means "maybe * it does, maybe it doesn't"), we try to infer whether it has an FCS. */voidadd_ethernet_trailer(packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree, int trailer_id, tvbuff_t *tvb, tvbuff_t *trailer_tvb, int fcs_len){ /* If there're some bytes left over, it could be a combination of: - padding to meet the minimum 64 byte frame length - an FCS, if present (if fcs_len is 0, we know it's not present; if fcs_len is 4, we know it's present; if fcs_len is -1, we need some heuristics to determine whether it's present) - information inserted by TAPs or other network monitoring equipment. If we don't know whether the FCS is present, then, if we don't have a network monitoring trailer, and if the Ethernet frame was claimed to have had 64 or more bytes - i.e., it was at least an FCS worth of data longer than the minimum payload size - we could assume the last 4 bytes of the trailer are an FCS. */ proto_item *item; proto_tree *checksum_tree; heur_dtbl_entry_t *hdtbl_entry; if (trailer_tvb) { guint trailer_length, trailer_reported_length; guint padding_length = 0; gboolean has_fcs = FALSE; tvbuff_t *real_trailer_tvb; trailer_length = tvb_captured_length(trailer_tvb); trailer_reported_length = tvb_reported_length(trailer_tvb); /* There can not have been padding when the length of the frame (including the trailer) is less than 60 bytes. */ if (eth_assume_padding && pinfo->fd->pkt_len>=60) { /* Calculate the amount of padding needed for a minimum sized frame */ if ( (pinfo->fd->pkt_len - trailer_reported_length) < 60 ) padding_length = 60 - (pinfo->fd->pkt_len - trailer_reported_length); /* Add the padding to the tree, unless it should be treated as part of the trailer and therefor be handed over to (one of) the ethernet-trailer dissectors */ if (padding_length > 0) { tvb_ensure_bytes_exist(tvb, 0, padding_length); proto_tree_add_item(fh_tree, hf_eth_padding, trailer_tvb, 0, padding_length, ENC_NA); trailer_length -= padding_length; trailer_reported_length -= padding_length; } } if (fcs_len != 0) { /* If fcs_len is 4, we assume we definitely have an FCS. Otherwise, then, if the frame is big enough that, if we have a trailer, it probably inclues an FCS, and we have enough space in the trailer for the FCS, we assume we have an FCS. "Big enough" means 64 bytes or more; any frame that big needs no trailer, as there's no need to pad an Ethernet packet past 60 bytes. The trailer must be at least 4 bytes long to have enough space for an FCS. */ if (fcs_len == 4 || (tvb_reported_length(tvb) >= 64 && trailer_reported_length >= 4)) { /* Either we know we have an FCS, or we believe we have an FCS. */ if (trailer_length < trailer_reported_length) { /* The packet is claimed to have enough data for a 4-byte FCS, but we didn't capture all of the packet. Slice off the 4-byte FCS from the reported length, and trim the captured length so it's no more than the reported length; that will slice off what of the FCS, if any, is in the captured packet. */ trailer_reported_length -= 4; if (trailer_length > trailer_reported_length) trailer_length = trailer_reported_length; has_fcs = TRUE; } else { /* We captured all of the packet, including what appears to be a 4-byte FCS. Slice it off. */ trailer_length -= 4; trailer_reported_length -= 4; has_fcs = TRUE; } } } /* Create a new tvb without the padding and/or the (assumed) fcs */ if (fcs_len==4) real_trailer_tvb = tvb_new_subset(trailer_tvb, padding_length, trailer_length, trailer_reported_length); else real_trailer_tvb = tvb_new_subset_remaining(trailer_tvb, padding_length);//.........这里部分代码省略.........
开发者ID:jiangxilong,项目名称:wireshark-1,代码行数:101,
示例22: parse_gsm_sms_ud_message/* Parse Short Message, only if UDH present * (otherwise this function is not called). * Call WSP dissector if port matches WSP traffic. */static voidparse_gsm_sms_ud_message(proto_tree *sm_tree, tvbuff_t *tvb, packet_info *pinfo, proto_tree *top_tree){ tvbuff_t *sm_tvb = NULL; proto_item *ti; proto_tree *subtree, *tree; guint8 udh_len, udh, len; guint sm_len = tvb_reported_length(tvb); guint sm_data_len; guint32 i = 0; /* Multiple Messages UDH */ gboolean is_fragmented = FALSE; fragment_head *fd_sm = NULL; guint16 sm_id = 0; guint16 frags = 0; guint16 frag = 0; gboolean save_fragmented = FALSE; gboolean try_gsm_sms_ud_reassemble = FALSE; /* SMS Message reassembly */ gboolean reassembled = FALSE; guint32 reassembled_in = 0; /* Port Number UDH */ guint16 p_src = 0; guint16 p_dst = 0; gboolean ports_available = FALSE; udh_len = tvb_get_guint8(tvb, i++); ti = proto_tree_add_uint(sm_tree, hf_gsm_sms_udh_length, tvb, 0, 1, udh_len); tree = proto_item_add_subtree(ti, ett_udh); while (i < udh_len) { udh = tvb_get_guint8(tvb, i++); len = tvb_get_guint8(tvb, i++); subtree = proto_tree_add_uint(tree, hf_gsm_sms_udh_iei, tvb, i-2, 2+len, udh); switch (udh) { case 0x00: /* Multiple messages - 8-bit message ID */ if (len == 3) { sm_id = tvb_get_guint8(tvb, i++); frags = tvb_get_guint8(tvb, i++); frag = tvb_get_guint8(tvb, i++); if (frags > 1) is_fragmented = TRUE; proto_item_append_text(subtree, ": message %u, part %u of %u", sm_id, frag, frags); subtree = proto_item_add_subtree(subtree, ett_udh_ie); proto_tree_add_uint(subtree, hf_gsm_sms_udh_multiple_messages_msg_id, tvb, i-3, 1, sm_id); proto_tree_add_uint(subtree, hf_gsm_sms_udh_multiple_messages_msg_parts, tvb, i-2, 1, frags); proto_tree_add_uint(subtree, hf_gsm_sms_udh_multiple_messages_msg_part, tvb, i-1, 1, frag); } else { proto_item_append_text(subtree, " - Invalid format!"); i += len; } break; case 0x08: /* Multiple messages - 16-bit message ID */ if (len == 4) { sm_id = tvb_get_ntohs(tvb, i); i += 2; frags = tvb_get_guint8(tvb, i++); frag = tvb_get_guint8(tvb, i++); if (frags > 1) is_fragmented = TRUE; proto_item_append_text(subtree, ": message %u, part %u of %u", sm_id, frag, frags); subtree = proto_item_add_subtree(subtree, ett_udh_ie); proto_tree_add_uint(subtree, hf_gsm_sms_udh_multiple_messages_msg_id, tvb, i-4, 2, sm_id); proto_tree_add_uint(subtree, hf_gsm_sms_udh_multiple_messages_msg_parts, tvb, i-2, 1, frags); proto_tree_add_uint(subtree, hf_gsm_sms_udh_multiple_messages_msg_part, tvb, i-1, 1, frag); } else { proto_item_append_text(subtree, " - Invalid format!"); i += len; } break; case 0x04: /* Port Number UDH - 8-bit address */ if (len == 2) { /* Port fields */ p_dst = tvb_get_guint8(tvb, i++); p_src = tvb_get_guint8(tvb, i++); proto_item_append_text(subtree, ": source port %u, destination port %u", p_src, p_dst); subtree = proto_item_add_subtree(subtree, ett_udh_ie);//.........这里部分代码省略.........
开发者ID:Ekleog,项目名称:wireshark,代码行数:101,
示例23: is_smb_direct parent_tree, remaining_length); } /* offset = data_offset + data_length; */ break; } return;}static enum SMB_DIRECT_HDR_TYPEis_smb_direct(tvbuff_t *tvb, packet_info *pinfo _U_){ gboolean maybe_neg_req = FALSE; gboolean maybe_data = FALSE; guint len = tvb_reported_length(tvb); if (len < 20) { return SMB_DIRECT_HDR_UNKNOWN; } if (len == 32 && tvb_get_letohs(tvb, 0) == 0x0100 && /* min version */ tvb_get_letohs(tvb, 2) == 0x0100 && /* max version */ tvb_get_letohs(tvb, 4) == 0x0100 && /* negotiated version */ tvb_get_letohs(tvb, 6) == 0x0000) /* reserved */ { /* Negotiate Response */ return SMB_DIRECT_HDR_NEG_REP; }
开发者ID:CharaD7,项目名称:wireshark,代码行数:30,
示例24: dissect_pbb_addressblockstatic int dissect_pbb_addressblock(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, guint maxoffset, guint8 addressType, guint8 addressSize) { guint8 addr[MAX_ADDR_SIZE]; guint8 numAddr; guint8 address_flags; guint8 head_length = 0, tail_length = 0; guint block_length = 0, midSize = 0; guint block_index = 0, head_index = 0, tail_index = 0, mid_index = 0, prefix_index = 0; proto_tree *addr_tree = NULL; proto_tree *addrFlags_tree = NULL; proto_tree *addrValue_tree = NULL; proto_item *addr_item = NULL; proto_item *addrFlags_item = NULL; proto_item *addrValue_item = NULL; int i = 0; if (maxoffset - offset < 2) { proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset, "Not enough octets for minimal addressblock header"); return tvb_reported_length(tvb); } DISSECTOR_ASSERT(addressSize <= MAX_ADDR_SIZE); memset(addr, 0, addressSize); block_length = 2; block_index = offset; midSize = addressSize; numAddr = tvb_get_guint8(tvb, offset++); address_flags = tvb_get_guint8(tvb, offset++); if ((address_flags & ADDR_HASHEAD) != 0) { head_index = offset; if (maxoffset - offset <= 0) { proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset, "Not enough octets for addressblock head"); return tvb_reported_length(tvb); } head_length = tvb_get_guint8(tvb, offset++); if (head_length > addressSize-1) { proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset, "address head length is too long"); return tvb_reported_length(tvb); } if (maxoffset - offset < head_length) { proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset, "Not enough octets for addressblock head"); return tvb_reported_length(tvb); } tvb_memcpy(tvb, addr, offset, head_length); midSize -= head_length; block_length += (head_length+1); offset += head_length; } if ((address_flags & ADDR_HASZEROTAIL) != 0) { tail_index = offset; if (maxoffset - offset <= 0) { proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset, "Not enough octets for addressblock tail"); return tvb_reported_length(tvb); } tail_length = tvb_get_guint8(tvb, offset++); if (tail_length > addressSize-1-head_length) { proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset, "address tail length is too long"); return tvb_reported_length(tvb); } midSize -= tail_length; block_length++; } else if ((address_flags & ADDR_HASFULLTAIL) != 0) { tail_index = offset; if (maxoffset - offset <= 0) { proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset, "Not enough octets for addressblock tail"); return tvb_reported_length(tvb); } tail_length = tvb_get_guint8(tvb, offset++); if (tail_length > addressSize-1-head_length) { proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset, "address tail length is too long"); return tvb_reported_length(tvb); } if (maxoffset - offset < tail_length) { proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset, "Not enough octets for addressblock tail"); return tvb_reported_length(tvb); }//.........这里部分代码省略.........
开发者ID:JudsonWilson,项目名称:wireshark,代码行数:101,
示例25: dissectstatic voiddissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto){ proto_tree *udp_tree = NULL; proto_item *ti, *hidden_item, *port_item; guint len; guint reported_len; vec_t cksum_vec[4]; guint32 phdr[2]; guint16 computed_cksum; int offset = 0; e_udphdr *udph; proto_tree *checksum_tree; proto_item *item; conversation_t *conv = NULL; struct udp_analysis *udpd = NULL; proto_tree *process_tree; udph=ep_new(e_udphdr); SET_ADDRESS(&udph->ip_src, pinfo->src.type, pinfo->src.len, pinfo->src.data); SET_ADDRESS(&udph->ip_dst, pinfo->dst.type, pinfo->dst.len, pinfo->dst.data); col_set_str(pinfo->cinfo, COL_PROTOCOL, (ip_proto == IP_PROTO_UDP) ? "UDP" : "UDPlite"); col_clear(pinfo->cinfo, COL_INFO); udph->uh_sport=tvb_get_ntohs(tvb, offset); udph->uh_dport=tvb_get_ntohs(tvb, offset+2); col_add_fstr(pinfo->cinfo, COL_INFO, "Source port: %s Destination port: %s", get_udp_port(udph->uh_sport), get_udp_port(udph->uh_dport)); if (tree) { if (udp_summary_in_tree) { if (ip_proto == IP_PROTO_UDP) { ti = proto_tree_add_protocol_format(tree, proto_udp, tvb, offset, 8, "User Datagram Protocol, Src Port: %s (%u), Dst Port: %s (%u)", get_udp_port(udph->uh_sport), udph->uh_sport, get_udp_port(udph->uh_dport), udph->uh_dport); } else { ti = proto_tree_add_protocol_format(tree, proto_udplite, tvb, offset, 8, "Lightweight User Datagram Protocol, Src Port: %s (%u), Dst Port: %s (%u)", get_udp_port(udph->uh_sport), udph->uh_sport, get_udp_port(udph->uh_dport), udph->uh_dport); } } else { ti = proto_tree_add_item(tree, (ip_proto == IP_PROTO_UDP) ? proto_udp : proto_udplite, tvb, offset, 8, ENC_NA); } udp_tree = proto_item_add_subtree(ti, ett_udp); port_item = proto_tree_add_uint_format(udp_tree, hf_udp_srcport, tvb, offset, 2, udph->uh_sport, "Source port: %s (%u)", get_udp_port(udph->uh_sport), udph->uh_sport); /* The beginning port number, 32768 + 666 (33434), is from LBL's traceroute.c source code and this code * further assumes that 3 attempts are made per hop */ if(udph->uh_sport > 32768 + 666 && udph->uh_sport <= 32768 + 666 + 30) expert_add_info_format(pinfo, port_item, PI_SEQUENCE, PI_CHAT, "Possible traceroute: hop #%u, attempt #%u", ((udph->uh_sport - 32768 - 666 - 1) / 3) + 1, ((udph->uh_sport - 32768 - 666 - 1) % 3) + 1 ); port_item = proto_tree_add_uint_format(udp_tree, hf_udp_dstport, tvb, offset + 2, 2, udph->uh_dport, "Destination port: %s (%u)", get_udp_port(udph->uh_dport), udph->uh_dport); if(udph->uh_dport > 32768 + 666 && udph->uh_dport <= 32768 + 666 + 30) expert_add_info_format(pinfo, port_item, PI_SEQUENCE, PI_CHAT, "Possible traceroute: hop #%u, attempt #%u", ((udph->uh_dport - 32768 - 666 - 1) / 3) + 1, ((udph->uh_dport - 32768 - 666 - 1) % 3) + 1 ); hidden_item = proto_tree_add_uint(udp_tree, hf_udp_port, tvb, offset, 2, udph->uh_sport); PROTO_ITEM_SET_HIDDEN(hidden_item); hidden_item = proto_tree_add_uint(udp_tree, hf_udp_port, tvb, offset+2, 2, udph->uh_dport); PROTO_ITEM_SET_HIDDEN(hidden_item); } if (ip_proto == IP_PROTO_UDP) { udph->uh_ulen = udph->uh_sum_cov = tvb_get_ntohs(tvb, offset+4); if (udph->uh_ulen < 8) { /* Bogus length - it includes the header, so it must be >= 8. */ /* XXX - should handle IPv6 UDP jumbograms (RFC 2675), where the length is zero */ item = proto_tree_add_uint_format(udp_tree, hf_udp_length, tvb, offset + 4, 2, udph->uh_ulen, "Length: %u (bogus, must be >= 8)", udph->uh_ulen); expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "Bad length value %u < 8", udph->uh_ulen); col_append_fstr(pinfo->cinfo, COL_INFO, " [BAD UDP LENGTH %u < 8]", udph->uh_ulen); return; } if ((udph->uh_ulen > tvb_reported_length(tvb)) && ! pinfo->fragmented && ! pinfo->flags.in_error_pkt) { /* Bogus length - it goes past the end of the IP payload */ item = proto_tree_add_uint_format(udp_tree, hf_udp_length, tvb, offset + 4, 2, udph->uh_ulen, "Length: %u (bogus, payload length %u)", udph->uh_ulen, tvb_reported_length(tvb)); expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "Bad length value %u > IP payload length", udph->uh_ulen); col_append_fstr(pinfo->cinfo, COL_INFO, " [BAD UDP LENGTH %u > IP PAYLOAD LENGTH]", udph->uh_ulen); } else { if (tree) { proto_tree_add_uint(udp_tree, hf_udp_length, tvb, offset + 4, 2, udph->uh_ulen); /* XXX - why is this here, given that this is UDP, not Lightweight UDP? */ hidden_item = proto_tree_add_uint(udp_tree, hf_udplite_checksum_coverage, tvb, offset + 4, 0, udph->uh_sum_cov); PROTO_ITEM_SET_HIDDEN(hidden_item); } } } else { udph->uh_ulen = pinfo->iplen - pinfo->iphdrlen; udph->uh_sum_cov = tvb_get_ntohs(tvb, offset+4);//.........这里部分代码省略.........
开发者ID:drower,项目名称:wireshark-1.10.0,代码行数:101,
注:本文中的tvb_reported_length函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ tvb_reported_length_remaining函数代码示例 C++ tvb_offset_exists函数代码示例 |