/* * Process the multipart preamble: * [ preamble line-end ] dashed-boundary transport-padding line-end * * Return the offset to the start of the first body-part. */ static gint process_preamble(proto_tree *tree, tvbuff_t *tvb, const guint8 *boundary, gint boundary_len, gboolean *last_boundary) { gint boundary_start, boundary_line_len; boundary_start = find_first_boundary(tvb, 0, boundary, boundary_len, &boundary_line_len, last_boundary); if (boundary_start == 0) { proto_tree_add_text(tree, tvb, boundary_start, boundary_line_len, "First boundary: %s", tvb_format_text(tvb, boundary_start, boundary_line_len)); return boundary_start + boundary_line_len; } else if (boundary_start > 0) { if (boundary_line_len > 0) { gint body_part_start = boundary_start + boundary_line_len; if (body_part_start > 0) { proto_tree_add_text(tree, tvb, 0, body_part_start, "Preamble"); } proto_tree_add_text(tree, tvb, boundary_start, boundary_line_len, "First boundary: %s", tvb_format_text(tvb, boundary_start, boundary_line_len)); return body_part_start; } } return -1; }
/* Code to actually dissect the packets */ static void dissect_dx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { proto_item *ti; proto_tree *dx_tree; int data_len; int offset; offset = 0; data_len = tvb_length_remaining( tvb, offset ); col_set_str( pinfo->cinfo, COL_PROTOCOL, "DX" ); col_add_fstr( pinfo->cinfo, COL_INFO, "%s", tvb_format_text( tvb, offset, 15 ) ); if ( parent_tree ) { /* create display subtree for the protocol */ ti = proto_tree_add_protocol_format( parent_tree, proto_dx, tvb, 0, -1, "DX (%s)", tvb_format_text( tvb, offset, 15 ) ); dx_tree = proto_item_add_subtree( ti, ett_dx ); offset = 0; proto_tree_add_item( dx_tree, hf_dx_report, tvb, offset, data_len, ENC_ASCII|ENC_NA ); } }
static void dissect_rsh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_tree *rsh_tree; proto_item *ti, *hidden_item; gint offset = 0; gint next_offset; int linelen; col_set_str(pinfo->cinfo, COL_PROTOCOL, "RSH"); if (check_col(pinfo->cinfo, COL_INFO)) { /* Put the first line from the buffer into the summary. */ tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE); linelen = next_offset - offset; /* include the line terminator */ /* * Make sure the line terminator isn't past the end of * the captured data in the packet, so we don't throw * an exception in the "tvb_get_ptr()" call. */ if (linelen > (int) tvb_length(tvb)) linelen = tvb_length(tvb); col_add_str(pinfo->cinfo, COL_INFO, tvb_format_text(tvb, offset, linelen)); } if (tree) { ti = proto_tree_add_item(tree, proto_rsh, tvb, offset, -1, FALSE); rsh_tree = proto_item_add_subtree(ti, ett_rsh); /* * Process the packet data, a line at a time. */ while (tvb_offset_exists(tvb, offset)) { /* * Find the end of the line. */ tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE); /* * Put this line. */ proto_tree_add_text(rsh_tree, tvb, offset, next_offset - offset, "%s", tvb_format_text(tvb, offset, next_offset - offset)); offset = next_offset; } if (pinfo->match_port == pinfo->destport) { hidden_item = proto_tree_add_boolean(rsh_tree, hf_rsh_request, tvb, 0, 0, 1); } else { hidden_item = proto_tree_add_boolean(rsh_tree, hf_rsh_response, tvb, 0, 0, 1); } PROTO_ITEM_SET_HIDDEN(hidden_item); } }
static proto_tree * add_charstring_tree(proto_tree *tree, tvbuff_t *tvb, int offset, int name_length, int value_length) { return proto_tree_add_subtree_format(tree, tvb, offset, 1 + 2 + name_length + 2 + value_length, ett_ipp_attr, NULL, "%s: %s", tvb_format_text(tvb, offset + 1 + 2, name_length), tvb_format_text(tvb, offset + 1 + 2 + name_length + 2, value_length)); }
static proto_tree * add_charstring_tree(proto_tree *tree, tvbuff_t *tvb, int offset, int name_length, int value_length) { proto_item *ti; ti = proto_tree_add_text(tree, tvb, offset, 1 + 2 + name_length + 2 + value_length, "%s: %s", tvb_format_text(tvb, offset + 1 + 2, name_length), tvb_format_text(tvb, offset + 1 + 2 + name_length + 2, value_length)); return proto_item_add_subtree(ti, ett_ipp_attr); }
static int dissect_beep_mime_header(tvbuff_t *tvb, int offset, struct beep_proto_data *beep_frame_data, proto_tree *tree) { proto_tree *ti = NULL, *mime_tree = NULL; int mime_length = header_len(tvb, offset), cc = 0; if (beep_frame_data && !beep_frame_data->mime_hdr) return 0; if (tree) { /* FIXME: Should calculate the whole length of the mime headers */ ti = proto_tree_add_text(tree, tvb, offset, mime_length, "Mime header: %s", tvb_format_text(tvb, offset, mime_length)); mime_tree = proto_item_add_subtree(ti, ett_mime_header); } if (mime_length == 0) { /* Default header */ if (tree) { proto_tree_add_text(mime_tree, tvb, offset, 0, "Default values"); } if ((cc = check_term(tvb, offset, mime_tree)) <= 0) { /* Ignore it, it will cause funnies in the rest of the dissect */ } } else { /* FIXME: Process the headers */ if (tree) { proto_tree_add_text(mime_tree, tvb, offset, mime_length, "Header: %s", tvb_format_text(tvb, offset, mime_length)); } if ((cc = check_term(tvb, offset + mime_length, mime_tree)) <= 0) { /* Ignore it, it will cause funnies in the rest of the dissect */ } } return mime_length + cc; /* FIXME: Check that the CRLF is there */ }
static void dissect_ftpdata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *ti; int data_length; gboolean is_text = TRUE; gint check_chars, i; col_set_str(pinfo->cinfo, COL_PROTOCOL, "FTP-DATA"); col_add_fstr(pinfo->cinfo, COL_INFO, "FTP Data: %u bytes", tvb_reported_length(tvb)); data_length = tvb_length(tvb); ti = proto_tree_add_item(tree, proto_ftp_data, tvb, 0, -1, ENC_NA); /* Check the first few chars to see whether it looks like a text file or not */ check_chars = MIN(10, data_length); for (i=0; i < check_chars; i++) { if (!isprint(tvb_get_guint8(tvb, i))) { is_text = FALSE; break; } } if (is_text) { /* Show as string, but don't format more text than will be displayed */ proto_item_append_text(ti, " (%s)", tvb_format_text(tvb, 0, MIN(data_length, ITEM_LABEL_LENGTH))); } else { /* Assume binary, just show the number of bytes */ proto_item_append_text(ti, " (%u bytes data)", data_length); } }
static void dissect_daap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *ti; proto_tree *daap_tree; int offset = 0; gboolean is_request = (pinfo->destport == TCP_PORT_DAAP); col_set_str(pinfo->cinfo, COL_PROTOCOL, "DAAP"); /* * XXX - what if the body is gzipped? This isn't the only protocol * running atop HTTP that might have a problem with that.... */ if (check_col(pinfo->cinfo, COL_INFO)) { if (is_request) { col_set_str(pinfo->cinfo, COL_INFO, "DAAP Request"); } else { /* This is done in two functions on purpose. If the tvb_get_xxx() * functions fail, at least something will be in the info column */ col_set_str(pinfo->cinfo, COL_INFO, "DAAP Response"); col_append_fstr(pinfo->cinfo, COL_INFO, " [tag: %s, size: %d]", tvb_format_text(tvb, offset, 4), tvb_get_ntohl(tvb, offset+4)); } } if (tree) { ti = proto_tree_add_item(tree, proto_daap, tvb, 0, -1, FALSE); daap_tree = proto_item_add_subtree(ti, ett_daap); dissect_daap_one_tag(daap_tree, tvb, offset, 0); } }
static void dissect_smtp_data(tvbuff_t *tvb, int offset, proto_tree *smtp_tree) { gint next_offset; if (smtp_tree) { while (tvb_offset_exists(tvb, offset)) { /* * Find the end of the line. */ tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE); /* * Put this line. */ proto_tree_add_text(smtp_tree, tvb, offset, next_offset - offset, "Message: %s", tvb_format_text(tvb, offset, next_offset - offset)); /* * Step to the next line. */ offset = next_offset; } } }
static void dissect_ftpdata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_tree *ti, *ftp_data_tree; int data_length; col_set_str(pinfo->cinfo, COL_PROTOCOL, "FTP-DATA"); col_add_fstr(pinfo->cinfo, COL_INFO, "FTP Data: %u bytes", tvb_reported_length(tvb)); if (tree) { data_length = tvb_length(tvb); ti = proto_tree_add_item(tree, proto_ftp_data, tvb, 0, -1, ENC_NA); ftp_data_tree = proto_item_add_subtree(ti, ett_ftp_data); /* * XXX - if this is binary data, it'll produce * a *really* long line. */ proto_tree_add_text(ftp_data_tree, tvb, 0, data_length, "FTP Data: %s", tvb_format_text(tvb, 0, data_length)); } }
static void dissect_msnms(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_tree *msnms_tree; proto_item *ti; gint offset = 0; const guchar *line; gint next_offset; int linelen; /* int tokenlen; */ /* const guchar *next_token; */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "MSNMS"); /* * Find the end of the first line. * * Note that "tvb_find_line_end()" will return a value that is * not longer than what's in the buffer, so the "tvb_get_ptr()" * call won't throw an exception. */ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE); line = tvb_get_ptr(tvb, offset, linelen); if (check_col(pinfo->cinfo, COL_INFO)) { /* * Put the first line from the buffer into the summary. */ col_add_str(pinfo->cinfo, COL_INFO, format_text(line, linelen)); } if (tree) { ti = proto_tree_add_item(tree, proto_msnms, tvb, offset, -1, FALSE); msnms_tree = proto_item_add_subtree(ti, ett_msnms); /* * Show the rest of the packet as text, * a line at a time. */ while (tvb_offset_exists(tvb, offset)) { /* * Find the end of the line. */ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE); /* * Put this line. */ proto_tree_add_text(msnms_tree, tvb, offset, next_offset - offset, "%s", tvb_format_text(tvb, offset, next_offset - offset)); offset = next_offset; } } }
/* * Name: isis_dissect_authentication_clv() * * Description: * Take apart the CLV that hold authentication information. This * is currently 1 octet auth type. * the two defined authentication types * are 1 for a clear text password and * 54 for a HMAC-MD5 digest * * Input: * tvbuff_t * : tvbuffer for packet data * proto_tree * : protocol display tree to fill out. May be NULL * int : offset into packet data where we are. * int : length of clv we are decoding * * Output: * void, but we will add to proto tree if !NULL. */ void isis_dissect_authentication_clv(tvbuff_t *tvb, proto_tree *tree, int offset, int length) { guchar pw_type; int auth_unsupported; proto_item *ti; if ( length <= 0 ) { return; } pw_type = tvb_get_guint8(tvb, offset); offset += 1; length--; auth_unsupported = FALSE; switch (pw_type) { case 1: ti = proto_tree_add_text ( tree, tvb, offset - 1, length + 1, "clear text (1), password (length %d) = ", length); if ( length > 0 ) { proto_item_append_text(ti, "%s", tvb_format_text(tvb, offset, length)); } else { proto_item_append_text(ti, "no clear-text password found!!!"); } break; case 54: ti = proto_tree_add_text ( tree, tvb, offset - 1, length + 1, "hmac-md5 (54), password (length %d) = ", length); if ( length == 16 ) { proto_item_append_text(ti, "0x%02x", tvb_get_guint8(tvb, offset)); offset += 1; length--; while (length > 0) { proto_item_append_text(ti, "%02x", tvb_get_guint8(tvb, offset)); offset += 1; length--; } } else { proto_item_append_text(ti, "illegal hmac-md5 digest format (must be 16 bytes)"); } break; default: ti = proto_tree_add_text ( tree, tvb, offset - 1, length + 1, "type 0x%02x (0x%02x): ", pw_type, length ); auth_unsupported=TRUE; break; } if ( auth_unsupported ) { isis_dissect_unknown(tvb, tree, offset, "Unknown authentication type" ); } }
static void tftp_dissect_options(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, guint16 opcode, tftp_conv_info_t *tftp_info) { int option_len, value_len; int value_offset; const char *optionname; const char *optionvalue; proto_tree *opt_tree; while (tvb_offset_exists(tvb, offset)) { /* option_len and value_len include the trailing 0 byte */ option_len = tvb_strsize(tvb, offset); value_offset = offset + option_len; value_len = tvb_strsize(tvb, value_offset); /* use xxx_len-1 to exclude the trailing 0 byte, it would be displayed as nonprinting character tvb_format_text() creates a temporary 0-terminated buffer */ optionname = tvb_format_text(tvb, offset, option_len-1); optionvalue = tvb_format_text(tvb, value_offset, value_len-1); opt_tree = proto_tree_add_subtree_format(tree, tvb, offset, option_len+value_len, ett_tftp_option, NULL, "Option: %s = %s", optionname, optionvalue); proto_tree_add_item(opt_tree, hf_tftp_option_name, tvb, offset, option_len, ENC_ASCII|ENC_NA); proto_tree_add_item(opt_tree, hf_tftp_option_value, tvb, value_offset, value_len, ENC_ASCII|ENC_NA); offset += option_len + value_len; col_append_fstr(pinfo->cinfo, COL_INFO, ", %s=%s", optionname, optionvalue); /* Special code to handle individual options */ if (!g_ascii_strcasecmp((const char *)optionname, "blksize") && opcode == TFTP_OACK) { gint blocksize = (gint)strtol((const char *)optionvalue, NULL, 10); if (blocksize < 8 || blocksize > 65464) { expert_add_info(pinfo, NULL, &ei_tftp_blocksize_range); } else { tftp_info->blocksize = blocksize; } } } }
static void add_charstring_value(const gchar *tag_desc, proto_tree *tree, tvbuff_t *tvb, int offset, int name_length, int value_length) { offset = add_value_head(tag_desc, tree, tvb, offset, name_length, value_length, NULL); proto_tree_add_text(tree, tvb, offset, value_length, "Value: %s", tvb_format_text(tvb, offset, value_length)); }
static int dissect_tapa_discover_unknown_new_tlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tapa_discover_tree, guint32 offset, gint remaining) { proto_item *item; proto_tree *tapa_discover_item_tree; guint8 item_type; gint item_length; const gchar *item_text; /*const gchar *item_type_text;*/ gboolean is_ascii; while (remaining > 3) { /* type(1) + flags(1) + length(2) */ item_type = tvb_get_guint8(tvb, offset); /*item_type_text = val_to_str(item_type, tapa_discover_unknown_vals, "%d");*/ item_length = tvb_get_ntohs(tvb, offset + 2) - 4; DISSECTOR_ASSERT(item_length > 0); is_ascii = check_ascii(tvb, offset + 4, item_length); if (is_ascii) item_text = tvb_format_text(tvb, offset + 4, item_length); else item_text = "BINARY-DATA"; col_append_fstr(pinfo->cinfo, COL_INFO, ", T=%d L=%d", item_type, item_length); item = proto_tree_add_text(tapa_discover_tree, tvb, offset, 4 + item_length, "Type %d, length %d, value %s", item_type, item_length, item_text); tapa_discover_item_tree = proto_item_add_subtree(item, ett_tapa_discover_req); proto_tree_add_item(tapa_discover_item_tree, hf_tapa_discover_newtlv_type, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(tapa_discover_item_tree, hf_tapa_discover_newtlv_pad, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(tapa_discover_item_tree, hf_tapa_discover_newtlv_length, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; if (is_ascii) proto_tree_add_item(tapa_discover_item_tree, hf_tapa_discover_newtlv_valuetext, tvb, offset, item_length, ENC_ASCII|ENC_NA); else proto_tree_add_item(tapa_discover_item_tree, hf_tapa_discover_newtlv_valuehex, tvb, offset, item_length, ENC_NA); offset += item_length; remaining -= (item_length + 4); } return offset; }
static void tftp_dissect_options(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, guint16 opcode, tftp_conv_info_t *tftp_info) { int option_len, value_len; int value_offset; const char *optionname; const char *optionvalue; proto_item *opt_item; proto_tree *opt_tree; while (tvb_offset_exists(tvb, offset)) { option_len = tvb_strsize(tvb, offset); /* length of option */ value_offset = offset + option_len; value_len = tvb_strsize(tvb, value_offset); /* length of value */ optionname = tvb_format_text(tvb, offset, option_len); optionvalue = tvb_format_text(tvb, value_offset, value_len); opt_item = proto_tree_add_text(tree, tvb, offset, option_len+value_len, "Option: %s = %s", optionname, optionvalue); opt_tree = proto_item_add_subtree(opt_item, ett_tftp_option); proto_tree_add_item(opt_tree, hf_tftp_option_name, tvb, offset, option_len, ENC_ASCII|ENC_NA); proto_tree_add_item(opt_tree, hf_tftp_option_value, tvb, value_offset, value_len, ENC_ASCII|ENC_NA); offset += option_len + value_len; col_append_fstr(pinfo->cinfo, COL_INFO, ", %s=%s", optionname, optionvalue); /* Special code to handle individual options */ if (!g_ascii_strcasecmp((const char *)optionname, "blksize") && opcode == TFTP_OACK) { gint blocksize = (gint)strtol((const char *)optionvalue, NULL, 10); if (blocksize < 8 || blocksize > 65464) { expert_add_info(pinfo, NULL, &ei_tftp_blocksize_range); } else { tftp_info->blocksize = blocksize; } } } }
static void do_address_str(const char* addr, tvbuff_t* tvb_string, asn1_ctx_t* actx) { wmem_strbuf_t *ddatype = (wmem_strbuf_t *)actx->value_ptr; p1_address_ctx_t* ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; do_address(addr, tvb_string, actx); if (ctx && ctx->do_address && ddatype && tvb_string) wmem_strbuf_append(ddatype, tvb_format_text(tvb_string, 0, tvb_captured_length(tvb_string))); }
static void dissect_cimd_parameter(tvbuff_t *tvb, proto_tree *tree, gint pindex, gint startOffset, gint endOffset) { /* Set up structures needed to add the param subtree and manage it */ proto_item *param_item = NULL; proto_tree *param_tree = NULL; param_item = proto_tree_add_text(tree, tvb, startOffset + 1, endOffset - (startOffset + 1), "%s", cimd_vals_PC[pindex].strptr ); param_tree = proto_item_add_subtree(param_item, (*vals_hdr_PC[pindex].ett_p)); proto_tree_add_string(param_tree, hf_cimd_pcode_indicator, tvb, startOffset + 1, CIMD_PC_LENGTH, tvb_format_text(tvb, startOffset + 1, CIMD_PC_LENGTH) ); proto_tree_add_string(param_tree, (*vals_hdr_PC[pindex].hf_p), tvb, startOffset + 1 + CIMD_PC_LENGTH + 1, endOffset - (startOffset + 1 + CIMD_PC_LENGTH + 1), tvb_format_text(tvb, startOffset + 1 + CIMD_PC_LENGTH + 1, endOffset - (startOffset + 1 + CIMD_PC_LENGTH + 1)) ); }
static void dissect_info_string_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item) { guint16 info_string_length; info_string_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH; proto_tree_add_item(parameter_tree, hf_info_string, parameter_tvb, INFO_STRING_OFFSET, info_string_length, ENC_ASCII|ENC_NA); proto_item_append_text(parameter_item, " (%.*s)", info_string_length, tvb_format_text(parameter_tvb, INFO_STRING_OFFSET, info_string_length)); }
static void dissect_pool_handle_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree) { guint16 handle_length; proto_item* pi; handle_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH; pi = proto_tree_add_item(parameter_tree, hf_pool_handle, parameter_tvb, POOL_HANDLE_OFFSET, handle_length, ENC_NA); proto_item_append_text(pi, " (%s)", tvb_format_text(parameter_tvb, POOL_HANDLE_OFFSET, handle_length)); }
static void dissect_text_interface_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item) { guint16 interface_id_length; interface_id_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH; proto_tree_add_item(parameter_tree, hf_text_interface_id, parameter_tvb, TEXT_INTERFACE_ID_OFFSET, interface_id_length, ENC_ASCII|ENC_NA); proto_item_append_text(parameter_item, " (%.*s)", interface_id_length, tvb_format_text(parameter_tvb, TEXT_INTERFACE_ID_OFFSET, interface_id_length)); }
static int check_term(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree) { proto_item *ti; /* First, check for CRLF, or, if global_beep_strict_term is false, * one of CR or LF ... If neither of these hold, we add an element * that complains of a protocol violation, and return -1, else * we add a terminator to the tree (possibly non-standard) and return * the count of characters we saw ... This may throw off the rest of the * dissection ... so-be-it! */ if ((tvb_get_guint8(tvb, offset) == 0x0d && tvb_get_guint8(tvb, offset + 1) == 0x0a)){ /* Correct terminator */ proto_tree_add_text(tree, tvb, offset, 2, "Terminator: CRLF"); return 2; } if ((tvb_get_guint8(tvb, offset) == 0x0d) && !global_beep_strict_term) { ti = proto_tree_add_text(tree, tvb, offset, 1, "Terminator: CR"); expert_add_info_format(pinfo, ti, PI_PROTOCOL, PI_WARN, "Nonstandard Terminator: CR"); return 1; } if ((tvb_get_guint8(tvb, offset) == 0x0a) && !global_beep_strict_term) { ti = proto_tree_add_text(tree, tvb, offset, 1, "Terminator: LF"); expert_add_info_format(pinfo, ti, PI_PROTOCOL, PI_WARN, "Nonstandard Terminator: LF"); return 1; } ti = proto_tree_add_text(tree, tvb, offset, 1, "Terminator: %s", tvb_format_text(tvb, offset, 2)); expert_add_info_format(pinfo, ti, PI_PROTOCOL, PI_WARN, "Invalid Terminator: %s", tvb_format_text(tvb, offset, 2)); return -1; }
static void do_address_str_tree(const char* addr, tvbuff_t* tvb_string, asn1_ctx_t* actx, proto_tree* tree) { wmem_strbuf_t *ddatype = (wmem_strbuf_t *)actx->value_ptr; p1_address_ctx_t* ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; do_address(addr, tvb_string, actx); if (ctx && ctx->do_address && tvb_string && ddatype) { if (wmem_strbuf_get_len(ddatype) > 0) { proto_item_append_text (tree, " (%s=%s)", wmem_strbuf_get_str(ddatype), tvb_format_text(tvb_string, 0, tvb_captured_length(tvb_string))); } } }
static void do_address(const char* addr, tvbuff_t* tvb_string, asn1_ctx_t* actx) { p1_address_ctx_t* ctx = get_do_address_ctx(actx); if (ctx && ctx->do_address) { if (addr) { wmem_strbuf_append(ctx->oraddress, addr); } if (tvb_string) { wmem_strbuf_append(ctx->oraddress, tvb_format_text(tvb_string, 0, tvb_captured_length(tvb_string))); } } }
static void do_address(const char* addr, tvbuff_t* tvb_string, asn1_ctx_t* actx) { p1_address_ctx_t* ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; if (ctx && ctx->do_address) { if (addr) { wmem_strbuf_append(ctx->oraddress, addr); } if (tvb_string) { wmem_strbuf_append(ctx->oraddress, tvb_format_text(tvb_string, 0, tvb_length(tvb_string))); } } }
/* ajp13, in sort of a belt-and-suspenders move, encodes strings with * both a leading length field, and a trailing null. Mostly, see * ajpv13a.html. The returned length _includes_ the trailing null, if * there is one. * * XXX - is there a tvbuff routine to handle this? */ static const gchar * ajp13_get_nstring(tvbuff_t *tvb, gint offset, guint16* ret_len) { guint16 len; len = tvb_get_ntohs(tvb, offset); if (ret_len) *ret_len = len+1; /* a size of 0xFFFF indicates a null string - no data follows */ if (len == 0xFFFF) len = 0; return tvb_format_text(tvb, offset+2, MIN(len, ITEM_LABEL_LENGTH)); }
static int dissect_tapa_discover_req(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tapa_discover_tree, guint32 offset, gint remaining) { proto_item *item; proto_tree *tapa_discover_item_tree; guint8 item_type; gint item_length; gchar *item_text; const gchar *item_type_text; while (remaining > 0) { item_type = tvb_get_guint8(tvb, offset); item_type_text = val_to_str(item_type, tapa_discover_request_vals, "%d"); item_length = tvb_get_ntohs(tvb, offset + 2); item_text = tvb_format_text(tvb, offset + 4, item_length); DISSECTOR_ASSERT(item_length > 0); col_append_fstr(pinfo->cinfo, COL_INFO, ", %s: %s", item_type_text, item_text); item = proto_tree_add_text(tapa_discover_tree, tvb, offset, 4 + item_length, "Type %d = %s, length %d, value %s", item_type, item_type_text, item_length, item_text); tapa_discover_item_tree = proto_item_add_subtree(item, ett_tapa_discover_req); proto_tree_add_item(tapa_discover_item_tree, hf_tapa_discover_req_type, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(tapa_discover_item_tree, hf_tapa_discover_req_pad, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(tapa_discover_item_tree, hf_tapa_discover_req_length, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(tapa_discover_item_tree, hf_tapa_discover_req_value, tvb, offset, item_length, ENC_NA); offset += item_length; remaining -= (item_length + 4); } return offset; }
static void dissect_payload_kink_tgt_req(packet_info *pinfo, tvbuff_t *tvb, int offset, proto_tree *tree){ proto_tree *payload_kink_tgt_req_tree; proto_item *ti; guint8 next_payload; guint8 reserved; guint payload_length; guint16 realm_name_length; int start_payload_offset = 0; /* Keep the begining of the payload offset */ payload_length = tvb_get_ntohs(tvb, offset + TO_PAYLOAD_LENGTH); realm_name_length = tvb_get_ntohs(tvb, offset + TO_REALM_NAME_LENGTH); start_payload_offset = offset; /* Make the subtree */ ti = proto_tree_add_text(tree, tvb, offset, payload_length,"KINK_TGT_REQ"); payload_kink_tgt_req_tree = proto_item_add_subtree(ti, ett_payload_kink_tgt_req); next_payload = tvb_get_guint8(tvb, offset); proto_tree_add_uint(payload_kink_tgt_req_tree, hf_kink_next_payload, tvb, offset, 1, next_payload); offset ++; reserved = tvb_get_guint8(tvb, offset); proto_tree_add_text(payload_kink_tgt_req_tree, tvb, offset, 1, "RESERVED: %u", reserved); offset ++; proto_tree_add_text(payload_kink_tgt_req_tree, tvb, offset, 2, "Payload Length: %u", payload_length); offset += 2; proto_tree_add_text(payload_kink_tgt_req_tree, tvb, offset, 2, "RealmNameLength: %u", realm_name_length); offset += 2; proto_tree_add_text(payload_kink_tgt_req_tree, tvb, offset, realm_name_length, "RealmName: %s", tvb_format_text(tvb, offset, realm_name_length)); offset += realm_name_length; /* This part consider the padding. Payload_length don't contain the padding. */ if(payload_length % PADDING != 0){ payload_length += (PADDING - (payload_length % PADDING)); } offset = start_payload_offset + payload_length; if(payload_length > 0) { control_payload(pinfo, tvb, offset, next_payload, tree); /* Recur control_payload() */ } }
/* * Display the entire message as raw text. */ static void tvb_raw_text_add(tvbuff_t *tvb, proto_tree *tree) { int offset, next_offset, linelen; offset = 0; while (tvb_offset_exists(tvb, offset)) { /* 'desegment' is FALSE so will set next_offset to beyond the end of the buffer if no line ending is found */ tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE); linelen = next_offset - offset; if(tree) { proto_tree_add_text(tree, tvb, offset, linelen, "%s", tvb_format_text(tvb, offset, linelen)); } offset = next_offset; } }
static void dissect_fcfcs_gieil (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) { int offset = 16; /* past the fcct header */ int len, tot_len, prevlen; if (tree) { if (isreq) { proto_tree_add_string (tree, hf_fcs_iename, tvb, offset, 8, tvb_fcwwn_to_str (tvb, offset)); } else { tot_len = tvb_get_guint8 (tvb, offset+3); proto_tree_add_text (tree, tvb, offset+3, 1, "List Length: %d", tot_len); prevlen = 0; len = tvb_strsize(tvb, offset+4); proto_tree_add_item (tree, hf_fcs_vendorname, tvb, offset+4, len, ENC_ASCII|ENC_NA); prevlen += len; len = tvb_strsize(tvb, offset+4+prevlen); proto_tree_add_item (tree, hf_fcs_modelname, tvb, offset+4+prevlen, len, ENC_ASCII|ENC_NA); prevlen += len; len = tvb_strsize(tvb, offset+4+prevlen); proto_tree_add_item (tree, hf_fcs_releasecode, tvb, offset+4+prevlen, len, ENC_ASCII|ENC_NA); prevlen += len; offset += (4+prevlen); while (tot_len > prevlen) { len = tvb_strsize(tvb, offset); proto_tree_add_text (tree, tvb, offset, len, "Vendor-specific Information: %s", tvb_format_text(tvb, offset, len-1)); prevlen += len; offset += len; } } } }