本文整理汇总了C++中SPRINT_BUF函数的典型用法代码示例。如果您正苦于以下问题:C++ SPRINT_BUF函数的具体用法?C++ SPRINT_BUF怎么用?C++ SPRINT_BUF使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SPRINT_BUF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: bond_slave_print_opt
static void bond_slave_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
{
SPRINT_BUF(b1);
if (!tb)
return;
if (tb[IFLA_BOND_SLAVE_STATE])
print_slave_state(f, tb[IFLA_BOND_SLAVE_STATE]);
if (tb[IFLA_BOND_SLAVE_MII_STATUS])
print_slave_mii_status(f, tb[IFLA_BOND_SLAVE_MII_STATUS]);
if (tb[IFLA_BOND_SLAVE_LINK_FAILURE_COUNT])
fprintf(f, "link_failure_count %d ",
rta_getattr_u32(tb[IFLA_BOND_SLAVE_LINK_FAILURE_COUNT]));
if (tb[IFLA_BOND_SLAVE_PERM_HWADDR])
fprintf(f, "perm_hwaddr %s ",
ll_addr_n2a(RTA_DATA(tb[IFLA_BOND_SLAVE_PERM_HWADDR]),
RTA_PAYLOAD(tb[IFLA_BOND_SLAVE_PERM_HWADDR]),
0, b1, sizeof(b1)));
if (tb[IFLA_BOND_SLAVE_QUEUE_ID])
fprintf(f, "queue_id %d ",
rta_getattr_u16(tb[IFLA_BOND_SLAVE_QUEUE_ID]));
if (tb[IFLA_BOND_SLAVE_AD_AGGREGATOR_ID])
fprintf(f, "ad_aggregator_id %d ",
rta_getattr_u16(tb[IFLA_BOND_SLAVE_AD_AGGREGATOR_ID]));
}
示例3: codel_print_xstats
static int codel_print_xstats(struct qdisc_util *qu, FILE *f,
struct rtattr *xstats)
{
struct tc_codel_xstats *st;
SPRINT_BUF(b1);
if (xstats == NULL)
return 0;
if (RTA_PAYLOAD(xstats) < sizeof(*st))
return -1;
st = RTA_DATA(xstats);
fprintf(f, " count %u lastcount %u ldelay %s",
st->count, st->lastcount, sprint_time(st->ldelay, b1));
if (st->dropping)
fprintf(f, " dropping");
if (st->drop_next < 0)
fprintf(f, " drop_next -%s", sprint_time(-st->drop_next, b1));
else
fprintf(f, " drop_next %s", sprint_time(st->drop_next, b1));
fprintf(f, "\n maxpacket %u ecn_mark %u drop_overlimit %u",
st->maxpacket, st->ecn_mark, st->drop_overlimit);
return 0;
}
示例4: print_maddr
static void print_maddr(FILE *fp, struct ma_info *list)
{
fprintf(fp, "\t");
if (list->addr.family == AF_PACKET) {
SPRINT_BUF(b1);
fprintf(fp, "link %s", ll_addr_n2a((unsigned char*)list->addr.data,
list->addr.bytelen, 0,
b1, sizeof(b1)));
} else {
char abuf[256];
switch(list->addr.family) {
case AF_INET:
fprintf(fp, "inet ");
break;
case AF_INET6:
fprintf(fp, "inet6 ");
break;
default:
fprintf(fp, "family %d ", list->addr.family);
break;
}
fprintf(fp, "%s",
format_host(list->addr.family,
-1,
list->addr.data,
abuf, sizeof(abuf)));
}
if (list->users != 1)
fprintf(fp, " users %d", list->users);
if (list->features)
fprintf(fp, " %s", list->features);
fprintf(fp, "\n");
}
示例5: 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);
}
示例6: 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;
}
示例7: print_tunnel
static void print_tunnel(struct ip_tunnel_parm *p)
{
char s1[256];
char s2[256];
char s3[64];
char s4[64];
format_host(AF_INET, 4, &p->iph.daddr, s1, sizeof(s1));
format_host(AF_INET, 4, &p->iph.saddr, s2, sizeof(s2));
inet_ntop(AF_INET, &p->i_key, s3, sizeof(s3));
inet_ntop(AF_INET, &p->o_key, s4, sizeof(s4));
printf("%s: %s/ip remote %s local %s ",
p->name,
p->iph.protocol == IPPROTO_IPIP ? "ip" :
(p->iph.protocol == IPPROTO_GRE ? "gre" :
(p->iph.protocol == IPPROTO_IPV6 ? "ipv6" : "unknown")),
p->iph.daddr ? s1 : "any", p->iph.saddr ? s2 : "any");
if (p->link) {
char *n = do_ioctl_get_ifname(p->link);
if (n) {
printf(" dev %s ", n);
free(n);
}
}
if (p->iph.ttl)
printf(" ttl %d ", p->iph.ttl);
else
printf(" ttl inherit ");
if (p->iph.tos) {
SPRINT_BUF(b1);
printf(" tos");
if (p->iph.tos & 1)
printf(" inherit");
if (p->iph.tos & ~1)
printf("%c%s ", p->iph.tos & 1 ? '/' : ' ',
rtnl_dsfield_n2a(p->iph.tos & ~1, b1, sizeof(b1)));
}
if (!(p->iph.frag_off & htons(IP_DF)))
printf(" nopmtudisc");
if ((p->i_flags & GRE_KEY) && (p->o_flags & GRE_KEY) && p->o_key == p->i_key)
printf(" key %s", s3);
else if ((p->i_flags | p->o_flags) & GRE_KEY) {
if (p->i_flags & GRE_KEY)
printf(" ikey %s ", s3);
if (p->o_flags & GRE_KEY)
printf(" okey %s ", s4);
}
if (p->i_flags & GRE_SEQ)
printf("%c Drop packets out of sequence.\n", _SL_);
if (p->i_flags & GRE_CSUM)
printf("%c Checksum in received packet is required.", _SL_);
if (p->o_flags & GRE_SEQ)
printf("%c Sequence packets on output.", _SL_);
if (p->o_flags & GRE_CSUM)
printf("%c Checksum output packets.", _SL_);
}
示例8: print_key
static void print_key(struct rtattr *key)
{
SPRINT_BUF(keyid);
print_string(PRINT_ANY, "key", " key %s\n",
hexstring_n2a(RTA_DATA(key), RTA_PAYLOAD(key),
keyid, sizeof(keyid)));
}
示例9: red_print_opt
static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
{
struct rtattr *tb[TCA_NRED_MAX + 1];
struct tc_nred_qopt *qopt;
__u32 max_P = 0;
SPRINT_BUF(b1);
SPRINT_BUF(b2);
SPRINT_BUF(b3);
//SPRINT_BUF(b4);
if (opt == NULL)
return 0;
parse_rtattr_nested(tb, TCA_NRED_MAX, opt);
if (tb[TCA_NRED_PARMS] == NULL)
return -1;
qopt = RTA_DATA(tb[TCA_NRED_PARMS]);
if (RTA_PAYLOAD(tb[TCA_NRED_PARMS]) < sizeof(*qopt))
return -1;
if (tb[TCA_NRED_MAX_P] &&
RTA_PAYLOAD(tb[TCA_NRED_MAX_P]) >= sizeof(__u32))
max_P = rta_getattr_u32(tb[TCA_NRED_MAX_P]);
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));
//sprint_size(qopt->decrement, b4));
if (qopt->flags & TC_RED_ECN)
fprintf(f, "ecn ");
if (qopt->flags & TC_RED_HARDDROP)
fprintf(f, "harddrop ");
if (qopt->flags & TC_RED_ADAPTATIVE)
fprintf(f, "adaptive ");
if (show_details) {
fprintf(f, "ewma %u ", qopt->Wlog);
if (max_P)
fprintf(f, "probability %lg ", max_P / pow(2, 32));
else
fprintf(f, "Plog %u ", qopt->Plog);
fprintf(f, "Scell_log %u", qopt->Scell_log);
}
return 0;
}
开发者ID:digideskio,项目名称:Comprehensive-analysis-of-RED-Algorithm-and-other-Active-Queue-Management-Techniques-to-improve-TCP,代码行数:46,代码来源:q_ered.c
示例10: 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;
}
示例11: print_gact
int
print_gact(struct action_util *au,FILE * f, struct rtattr *arg)
{
SPRINT_BUF(b1);
#ifdef CONFIG_GACT_PROB
SPRINT_BUF(b2);
struct tc_gact_p *pp = NULL;
struct tc_gact_p pp_dummy;
#endif
struct tc_gact *p = NULL;
struct rtattr *tb[TCA_GACT_MAX + 1];
if (arg == NULL)
return -1;
parse_rtattr_nested(tb, TCA_GACT_MAX, arg);
if (tb[TCA_GACT_PARMS] == NULL) {
fprintf(f, "[NULL gact parameters]");
return -1;
}
p = RTA_DATA(tb[TCA_GACT_PARMS]);
fprintf(f, "gact action %s", action_n2a(p->action, b1, sizeof (b1)));
#ifdef CONFIG_GACT_PROB
if (NULL != tb[TCA_GACT_PROB]) {
pp = RTA_DATA(tb[TCA_GACT_PROB]);
} else {
/* need to keep consistent output */
memset(&pp_dummy, 0, sizeof (pp_dummy));
pp = &pp_dummy;
}
fprintf(f, "\n\t random type %s %s val %d",prob_n2a(pp->ptype), action_n2a(pp->paction, b2, sizeof (b2)), pp->pval);
#endif
fprintf(f, "\n\t index %d ref %d bind %d",p->index, p->refcnt, p->bindcnt);
if (show_stats) {
if (tb[TCA_GACT_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_GACT_TM]);
print_tm(f,tm);
}
}
fprintf(f, "\n ");
return 0;
}
示例12: hfsc_print_sc
static void
hfsc_print_sc(FILE *f, char *name, struct tc_service_curve *sc)
{
SPRINT_BUF(b1);
fprintf(f, "%s ", name);
fprintf(f, "m1 %s ", sprint_rate(sc->m1, b1));
fprintf(f, "d %s ", sprint_time(tc_core_ktime2time(sc->d), b1));
fprintf(f, "m2 %s ", sprint_rate(sc->m2, b1));
}
示例13: esfq_print_opt
static int esfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
{
struct tc_esfq_qopt *qopt;
SPRINT_BUF(b1);
if (opt == NULL)
return 0;
if (RTA_PAYLOAD(opt) < sizeof(*qopt))
return -1;
qopt = RTA_DATA(opt);
fprintf(f, "quantum %s ", sprint_size(qopt->quantum, b1));
if (show_details) {
fprintf(f, "limit %up flows %u/%u ",
qopt->limit, qopt->flows, qopt->divisor);
}
if (qopt->perturb_period)
fprintf(f, "perturb %dsec ", qopt->perturb_period);
fprintf(f,"hash: ");
switch(qopt->hash_kind)
{
case TCA_SFQ_HASH_CLASSIC:
fprintf(f,"classic");
break;
case TCA_SFQ_HASH_DST:
fprintf(f,"dst");
break;
case TCA_SFQ_HASH_SRC:
fprintf(f,"src");
break;
case TCA_SFQ_HASH_FWMARK:
fprintf(f,"fwmark");
break;
case TCA_SFQ_HASH_CTORIGSRC:
fprintf(f,"ctorigsrc");
break;
case TCA_SFQ_HASH_CTORIGDST:
fprintf(f,"ctorigdst");
break;
case TCA_SFQ_HASH_CTREPLSRC:
fprintf(f,"ctreplsrc");
break;
case TCA_SFQ_HASH_CTREPLDST:
fprintf(f,"ctrepldst");
break;
case TCA_SFQ_HASH_CTNATCHG:
fprintf(f,"ctnatchg");
break;
default:
fprintf(f,"Unknown");
}
return 0;
}
示例14: hsr_print_opt
static void hsr_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
{
SPRINT_BUF(b1);
if (!tb)
return;
if (tb[IFLA_HSR_SLAVE1] &&
RTA_PAYLOAD(tb[IFLA_HSR_SLAVE1]) < sizeof(__u32))
return;
if (tb[IFLA_HSR_SLAVE2] &&
RTA_PAYLOAD(tb[IFLA_HSR_SLAVE2]) < sizeof(__u32))
return;
if (tb[IFLA_HSR_SEQ_NR] &&
RTA_PAYLOAD(tb[IFLA_HSR_SEQ_NR]) < sizeof(__u16))
return;
if (tb[IFLA_HSR_SUPERVISION_ADDR] &&
RTA_PAYLOAD(tb[IFLA_HSR_SUPERVISION_ADDR]) < ETH_ALEN)
return;
if (tb[IFLA_HSR_SLAVE1])
print_string(PRINT_ANY,
"slave1",
"slave1 %s ",
ll_index_to_name(rta_getattr_u32(tb[IFLA_HSR_SLAVE1])));
else
print_null(PRINT_ANY, "slave1", "slave1 %s ", "<none>");
if (tb[IFLA_HSR_SLAVE2])
print_string(PRINT_ANY,
"slave2",
"slave2 %s ",
ll_index_to_name(rta_getattr_u32(tb[IFLA_HSR_SLAVE2])));
else
print_null(PRINT_ANY, "slave2", "slave2 %s ", "<none>");
if (tb[IFLA_HSR_SEQ_NR])
print_int(PRINT_ANY,
"seq_nr",
"sequence %d ",
rta_getattr_u16(tb[IFLA_HSR_SEQ_NR]));
if (tb[IFLA_HSR_SUPERVISION_ADDR])
print_string(PRINT_ANY,
"supervision_addr",
"supervision %s ",
ll_addr_n2a(RTA_DATA(tb[IFLA_HSR_SUPERVISION_ADDR]),
RTA_PAYLOAD(tb[IFLA_HSR_SUPERVISION_ADDR]),
ARPHRD_VOID,
b1, sizeof(b1)));
}
示例15: drr_print_xstats
static int drr_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstats)
{
struct tc_drr_stats *x;
SPRINT_BUF(b1);
if (xstats == NULL)
return 0;
if (RTA_PAYLOAD(xstats) < sizeof(*x))
return -1;
x = RTA_DATA(xstats);
fprintf(f, " deficit %s ", sprint_size(x->deficit, b1));
return 0;
}