• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ plurality函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中plurality函数的典型用法代码示例。如果您正苦于以下问题:C++ plurality函数的具体用法?C++ plurality怎么用?C++ plurality使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了plurality函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: dissect_auto_rp

static void dissect_auto_rp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
        guint8 ver_type, rp_count;

        col_set_str(pinfo->cinfo, COL_PROTOCOL, "Auto-RP");
        col_clear(pinfo->cinfo, COL_INFO);

        ver_type = tvb_get_guint8(tvb, 0);
        rp_count = tvb_get_guint8(tvb, 1);
        if (check_col(pinfo->cinfo, COL_INFO))
                col_add_fstr(pinfo->cinfo, COL_INFO, "%s (v%s) for %u RP%s",
                             val_to_str(lo_nibble(ver_type), auto_rp_type_vals, "Unknown"),
                             val_to_str(hi_nibble(ver_type), auto_rp_ver_vals, "Unknown"),
                             rp_count, plurality(rp_count, "", "s"));

        if (tree) {
                proto_item *ti, *tv;
                proto_tree *auto_rp_tree, *ver_type_tree;
                int i, offset;
                guint16 holdtime;

                offset = 0;
                ti = proto_tree_add_item(tree, proto_auto_rp, tvb, offset, -1, FALSE);
                auto_rp_tree = proto_item_add_subtree(ti, ett_auto_rp);

                tv = proto_tree_add_text(auto_rp_tree, tvb, offset, 1, "Version: %s, Packet type: %s",
                                         val_to_str(hi_nibble(ver_type), auto_rp_ver_vals, "Unknown"),
                                         val_to_str(lo_nibble(ver_type), auto_rp_type_vals, "Unknown"));
                ver_type_tree = proto_item_add_subtree(tv, ett_auto_rp_ver_type);
                proto_tree_add_uint(ver_type_tree, hf_auto_rp_version, tvb, offset, 1, ver_type);
                proto_tree_add_uint(ver_type_tree, hf_auto_rp_type, tvb, offset, 1, ver_type);
                offset++;

                proto_tree_add_uint(auto_rp_tree, hf_auto_rp_count, tvb, offset, 1, rp_count);
                offset++;

                holdtime = tvb_get_ntohs(tvb, offset);
                proto_tree_add_uint_format_value(auto_rp_tree, hf_auto_rp_holdtime, tvb, offset, 2, holdtime,
                                           "%u second%s", holdtime, plurality(holdtime, "", "s"));
                offset+=2;

                proto_tree_add_text(auto_rp_tree, tvb, offset, 4, "Reserved: 0x%x", tvb_get_ntohs(tvb, offset));
                offset+=4;

                for (i = 0; i < rp_count; i++)
                        offset = do_auto_rp_map(tvb, offset, auto_rp_tree);

                if (tvb_offset_exists(tvb, offset))
                        proto_tree_add_text(tree, tvb, offset, -1, "Trailing junk");
        }

        return;
}
开发者ID:AkhilaAG,项目名称:gluster-wireshark-1.4,代码行数:53,代码来源:packet-auto_rp.c


示例2: dissect_auto_rp

static void dissect_auto_rp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
    guint8 ver_type, rp_count;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "Auto-RP");
    col_clear(pinfo->cinfo, COL_INFO);

    ver_type = tvb_get_guint8(tvb, 0);
    rp_count = tvb_get_guint8(tvb, 1);
    col_add_fstr(pinfo->cinfo, COL_INFO, "%s (v%s) for %u RP%s",
                 val_to_str_const(lo_nibble(ver_type), auto_rp_type_vals, "Unknown"),
                 val_to_str_const(hi_nibble(ver_type), auto_rp_ver_vals,  "Unknown"),
                 rp_count, plurality(rp_count, "", "s"));

    if (tree) {
        proto_item *ti;
        proto_tree *auto_rp_tree, *ver_type_tree;
        int         i, offset;
        guint16     holdtime;

        offset = 0;
        ti = proto_tree_add_item(tree, proto_auto_rp, tvb, offset, -1, ENC_NA);
        auto_rp_tree = proto_item_add_subtree(ti, ett_auto_rp);

        ver_type_tree = proto_tree_add_subtree_format(auto_rp_tree, tvb, offset, 1,
                        ett_auto_rp_ver_type, NULL, "Version: %s, Packet type: %s",
                        val_to_str_const(hi_nibble(ver_type), auto_rp_ver_vals,  "Unknown"),
                        val_to_str_const(lo_nibble(ver_type), auto_rp_type_vals, "Unknown"));
        proto_tree_add_uint(ver_type_tree, hf_auto_rp_version, tvb, offset, 1, ver_type);
        proto_tree_add_uint(ver_type_tree, hf_auto_rp_type, tvb, offset, 1, ver_type);
        offset++;

        proto_tree_add_uint(auto_rp_tree, hf_auto_rp_count, tvb, offset, 1, rp_count);
        offset++;

        holdtime = tvb_get_ntohs(tvb, offset);
        proto_tree_add_uint_format_value(auto_rp_tree, hf_auto_rp_holdtime, tvb, offset, 2, holdtime,
                                         "%u second%s", holdtime, plurality(holdtime, "", "s"));
        offset+=2;

        proto_tree_add_item(auto_rp_tree, hf_auto_rp_reserved, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset+=4;

        for (i = 0; i < rp_count; i++)
            offset = do_auto_rp_map(tvb, offset, auto_rp_tree);

        if (tvb_reported_length_remaining(tvb, offset) > 0)
            proto_tree_add_item(tree, hf_auto_rp_trailing_junk, tvb, offset, -1, ENC_NA);
    }

    return;
}
开发者ID:mvwicky,项目名称:NotesMiscellanea,代码行数:52,代码来源:packet-auto_rp.c


示例3: setWindowTitle

void FileSetDialog::addFile(fileset_entry *entry) {
    QString created;
    QString modified;
    QString dir_name;
    QString elided_dir_name;
    QTreeWidgetItem *entry_item;
    gchar *size_str;

    if (!entry) {
        setWindowTitle(wsApp->windowTitleString(tr("No files in Set")));
        fs_ui_->directoryLabel->setText(tr("No capture loaded"));
        fs_ui_->directoryLabel->setEnabled(false);
        return;
    }

    created = nameToDate(entry->name);
    if(created.length() < 1) {
        /* if this file doesn't follow the file set pattern, */
        /* use the creation time of that file */
        /* http://en.wikipedia.org/wiki/ISO_8601 */
        created = QDateTime::fromTime_t(entry->ctime).toLocalTime().toString("yyyy-MM-dd HH:mm:ss");
    }

    modified = QDateTime::fromTime_t(entry->mtime).toLocalTime().toString("yyyy-MM-dd HH:mm:ss");

    size_str = format_size(entry->size, format_size_unit_bytes|format_size_prefix_si);

    entry_item = new QTreeWidgetItem(fs_ui_->fileSetTree);
    entry_item->setToolTip(0, QString(tr("Open this capture file")));
    entry_item->setData(0, Qt::UserRole, qVariantFromValue(entry));

    entry_item->setText(0, entry->name);
    entry_item->setText(1, created);
    entry_item->setText(2, modified);
    entry_item->setText(3, size_str);
    g_free(size_str);
    // Not perfect but better than nothing.
    entry_item->setTextAlignment(3, Qt::AlignRight);

    setWindowTitle(wsApp->windowTitleString(tr("%1 File%2 in Set")
                                            .arg(fs_ui_->fileSetTree->topLevelItemCount())
                                            .arg(plurality(fs_ui_->fileSetTree->topLevelItemCount(), "", "s"))));

    dir_name = fileset_get_dirname();
    fs_ui_->directoryLabel->setText(dir_name);
    fs_ui_->directoryLabel->setUrl(QUrl::fromLocalFile(dir_name).toString());
    fs_ui_->directoryLabel->setEnabled(true);

    if(entry->current) {
        fs_ui_->fileSetTree->setCurrentItem(entry_item);
    }

    if (close_button_)
        close_button_->setEnabled(true);

    fs_ui_->fileSetTree->addTopLevelItem(entry_item);
    for (int i = 0; i < fs_ui_->fileSetTree->columnCount(); i++)
        fs_ui_->fileSetTree->resizeColumnToContents(i);
    fs_ui_->fileSetTree->setFocus();
}
开发者ID:MultipathDTLS,项目名称:wireshark,代码行数:60,代码来源:file_set_dialog.cpp


示例4: dissect_xtp_data

static void
dissect_xtp_data(tvbuff_t *tvb, proto_tree *tree, guint32 offset, gboolean have_btag) {
	guint32 len = tvb_length_remaining(tvb, offset);
	proto_item *ti;
	proto_tree *xtp_subtree;
	guint64 btag;

	ti = proto_tree_add_text(tree, tvb, offset, len, "Data Segment");
	xtp_subtree = proto_item_add_subtree(ti, ett_xtp_data);

	if (have_btag) {
		btag = tvb_get_ntohl(tvb, offset);
		btag <<= 32;
		btag += tvb_get_ntohl(tvb, offset+4);
		proto_tree_add_uint64(xtp_subtree, hf_xtp_btag, tvb, offset, 8, btag);
		offset += 8;
		len -= 8;
	}

	proto_tree_add_text(xtp_subtree, tvb, offset, len,
		"Data (%u byte%s)", len,
		plurality(len, "", "s"));

	return;
}
开发者ID:pvons,项目名称:wireshark,代码行数:25,代码来源:packet-xtp.c


示例5: dissect_diagnostic_information_parameter

static void
dissect_diagnostic_information_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
  guint16 diag_info_length;

  diag_info_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
  proto_tree_add_item(parameter_tree, hf_diag_info, parameter_tvb, PARAMETER_VALUE_OFFSET, diag_info_length, ENC_NA);
  proto_item_append_text(parameter_item, " (%u byte%s)", diag_info_length, plurality(diag_info_length, "", "s"));
}
开发者ID:VincentLadeveze,项目名称:802154e-wireshark,代码行数:9,代码来源:packet-dua.c


示例6: xdmcp_add_bytes

static gint xdmcp_add_bytes(proto_tree *tree, const char *text,
		     tvbuff_t *tvb, gint offset)
{
  guint len;
  len = tvb_get_ntohs(tvb, offset);
  proto_tree_add_text(tree, tvb, offset, len+2,
		      "%s (%u byte%s)", text, len, plurality(len, "", "s"));
  return len+2;
}
开发者ID:AkhilaAG,项目名称:gluster-wireshark-1.4,代码行数:9,代码来源:packet-xdmcp.c


示例7: dissect_heartbeat_data_parameter

static void
dissect_heartbeat_data_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
  guint16 heartbeat_data_length;

  heartbeat_data_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
  proto_tree_add_item(parameter_tree, hf_heartbeat_data, parameter_tvb, HEARTBEAT_DATA_OFFSET, heartbeat_data_length, NETWORK_BYTE_ORDER);
  proto_item_append_text(parameter_item, " (%u byte%s)", heartbeat_data_length, plurality(heartbeat_data_length, "", "s"));
}
开发者ID:flaub,项目名称:HotFuzz,代码行数:9,代码来源:packet-dua.c


示例8: dissect_cookie_parameter

static void
dissect_cookie_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
  guint16 cookie_length;

  cookie_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
  if (cookie_length > 0)
    proto_tree_add_item(parameter_tree, hf_cookie, parameter_tvb, COOKIE_OFFSET, cookie_length, ENC_NA);
  proto_item_append_text(parameter_item, " (%u byte%s)", cookie_length, plurality(cookie_length, "", "s"));
}
开发者ID:crondaemon,项目名称:wireshark,代码行数:10,代码来源:packet-asap.c


示例9: capture_input_drops

/* Capture child told us how many dropped packets it counted.
 */
void
capture_input_drops(capture_session *cap_session, guint32 dropped)
{
  g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "%u packet%s dropped", dropped, plurality(dropped, "", "s"));

  g_assert(cap_session->state == CAPTURE_RUNNING);

  cf_set_drops_known((capture_file *)cap_session->cf, TRUE);
  cf_set_drops((capture_file *)cap_session->cf, dropped);
}
开发者ID:PaulCharlton,项目名称:wireshark,代码行数:12,代码来源:capture.c


示例10: decode_content

void
decode_content(tvbuff_t *tvb, proto_tree *tree, gint offset)
{
    gint payload_len;
    proto_tree_add_item(tree, hf_scribe_content_type, tvb, offset, 2, FALSE);
    offset += 2;
    payload_len = tvb_reported_length_remaining(tvb, offset);
    proto_tree_add_text(tree, tvb, offset, payload_len,
				    "Payload (%u byte%s)", payload_len,
				    plurality(payload_len, "", "s"));
}
开发者ID:baont,项目名称:thesis,代码行数:11,代码来源:packet-scribe.c


示例11: dissect_sccpmg_unknown_message

static void
dissect_sccpmg_unknown_message(tvbuff_t *message_tvb, proto_tree *sccpmg_tree)
{
	guint32 message_length;

	message_length = tvb_length(message_tvb);

	proto_tree_add_text(sccpmg_tree, message_tvb, 0, message_length,
			    "Unknown message (%u byte%s)", message_length,
			    plurality(message_length, "", "s"));
}
开发者ID:LucaBongiorni,项目名称:LTE_monitor_c2xx,代码行数:11,代码来源:packet-sccpmg.c


示例12: dissect_media

static int
dissect_media(tvbuff_t *tvb, packet_info *pinfo , proto_tree *tree, void* data)
{
    int bytes;
    proto_item *ti;
    proto_tree *media_tree = 0;
    heur_dtbl_entry_t *hdtbl_entry;

    if (dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, tree, &hdtbl_entry, data)) {
        return tvb_reported_length(tvb);
    }

    /* Add media type to the INFO column if it is visible */
    col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", (pinfo->match_string) ? pinfo->match_string : "");

    if (tree) {
        if ( (bytes = tvb_reported_length(tvb)) > 0 )
        {
            ti = proto_tree_add_item(tree, proto_media, tvb, 0, -1, ENC_NA);
            media_tree = proto_item_add_subtree(ti, ett_media);

            if (data) {
                /* The media type has parameters */
                proto_tree_add_bytes_format_value(media_tree, hf_media_type, tvb, 0, bytes,
                    NULL, "%s; %s (%d byte%s)",
                    pinfo->match_string, (char *)data,
                    bytes, plurality(bytes, "", "s"));
            } else {
                /* The media type has no parameters */
                proto_tree_add_bytes_format_value(media_tree, hf_media_type, tvb, 0, bytes,
                    NULL, "%s (%d byte%s)",
                    pinfo->match_string ? pinfo->match_string : "",
                    bytes, plurality(bytes, "", "s"));
            }
        }
    }

    return tvb_reported_length(tvb);
}
开发者ID:ARK1988,项目名称:wireshark,代码行数:39,代码来源:packet-media.c


示例13: do_auto_rp_map

/*
 * Handles one Auto-RP map entry. Returns the new offset.
 */
static int do_auto_rp_map(tvbuff_t *tvb, int offset, proto_tree *auto_rp_tree)
{
        proto_item *ti;
        proto_tree *map_tree;
        guint8 group_count;
        guint32 rp_addr;      /* In network byte order */
        int i;

        rp_addr = tvb_get_ipv4(tvb, offset);
        group_count = tvb_get_guint8(tvb, offset + 5);

                               /* sizeof map header + n * sizeof encoded group addresses */
        ti = proto_tree_add_text(auto_rp_tree, tvb, offset, 6 + group_count * 6,
                                 "RP %s: %u group%s", ip_to_str((void *)&rp_addr),
                                 group_count, plurality(group_count, "", "s"));
        map_tree = proto_item_add_subtree(ti, ett_auto_rp_map);

        proto_tree_add_ipv4(map_tree, hf_auto_rp_rp_addr, tvb, offset, 4, rp_addr);
        offset += 4;
        proto_tree_add_uint(map_tree, hf_auto_rp_pim_ver, tvb, offset, 1, tvb_get_guint8(tvb, offset));
        offset++;
        proto_tree_add_text(map_tree, tvb, offset, 1, "Number of groups this RP maps to: %u", group_count);
        offset++;

        for (i = 0; i < group_count; i++) {
                proto_item *gi;
                proto_tree *grp_tree;
                guint8 sign, mask_len;
                guint32 group_addr;     /* In network byte order */

                sign = tvb_get_guint8(tvb, offset);
                mask_len = tvb_get_guint8(tvb, offset + 1);
                group_addr = tvb_get_ipv4(tvb, offset + 2);
                gi = proto_tree_add_text(map_tree, tvb, offset, 6, "Group %s/%u (%s)",
                                         ip_to_str((void *)&group_addr), mask_len,
                                         val_to_str(sign&AUTO_RP_SIGN_MASK, auto_rp_mask_sign_vals, ""));
                grp_tree = proto_item_add_subtree(gi, ett_auto_rp_group);

                proto_tree_add_uint(grp_tree, hf_auto_rp_prefix_sgn, tvb, offset, 1, sign);
                offset++;
                proto_tree_add_uint(grp_tree, hf_auto_rp_mask_len, tvb, offset, 1, mask_len);
                offset++;
                proto_tree_add_ipv4(grp_tree, hf_auto_rp_group_prefix, tvb, offset, 4, group_addr);
                offset += 4;

        }

        return offset;
}
开发者ID:AkhilaAG,项目名称:gluster-wireshark-1.4,代码行数:52,代码来源:packet-auto_rp.c


示例14: dissect_integer_range_interface_identifier_parameter

static void
dissect_integer_range_interface_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
  guint16 number_of_ranges, range_number;
  gint offset;

  number_of_ranges = (tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH) / INTERVAL_LENGTH;
  offset = PARAMETER_VALUE_OFFSET;
  for(range_number = 1; range_number <= number_of_ranges; range_number++) {
    proto_tree_add_item(parameter_tree, hf_interface_range_start, parameter_tvb, offset + START_OFFSET, START_LENGTH, NETWORK_BYTE_ORDER);
    proto_tree_add_item(parameter_tree, hf_interface_range_end,   parameter_tvb, offset + END_OFFSET,   END_LENGTH,   NETWORK_BYTE_ORDER);
    offset += INTERVAL_LENGTH;
  };

  proto_item_append_text(parameter_item, " (%u range%s)", number_of_ranges, plurality(number_of_ranges, "", "s"));
}
开发者ID:flaub,项目名称:HotFuzz,代码行数:16,代码来源:packet-dua.c


示例15: dissect_protocol_data_parameter

static void
dissect_protocol_data_parameter(tvbuff_t *parameter_tvb, proto_item *parameter_item, packet_info *pinfo, proto_tree *tree)
{
  guint16 protocol_data_length;
  tvbuff_t *protocol_data_tvb;

  protocol_data_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
  protocol_data_tvb    = tvb_new_subset_length(parameter_tvb, PROTOCOL_DATA_OFFSET, protocol_data_length);
  if(dpnss_handle){
    call_dissector(dpnss_handle, protocol_data_tvb, pinfo, tree);
    return;
  }

  call_dissector(data_handle, protocol_data_tvb, pinfo, tree);

  proto_item_append_text(parameter_item, " (%u byte%s)", protocol_data_length, plurality(protocol_data_length, "", "s"));
}
开发者ID:VincentLadeveze,项目名称:802154e-wireshark,代码行数:17,代码来源:packet-dua.c


示例16: do_auto_rp_map

/*
 * Handles one Auto-RP map entry. Returns the new offset.
 */
static int do_auto_rp_map(tvbuff_t *tvb, int offset, proto_tree *auto_rp_tree)
{
    proto_tree *map_tree;
    guint8      group_count;
    int         i;

    group_count = tvb_get_guint8(tvb, offset + 5);

    /* sizeof map header + n * sizeof encoded group addresses */
    map_tree = proto_tree_add_subtree_format(auto_rp_tree, tvb, offset, 6 + group_count * 6,
               ett_auto_rp_map, NULL,
               "RP %s: %u group%s", tvb_ip_to_str(tvb, offset),
               group_count, plurality(group_count, "", "s"));

    proto_tree_add_item(map_tree, hf_auto_rp_rp_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
    offset += 4;
    proto_tree_add_item(map_tree, hf_auto_rp_pim_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset++;
    proto_tree_add_uint(map_tree, hf_auto_rp_group_num, tvb, offset, 1, group_count);
    offset++;

    for (i = 0; i < group_count; i++) {
        proto_tree *grp_tree;
        guint8      sign, mask_len;

        sign = tvb_get_guint8(tvb, offset);
        mask_len = tvb_get_guint8(tvb, offset + 1);
        grp_tree = proto_tree_add_subtree_format(map_tree, tvb, offset, 6,
                   ett_auto_rp_group, NULL, "Group %s/%u (%s)",
                   tvb_ip_to_str(tvb, offset + 2), mask_len,
                   val_to_str_const(sign&AUTO_RP_SIGN_MASK, auto_rp_mask_sign_vals, ""));

        proto_tree_add_uint(grp_tree, hf_auto_rp_prefix_sgn, tvb, offset, 1, sign);
        offset++;
        proto_tree_add_uint(grp_tree, hf_auto_rp_mask_len, tvb, offset, 1, mask_len);
        offset++;
        proto_tree_add_item(grp_tree, hf_auto_rp_group_prefix, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;

    }

    return offset;
}
开发者ID:mvwicky,项目名称:NotesMiscellanea,代码行数:46,代码来源:packet-auto_rp.c


示例17: decode_past_error

gint
decode_past_error(tvbuff_t *tvb, proto_tree *tree, gint offset)
{
  guint32 error_len;
  guint32 remaining = (guint32) tvb_reported_length_remaining(tvb, offset);

  if (remaining < 4){
    proto_tree_add_text(tree, tvb, offset, remaining, "Too short attributes!");
    return -1;
  }
  error_len = tvb_get_ntohl(tvb, offset);
  proto_tree_add_uint(tree, hf_past_error_len, tvb, offset, 4, error_len);

  if (error_len > 0){
    if (remaining < (4 + error_len)){
      proto_tree_add_text(tree, tvb, offset + 4, remaining, "Too short attributes!");
      return -1;
    }
    proto_tree_add_text(tree, tvb, offset + 4, error_len,
				    "Error (%u byte%s)", error_len,
				    plurality(error_len, "", "s"));
  }
  return (offset + error_len + 4);
}
开发者ID:barnyard,项目名称:freepastry,代码行数:24,代码来源:packet-past.c


示例18: decode_past_content_handle

gint
decode_past_content_handle(tvbuff_t *tvb, proto_tree *tree, gint offset)
{
  guint16 content_handle_type;
  guint remaining = tvb_reported_length_remaining(tvb, offset);

  if (remaining < 2){
    proto_tree_add_text(tree, tvb, offset, remaining, "Too short attributes!");
    return -1;
  }

  content_handle_type = tvb_get_ntohs(tvb, offset);
  proto_tree_add_uint(tree, hf_past_content_handle_type, tvb, offset, 2, content_handle_type);

    if (content_handle_type == 0) {
      guint32 content_handle_len;
      if (remaining < 6){/*3 = type + len*/
        proto_tree_add_text(tree, tvb, offset + 2, remaining, "Too short attributes!");
      return -1;
      }
      content_handle_len = (guint32) tvb_get_ntohl(tvb, offset +2);
      proto_tree_add_uint(tree, hf_past_content_handle_len, tvb, offset + 2, 4, content_handle_len);
      if (remaining < (6 + content_handle_len)){
        proto_tree_add_text(tree, tvb, offset + 6, remaining, "Too short attributes!");
        return -1;
      }
      proto_tree_add_text(tree, tvb, offset + 6, content_handle_len,
				    "Past handle content (%u byte%s)", content_handle_len,
				    plurality(content_handle_len, "", "s"));
      return (offset + content_handle_len + 6);
    } else {
      /*unknown type, cannot dissect more data*/
      proto_tree_add_text(tree, tvb, offset + 6, -1, "Not supported by dissector.");
      return -1;
    }
}
开发者ID:barnyard,项目名称:freepastry,代码行数:36,代码来源:packet-past.c


示例19: dissect_xdmcp


//.........这里部分代码省略.........
	  const char *ip_string;

	  gint alen;
	  gint ctype = tvb_get_ntohs(tvb, offset);
	  offset += 2;
	  alen = tvb_get_ntohs(tvb, caddrs_offset);
	  caddrs_offset += 2;

	  if ((ctype == 0) && (alen == 4)) {
	    ip_string = ip_to_str(tvb_get_ptr(tvb, caddrs_offset, 4));
	  } else if ((ctype == 6) && (alen == 16)) {
	    ip_string = ip6_to_str((const struct e_in6_addr *)tvb_get_ptr(tvb, caddrs_offset, 16));
	  } else {
	    ip_string = NULL;
	  }

	  connection_ti = proto_tree_add_text(clist_tree, NULL, 0, 0,
					      "Connection %d%s%s", n,
					      (ip_string ? ": " : ""),
					      (ip_string ? ip_string : ""));
	  connection_tree = proto_item_add_subtree(connection_ti,
						   ett_xdmcp_connection);

	  proto_tree_add_text(connection_tree, tvb, offset-2, 2,
			      "Type: %s",
			      val_to_str(ctype, family_vals,
					 "Unknown (0x%04x)"));
	  if (ip_string) {
	    proto_tree_add_text(connection_tree, tvb, caddrs_offset-2, alen+2,
				"Address: %s", ip_string);
	  } else {
	    proto_tree_add_text(connection_tree, tvb, caddrs_offset-2, alen+2,
				"Address: (%u byte%s)", alen,
				plurality(alen, "", "s"));
	  }
	  caddrs_offset += alen;
	  ctypes_len--;
	  n++;
	}
	offset = caddrs_offset;
	proto_item_set_len(clist_ti, offset - ctypes_start_offset);

	offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_authentication_name,
				   tvb, offset);
	offset += xdmcp_add_bytes(xdmcp_tree, "Authentication data",
				  tvb, offset);

	offset += xdmcp_add_authorization_names(xdmcp_tree, tvb, offset);

	offset += xdmcp_add_text(xdmcp_tree, "Manufacturer display ID",
				 tvb, offset);
	break;
      }

      case XDMCP_ACCEPT:
	proto_tree_add_item(xdmcp_tree, hf_xdmcp_session_id, tvb,
			    offset, 4, FALSE);
	offset += 4;
	offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_authentication_name,
				   tvb, offset);
	offset += xdmcp_add_bytes(xdmcp_tree, "Authentication data",
				  tvb, offset);
	offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_authorization_name,
				   tvb, offset);
	offset += xdmcp_add_bytes(xdmcp_tree, "Authorization data",
				  tvb, offset);
开发者ID:AkhilaAG,项目名称:gluster-wireshark-1.4,代码行数:67,代码来源:packet-xdmcp.c


示例20: dissect_unknown_cause

static void
dissect_unknown_cause(tvbuff_t *cause_tvb, proto_tree *cause_tree, proto_item *cause_item)
{
  guint16 code, length, cause_info_length;

  code              = tvb_get_ntohs(cause_tvb, CAUSE_CODE_OFFSET);
  length            = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET);
  cause_info_length = length - CAUSE_HEADER_LENGTH;
  if (cause_info_length > 0)
    proto_tree_add_item(cause_tree, hf_cause_info, cause_tvb, CAUSE_INFO_OFFSET, cause_info_length, ENC_NA);
  proto_item_append_text(cause_item, " (code %u and %u byte%s information)", code, cause_info_length, plurality(cause_info_length, "", "s"));
}
开发者ID:crondaemon,项目名称:wireshark,代码行数:12,代码来源:packet-asap.c



注:本文中的plurality函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ply_list_get_next_node函数代码示例发布时间:2022-05-30
下一篇:
C++ plumed_merror函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap