这篇教程C++ tvb_bytes_exist函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中tvb_bytes_exist函数的典型用法代码示例。如果您正苦于以下问题:C++ tvb_bytes_exist函数的具体用法?C++ tvb_bytes_exist怎么用?C++ tvb_bytes_exist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了tvb_bytes_exist函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: dissect_ice_facet/* * This function dissects an "Ice facet", adds hf(s) to "tree" and returns consumed * bytes in "*consumed", if errors "*consumed" is -1. */static void dissect_ice_facet(proto_tree *tree, int hf_icep, tvbuff_t *tvb, guint32 offset, gint32 *consumed){ /* p. 588, chapter 23.2.6: * "facet" is a StringSeq, a StringSeq is a: * sequence<string> * * * sequence == Size + SizeElements * sequence = 1byte (0..254) + SizeElements * or * sequence = 1byte (255) + 1int (255..2^32-1) + SizeElements * * * p.613. chapter 23.3.2 * "facet has either zero elements (empty) or one element" * * */ guint32 Size = 0; /* number of elements in the sequence */ char *s = NULL; (*consumed) = 0; /* check first byte */ if ( !tvb_bytes_exist(tvb, offset, 1) ) { if (tree) proto_tree_add_text(tree, tvb, offset, -1, "facet field missing"); if ( check_col(mypinfo->cinfo, COL_INFO) ) { col_append_str(mypinfo->cinfo, COL_INFO, " (facet field missing)"); } (*consumed) = -1; return; } /* get first byte of Size */ Size = tvb_get_guint8(tvb, offset); offset++; (*consumed)++; if ( Size == 0 ) { if (tree) { s = ep_strdup( "(empty)" ); /* display the 0x00 Size byte when click on a empty ice_string */ proto_tree_add_string(tree, hf_icep, tvb, offset - 1, 1, s); } return; } if ( Size == 1 ) { gint32 consumed_facet = 0; dissect_ice_string(tree, hf_icep, tvb, offset, &consumed_facet, NULL, TRUE); if ( consumed_facet == -1 ) { (*consumed) = -1; return; } offset += consumed_facet; (*consumed) += consumed_facet; return; } /* if here => Size > 1 => not possible */ if (tree) /* display the XX Size byte when click here */ proto_tree_add_text(tree, tvb, offset - 1, 1, "facet can be max one element"); if ( check_col(mypinfo->cinfo, COL_INFO) ) { col_append_str(mypinfo->cinfo, COL_INFO, " (facet can be max one element)"); } (*consumed) = -1; return;}
开发者ID:RazZziel,项目名称:wireshark-dplay,代码行数:90,
示例2: dissect_rlogin/**************************************************************** * Main dissection function ****************************************************************/static intdissect_rlogin(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data){ struct tcpinfo *tcpinfo = (struct tcpinfo *)data; conversation_t *conversation; rlogin_hash_entry_t *hash_info; guint length; gint ti_offset; /* Get or create conversation */ conversation = find_or_create_conversation(pinfo); /* Get or create data associated with this conversation */ hash_info = (rlogin_hash_entry_t *)conversation_get_proto_data(conversation, proto_rlogin); if (!hash_info) { /* Populate new data struct... */ hash_info = wmem_new(wmem_file_scope(), rlogin_hash_entry_t); hash_info->state = NONE; hash_info->info_framenum = 0; /* no frame has the number 0 */ hash_info->user_name[0] = '/0'; /* ... and store in conversation */ conversation_add_proto_data(conversation, proto_rlogin, hash_info); } /* Set protocol column text */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "Rlogin"); /* Set info column */ /* Show user-name if available */ if (hash_info->user_name[0]) { col_add_fstr(pinfo->cinfo, COL_INFO, "User name: %s, ", hash_info->user_name); } else { col_clear(pinfo->cinfo, COL_INFO); } /* Work out packet content summary for display */ length = tvb_reported_length(tvb); if (length != 0) { /* Initial NULL byte represents part of connection handshake */ if (tvb_get_guint8(tvb, 0) == '/0') { col_append_str(pinfo->cinfo, COL_INFO, (pinfo->destport == RLOGIN_PORT) ? "Start Handshake" : "Startup info received"); } else if (tcpinfo && IS_TH_URG(tcpinfo->flags) && length >= tcpinfo->urgent_pointer) { /* Urgent pointer inside current data represents a control message */ col_append_str(pinfo->cinfo, COL_INFO, "Control Message"); } else { /* Search for 2 consecutive ff bytes (signifies window change control message) */ ti_offset = tvb_find_guint8(tvb, 0, -1, 0xff); if (ti_offset != -1 && tvb_bytes_exist(tvb, ti_offset + 1, 1) && tvb_get_guint8(tvb, ti_offset + 1) == 0xff) { col_append_str(pinfo->cinfo, COL_INFO, "Terminal Info"); } else { /* Show any text data in the frame */ int bytes_to_copy = tvb_captured_length(tvb); if (bytes_to_copy > 128) { /* Truncate to 128 bytes for display */ bytes_to_copy = 128; } /* Add data into info column */ col_append_fstr(pinfo->cinfo, COL_INFO, "Data: %s", tvb_format_text(tvb, 0, bytes_to_copy)); } } } /* See if conversation state needs to be updated */ rlogin_state_machine(hash_info, tvb, pinfo); /* Dissect in detail */ rlogin_display(hash_info, tvb, pinfo, tree, tcpinfo); return tvb_captured_length(tvb);}
开发者ID:HeartFlying,项目名称:wireshark,代码行数:99,
示例3: dissect_wtp_common//.........这里部分代码省略.........#ifdef DEBUG fprintf( stderr, "dissect_wtp: cbHeader = %d/n", cbHeader );#endif /* * Any remaining data ought to be WSP data (if not WTP ACK, NACK * or ABORT pdu), so, if we have any remaining data, and it's * not an ACK, NACK, or ABORT PDU, hand it off (defragmented) to the * WSP dissector. * Note that the last packet of a fragmented WTP message needn't * contain any data, so we allow payloadless packets to be * reassembled. (XXX - does the reassembly code handle this * for packets other than the last packet?) * * Try calling a subdissector only if: * - The WTP payload is ressembled in this very packet, * - The WTP payload is not fragmented across packets. */ dataOffset = offCur + cbHeader + vHeader; dataLen = tvb_reported_length_remaining(tvb, dataOffset); if ((dataLen >= 0) && ! ((pdut==ACK) || (pdut==NEGATIVE_ACK) || (pdut==ABORT))) { /* Try to reassemble if needed, and hand over to WSP * A fragmented WTP packet is either: * - An INVOKE with fTTR (transmission trailer) not set, * - a SEGMENTED_INVOKE, * - A RESULT with fTTR (transmission trailer) not set, * - a SEGMENTED_RESULT. */ if ( ( (pdut == SEGMENTED_INVOKE) || (pdut == SEGMENTED_RESULT) || ( ((pdut == INVOKE) || (pdut == RESULT)) && (!fTTR) ) ) && tvb_bytes_exist(tvb, dataOffset, dataLen) ) { /* Try reassembling fragments */ fragment_head *fd_wtp = NULL; guint32 reassembled_in = 0; gboolean save_fragmented = pinfo->fragmented; pinfo->fragmented = TRUE; fd_wtp = fragment_add_seq(&wtp_reassembly_table, tvb, dataOffset, pinfo, TID, NULL, psn, dataLen, !fTTR, 0); /* XXX - fragment_add_seq() yields NULL unless Wireshark knows * that the packet is part of a reassembled whole. This means * that fd_wtp will be NULL as long as Wireshark did not encounter * (and process) the packet containing the last fragment. * This implies that Wireshark needs two passes over the data for * correct reassembly. At the first pass, a capture containing * three fragments plus a retransmssion of the last fragment * will progressively show: * * Packet 1: (Unreassembled fragment 1) * Packet 2: (Unreassembled fragment 2) * Packet 3: (Reassembled WTP) * Packet 4: (WTP payload reassembled in packet 3) * * However at subsequent evaluation (e.g., by applying a display * filter) the packet summary will show: * * Packet 1: (WTP payload reassembled in packet 3) * Packet 2: (WTP payload reassembled in packet 3) * Packet 3: (Reassembled WTP) * Packet 4: (WTP payload reassembled in packet 3) * * This is important to know, and also affects read filters!
开发者ID:kevincox,项目名称:wireshark,代码行数:67,
示例4: req_resp_hdrs_do_reassembly//.........这里部分代码省略......... */ chunked_encoding = TRUE; } } } } } } /* * The above loop ends when we reached the end of the headers, so * there should be content_length bytes after the 4 terminating bytes * and next_offset points to after the end of the headers. */ if (desegment_body) { if (content_length_found) { if (content_length >= 128*1024) { /* MS-RPCH stipulate that the content-length must be between 128K and 2G */ gchar *tmp; if (content_type_found && strncmp(content_type, "application/rpc", 15) == 0) { /* It looks like a RPC_IN_DATA request or a RPC_OUT_DATA response * in which the content-length is meaningless */ return TRUE; } /* Following sizeof will return the length of the string + /0 we need to not count it*/ tmp = tvb_get_ephemeral_string(tvb, 0, sizeof("RPC_OUT_DATA") - 1); if ((strncmp(tmp, "RPC_IN_DATA", sizeof("RPC_IN_DATA") - 1) == 0) || (strncmp(tmp, "RPC_OUT_DATA", sizeof("RPC_OUT_DATA") - 1) == 0)) { return TRUE; } } /* next_offset has been set to the end of the headers */ if (!tvb_bytes_exist(tvb, next_offset, content_length)) { length_remaining = tvb_length_remaining(tvb, next_offset); reported_length_remaining = tvb_reported_length_remaining(tvb, next_offset); if (length_remaining < reported_length_remaining) { /* * It's a waste of time asking for more * data, because that data wasn't captured. */ return TRUE; } if (length_remaining == -1) length_remaining = 0; pinfo->desegment_offset = offset; pinfo->desegment_len = content_length - length_remaining; return FALSE; } } else if (chunked_encoding) { /* * This data is chunked, so we need to keep pulling * data until we reach the end of the stream, or a * zero sized chunk. * * XXX * This doesn't bother with trailing headers; I don't * think they are really used, and we'd have to use * is_http_request_or_reply() to determine if it was * a trailing header, or the start of a new response. */ gboolean done_chunking = FALSE;
开发者ID:hubolo,项目名称:wireshark-1.8.0,代码行数:66,
示例5: dissect_nhrp_hdrvoid dissect_nhrp_hdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint *pOffset, gint *pMandLen, gint *pExtLen, oui_info_t **pOuiInfo, e_nhrp_hdr *hdr){ gint offset = *pOffset; const gchar *pro_type_str; guint total_len = tvb_reported_length(tvb); guint16 ipcsum, rx_chksum; proto_item *nhrp_tree_item = NULL; proto_tree *nhrp_tree = NULL; proto_item *shtl_tree_item = NULL; proto_tree *shtl_tree = NULL; proto_item *sstl_tree_item = NULL; proto_tree *sstl_tree = NULL; proto_item *ti; nhrp_tree_item = proto_tree_add_text(tree, tvb, offset, 20, "NHRP Fixed Header"); nhrp_tree = proto_item_add_subtree(nhrp_tree_item, ett_nhrp_hdr); hdr->ar_pktsz = tvb_get_ntohs(tvb, 10); if (total_len > hdr->ar_pktsz) { total_len = hdr->ar_pktsz; } hdr->ar_afn = tvb_get_ntohs(tvb, offset); proto_tree_add_item(nhrp_tree, hf_nhrp_hdr_afn, tvb, offset, 2, FALSE); offset += 2; hdr->ar_pro_type = tvb_get_ntohs(tvb, offset); if (hdr->ar_pro_type <= 0xFF) { /* It's an NLPID */ pro_type_str = val_to_str(hdr->ar_pro_type, nlpid_vals, "Unknown NLPID"); } else if (hdr->ar_pro_type <= 0x3FF) { /* Reserved for future use by the IETF */ pro_type_str = "Reserved for future use by the IETF"; } else if (hdr->ar_pro_type <= 0x04FF) { /* Allocated for use by the ATM Forum */ pro_type_str = "Allocated for use by the ATM Forum"; } else if (hdr->ar_pro_type <= 0x05FF) { /* Experimental/Local use */ pro_type_str = "Experimental/Local use"; } else { pro_type_str = val_to_str(hdr->ar_pro_type, etype_vals, "Unknown Ethertype"); } proto_tree_add_uint_format(nhrp_tree, hf_nhrp_hdr_pro_type, tvb, offset, 2, hdr->ar_pro_type, "Protocol Type (short form): %s (0x%04x)", pro_type_str, hdr->ar_pro_type); offset += 2; if (hdr->ar_pro_type == NLPID_SNAP) { /* * The long form protocol type is a SNAP OUI and PID. */ hdr->ar_pro_type_oui = tvb_get_ntoh24(tvb, offset); proto_tree_add_uint(nhrp_tree, hf_nhrp_hdr_pro_snap_oui, tvb, offset, 3, hdr->ar_pro_type_oui); offset += 3; hdr->ar_pro_type_pid = tvb_get_ntohs(tvb, offset); *pOuiInfo = get_snap_oui_info(hdr->ar_pro_type_oui); if (*pOuiInfo != NULL) { proto_tree_add_uint(nhrp_tree, *(*pOuiInfo)->field_info->p_id, tvb, offset, 2, hdr->ar_pro_type_pid); } else { proto_tree_add_uint(nhrp_tree, hf_nhrp_hdr_pro_snap_pid, tvb, offset, 2, hdr->ar_pro_type_pid); } } else { /* * XXX - we should check that this is zero, as RFC 2332 * says it should be zero. */ proto_tree_add_text(nhrp_tree, tvb, offset, 5, "Protocol Type (long form): %s", tvb_bytes_to_str(tvb, offset, 5)); offset += 5; } proto_tree_add_item(nhrp_tree, hf_nhrp_hdr_hopcnt, tvb, offset, 1, FALSE); offset += 1; proto_tree_add_item(nhrp_tree, hf_nhrp_hdr_pktsz, tvb, offset, 2, FALSE); offset += 2; rx_chksum = tvb_get_ntohs(tvb, offset); if (tvb_bytes_exist(tvb, 0, total_len)) { ipcsum = nhrp_checksum(tvb_get_ptr(tvb, 0, total_len), total_len); if (ipcsum == 0) { proto_tree_add_uint_format(nhrp_tree, hf_nhrp_hdr_chksum, tvb, offset, 2, rx_chksum, "NHRP Packet checksum: 0x%04x [correct]", rx_chksum);//.........这里部分代码省略.........
开发者ID:AkhilaAG,项目名称:gluster-wireshark-1.4,代码行数:101,
示例6: client_display_socks_v5static voidclient_display_socks_v5(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, socks_hash_entry_t *hash_info, sock_state_t* state_info) {/* Display the protocol tree for the version. This routine uses the *//* stored conversation information to decide what to do with the row. *//* Per packet information would have been better to do this, but we *//* didn't have that when I wrote this. And I didn't expect this to get *//* so messy. */ unsigned int i; const char *AuthMethodStr; sock_state_t new_state_info; /* Either there is an error, or we're done with the state machine (so there's nothing to display) */ if (state_info == NULL) return; proto_tree_add_item( tree, hf_socks_ver, tvb, offset, 1, ENC_BIG_ENDIAN); ++offset; if (state_info->client == clientStart) { proto_tree *AuthTree; proto_item *ti; guint8 num_auth_methods, auth; ti = proto_tree_add_text( tree, tvb, offset, -1, "Client Authentication Methods"); AuthTree = proto_item_add_subtree(ti, ett_socks_auth); num_auth_methods = tvb_get_guint8(tvb, offset); proto_item_set_len(ti, num_auth_methods+1); proto_tree_add_item( AuthTree, hf_client_auth_method_count, tvb, offset, 1, ENC_NA); ++offset; for( i = 0; i < num_auth_methods; ++i) { auth = tvb_get_guint8( tvb, offset); AuthMethodStr = get_auth_method_name(auth); proto_tree_add_uint_format(AuthTree, hf_client_auth_method, tvb, offset, 1, auth, "Method[%u]: %u (%s)", i, auth, AuthMethodStr); ++offset; } if ((num_auth_methods == 1) && (tvb_bytes_exist(tvb, offset + 2, 1)) && (tvb_get_guint8(tvb, offset + 2) == 0) && (tvb_reported_length_remaining(tvb, offset + 2 + num_auth_methods) > 0)) { new_state_info.client = clientV5Command; client_display_socks_v5(tvb, offset, pinfo, tree, hash_info, &new_state_info); } } else if (state_info->client == clientV5Command) { proto_tree_add_item( tree, hf_socks_cmd, tvb, offset, 1, ENC_NA); ++offset; proto_tree_add_item( tree, hf_socks_reserved, tvb, offset, 1, ENC_NA); ++offset; offset = display_address(tvb, offset, tree); proto_tree_add_item( tree, hf_client_port, tvb, offset, 2, ENC_BIG_ENDIAN); } else if ((state_info->client == clientWaitForAuthReply) && (state_info->server == serverInitReply)) { guint16 len; gchar* str; switch(hash_info->authentication_method) { case NO_AUTHENTICATION: break; case USER_NAME_AUTHENTICATION: /* process user name */ len = tvb_get_guint8(tvb, offset); str = tvb_get_string(wmem_packet_scope(), tvb, offset+1, len); proto_tree_add_string(tree, hf_socks_username, tvb, offset, len+1, str); offset += (len+1); len = tvb_get_guint8(tvb, offset); str = tvb_get_string(wmem_packet_scope(), tvb, offset+1, len); proto_tree_add_string(tree, hf_socks_password, tvb, offset, len+1, str); /* offset += (len+1); */ break; case GSS_API_AUTHENTICATION: proto_tree_add_item( tree, hf_gssapi_command, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item( tree, hf_gssapi_length, tvb, offset+1, 2, ENC_BIG_ENDIAN); len = tvb_get_ntohs(tvb, offset+1); if (len > 0) proto_tree_add_item( tree, hf_gssapi_payload, tvb, offset+3, len, ENC_NA); break; default: break; } }}
开发者ID:huzhiren,项目名称:wireshark,代码行数:98,
示例7: dissect_slimp3static intdissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ const char *opcode_str; proto_tree *slimp3_tree = NULL; proto_item *ti = NULL, *hidden_item; gint i1; gint offset = 0; guint16 opcode; guchar lcd_char; char lcd_str[MAX_LCD_STR_LEN + 1]; int to_server = FALSE; int old_protocol = FALSE; address tmp_addr; gboolean in_str; int lcd_strlen; /* * If it doesn't begin with a known opcode, reject it, so that * traffic that happens to be do or from one of our ports * doesn't get misidentified as SliMP3 traffic. */ if (!tvb_bytes_exist(tvb, offset, 1)) return 0; /* not even an opcode */ opcode = tvb_get_guint8(tvb, offset); opcode_str = match_strval(opcode, slimp3_opcode_vals); if (opcode_str == NULL) return 0; col_set_str(pinfo->cinfo, COL_PROTOCOL, "SliMP3"); if (check_col(pinfo->cinfo, COL_INFO)) { col_add_str(pinfo->cinfo, COL_INFO, opcode_str); } if (tree) { ti = proto_tree_add_item(tree, proto_slimp3, tvb, offset, -1, ENC_NA); slimp3_tree = proto_item_add_subtree(ti, ett_slimp3); proto_tree_add_uint(slimp3_tree, hf_slimp3_opcode, tvb, offset, 1, opcode); } /* The new protocol (v1.3 and later) uses an IANA-assigned port number. * It usually uses the same number for both sizes of the conversation, so * the port numbers can't always be used to determine client and server. * The new protocol places the clients MAC address in the packet, so that * is used to identify packets originating at the client. */ if ((pinfo->destport == UDP_PORT_SLIMP3_V2) && (pinfo->srcport == UDP_PORT_SLIMP3_V2)) { SET_ADDRESS(&tmp_addr, AT_ETHER, 6, tvb_get_ptr(tvb, offset+12, 6)); to_server = ADDRESSES_EQUAL(&tmp_addr, &pinfo->dl_src); } else if (pinfo->destport == UDP_PORT_SLIMP3_V2) { to_server = TRUE; } else if (pinfo->srcport == UDP_PORT_SLIMP3_V2) { to_server = FALSE; } if (pinfo->destport == UDP_PORT_SLIMP3_V1) { to_server = TRUE; old_protocol = TRUE; } else if (pinfo->srcport == UDP_PORT_SLIMP3_V1) { to_server = FALSE; old_protocol = TRUE; } switch (opcode) { case SLIMP3_IR: /* IR code * * [0] 'i' as in "IR" * [1] 0x00 * [2..5] player's time since startup in ticks @625 KHz * [6] IR code id, ff=JVC, 02=SLIMP3 * [7] number of meaningful bits - 16 for JVC, 32 for SLIMP3 * [8..11] the 32-bit IR code * [12..17] reserved */ if (tree) { hidden_item = proto_tree_add_item(slimp3_tree, hf_slimp3_ir, tvb, offset+8, 4, ENC_BIG_ENDIAN); PROTO_ITEM_SET_HIDDEN(hidden_item); i1 = tvb_get_ntohl(tvb, offset+2); proto_tree_add_text(slimp3_tree, tvb, offset+2, 4, "Uptime: %u sec (%u ticks)", i1/625000, i1); i1 = tvb_get_guint8(tvb, offset+6); proto_tree_add_text(slimp3_tree, tvb, offset+6, 1, "Code identifier: 0x%0x: %s", i1, val_to_str(i1, slimp3_ir_types, "Unknown")); proto_tree_add_text(slimp3_tree, tvb, offset+7, 1, "Code bits: %d", tvb_get_guint8(tvb, offset+7)); i1 = tvb_get_ntohl(tvb, offset+8); /* Check the code to figure out which remote is being used. */ if (tvb_get_guint8(tvb, offset+6) == 0x02 &&//.........这里部分代码省略.........
开发者ID:hubolo,项目名称:wireshark-1.8.0,代码行数:101,
示例8: dissect_ice_string/* * This function dissects an "Ice string", adds hf to "tree" and returns consumed * bytes in "*consumed", if errors "*consumed" is -1. * * "*dest" is a null terminated version of the dissected Ice string. */static void dissect_ice_string(packet_info *pinfo, proto_tree *tree, proto_item *item, int hf_icep, tvbuff_t *tvb, guint32 offset, gint32 *consumed, char **dest){ /* p. 586 chapter 23.2.1 and p. 588 chapter 23.2.5 * string == Size + content * string = 1byte (0..254) + string not null terminated * or * string = 1byte (255) + 1int (255..2^32-1) + string not null terminated */ guint32 Size = 0; char *s = NULL; (*consumed) = 0; /* check for first byte */ if ( !tvb_bytes_exist(tvb, offset, 1) ) { if (item) expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "1st byte of Size missing"); col_append_str(mypinfo->cinfo, COL_INFO, " (1st byte of Size missing)"); (*consumed) = -1; return; } /* get the Size */ Size = tvb_get_guint8(tvb, offset); offset++; (*consumed)++; if ( Size == 255 ) { /* check for next 4 bytes */ if ( !tvb_bytes_exist(tvb, offset, 4) ) { if (item) expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "second field of Size missing"); col_append_str(mypinfo->cinfo, COL_INFO, " (second field of Size missing)"); (*consumed) = -1; return; } /* get second field of Size */ Size = tvb_get_letohl(tvb, offset); offset += 4; (*consumed) += 4; } DBG1("string.Size --> %d/n", Size); /* check if the string exists */ if ( !tvb_bytes_exist(tvb, offset, Size) ) { if (item) expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "missing or truncated string"); col_append_str(mypinfo->cinfo, COL_INFO, " (missing or truncated string)"); (*consumed) = -1; return; } if ( Size > icep_max_ice_string_len ) { if (item) expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "string too long"); col_append_str(mypinfo->cinfo, COL_INFO, " (string too long)"); (*consumed) = -1; return; } if ( Size != 0 ) { s = tvb_get_ephemeral_string(tvb, offset, Size); if (tree) proto_tree_add_string(tree, hf_icep, tvb, offset, Size, s); } else { s = g_strdup("(empty)"); /* display the 0x00 Size byte when click on a empty ice_string */ if (tree) proto_tree_add_string(tree, hf_icep, tvb, offset - 1, 1, s); } if ( dest != NULL ) *dest = s; /*offset += Size;*/ (*consumed) += Size;//.........这里部分代码省略.........
开发者ID:SayCV,项目名称:wireshark,代码行数:101,
示例9: dissect_mpeg_audio_framestatic gbooleandissect_mpeg_audio_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ guint32 h; struct mpa mpa; int data_size = 0; asn1_ctx_t asn1_ctx; int offset = 0; static const char *version_names[] = { "1", "2", "2.5" }; if (!tvb_bytes_exist(tvb, 0, 4)) return FALSE; /* not enough data for an MPEG audio frame */ h = tvb_get_ntohl(tvb, 0); MPA_UNMARSHAL(&mpa, h); if (!MPA_SYNC_VALID(&mpa)) return FALSE; if (!MPA_VERSION_VALID(&mpa)) return FALSE; if (!MPA_LAYER_VALID(&mpa)) return FALSE; col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "MPEG-%s", version_names[mpa_version(&mpa)]); col_add_fstr(pinfo->cinfo, COL_INFO, "Audio Layer %d", mpa_layer(&mpa) + 1); if (MPA_BITRATE_VALID(&mpa) && MPA_FREQUENCY_VALID(&mpa)) { data_size = (int)(MPA_DATA_BYTES(&mpa) - sizeof mpa); if (check_col(pinfo->cinfo, COL_DEF_SRC)) { SET_ADDRESS(&pinfo->src, AT_NONE, 0, NULL); col_add_fstr(pinfo->cinfo, COL_DEF_SRC, "%d kb/s", mpa_bitrate(&mpa) / 1000); } if (check_col(pinfo->cinfo, COL_DEF_DST)) { SET_ADDRESS(&pinfo->dst, AT_NONE, 0, NULL); col_add_fstr(pinfo->cinfo, COL_DEF_DST, "%g kHz", mpa_frequency(&mpa) / (float)1000); } } if (tree == NULL) return TRUE; asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, pinfo); offset = dissect_mpeg_audio_Audio(tvb, offset, &asn1_ctx, tree, proto_mpeg_audio); if (data_size > 0) { unsigned int padding; proto_tree_add_item(tree, hf_mpeg_audio_data, tvb, offset / 8, data_size, FALSE); offset += data_size * 8; padding = mpa_padding(&mpa); if (padding > 0) { proto_tree_add_item(tree, hf_mpeg_audio_padbytes, tvb, offset / 8, padding, FALSE); offset += padding * 8; } } return TRUE;}
开发者ID:AkhilaAG,项目名称:gluster-wireshark-1.4,代码行数:61,
示例10: dissect_clnp//.........这里部分代码省略......... "Segment offset : %6u", segment_offset); proto_tree_add_text(clnp_tree, tvb, offset + 4 , 2, "Total length : %6u", tvb_get_ntohs(tvb, offset + 4)); } offset += 6; opt_len -= 6; } if (tree) { /* To do : decode options */#if 0 proto_tree_add_text(clnp_tree, tvb, offset, cnf_hdr_len - offset, "Options/Data: <not shown>");#endif/* QUICK HACK Option Len:= PDU_Hd_length-( FixedPart+AddresPart+SegmentPart )*/ dissect_osi_options( opt_len, tvb, offset, clnp_tree ); } offset = cnf_hdr_len; /* If clnp_reassemble is on, this is a segment, we have all the * data in the segment, and the checksum is valid, then just add the * segment to the hashtable. */ save_fragmented = pinfo->fragmented; if (clnp_reassemble && (cnf_type & CNF_SEG_OK) && ((cnf_type & CNF_MORE_SEGS) || segment_offset != 0) && tvb_bytes_exist(tvb, offset, segment_length - cnf_hdr_len) && segment_length > cnf_hdr_len && cksum_status != CKSUM_NOT_OK) { fd_head = fragment_add_check(tvb, offset, pinfo, du_id, clnp_segment_table, clnp_reassembled_table, segment_offset, segment_length - cnf_hdr_len, cnf_type & CNF_MORE_SEGS); next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled CLNP", fd_head, &clnp_frag_items, &update_col_info, clnp_tree); } else { /* If this is the first segment, dissect its contents, otherwise just show it as a segment. XXX - if we eventually don't save the reassembled contents of all segmented datagrams, we may want to always reassemble. */ if ((cnf_type & CNF_SEG_OK) && segment_offset != 0) { /* Not the first segment - don't dissect it. */ next_tvb = NULL; } else { /* First segment, or not segmented. Dissect what we have here. */ /* Get a tvbuff for the payload. */ next_tvb = tvb_new_subset_remaining(tvb, offset); /* * If this is the first segment, but not the only segment, * tell the next protocol that. */ if ((cnf_type & (CNF_SEG_OK|CNF_MORE_SEGS)) == (CNF_SEG_OK|CNF_MORE_SEGS)) pinfo->fragmented = TRUE; else pinfo->fragmented = FALSE;
开发者ID:hubolo,项目名称:wireshark-1.8.0,代码行数:67,
示例11: osi_check_and_get_checksumgbooleanosi_check_and_get_checksum( tvbuff_t *tvb, int offset, guint len, int offset_check, guint16* result) { const guint8 *p; guint8 discard = 0; guint32 c0, c1, factor; guint seglen, initlen = len; guint i; int block, x, y; /* Make sure the checksum is part of the data being checksummed. */ DISSECTOR_ASSERT(offset_check >= offset); DISSECTOR_ASSERT((guint)offset_check + 2 <= (guint)offset + len); /* * If we don't have all the data to be checksummed, report that and don't * try checksumming. */ if (!tvb_bytes_exist(tvb, offset, len)) return FALSE; offset_check -= offset; p = tvb_get_ptr( tvb, offset, len ); block = offset_check / 5803; /* * The maximum values of c0 and c1 will occur if all bytes have the * value 255; if so, then c0 will be len*255 and c1 will be * (len*255 + (len-1)*255 + ... + 255), which is * (len + (len - 1) + ... + 1)*255, or 255*(len*(len + 1))/2. * This means it can overflow if "len" is 5804 or greater. * * (A+B) mod 255 = ((A mod 255) + (B mod 255) mod 255, so * we can solve this by taking c0 and c1 mod 255 every * 5803 bytes. */ c0 = 0; c1 = 0; while (len != 0) { seglen = len; if ( block-- == 0 ) { seglen = offset_check % 5803; discard = 1; } else if ( seglen > 5803 ) seglen = 5803; for (i = 0; i < seglen; i++) { c0 = c0 + *(p++); c1 += c0; } if ( discard ) { /* * This works even if (offset_check % 5803) == 5802 */ p += 2; c1 += 2*c0; len -= 2; discard = 0; } c0 = c0 % 255; c1 = c1 % 255; len -= seglen; } factor = ( initlen - offset_check ) * c0; x = factor - c0 - c1; y = c1 - factor - 1; /* * This algorithm uses the 8 bits one's complement arithmetic. * Therefore, we must correct an effect produced * by the "standard" arithmetic (two's complement) */ if (x < 0 ) x--; if (y > 0 ) y++; x %= 255; y %= 255; if (x == 0) x = 0xFF; if (y == 0) y = 0x01; *result = ( x << 8 ) | ( y & 0xFF ); return TRUE;}
开发者ID:wireshark,项目名称:wireshark,代码行数:87,
示例12: get_next_fcip_header_offset/* This routine attempts to locate the position of the next header in the * provided segment */static guintget_next_fcip_header_offset (tvbuff_t *tvb, packet_info *pinfo, gint offset){ gint bytes_remaining = tvb_reported_length_remaining (tvb, offset); gint frame_len; guint16 flen, flen1; fcip_eof_t eof, eofc; /* * As per the FCIP standard, the following tests must PASS: * 1) Frame Length field validation -- 15 < Frame Length < 545; * 2) Comparison of Frame Length field to its ones complement; and * 3) A valid EOF is found in the word preceding the start of the next * FCIP header as indicated by the Frame Length field, to be tested * as follows: * 1) Bits 24-31 and 16-23 contain identical legal EOF values (the * list of legal EOF values is in the FC Frame Encapsulation * [21]); and * 2) Bits 8-15 and 0-7 contain the ones complement of the EOF * value found in bits 24-31. * * As per the FCIP standard, in addition, at least 3 of the following set * of tests must be performed to identify that we've located the start of * an FCIP frame. * a) Protocol# ones complement field (1 test); * b) Version ones complement field (1 test); * c) Replication of encapsulation word 0 in word 1 (1 test); * d) Reserved field and its ones complement (2 tests); * e) Flags field and its ones complement (2 tests); * f) CRC field is equal to zero (1 test); (DON'T DO THIS TEST!) * g) SOF fields and ones complement fields (4 tests); * h) Format and values of FC header (1 test); * i) CRC of FC Frame (2 tests); * j) FC Frame Encapsulation header information in the next FCIP Frame * (1 test). * * At least 3 of the 16 tests listed above SHALL be performed. Failure * of any of the above tests actually performed SHALL indicate an * encapsulation error and the FC Frame SHALL NOT be forwarded on to * the FC Entity. */NXT_BYTE: while (bytes_remaining) { if (bytes_remaining < FCIP_ENCAP_HEADER_LEN) { if(fcip_desegment && pinfo->can_desegment) { /* * This frame doesn't have all of the data for * the message header, but we can do reassembly on it. * * Tell the TCP dissector where the data for this * message starts in the data it handed us, and that we need * "some more data." Don't tell it exactly how many bytes * we need because if/when we ask for even more (after the * header) that will break reassembly. */ pinfo->desegment_offset = offset; pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT; return -2; } } /* I check that we have a valid header before checking for the frame * length and the other initial tests. */ /* * Tests a, b and c */ if (tvb_memeql(tvb, offset, fcip_header_8_bytes, 8) != 0) { offset++; bytes_remaining--; goto NXT_BYTE; } flen = (tvb_get_ntohs (tvb, offset+12)) & 0x03FF; frame_len = (tvb_get_ntohs (tvb, offset+12) & 0x03FF)*4; if ((flen < 15) || (flen > 545)) { /* Frame length check failed. Skip byte and try again */ offset++; bytes_remaining--; goto NXT_BYTE; } flen1 = (tvb_get_ntohs (tvb, offset+14)) & 0x03FF; if ((flen & 0x03FF) != ((~flen1)&0x03FF)) { /* frame_len and its one's complement are not the same */ offset++; bytes_remaining--; goto NXT_BYTE; } /* Valid EOF check */ if (tvb_bytes_exist (tvb, offset+(frame_len-1)*4, 4)) { eof = (fcip_eof_t)tvb_get_guint8 (tvb, offset+(frame_len-1)*4); eofc = (fcip_eof_t)tvb_get_guint8 (tvb, offset+(frame_len-1)*4+2);//.........这里部分代码省略.........
开发者ID:ajitlakhwani,项目名称:wireshark,代码行数:101,
示例13: dissect_ice_facet/* * This function dissects an "Ice facet", adds hf(s) to "tree" and returns consumed * bytes in "*consumed", if errors "*consumed" is -1. */static void dissect_ice_facet(packet_info *pinfo, proto_tree *tree, proto_item *item, int hf_icep, tvbuff_t *tvb, guint32 offset, gint32 *consumed){ /* p. 588, chapter 23.2.6: * "facet" is a StringSeq, a StringSeq is a: * sequence<string> * * * sequence == Size + SizeElements * sequence = 1byte (0..254) + SizeElements * or * sequence = 1byte (255) + 1int (255..2^32-1) + SizeElements * * * p.613. chapter 23.3.2 * "facet has either zero elements (empty) or one element" * * */ guint32 Size = 0; /* number of elements in the sequence */ (*consumed) = 0; /* check first byte */ if ( !tvb_bytes_exist(tvb, offset, 1) ) { if (item) expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "facet field missing"); col_append_str(mypinfo->cinfo, COL_INFO, " (facet field missing)"); (*consumed) = -1; return; } /* get first byte of Size */ Size = tvb_get_guint8(tvb, offset); offset++; (*consumed)++; if ( Size == 0 ) { if (tree) { /* display the 0x00 Size byte when click on a empty ice_string */ proto_tree_add_string(tree, hf_icep, tvb, offset - 1, 1, "(empty)"); } return; } if ( Size == 1 ) { gint32 consumed_facet = 0; dissect_ice_string(pinfo, tree, item, hf_icep, tvb, offset, &consumed_facet, NULL); if ( consumed_facet == -1 ) { (*consumed) = -1; return; } /*offset += consumed_facet;*/ (*consumed) += consumed_facet; return; } /* if here => Size > 1 => not possible */ if (item) /* display the XX Size byte when click here */ expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "facet can be max one element"); col_append_str(mypinfo->cinfo, COL_INFO, " (facet can be max one element)"); (*consumed) = -1; return;}
开发者ID:SayCV,项目名称:wireshark,代码行数:83,
示例14: dissect_fcipstatic gbooleandissect_fcip (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean check_port){ gint offset = 0, start = 0, frame_len = 0; gint bytes_remaining = tvb_captured_length (tvb); guint8 pflags, sof = 0, eof = 0; /* Set up structures needed to add the protocol subtree and manage it */ proto_item *ti; proto_tree *fcip_tree = NULL; tvbuff_t *next_tvb; fc_data_t fc_data; if (bytes_remaining < FCIP_ENCAP_HEADER_LEN) { return FALSE; } if (check_port && ((pinfo->srcport != fcip_port) && (pinfo->destport != fcip_port))) { return FALSE; } while (bytes_remaining > FCIP_ENCAP_HEADER_LEN) { if ((offset = get_next_fcip_header_offset (tvb, pinfo, offset)) == -1) { return FALSE; } else if (offset == -2) { /* We need more data to desegment */ return (TRUE); } start = offset; col_set_str(pinfo->cinfo, COL_PROTOCOL, "FCIP"); frame_len = (tvb_get_ntohs (tvb, offset+12) & 0x03FF)*4; if (bytes_remaining < frame_len) { if(fcip_desegment && pinfo->can_desegment) { /* * This frame doesn't have all of the data for * this message, but we can do reassembly on it. * * Tell the TCP dissector where the data for this * message starts in the data it handed us, and * how many more bytes we need, and return. */ pinfo->desegment_offset = offset; pinfo->desegment_len = frame_len - bytes_remaining; return (TRUE); } } pflags = tvb_get_guint8 (tvb, start+8); if (tree) { if (FCIP_IS_SF (pflags)) { ti = proto_tree_add_protocol_format (tree, proto_fcip, tvb, 0, FCIP_ENCAP_HEADER_LEN, "FCIP"); } else if (tvb_bytes_exist (tvb, offset, offset+frame_len-4)) { sof = tvb_get_guint8 (tvb, offset+FCIP_ENCAP_HEADER_LEN); eof = tvb_get_guint8 (tvb, offset+frame_len - 4); ti = proto_tree_add_protocol_format (tree, proto_fcip, tvb, 0, FCIP_ENCAP_HEADER_LEN, "FCIP (%s/%s)", val_to_str (sof, fcip_sof_vals, "0x%x"), val_to_str (eof, fcip_eof_vals, "0x%x")); } else { sof = tvb_get_guint8 (tvb, offset+FCIP_ENCAP_HEADER_LEN); ti = proto_tree_add_protocol_format (tree, proto_fcip, tvb, 0, FCIP_ENCAP_HEADER_LEN, "FCIP (%s/%s)", val_to_str (sof, fcip_sof_vals, "0x%x"), "NA"); } fcip_tree = proto_item_add_subtree (ti, ett_fcip); /* Dissect the Common FC Encap header */ dissect_fcencap_header (tvb, fcip_tree, offset); offset += FCIP_ENCAP_HEADER_LEN; if (!FCIP_IS_SF (pflags)) { /* print SOF */ proto_tree_add_item (fcip_tree, hf_fcip_sof, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item (fcip_tree, hf_fcip_sof_c, tvb, offset+2, 1, ENC_BIG_ENDIAN); /* print EOF */ offset += (frame_len-FCIP_ENCAP_HEADER_LEN-4); if (tvb_bytes_exist (tvb, offset, 4)) { proto_tree_add_item (fcip_tree, hf_fcip_eof, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item (fcip_tree, hf_fcip_eof_c, tvb, offset+2, 1, ENC_BIG_ENDIAN);//.........这里部分代码省略.........
开发者ID:ajitlakhwani,项目名称:wireshark,代码行数:101,
示例15: dissect_ice_context/* * This function dissects an "Ice context", adds hf(s) to "tree" and returns consumed * bytes in "*consumed", if errors "*consumed" is -1. */static void dissect_ice_context(packet_info *pinfo, proto_tree *tree, proto_item *item, tvbuff_t *tvb, guint32 offset, gint32 *consumed){ /* p. 588, chapter 23.2.7 and p. 613, 23.3.2: * "context" is a dictionary<string, string> * * dictionary<string, string> == Size + SizeKeyValuePairs * dictionary<string, string> = 1byte (0..254) + SizeKeyValuePairs * or * dictionary<string, string>= 1byte (255) + 1int (255..2^32-1)+SizeKeyValuePairs * */ guint32 Size = 0; /* number of key-value in the dictionary */ guint32 i = 0; const char *s = NULL; (*consumed) = 0; /* check first byte */ if ( !tvb_bytes_exist(tvb, offset, 1) ) { if (item) expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "context missing"); col_append_str(mypinfo->cinfo, COL_INFO, " (context missing)"); (*consumed) = -1; return; } /* get first byte of Size */ Size = tvb_get_guint8(tvb, offset); offset++; (*consumed)++; if ( Size == 255 ) { /* check for next 4 bytes */ if ( !tvb_bytes_exist(tvb, offset, 4) ) { if (item) expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "second field of Size missing"); col_append_str(mypinfo->cinfo, COL_INFO, " (second field of Size missing)"); (*consumed) = -1; return; } /* get second field of Size */ Size = tvb_get_letohl(tvb, offset); offset += 4; (*consumed) += 4; } DBG1("context.Size --> %d/n", Size); if ( Size > icep_max_ice_context_pairs ) { if (item) /* display the XX Size byte when click here */ expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "too long context"); col_append_str(mypinfo->cinfo, COL_INFO, " (too long context)"); (*consumed) = -1; return; } if (Size == 0) { s = "(empty)"; /* display the 0x00 Size byte when click on a empty context */ if (tree) proto_tree_add_string(tree, hf_icep_context, tvb, offset - 1, 1, s); return; } /* looping through the dictionary */ for ( i = 0; i < Size; i++ ) { /* key */ gint32 consumed_key = 0; char *str_key = NULL; /* value */ gint32 consumed_value = 0; char *str_value = NULL; proto_item *ti = NULL; DBG1("looping through context dictionary, loop #%d/n", i); ti = proto_tree_add_text(tree, tvb, offset, -1, "Invocation Context"); dissect_ice_string(pinfo, tree, ti, hf_icep_invocation_key, tvb, offset, &consumed_key, &str_key); if ( consumed_key == -1 ) { (*consumed) = -1;//.........这里部分代码省略.........
开发者ID:SayCV,项目名称:wireshark,代码行数:101,
示例16: dissect_ifcp_pdustatic voiddissect_ifcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree){ gint offset = 0, frame_len = 0; guint8 sof = 0, eof = 0; proto_item *ti; proto_tree *tree = NULL; tvbuff_t *next_tvb; guint8 protocol; proto_tree *protocol_tree=NULL; proto_tree *version_tree=NULL; proto_tree *frame_len_tree=NULL; proto_tree *sof_tree=NULL; proto_tree *eof_tree=NULL; /* verify we have a full header (do we need to do this? */ if(tvb_length(tvb)<iFCP_ENCAP_HEADER_LEN) { return; } col_set_str(pinfo->cinfo, COL_PROTOCOL, "iFCP"); frame_len = (tvb_get_ntohs (tvb, offset+12) & 0x03FF)*4; if (parent_tree) { if (tvb_bytes_exist (tvb, offset, frame_len-4)) { sof = tvb_get_guint8 (tvb, offset+iFCP_ENCAP_HEADER_LEN); eof = tvb_get_guint8 (tvb, offset+frame_len - 4); ti = proto_tree_add_protocol_format (parent_tree, proto_ifcp, tvb, offset, iFCP_ENCAP_HEADER_LEN, "iFCP (%s/%s)", val_to_str (sof, ifcp_sof_vals, "0x%x"), val_to_str (eof, ifcp_eof_vals, "0x%x")); } else { sof = tvb_get_guint8 (tvb, offset+iFCP_ENCAP_HEADER_LEN); ti = proto_tree_add_protocol_format (parent_tree, proto_ifcp, tvb, offset, iFCP_ENCAP_HEADER_LEN, "iFCP (%s/%s)", val_to_str (sof, ifcp_sof_vals, "0x%x"), "NA"); } tree = proto_item_add_subtree (ti, ett_ifcp); } /* The Common FC Encap header */ /* protocol */ protocol = tvb_get_guint8 (tvb, offset); ti=proto_tree_add_item(tree, hf_ifcp_protocol, tvb, offset, 1, 0); if(ti) { protocol_tree=proto_item_add_subtree(ti, ett_ifcp_protocol); } offset++; /* version */ ti=proto_tree_add_item(tree, hf_ifcp_version, tvb, offset, 1, 0); if(ti) { version_tree=proto_item_add_subtree(ti, ett_ifcp_version); } offset++; /* protocol complement */ proto_tree_add_item(protocol_tree, hf_ifcp_protocol_c, tvb, offset, 1, 0); offset++; /* version complement */ proto_tree_add_item(version_tree, hf_ifcp_version_c, tvb, offset, 1, 0); offset++; /* 4 reserved bytes */ offset+=4; /* iFCP specific fields */ if(protocol==FCENCAP_PROTO_iFCP) { /* LS_COMMAND_ACC */ proto_tree_add_item(tree, hf_ifcp_ls_command_acc, tvb, offset, 1, 0); offset++; /* iFCP Flags */ offset=dissect_ifcpflags(tvb, offset, tree); /* SOF */ ti=proto_tree_add_item(tree, hf_ifcp_sof, tvb, offset, 1, 0); if(ti) { sof_tree=proto_item_add_subtree(ti, ett_ifcp_sof); } offset++; /* EOF */ ti=proto_tree_add_item(tree, hf_ifcp_eof, tvb, offset, 1, 0); if(ti) { eof_tree=proto_item_add_subtree(ti, ett_ifcp_eof); }//.........这里部分代码省略.........
开发者ID:flaub,项目名称:HotFuzz,代码行数:101,
示例17: dissect_ice_params/* * This function dissects an "Ice params", adds hf(s) to "tree" and returns consumed * bytes in "*consumed", if errors "*consumed" is -1. */static void dissect_ice_params(packet_info *pinfo, proto_tree *tree, proto_item *item, tvbuff_t *tvb, guint32 offset, gint32 *consumed){ /* p. 612, chapter 23.3.2 and p. 587, 23.2.2: * "params" is an Encapsulation * * struct Encapsulation { * int size; * byte major; * byte minor; * //(size - 6) bytes of data * } * */ gint32 size = 0; gint tvb_data_remained = 0; (*consumed) = 0; /* check first 6 bytes */ if ( !tvb_bytes_exist(tvb, offset, ICEP_MIN_PARAMS_SIZE) ) { if (item) expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "params missing"); col_append_str(mypinfo->cinfo, COL_INFO, " (params missing)"); (*consumed) = -1; return; } /* get the size */ size = tvb_get_letohl(tvb, offset); DBG1("params.size --> %d/n", size); if ( size < ICEP_MIN_PARAMS_SIZE ) { if (item) expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "params size too small"); col_append_str(mypinfo->cinfo, COL_INFO, " (params size too small)"); (*consumed) = -1; return; } if ( tree ) { proto_tree_add_item(tree, hf_icep_params_size, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; (*consumed) += 4; proto_tree_add_item(tree, hf_icep_params_major, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; (*consumed)++; proto_tree_add_item(tree, hf_icep_params_minor, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; (*consumed)++; } else { /* skip size, major, minor */ offset += 6; (*consumed) += 6; } if( size == ICEP_MIN_PARAMS_SIZE ) /* no encapsulatd data present, it's normal */ return; /* check if I got all encapsulated data */ tvb_data_remained = tvb_reported_length_remaining(tvb, offset); if ( tvb_data_remained < ( size - ICEP_MIN_PARAMS_SIZE ) ) { if (item) expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "missing encapsulated data (%d bytes)", size - ICEP_MIN_PARAMS_SIZE - tvb_data_remained); if ( check_col(mypinfo->cinfo, COL_INFO) ) { col_append_fstr(mypinfo->cinfo, COL_INFO, " (missing encapsulated data (%d bytes))", size - ICEP_MIN_PARAMS_SIZE - tvb_data_remained); } (*consumed) = -1; return; } /* encapsulated params */ if (tree) { proto_tree_add_item(tree, hf_icep_params_encapsulated, tvb, offset, (size - ICEP_MIN_PARAMS_SIZE), ENC_LITTLE_ENDIAN);//.........这里部分代码省略.........
开发者ID:SayCV,项目名称:wireshark,代码行数:101,
示例18: dissect_clnp//.........这里部分代码省略......... du_id = tvb_get_ntohs(tvb, offset); proto_tree_add_text(clnp_tree, tvb, offset, 2, "Data unit identifier: %06u", du_id); segment_offset = tvb_get_ntohs(tvb, offset + 2); proto_tree_add_text(clnp_tree, tvb, offset + 2 , 2, "Segment offset : %6u", segment_offset); total_length = tvb_get_ntohs(tvb, offset + 4); ti_tot_len = proto_tree_add_text(clnp_tree, tvb, offset + 4 , 2, "Total length : %6u", total_length); if (total_length < segment_length) { /* Reassembled length is less than the length of this segment. */ expert_add_info_format(pinfo, ti_tot_len, &ei_clnp_length, "Total length < segment length %u", segment_length); return; } offset += SEGMENTATION_PART_LEN; opt_len -= SEGMENTATION_PART_LEN; } dissect_osi_options(opt_len, tvb, offset, clnp_tree); offset += opt_len; /* If clnp_reassemble is on, this is a segment, we have all the * data in the segment, and the checksum is valid, then just add the * segment to the hashtable. */ save_fragmented = pinfo->fragmented; if (clnp_reassemble && (cnf_type & CNF_SEG_OK) && ((cnf_type & CNF_MORE_SEGS) || segment_offset != 0) && tvb_bytes_exist(tvb, offset, segment_length - cnf_hdr_len) && segment_length > cnf_hdr_len && cksum_status != CKSUM_NOT_OK) { fd_head = fragment_add_check(&clnp_reassembly_table, tvb, offset, pinfo, du_id, NULL, segment_offset, segment_length - cnf_hdr_len, cnf_type & CNF_MORE_SEGS); next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled CLNP", fd_head, &clnp_frag_items, &update_col_info, clnp_tree); } else { /* If this is the first segment, dissect its contents, otherwise just show it as a segment. XXX - if we eventually don't save the reassembled contents of all segmented datagrams, we may want to always reassemble. */ if ((cnf_type & CNF_SEG_OK) && segment_offset != 0) { /* Not the first segment - don't dissect it. */ next_tvb = NULL; } else { /* First segment, or not segmented. Dissect what we have here. */ /* Get a tvbuff for the payload. Set its length to the segment length, and flag it as a fragment, so going past the end reports FragmentBoundsError, i.e. "there's data missing because this isn't reassembled", not ReportedBoundsError, i.e. "the dissector ran past the end of the packet, so the packet must not have been constructed properly". */ next_tvb = tvb_new_subset_length(tvb, offset, segment_length - cnf_hdr_len); tvb_set_fragment(next_tvb); /* * If this is the first segment, but not the only segment,
开发者ID:VincentLadeveze,项目名称:802154e-wireshark,代码行数:67,
示例19: dissect_icep_request_commonstatic void dissect_icep_request_common(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, proto_tree *icep_sub_tree, proto_item* icep_sub_item, gint32 *total_consumed){ /* p. 613, chapter 23.3.3 and p. 612 chapter 23.3.2: * Request and BatchRequest differ only in the first 4 bytes (requestID) * so them share this part * * Ice::Identity id; * Ice::StringSeq facet; * string operation; * byte mode; * Ice::Context context; * Encapsulation params; * } */ gint32 consumed = 0; char *namestr = NULL; char *opstr = NULL; (*total_consumed) = 0; /* check common header (i.e. the batch request one)*/ if ( !tvb_bytes_exist(tvb, offset, ICEP_MIN_COMMON_REQ_HEADER_SIZE) ) { if (icep_sub_item) expert_add_info_format(pinfo, icep_sub_item, PI_MALFORMED, PI_ERROR, "too short header"); col_append_str(mypinfo->cinfo, COL_INFO, " (too short header)"); goto error; } /* got at least 15 bytes */ /* "id" is a: * struct Identity { * string name; * string category; * } */ dissect_ice_string(pinfo, icep_sub_tree, icep_sub_item, hf_icep_id_name, tvb, offset, &consumed, &namestr); if ( consumed == -1 ) goto error; offset += consumed; DBG1("consumed --> %d/n", consumed); (*total_consumed) += consumed; dissect_ice_string(pinfo, icep_sub_tree, icep_sub_item, hf_icep_id_category, tvb, offset, &consumed, NULL); if ( consumed == -1 ) goto error; offset += consumed; DBG1("consumed --> %d/n", consumed); (*total_consumed) += consumed; /* "facet" is a: * sequence<string> StringSeq * */ dissect_ice_facet(pinfo, icep_sub_tree, icep_sub_item, hf_icep_facet, tvb, offset, &consumed); if ( consumed == -1 ) goto error; offset += consumed; DBG1("consumed --> %d/n", consumed); (*total_consumed) += consumed; /* "operation" is an ice_string * */ dissect_ice_string(pinfo, icep_sub_tree, icep_sub_item, hf_icep_operation, tvb, offset, &consumed, &opstr); if ( consumed == -1 ) goto error; else { offset += consumed; DBG1("consumed --> %d/n", consumed); (*total_consumed) += consumed; if ( opstr && namestr ) { DBG2("operation --> %s.%s()/n", namestr, opstr); if ( check_col(mypinfo->cinfo, COL_INFO) ) { col_append_fstr(mypinfo->cinfo, COL_INFO, " %s.%s()", namestr, opstr); } opstr = NULL; namestr = NULL; } } /* check and get mode byte */ if ( !tvb_bytes_exist(tvb, offset, 1) ) {//.........这里部分代码省略.........
开发者ID:SayCV,项目名称:wireshark,代码行数:101,
示例20: dissect_icep_requeststatic void dissect_icep_request(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, proto_tree *icep_tree, proto_item* icep_item){ /* p. 612, chapter 23.3.2: * * struct RequestData { * int requestID; * Ice::Identity id; * Ice::StringSeq facet; * string operation; * byte mode; * Ice::Context context; * Encapsulation params; * } */ proto_item *ti = NULL; proto_tree *icep_sub_tree = NULL; gint32 consumed = 0; guint32 reqid = 0; DBG0("dissect request/n"); /* check for req id */ if ( !tvb_bytes_exist(tvb, offset, 4) ) { if (icep_item) expert_add_info_format(pinfo, icep_item, PI_MALFORMED, PI_ERROR, "too short header"); col_append_str(mypinfo->cinfo, COL_INFO, " (too short header)"); return; } /* got at least 4 bytes */ /* create display subtree for this message type */ reqid = tvb_get_letohl(tvb, offset); if (icep_tree) { ti = proto_tree_add_text(icep_tree, tvb, offset, -1, "Request Message Body"); icep_sub_tree = proto_item_add_subtree(ti, ett_icep_msg); proto_tree_add_item(icep_sub_tree, hf_icep_request_id, tvb, offset, 4, ENC_LITTLE_ENDIAN); } if ( reqid != 0 ) { if ( check_col(mypinfo->cinfo, COL_INFO) ) { col_append_fstr(mypinfo->cinfo, COL_INFO, "(%d):", tvb_get_letohl(tvb, offset)); } } else col_append_str(mypinfo->cinfo, COL_INFO, "(oneway):"); offset += 4; DBG0("consumed --> 4/n"); dissect_icep_request_common(tvb, offset, pinfo, icep_sub_tree, ti, &consumed); if ( consumed == -1 ) return; /*offset += consumed;*/ DBG1("consumed --> %d/n", consumed);}
开发者ID:SayCV,项目名称:wireshark,代码行数:72,
示例21: dissect_tns_datastatic void dissect_tns_data(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, proto_tree *tns_tree){ proto_tree *data_tree = NULL, *ti; proto_item *hidden_item; int is_sns = 0; if ( tvb_bytes_exist(tvb, offset+2, 4) ) { if ( tvb_get_guint8(tvb, offset+2) == 0xDE && tvb_get_guint8(tvb, offset+3) == 0xAD && tvb_get_guint8(tvb, offset+4) == 0xBE && tvb_get_guint8(tvb, offset+5) == 0xEF ) { is_sns = 1; } } if ( tree ) { if ( is_sns ) { ti = proto_tree_add_text(tns_tree, tvb, offset, -1, "Secure Network Services"); } else { ti = proto_tree_add_text(tns_tree, tvb, offset, -1, "Data"); } data_tree = proto_item_add_subtree(ti, ett_tns_data); hidden_item = proto_tree_add_boolean(tns_tree, hf_tns_data, tvb, 0, 0, TRUE); PROTO_ITEM_SET_HIDDEN(hidden_item); } if ( tree ) { proto_tree *df_tree = NULL; ti = proto_tree_add_item(data_tree, hf_tns_data_flag, tvb, offset, 2, ENC_BIG_ENDIAN); df_tree = proto_item_add_subtree(ti, ett_tns_data_flag); proto_tree_add_item(df_tree, hf_tns_data_flag_send, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(df_tree, hf_tns_data_flag_rc, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(df_tree, hf_tns_data_flag_c, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(df_tree, hf_tns_data_flag_reserved, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(df_tree, hf_tns_data_flag_more, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(df_tree, hf_tns_data_flag_eof, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(df_tree, hf_tns_data_flag_dic, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(df_tree, hf_tns_data_flag_rts, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(df_tree, hf_tns_data_flag_sntt, tvb, offset, 2, ENC_BIG_ENDIAN); } offset += 2; if ( is_sns ) { col_append_str(pinfo->cinfo, COL_INFO, ", SNS"); } else { col_append_str(pinfo->cinfo, COL_INFO, ", Data"); } call_dissector(data_handle, tvb_new_subset_remaining(tvb, offset), pinfo, data_tree); return;}
开发者ID:huzhiren,项目名称:wireshark,代码行数:70,
示例22: dissect_icep_batch_requeststatic void dissect_icep_batch_request(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, proto_tree *icep_tree, proto_item* icep_item){ /* p. 613, chapter 23.3.3 * A batch request msg is a "sequence" of batch request * Sequence is Size + elements * * struct BatchRequestData { * Ice::Identity id; * Ice::StringSeq facet; * string operation; * byte mode; * Ice::Context context; * Encapsulation params; * } * * NOTE!!!: * The only real implementation of the Ice protocol puts a 32bit count in front * of a Batch Request, *not* an Ice::Sequence (as the standard says). Basically the * same people wrote both code and standard so I'll follow the code. */ proto_item *ti = NULL; proto_tree *icep_sub_tree = NULL; guint32 num_reqs = 0; guint32 i = 0; gint32 consumed = 0; DBG0("dissect batch request/n"); /* check for first 4 byte */ if ( !tvb_bytes_exist(tvb, offset, 4) ) { if (icep_item) expert_add_info_format(pinfo, icep_item, PI_MALFORMED, PI_ERROR, "counter of batch requests missing"); col_append_str(mypinfo->cinfo, COL_INFO, " (counter of batch requests missing)"); return; } num_reqs = tvb_get_letohl(tvb, offset); offset += 4; DBG1("batch_requests.count --> %d/n", num_reqs); if ( num_reqs > icep_max_batch_requests ) { if (icep_item) expert_add_info_format(pinfo, icep_item, PI_PROTOCOL, PI_WARN, "too many batch requests (%d)", num_reqs); if ( check_col(mypinfo->cinfo, COL_INFO) ) { col_append_fstr(mypinfo->cinfo, COL_INFO, " (too many batch requests, %d)", num_reqs); } return; } if ( num_reqs == 0 ) { if (icep_tree) proto_tree_add_text(icep_tree, tvb, offset, -1, "empty batch requests sequence"); col_append_str(mypinfo->cinfo, COL_INFO, " (empty batch requests sequence)"); return; } col_append_str(mypinfo->cinfo, COL_INFO, ":"); /* * process requests */ for ( i = 0; i < num_reqs; i++ ) { DBG1("looping through sequence of batch requests, loop #%d/n", i); /* create display subtree for this message type */ if (icep_tree) { ti = proto_tree_add_text(icep_tree, tvb, offset, -1, "Batch Request Message Body: #%d", i); icep_sub_tree = proto_item_add_subtree(ti, ett_icep_msg); } if ( check_col(mypinfo->cinfo, COL_INFO) && (i != 0) ) { col_append_str(mypinfo->cinfo, COL_INFO, ","); }//.........这里部分代码省略.........
开发者ID:SayCV,项目名称:wireshark,代码行数:101,
示例23: rlogin_display//.........这里部分代码省略......... /* Terminal type/speed. */ slash_offset = tvb_find_guint8(tvb, offset, -1, '/'); if (slash_offset != -1) { guint8* str = NULL; guint32 term_len = 0; gboolean term_len_valid; proto_item* pi = NULL; /* Terminal type */ proto_tree_add_item(user_info_tree, hf_user_info_terminal_type, tvb, offset, slash_offset-offset, ENC_ASCII|ENC_NA); offset = slash_offset + 1; /* Terminal speed */ str_len = tvb_strsize(tvb, offset); str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, str_len, ENC_NA|ENC_ASCII); term_len_valid = ws_strtou32(str, NULL, &term_len); pi = proto_tree_add_uint(user_info_tree, hf_user_info_terminal_speed, tvb, offset, str_len, term_len); if (!term_len_valid) expert_add_info(pinfo, pi, &ei_rlogin_termlen_invalid); offset += str_len; } } if (!tvb_offset_exists(tvb, offset)) { /* No more data to check */ return; } /* Test for terminal information, the data will have 2 0xff bytes */ /* look for first 0xff byte */ ti_offset = tvb_find_guint8(tvb, offset, -1, 0xff); /* Next byte must also be 0xff */ if (ti_offset != -1 && tvb_bytes_exist(tvb, ti_offset + 1, 1) && tvb_get_guint8(tvb, ti_offset + 1) == 0xff) { guint16 rows, columns; /* Have found terminal info. */ if (ti_offset > offset) { /* There's data before the terminal info. */ proto_tree_add_item(rlogin_tree, hf_data, tvb, offset, ti_offset - offset, ENC_ASCII|ENC_NA); } /* Create window info tree */ window_info_item = proto_tree_add_item(rlogin_tree, hf_window_info, tvb, offset, 12, ENC_NA); window_tree = proto_item_add_subtree(window_info_item, ett_rlogin_window); /* Cookie */ proto_tree_add_item(window_tree, hf_magic_cookie, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* These bytes should be "ss" */ proto_tree_add_item(window_tree, hf_window_info_ss, tvb, offset, 2, ENC_ASCII|ENC_NA); offset += 2; /* Character rows */ rows = tvb_get_ntohs(tvb, offset); proto_tree_add_item(window_tree, hf_window_info_rows, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* Characters per row */ columns = tvb_get_ntohs(tvb, offset); proto_tree_add_item(window_tree, hf_window_info_cols, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* x pixels */ proto_tree_add_item(window_tree, hf_window_info_x_pixels, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* y pixels */ proto_tree_add_item(window_tree, hf_window_info_y_pixels, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* Show setting highlights in info column */ col_append_fstr(pinfo->cinfo, COL_INFO, " (rows=%u, cols=%u)", rows, columns); } if (tvb_offset_exists(tvb, offset)) { /* There's more data in the frame. */ proto_tree_add_item(rlogin_tree, hf_data, tvb, offset, -1, ENC_ASCII|ENC_NA); }}
开发者ID:HeartFlying,项目名称:wireshark,代码行数:101,
示例24: dissect_icep_replystatic void dissect_icep_reply(tvbuff_t *tvb, guint32 offset, packet_info *pinfo, proto_tree *icep_tree, proto_item* icep_item){ /* p. 614, chapter 23.3.4: * * struct ReplyData { * int requestId; * byte replyStatus; * [... messageSize - 19 bytes ... ] * } */ gint32 messageSize = 0; guint32 tvb_data_remained = 0; guint32 reported_reply_data = 0; proto_item *ti = NULL; proto_tree *icep_sub_tree = NULL; DBG0("dissect reply/n"); /* get at least a full reply message header */ if ( !tvb_bytes_exist(tvb, offset, ICEP_MIN_REPLY_SIZE) ) { if (icep_item) expert_add_info_format(pinfo, icep_item, PI_MALFORMED, PI_ERROR, "too short header"); col_append_str(mypinfo->cinfo, COL_INFO, " (too short header)"); return; } /* got 5 bytes, then data */ /* create display subtree for this message type */ if (icep_tree) { ti = proto_tree_add_text(icep_tree, tvb, offset, -1, "Reply Message Body"); icep_sub_tree = proto_item_add_subtree(ti, ett_icep_msg); proto_tree_add_item(icep_sub_tree, hf_icep_request_id, tvb, offset, 4, ENC_LITTLE_ENDIAN); } if ( check_col(mypinfo->cinfo, COL_INFO) ) { col_append_fstr(mypinfo->cinfo, COL_INFO, "(%d):", tvb_get_letohl(tvb, offset)); } offset += 4; if (icep_tree) proto_tree_add_item(icep_sub_tree, hf_icep_reply_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); if ( check_col(mypinfo->cinfo, COL_INFO) ) { col_append_fstr(mypinfo->cinfo, COL_INFO, " %s", val_to_str_const(tvb_get_guint8(tvb, offset), icep_replystatus_vals, "unknown reply status")); } offset++; DBG1("consumed --> %d/n", 5); /* check if I got all reply data */ tvb_data_remained = tvb_length_remaining(tvb, offset); messageSize = tvb_get_letohl(tvb, 10); reported_reply_data = messageSize - (ICEP_HEADER_SIZE + ICEP_MIN_REPLY_SIZE); /* no */ if ( tvb_data_remained < reported_reply_data ) { if (icep_sub_tree) expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR, "Reply Data (missing %d bytes out of %d)", reported_reply_data - tvb_data_remained, reported_reply_data); if ( check_col(mypinfo->cinfo, COL_INFO) ) { col_append_fstr(mypinfo->cinfo, COL_INFO, " (missing reply data, %d bytes)", reported_reply_data - tvb_data_remained); } /*offset += tvb_data_remained;*/ DBG1("consumed --> %d/n", tvb_data_remained); return; } /* yes (reported_reply_data can be 0) */ if (icep_sub_tree) { proto_tree_add_item(icep_sub_tree, hf_icep_reply_data, tvb, offset, reported_reply_data, ENC_NA); } /*offset += reported_reply_data;*/ DBG1("consumed --> %d/n", reported_reply_data);//.........这里部分代码省略.........
开发者ID:SayCV,项目名称:wireshark,代码行数:101,
示例25: parse_gsm_sms_ud_message//.........这里部分代码省略......... break; default: i += len; break; } } if (tvb_reported_length_remaining(tvb, i) <= 0) return; /* No more data */ /* * XXX - where does the "1" come from? If it weren't there, * "sm_data_len" would, I think, be the same as * "tvb_reported_length_remaining(tvb, i)". * * I think that the above check ensures that "sm_len" won't * be less than or equal to "udh_len", so it ensures that * "sm_len" won't be less than "1 + udh_len", so we don't * have to worry about "sm_data_len" being negative. */ sm_data_len = sm_len - (1 + udh_len); if (sm_data_len == 0) return; /* no more data */ /* * Try reassembling the packets. * XXX - fragment numbers are 1-origin, but the fragment number * field could be 0. * Should we flag a fragmented message with a fragment number field * of 0? * What if the fragment count is 0? Should we flag that as well? */ if (is_fragmented && frag != 0 && frags != 0 && tvb_bytes_exist(tvb, i, sm_data_len)) { try_gsm_sms_ud_reassemble = TRUE; save_fragmented = pinfo->fragmented; pinfo->fragmented = TRUE; fd_sm = fragment_add_seq_check(&sm_reassembly_table, tvb, i, pinfo, sm_id, /* guint32 ID for fragments belonging together */ NULL, frag-1, /* guint32 fragment sequence number */ sm_data_len, /* guint32 fragment length */ (frag != frags)); /* More fragments? */ if (fd_sm) { reassembled = TRUE; reassembled_in = fd_sm->reassembled_in; } sm_tvb = process_reassembled_data(tvb, i, pinfo, "Reassembled Short Message", fd_sm, &sm_frag_items, NULL, sm_tree); if (reassembled) { /* Reassembled */ col_append_str(pinfo->cinfo, COL_INFO, " (Short Message Reassembled)"); } else { /* Not last packet of reassembled Short Message */ col_append_fstr(pinfo->cinfo, COL_INFO, " (Short Message fragment %u of %u)", frag, frags); } } /* Else: not fragmented */ if (! sm_tvb) /* One single Short Message, or not reassembled */ sm_tvb = tvb_new_subset_remaining(tvb, i); /* Try calling a subdissector */ if (sm_tvb) {
开发者ID:MultipathDTLS,项目名称:wireshark,代码行数:67,
示例26: dissect_ice_string/* * This function dissects an "Ice string", adds hf to "tree" and returns consumed * bytes in "*consumed", if errors "*consumed" is -1. * * "*dest" is a null terminated version of the dissected Ice string. */static void dissect_ice_string(proto_tree *tree, int hf_icep, tvbuff_t *tvb, guint32 offset, gint32 *consumed, char **dest, gboolean add_hf){ /* p. 586 chapter 23.2.1 and p. 588 chapter 23.2.5 * string == Size + content * string = 1byte (0..254) + string not null terminated * or * string = 1byte (255) + 1int (255..2^32-1) + string not null terminated */ guint32 Size = 0; char *s = NULL; (*consumed) = 0; /* check for first byte */ if ( !tvb_bytes_exist(tvb, offset, 1) ) { if (tree) proto_tree_add_text(tree, tvb, offset, -1, "1st byte of Size missing"); if ( check_col(mypinfo->cinfo, COL_INFO) ) { col_append_str(mypinfo->cinfo, COL_INFO, " (1st byte of Size missing)"); } (*consumed) = -1; return; } /* get the Size */ Size = tvb_get_guint8(tvb, offset); offset++; (*consumed)++; if ( Size == 255 ) { /* check for next 4 bytes */ if ( !tvb_bytes_exist(tvb, offset, 4) ) { if (tree) proto_tree_add_text(tree, tvb, offset, -1, "second field of Size missing"); if ( check_col(mypinfo->cinfo, COL_INFO) ) { col_append_str(mypinfo->cinfo, COL_INFO, " (second field of Size missing)"); } (*consumed) = -1; return; } /* get second field of Size */ Size = tvb_get_letohl(tvb, offset); offset += 4; (*consumed) += 4; } DBG1("string.Size --> %d/n", Size); /* check if the string exists */ if ( !tvb_bytes_exist(tvb, offset, Size) ) { if (tree) proto_tree_add_text(tree, tvb, offset, -1, "missing or truncated string"); if ( check_col(mypinfo->cinfo, COL_INFO) ) { col_append_str(mypinfo->cinfo, COL_INFO, " (missing or truncated string)"); } (*consumed) = -1; return; } if ( Size > ICEP_MAX_ICE_STRING_LEN ) { if (tree) proto_tree_add_text(tree, tvb, offset, -1, "string too long"); if ( check_col(mypinfo->cinfo, COL_INFO) ) { col_append_str(mypinfo->cinfo, COL_INFO, " (string too long)"); } (*consumed) = -1; return; } //.........这里部分代码省略.........
开发者ID:RazZziel,项目名称:wireshark-dplay,代码行数:101,
注:本文中的tvb_bytes_exist函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ tvb_captured_length函数代码示例 C++ tvUnboxIfNeeded函数代码示例 |