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

C++ parse_rtattr_nested函数代码示例

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

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



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

示例1: print_linktype

static void print_linktype(FILE *fp, struct rtattr *tb)
{
	struct rtattr *linkinfo[IFLA_INFO_MAX+1];
	struct link_util *lu;
	char *kind;

	parse_rtattr_nested(linkinfo, IFLA_INFO_MAX, tb);

	if (!linkinfo[IFLA_INFO_KIND])
		return;
	kind = RTA_DATA(linkinfo[IFLA_INFO_KIND]);

	fprintf(fp, "%s", _SL_);
	fprintf(fp, "    %s ", kind);

	lu = get_link_kind(kind);
	if (!lu || !lu->print_opt)
		return;

	if (1) {
		struct rtattr *attr[lu->maxattr+1], **data = NULL;

		if (linkinfo[IFLA_INFO_DATA]) {
			parse_rtattr_nested(attr, lu->maxattr,
					    linkinfo[IFLA_INFO_DATA]);
			data = attr;
		}
		lu->print_opt(lu, fp, data);

		if (linkinfo[IFLA_INFO_XSTATS] && show_stats &&
		    lu->print_xstats)
			lu->print_xstats(lu, fp, linkinfo[IFLA_INFO_XSTATS]);
	}
}
开发者ID:Azzik,项目名称:iproute2,代码行数:34,代码来源:ipaddress.c


示例2: print_linktype

static void print_linktype(FILE *fp, struct rtattr *tb)
{
	struct rtattr *linkinfo[IFLA_INFO_MAX+1];
	struct link_util *lu;
	struct link_util *slave_lu;
	char *kind;
	char *slave_kind;

	parse_rtattr_nested(linkinfo, IFLA_INFO_MAX, tb);

	if (linkinfo[IFLA_INFO_KIND]) {
		kind = RTA_DATA(linkinfo[IFLA_INFO_KIND]);

		fprintf(fp, "%s", _SL_);
		fprintf(fp, "    %s ", kind);

		lu = get_link_kind(kind);
		if (lu && lu->print_opt) {
			struct rtattr *attr[lu->maxattr+1], **data = NULL;

			if (linkinfo[IFLA_INFO_DATA]) {
				parse_rtattr_nested(attr, lu->maxattr,
						    linkinfo[IFLA_INFO_DATA]);
				data = attr;
			}
			lu->print_opt(lu, fp, data);

			if (linkinfo[IFLA_INFO_XSTATS] && show_stats &&
			    lu->print_xstats)
				lu->print_xstats(lu, fp, linkinfo[IFLA_INFO_XSTATS]);
		}
	}

	if (linkinfo[IFLA_INFO_SLAVE_KIND]) {
		slave_kind = RTA_DATA(linkinfo[IFLA_INFO_SLAVE_KIND]);

		fprintf(fp, "%s", _SL_);
		fprintf(fp, "    %s_slave ", slave_kind);

		slave_lu = get_link_slave_kind(slave_kind);
		if (slave_lu && slave_lu->print_opt) {
			struct rtattr *attr[slave_lu->maxattr+1], **data = NULL;

			if (linkinfo[IFLA_INFO_SLAVE_DATA]) {
				parse_rtattr_nested(attr, slave_lu->maxattr,
						    linkinfo[IFLA_INFO_SLAVE_DATA]);
				data = attr;
			}
			slave_lu->print_opt(slave_lu, fp, data);
		}
	}
}
开发者ID:sostheim,项目名称:iproute2-lib,代码行数:52,代码来源:ipaddress.c


示例3: print_connmark

static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)
{
	struct rtattr *tb[TCA_CONNMARK_MAX + 1];
	struct tc_connmark *ci;

	if (arg == NULL)
		return -1;

	parse_rtattr_nested(tb, TCA_CONNMARK_MAX, arg);
	if (tb[TCA_CONNMARK_PARMS] == NULL) {
		fprintf(f, "[NULL connmark parameters]");
		return -1;
	}

	ci = RTA_DATA(tb[TCA_CONNMARK_PARMS]);

	fprintf(f, " connmark zone %d\n", ci->zone);
	fprintf(f, "\t index %d ref %d bind %d", ci->index,
		ci->refcnt, ci->bindcnt);

	if (show_stats) {
		if (tb[TCA_CONNMARK_TM]) {
			struct tcf_t *tm = RTA_DATA(tb[TCA_CONNMARK_TM]);
			print_tm(f, tm);
		}
	}
	fprintf(f, "\n");

	return 0;
}
开发者ID:vsergeenko,项目名称:po20151110svn,代码行数:30,代码来源:m_connmark.c


示例4: wrr_print_opt

static int wrr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
{

	struct rtattr *tb[TCA_OPTIONS-1];
	struct wrr_class_opt *copt;
	struct wrr_gopt *gopt;

	if (opt == NULL)
		return 0;

	parse_rtattr_nested(tb, TCA_WRR_MAX, opt);

	if (tb[TCA_WRR_PARAMS]) {

	    copt = RTA_DATA(tb[TCA_WRR_PARAMS]);
	    if (RTA_PAYLOAD(tb[TCA_WRR_PARAMS])  < sizeof(*copt)) return -1;
	    fprintf(f, "quantum %u nfmark %u.", copt->quantum, copt->handle);

	}
	if (tb[TCA_WRR_INIT]) {

	    gopt = RTA_DATA(tb[TCA_WRR_INIT]);
	    if (RTA_PAYLOAD(tb[TCA_WRR_INIT])  < sizeof(*gopt)) return -1;
	    fprintf(f, "queues %u", gopt->total_queues);

	}

	return 0;
}
开发者ID:springware,项目名称:92u10,代码行数:29,代码来源:q_wrr.c


示例5: pedit_keys_ex_getattr

static int pedit_keys_ex_getattr(struct rtattr *attr,
				 struct m_pedit_key_ex *keys_ex, int n)
{
	struct rtattr *i;
	int rem = RTA_PAYLOAD(attr);
	struct rtattr *tb[TCA_PEDIT_KEY_EX_MAX + 1];
	struct m_pedit_key_ex *k = keys_ex;

	for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
		if (!n)
			return -1;

		if (i->rta_type != TCA_PEDIT_KEY_EX)
			return -1;

		parse_rtattr_nested(tb, TCA_PEDIT_KEY_EX_MAX, i);

		k->htype = rta_getattr_u16(tb[TCA_PEDIT_KEY_EX_HTYPE]);
		k->cmd = rta_getattr_u16(tb[TCA_PEDIT_KEY_EX_CMD]);

		k++;
		n--;
	}

	return !!n;
}
开发者ID:eworm-de,项目名称:iproute2,代码行数:26,代码来源:m_pedit.c


示例6: print_vfinfo

static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
{
	struct ifla_vf_mac *vf_mac;
	struct ifla_vf_vlan *vf_vlan;
	struct ifla_vf_tx_rate *vf_tx_rate;
	struct rtattr *vf[IFLA_VF_MAX+1];
	SPRINT_BUF(b1);

	if (vfinfo->rta_type != IFLA_VF_INFO) {
		fprintf(stderr, "BUG: rta type is %d\n", vfinfo->rta_type);
		return;
	}

	parse_rtattr_nested(vf, IFLA_VF_MAX, vfinfo);

	vf_mac = RTA_DATA(vf[IFLA_VF_MAC]);
	vf_vlan = RTA_DATA(vf[IFLA_VF_VLAN]);
	vf_tx_rate = RTA_DATA(vf[IFLA_VF_TX_RATE]);

	fprintf(fp, "\n    vf %d MAC %s", vf_mac->vf,
		ll_addr_n2a((unsigned char *)&vf_mac->mac,
		ETH_ALEN, 0, b1, sizeof(b1)));
	if (vf_vlan->vlan)
		fprintf(fp, ", vlan %d", vf_vlan->vlan);
	if (vf_vlan->qos)
		fprintf(fp, ", qos %d", vf_vlan->qos);
	if (vf_tx_rate->rate)
		fprintf(fp, ", tx rate %d (Mbps)", vf_tx_rate->rate);
}
开发者ID:mptcp-arndale,项目名称:android_external_iproute2,代码行数:29,代码来源:ipaddress.c


示例7: fw_print_opt

static int fw_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 handle)
{
	struct rtattr *tb[TCA_FW_MAX+1];

	if (opt == NULL)
		return 0;

	parse_rtattr_nested(tb, TCA_FW_MAX, opt);

	if (handle)
		fprintf(f, "handle 0x%x ", handle);

	if (tb[TCA_FW_CLASSID]) {
		SPRINT_BUF(b1);
		fprintf(f, "classid %s ", sprint_tc_classid(*(__u32*)RTA_DATA(tb[TCA_FW_CLASSID]), b1));
	}

	if (tb[TCA_FW_POLICE])
		tc_print_police(f, tb[TCA_FW_POLICE]);
	if (tb[TCA_FW_INDEV]) {
		struct rtattr *idev = tb[TCA_FW_INDEV];
		fprintf(f, "input dev %s ",(char *)RTA_DATA(idev));
	}
	
	if (tb[TCA_FW_ACT]) {
		fprintf(f, "\n");
		tc_print_action(f, tb[TCA_FW_ACT]);
	}
	return 0;
}
开发者ID:NieHao,项目名称:R7000,代码行数:30,代码来源:f_fw.c


示例8: red_print_opt

static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
{
	struct rtattr *tb[TCA_RED_STAB+1];
	struct tc_red_qopt *qopt;
	SPRINT_BUF(b1);
	SPRINT_BUF(b2);
	SPRINT_BUF(b3);

	if (opt == NULL)
		return 0;

	parse_rtattr_nested(tb, TCA_RED_STAB, opt);

	if (tb[TCA_RED_PARMS] == NULL)
		return -1;
	qopt = RTA_DATA(tb[TCA_RED_PARMS]);
	if (RTA_PAYLOAD(tb[TCA_RED_PARMS])  < sizeof(*qopt))
		return -1;
	fprintf(f, "limit %s min %s max %s ",
		sprint_size(qopt->limit, b1),
		sprint_size(qopt->qth_min, b2),
		sprint_size(qopt->qth_max, b3));
#ifdef TC_RED_ECN
	if (qopt->flags & TC_RED_ECN)
		fprintf(f, "ecn ");
#endif
	if (show_details) {
		fprintf(f, "ewma %u Plog %u Scell_log %u",
			qopt->Wlog, qopt->Plog, qopt->Scell_log);
	}
	return 0;
}
开发者ID:cmtsij,项目名称:Vizio_XWR100_GPL,代码行数:32,代码来源:q_red.c


示例9: ipoe_vlan_mon_handler

static void ipoe_vlan_mon_handler(const struct sockaddr_nl *addr, struct nlmsghdr *h)
{
	struct rtattr *tb[PKT_ATTR_MAX + 1];
	struct rtattr *tb2[IPOE_ATTR_MAX + 1];
	struct genlmsghdr *ghdr = NLMSG_DATA(h);
	int len = h->nlmsg_len;
	struct rtattr *attrs;
	int i;
	int ifindex, vid;

	len -= NLMSG_LENGTH(GENL_HDRLEN);

	if (len < 0) {
		log_warn("ipoe: wrong controller message length %d\n", len);
		return;
	}

	attrs = (struct rtattr *)((char *)ghdr + GENL_HDRLEN);
	parse_rtattr(tb, PKT_ATTR_MAX, attrs, len);

	for (i = 1; i < PKT_ATTR_MAX; i++) {
		if (!tb[i])
			break;

		parse_rtattr_nested(tb2, IPOE_ATTR_MAX, tb[i]);

		if (!tb2[IPOE_ATTR_IFINDEX] || !tb2[IPOE_ATTR_ADDR])
			continue;

		ifindex = *(uint32_t *)(RTA_DATA(tb2[IPOE_ATTR_IFINDEX]));
		vid = *(uint32_t *)(RTA_DATA(tb2[IPOE_ATTR_ADDR]));

		ipoe_vlan_notify(ifindex, vid);
	}
}
开发者ID:jorgeluiztaioque,项目名称:accel-ppp-fork,代码行数:35,代码来源:ipoe_netlink.c


示例10: cgroup_print_opt

static int cgroup_print_opt(struct filter_util *qu, FILE *f,
			   struct rtattr *opt, __u32 handle)
{
	struct rtattr *tb[TCA_CGROUP_MAX+1];

	if (opt == NULL)
		return 0;

	parse_rtattr_nested(tb, TCA_CGROUP_MAX, opt);

	if (handle)
		fprintf(f, "handle 0x%x ", handle);

	if (tb[TCA_CGROUP_EMATCHES])
		print_ematch(f, tb[TCA_CGROUP_EMATCHES]);

	if (tb[TCA_CGROUP_POLICE]) {
		fprintf(f, "\n");
		tc_print_police(f, tb[TCA_CGROUP_POLICE]);
	}

	if (tb[TCA_CGROUP_ACT])
		tc_print_action(f, tb[TCA_CGROUP_ACT]);

	return 0;
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:26,代码来源:f_cgroup.c


示例11: tc_print_action

int
tc_print_action(FILE * f, const struct rtattr *arg)
{

	int i;
	struct rtattr *tb[TCA_ACT_MAX_PRIO + 1];

	if (arg == NULL)
		return 0;

	parse_rtattr_nested(tb, TCA_ACT_MAX_PRIO, arg);

	if (tab_flush && NULL != tb[0]  && NULL == tb[1]) {
		int ret = tc_print_one_action(f, tb[0]);
		return ret;
	}

	for (i = 0; i < TCA_ACT_MAX_PRIO; i++) {
		if (tb[i]) {
			fprintf(f, "\n\taction order %d: ", i + batch_c);
			if (0 > tc_print_one_action(f, tb[i])) {
				fprintf(f, "Error printing action\n");
			}
		}

	}

	batch_c+=TCA_ACT_MAX_PRIO ;
	return 0;
}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:30,代码来源:m_action.c


示例12: print_ematch

int print_ematch(FILE *fd, const struct rtattr *rta)
{
	struct rtattr *tb[TCA_EMATCH_TREE_MAX+1];
	struct tcf_ematch_tree_hdr *hdr;

	if (parse_rtattr_nested(tb, TCA_EMATCH_TREE_MAX, rta) < 0)
		return -1;

	if (tb[TCA_EMATCH_TREE_HDR] == NULL) {
		fprintf(stderr, "Missing ematch tree header\n");
		return -1;
	}

	if (tb[TCA_EMATCH_TREE_LIST] == NULL) {
		fprintf(stderr, "Missing ematch tree list\n");
		return -1;
	}

	if (RTA_PAYLOAD(tb[TCA_EMATCH_TREE_HDR]) < sizeof(*hdr)) {
		fprintf(stderr, "Ematch tree header size mismatch\n");
		return -1;
	}

	hdr = RTA_DATA(tb[TCA_EMATCH_TREE_HDR]);

	return print_ematch_list(fd, hdr, tb[TCA_EMATCH_TREE_LIST]);
}
开发者ID:Nymphetaminer,项目名称:dsl-n55u,代码行数:27,代码来源:m_ematch.c


示例13: get_ctrl_grp_id

static int
get_ctrl_grp_id(struct rtattr *arg)
{
	struct rtattr *tb[CTRL_ATTR_MCAST_GRP_MAX + 1];
	char *name;

	if (arg == NULL)
		return -1;

	/* nested within the CTRL_ATTR_MCAST_GROUPS attribute are the  */
	/* group name and ID  */
	parse_rtattr_nested(tb, CTRL_ATTR_MCAST_GRP_MAX, arg);

	/* if either of the entries needed cannot be found, bail */
	if (!tb[CTRL_ATTR_MCAST_GRP_NAME] || !tb[CTRL_ATTR_MCAST_GRP_ID])
		return -1;

	/* get the name of this multicast group we've found */
	name = RTA_DATA(tb[CTRL_ATTR_MCAST_GRP_NAME]);

	/* if it does not match the ACPI event multicast group name, bail */
	if (strcmp(name, ACPI_EVENT_MCAST_GROUP_NAME))
		return -1;

	/* At this point, we've found what we were looking for.  We now  */
	/* have the multicast group ID for ACPI events over generic netlink. */
	acpi_event_mcast_group_id =
		*((__u32 *)RTA_DATA(tb[CTRL_ATTR_MCAST_GRP_ID]));

	return 0;
}
开发者ID:ystk,项目名称:debian-acpid,代码行数:31,代码来源:acpi_ids.c


示例14: myred_print_opt

static int myred_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
{
	struct rtattr *tb[TCA_MYRED_STAB+1];
	struct tc_myred_qopt *qopt;


	SPRINT_BUF(b1);

	if (opt == NULL)
		return 0;

	parse_rtattr_nested(tb, TCA_MYRED_STAB, opt);

	if (tb[TCA_MYRED_PARMS] == NULL)
		return -1;
	qopt = RTA_DATA(tb[TCA_MYRED_PARMS]);
	if (RTA_PAYLOAD(tb[TCA_MYRED_PARMS])  < sizeof(*qopt))
		return -1;
	fprintf(f, "limit %s",
		sprint_size(qopt->limit, b1));
#ifdef TC_MYRED_ECN
	if (qopt->flags & TC_MYRED_ECN)
		fprintf(f, "ecn ");
#endif
	/*qjl*/
	if (show_details) {
		fprintf(f, "p_init %lf p_min %lf p_max %lf q_min %d q_max %d sampl_period %d",
			qopt->p_init, qopt->p_min, qopt->p_max, qopt->q_min, qopt->q_max, qopt->sampl_period);
	}
	return 0;
}
开发者ID:share-zhou,项目名称:myred,代码行数:31,代码来源:q_myred.c


示例15: atm_print_opt

static int atm_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
{
	struct rtattr *tb[TCA_ATM_MAX+1];
	char buffer[MAX_ATM_ADDR_LEN+1];

	if (opt == NULL)
		return 0;

	parse_rtattr_nested(tb, TCA_ATM_MAX, opt);
	if (tb[TCA_ATM_ADDR]) {
		if (RTA_PAYLOAD(tb[TCA_ATM_ADDR]) <
		    sizeof(struct sockaddr_atmpvc))
			fprintf(stderr,"ATM: address too short\n");
		else {
			if (atm2text(buffer,MAX_ATM_ADDR_LEN,
			    RTA_DATA(tb[TCA_ATM_ADDR]),A2T_PRETTY | A2T_NAME) <
			    0) fprintf(stderr,"atm2text error\n");
			fprintf(f,"pvc %s ",buffer);
		}
	}
	if (tb[TCA_ATM_HDR]) {
		int i;
		const __u8 *hdr = RTA_DATA(tb[TCA_ATM_HDR]);

		fprintf(f,"hdr");
		for (i = 0; i < RTA_PAYLOAD(tb[TCA_ATM_HDR]); i++)
			fprintf(f,"%c%02x", i ? '.' : ' ', hdr[i]);
		if (!i) fprintf(f," .");
		fprintf(f," ");
	}
	if (tb[TCA_ATM_EXCESS]) {
		__u32 excess;

		if (RTA_PAYLOAD(tb[TCA_ATM_EXCESS]) < sizeof(excess))
			fprintf(stderr,"ATM: excess class ID too short\n");
		else {
			excess = rta_getattr_u32(tb[TCA_ATM_EXCESS]);
			if (!excess) fprintf(f,"excess clp ");
			else {
				char buf[64];

				print_tc_classid(buf,sizeof(buf),excess);
				fprintf(f,"excess %s ",buf);
			}
		}
	}
	if (tb[TCA_ATM_STATE]) {
		static const char *map[] = { ATM_VS2TXT_MAP };
		int state;

		if (RTA_PAYLOAD(tb[TCA_ATM_STATE]) < sizeof(state))
			fprintf(stderr,"ATM: state field too short\n");
		else {
			state = *(int *) RTA_DATA(tb[TCA_ATM_STATE]);
			fprintf(f,"%s ",map[state]);
		}
	}
	return 0;
}
开发者ID:duki994,项目名称:G900H-Platform-XXU1BOA7,代码行数:59,代码来源:q_atm.c


示例16: tcindex_print_opt

static int tcindex_print_opt(struct filter_util *qu, FILE *f,
     struct rtattr *opt, __u32 handle)
{
	struct rtattr *tb[TCA_TCINDEX_MAX+1];

	if (opt == NULL)
		return 0;

	parse_rtattr_nested(tb, TCA_TCINDEX_MAX, opt);

	if (handle != ~0) fprintf(f, "handle 0x%04x ", handle);
	if (tb[TCA_TCINDEX_HASH]) {
		__u16 hash;

		if (RTA_PAYLOAD(tb[TCA_TCINDEX_HASH]) < sizeof(hash))
			return -1;
		hash = rta_getattr_u16(tb[TCA_TCINDEX_HASH]);
		fprintf(f, "hash %d ", hash);
	}
	if (tb[TCA_TCINDEX_MASK]) {
		__u16 mask;

		if (RTA_PAYLOAD(tb[TCA_TCINDEX_MASK]) < sizeof(mask))
			return -1;
		mask = rta_getattr_u16(tb[TCA_TCINDEX_MASK]);
		fprintf(f, "mask 0x%04x ", mask);
	}
	if (tb[TCA_TCINDEX_SHIFT]) {
		int shift;

		if (RTA_PAYLOAD(tb[TCA_TCINDEX_SHIFT]) < sizeof(shift))
			return -1;
		shift = *(int *) RTA_DATA(tb[TCA_TCINDEX_SHIFT]);
		fprintf(f, "shift %d ", shift);
	}
	if (tb[TCA_TCINDEX_FALL_THROUGH]) {
		int fall_through;

		if (RTA_PAYLOAD(tb[TCA_TCINDEX_FALL_THROUGH]) <
		    sizeof(fall_through))
			return -1;
		fall_through = *(int *) RTA_DATA(tb[TCA_TCINDEX_FALL_THROUGH]);
		fprintf(f, fall_through ? "fall_through " : "pass_on ");
	}
	if (tb[TCA_TCINDEX_CLASSID]) {
		SPRINT_BUF(b1);
		fprintf(f, "classid %s ", sprint_tc_classid(*(__u32 *)
		    RTA_DATA(tb[TCA_TCINDEX_CLASSID]), b1));
	}
	if (tb[TCA_TCINDEX_POLICE]) {
		fprintf(f, "\n");
		tc_print_police(f, tb[TCA_TCINDEX_POLICE]);
	}
	if (tb[TCA_TCINDEX_ACT]) {
		fprintf(f, "\n");
		tc_print_police(f, tb[TCA_TCINDEX_ACT]);
	}
	return 0;
}
开发者ID:idosch,项目名称:iproute2,代码行数:59,代码来源:f_tcindex.c


示例17: tbf_print_opt

static int tbf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
{
	struct rtattr *tb[TCA_TBF_PTAB+1];
	struct tc_tbf_qopt *qopt;
	double buffer, mtu;
	double latency;
	SPRINT_BUF(b1);
	SPRINT_BUF(b2);

	if (opt == NULL)
		return 0;

	parse_rtattr_nested(tb, TCA_TBF_PTAB, opt);

	if (tb[TCA_TBF_PARMS] == NULL)
		return -1;

	qopt = RTA_DATA(tb[TCA_TBF_PARMS]);
	if (RTA_PAYLOAD(tb[TCA_TBF_PARMS])  < sizeof(*qopt))
		return -1;
	fprintf(f, "rate %s ", sprint_rate(qopt->rate.rate, b1));
	buffer = tc_calc_xmitsize(qopt->rate.rate, qopt->buffer);
	if (show_details) {
		fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1),
			1<<qopt->rate.cell_log, sprint_size(qopt->rate.mpu, b2));
	} else {
		fprintf(f, "burst %s ", sprint_size(buffer, b1));
	}
	if (show_raw)
		fprintf(f, "[%08x] ", qopt->buffer);
	if (qopt->peakrate.rate) {
		fprintf(f, "peakrate %s ", sprint_rate(qopt->peakrate.rate, b1));
		if (qopt->mtu || qopt->peakrate.mpu) {
			mtu = tc_calc_xmitsize(qopt->peakrate.rate, qopt->mtu);
			if (show_details) {
				fprintf(f, "mtu %s/%u mpu %s ", sprint_size(mtu, b1),
					1<<qopt->peakrate.cell_log, sprint_size(qopt->peakrate.mpu, b2));
			} else {
				fprintf(f, "minburst %s ", sprint_size(mtu, b1));
			}
			if (show_raw)
				fprintf(f, "[%08x] ", qopt->mtu);
		}
	}

	if (show_raw)
		fprintf(f, "limit %s ", sprint_size(qopt->limit, b1));

	latency = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->rate.rate) - tc_core_tick2time(qopt->buffer);
	if (qopt->peakrate.rate) {
		double lat2 = TIME_UNITS_PER_SEC*(qopt->limit/(double)qopt->peakrate.rate) - tc_core_tick2time(qopt->mtu);
		if (lat2 > latency)
			latency = lat2;
	}
	fprintf(f, "lat %s ", sprint_time(latency, b1));

	return 0;
}
开发者ID:Nymphetaminer,项目名称:dsl-n55u,代码行数:58,代码来源:q_tbf.c


示例18: pie_print_opt

static int pie_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
{
	struct rtattr *tb[TCA_PIE_MAX + 1];
	unsigned int limit;
	unsigned int tupdate;
	unsigned int target;
	unsigned int alpha;
	unsigned int beta;
	unsigned ecn;
	unsigned bytemode;
	SPRINT_BUF(b1);

	if (opt == NULL)
		return 0;

	parse_rtattr_nested(tb, TCA_PIE_MAX, opt);

	if (tb[TCA_PIE_LIMIT] &&
	    RTA_PAYLOAD(tb[TCA_PIE_LIMIT]) >= sizeof(__u32)) {
		limit = rta_getattr_u32(tb[TCA_PIE_LIMIT]);
		fprintf(f, "limit %up ", limit);
	}
	if (tb[TCA_PIE_TARGET] &&
	    RTA_PAYLOAD(tb[TCA_PIE_TARGET]) >= sizeof(__u32)) {
		target = rta_getattr_u32(tb[TCA_PIE_TARGET]);
		fprintf(f, "target %s ", sprint_time(target, b1));
	}
	if (tb[TCA_PIE_TUPDATE] &&
	    RTA_PAYLOAD(tb[TCA_PIE_TUPDATE]) >= sizeof(__u32)) {
		tupdate = rta_getattr_u32(tb[TCA_PIE_TUPDATE]);
		fprintf(f, "tupdate %s ", sprint_time(tupdate, b1));
	}
	if (tb[TCA_PIE_ALPHA] &&
	    RTA_PAYLOAD(tb[TCA_PIE_ALPHA]) >= sizeof(__u32)) {
		alpha = rta_getattr_u32(tb[TCA_PIE_ALPHA]);
		fprintf(f, "alpha %u ", alpha);
	}
	if (tb[TCA_PIE_BETA] &&
	    RTA_PAYLOAD(tb[TCA_PIE_BETA]) >= sizeof(__u32)) {
		beta = rta_getattr_u32(tb[TCA_PIE_BETA]);
		fprintf(f, "beta %u ", beta);
	}

	if (tb[TCA_PIE_ECN] && RTA_PAYLOAD(tb[TCA_PIE_ECN]) >= sizeof(__u32)) {
		ecn = rta_getattr_u32(tb[TCA_PIE_ECN]);
		if (ecn)
			fprintf(f, "ecn ");
	}

	if (tb[TCA_PIE_BYTEMODE] &&
	    RTA_PAYLOAD(tb[TCA_PIE_BYTEMODE]) >= sizeof(__u32)) {
		bytemode = rta_getattr_u32(tb[TCA_PIE_BYTEMODE]);
		if (bytemode)
			fprintf(f, "bytemode ");
	}

	return 0;
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:58,代码来源:q_pie.c


示例19: print_encap_mpls

static void print_encap_mpls(FILE *fp, struct rtattr *encap)
{
	struct rtattr *tb[MPLS_IPTUNNEL_MAX+1];

	parse_rtattr_nested(tb, MPLS_IPTUNNEL_MAX, encap);

	if (tb[MPLS_IPTUNNEL_DST])
		fprintf(fp, " %s ",
		        format_host_rta(AF_MPLS, tb[MPLS_IPTUNNEL_DST]));
}
开发者ID:multipath-tcp,项目名称:iproute-mptcp,代码行数:10,代码来源:iproute_lwtunnel.c


示例20: parse_rtattr_nested

static char *parse_link_kind(struct rtattr *tb)
{
	struct rtattr *linkinfo[IFLA_INFO_MAX+1];

	parse_rtattr_nested(linkinfo, IFLA_INFO_MAX, tb);

	if (linkinfo[IFLA_INFO_KIND])
		return RTA_DATA(linkinfo[IFLA_INFO_KIND]);

	return "";
}
开发者ID:sostheim,项目名称:iproute2-lib,代码行数:11,代码来源:ipaddress.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ parse_string函数代码示例发布时间:2022-05-30
下一篇:
C++ parse_rtattr函数代码示例发布时间: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