本文整理汇总了C++中parse_rtattr_nested函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_rtattr_nested函数的具体用法?C++ parse_rtattr_nested怎么用?C++ parse_rtattr_nested使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_rtattr_nested函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]);
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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]);
}
示例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;
}
示例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;
}
示例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;
}