当前位置: 首页>>代码示例>>C++>>正文


C++ parse_rtattr函数代码示例

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


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

示例1: print_addrlabel

int print_addrlabel(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
{
	FILE *fp = (FILE*)arg;
	struct ifaddrlblmsg *ifal = NLMSG_DATA(n);
	int len = n->nlmsg_len;
	int host_len = -1;
	struct rtattr *tb[IFAL_MAX+1];
	char abuf[256];

	if (n->nlmsg_type != RTM_NEWADDRLABEL && n->nlmsg_type != RTM_DELADDRLABEL)
		return 0;

	len -= NLMSG_LENGTH(sizeof(*ifal));
	if (len < 0)
		return -1;

	parse_rtattr(tb, IFAL_MAX, IFAL_RTA(ifal), len);

	if (ifal->ifal_family == AF_INET)
		host_len = 32;
	else if (ifal->ifal_family == AF_INET6)
		host_len = 128;

	if (n->nlmsg_type == RTM_DELADDRLABEL)
		fprintf(fp, "Deleted ");

	if (tb[IFAL_ADDRESS]) {
		fprintf(fp, "prefix %s/%u ",
			format_host(ifal->ifal_family,
				    RTA_PAYLOAD(tb[IFAL_ADDRESS]),
				    RTA_DATA(tb[IFAL_ADDRESS]),
				    abuf, sizeof(abuf)),
			ifal->ifal_prefixlen);
	}

	if (ifal->ifal_index)
		fprintf(fp, "dev %s ", ll_index_to_name(ifal->ifal_index));

	if (tb[IFAL_LABEL] && RTA_PAYLOAD(tb[IFAL_LABEL]) == sizeof(int32_t)) {
		int32_t label;
		memcpy(&label, RTA_DATA(tb[IFAL_LABEL]), sizeof(label));
		fprintf(fp, "label %d ", label);
	}

	fprintf(fp, "\n");
	fflush(fp);
	return 0;
}
开发者ID:247a,项目名称:lenovo_b6000-8000_kernel_source,代码行数:48,代码来源:ipaddrlabel.c

示例2: netlink_reflect_filter

/* Netlink flag Link update */
static int
netlink_reflect_filter(struct sockaddr_nl *snl, struct nlmsghdr *h)
{
	struct ifinfomsg *ifi;
	struct rtattr *tb[IFLA_MAX + 1];
	interface_t *ifp;
	int len;

	ifi = NLMSG_DATA(h);
	if (!(h->nlmsg_type == RTM_NEWLINK || h->nlmsg_type == RTM_DELLINK))
		return 0;

	len = h->nlmsg_len - NLMSG_LENGTH(sizeof (struct ifinfomsg));
	if (len < 0)
		return -1;

	/* Interface name lookup */
	memset(tb, 0, sizeof (tb));
	parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
	if (tb[IFLA_IFNAME] == NULL)
		return -1;

	/* ignore loopback device */
	if (ifi->ifi_type == ARPHRD_LOOPBACK)
		return 0;

	/* find the VMAC interface (if any) */
	ifp = if_get_by_vmac_base_ifindex(ifi->ifi_index);

	/* if found, reflect base interface flags on VMAC interface */
	if (ifp)
		ifp->flags = ifi->ifi_flags;

	/* find the interface_t */
	ifp = if_get_by_ifindex(ifi->ifi_index);
	if (!ifp)
		return -1;

	/*
	 * Update flags.
	 * VMAC interfaces should never update it own flags, only be reflected
	 * by the base interface flags, see above.
	 */
	if (!ifp->vmac)
		ifp->flags = ifi->ifi_flags;

	return 0;
}
开发者ID:jonasj76,项目名称:keepalived,代码行数:49,代码来源:vrrp_netlink.c

示例3: get_rtstat_nlmsg

int get_rtstat_nlmsg(struct sockaddr_nl *who, struct nlmsghdr *m, void *arg)
{
#ifndef IFLA_RTSTATS
		return -1;
#else
	struct ifinfomsg *ifi = NLMSG_DATA(m);
	struct rtattr * tb[IFLA_MAX+1];
	int len = m->nlmsg_len;
	struct rtstat_ent *n;
	unsigned long ival[RTMAXS];
	int i;

	if (m->nlmsg_type != RTM_NEWLINK)
		return 0;

	len -= NLMSG_LENGTH(sizeof(*ifi));
	if (len < 0)
		return -1;

	if (!(ifi->ifi_flags&IFF_UP))
		return 0;


	memset(tb, 0, sizeof(tb));
	parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
	if (tb[IFLA_IFNAME] == NULL || tb[IFLA_RTSTATS] == NULL)
		return 0;

	n = malloc(sizeof(*n));
	if (!n)
		abort();
	n->ifindex = ifi->ifi_index;
	n->name = strdup(RTA_DATA(tb[IFLA_IFNAME]));

	memcpy(&ival, RTA_DATA(tb[IFLA_RTSTATS]), sizeof(ival));

	for (i=0; i<RTMAXS; i++) {
		n->ival[i] = ival[i];
	}

	n->next = rtstat_db;
	rtstat_db = n;


	return 0;
#endif
}
开发者ID:JackieXie168,项目名称:connect,代码行数:47,代码来源:ifnetlink-linux-lib1.c

示例4: hfsc_print_class_opt

static int
hfsc_print_class_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
{
	struct rtattr *tb[TCA_HFSC_MAX+1];
	struct tc_service_curve *rsc = NULL, *fsc = NULL, *usc = NULL;

	if (opt == NULL)
		return 0;

	memset(tb, 0, sizeof(tb));
	parse_rtattr(tb, TCA_HFSC_MAX, RTA_DATA(opt), RTA_PAYLOAD(opt));

	if (tb[TCA_HFSC_RSC]) {
		if (RTA_PAYLOAD(tb[TCA_HFSC_RSC]) < sizeof(*rsc))
			fprintf(stderr, "HFSC: truncated realtime option\n");
		else
			rsc = RTA_DATA(tb[TCA_HFSC_RSC]);
	}
	if (tb[TCA_HFSC_FSC]) {
		if (RTA_PAYLOAD(tb[TCA_HFSC_FSC]) < sizeof(*fsc))
			fprintf(stderr, "HFSC: truncated linkshare option\n");
		else
			fsc = RTA_DATA(tb[TCA_HFSC_FSC]);
	}
	if (tb[TCA_HFSC_USC]) {
		if (RTA_PAYLOAD(tb[TCA_HFSC_USC]) < sizeof(*usc))
			fprintf(stderr, "HFSC: truncated upperlimit option\n");
		else
			usc = RTA_DATA(tb[TCA_HFSC_USC]);
	}

	
	if (rsc != NULL && fsc != NULL &&
	    memcmp(rsc, fsc, sizeof(*rsc)) == 0)
		hfsc_print_sc(f, "sc", rsc);
	else {
		if (rsc != NULL)
			hfsc_print_sc(f, "rt", rsc);
		if (fsc != NULL)
			hfsc_print_sc(f, "ls", fsc);
	}
	if (usc != NULL)
		hfsc_print_sc(f, "ul", usc);

	return 0;
}
开发者ID:jameshilliard,项目名称:actiontec_opensrc_mi424wr-rev-ef_fw-20-20-8,代码行数:46,代码来源:q_hfsc.c

示例5: print_ila_mapping

static int print_ila_mapping(const struct sockaddr_nl *who,
			     struct nlmsghdr *n, void *arg)
{
	FILE *fp = (FILE *)arg;
	struct genlmsghdr *ghdr;
	struct rtattr *tb[ILA_ATTR_MAX + 1];
	int len = n->nlmsg_len;

	if (n->nlmsg_type != genl_family)
		return 0;

	len -= NLMSG_LENGTH(GENL_HDRLEN);
	if (len < 0)
		return -1;

	ghdr = NLMSG_DATA(n);
	parse_rtattr(tb, ILA_ATTR_MAX, (void *) ghdr + GENL_HDRLEN, len);

	print_ila_locid(fp, ILA_ATTR_LOCATOR_MATCH, tb, ADDR_BUF_SIZE);
	print_ila_locid(fp, ILA_ATTR_LOCATOR, tb, ADDR_BUF_SIZE);

	if (tb[ILA_ATTR_IFINDEX])
		fprintf(fp, "%-16s",
			ll_index_to_name(rta_getattr_u32(
						tb[ILA_ATTR_IFINDEX])));
	else
		fprintf(fp, "%-10s ", "-");

	if (tb[ILA_ATTR_CSUM_MODE])
		fprintf(fp, "%s",
			ila_csum_mode2name(rta_getattr_u8(
						tb[ILA_ATTR_CSUM_MODE])));
	else
		fprintf(fp, "%-10s ", "-");

	if (tb[ILA_ATTR_IDENT_TYPE])
		fprintf(fp, "%s",
			ila_ident_type2name(rta_getattr_u8(
						tb[ILA_ATTR_IDENT_TYPE])));
	else
		fprintf(fp, "-");

	fprintf(fp, "\n");

	return 0;
}
开发者ID:hannes,项目名称:iproute2,代码行数:46,代码来源:ipila.c

示例6: parse_ematch_meta

/*
 * parse ematch meta
 */
int parse_ematch_meta(char *msg, char *mp, void *p, int len)
{
    struct rtattr *meta[__TCA_EM_META_MAX];
    struct tcf_meta_hdr *hdr = NULL;
    struct tcf_meta_val *left = NULL, *right = NULL;

    parse_rtattr(meta, TCA_EM_META_MAX, p, len);

    if(meta[TCA_EM_META_HDR]) {
        if(RTA_PAYLOAD(meta[TCA_EM_META_HDR]) < sizeof(*hdr)) {
            rec_log("error: %s: TCA_EM_META_HDR: payload too short", __func__);
            return(1);
        }
        hdr = (struct tcf_meta_hdr *)RTA_DATA(meta[TCA_EM_META_HDR]);
        left = &(hdr->left);
        right = &(hdr->right);
    } else {
        rec_log("error: %s: TCA_EM_META_HDR: no attribute", __func__);
        return(1);
    }

    mp = add_log(msg, mp, "match=(");

    if(meta[TCA_EM_META_LVALUE]) {
        if(parse_tca_em_meta_value(msg, &mp, left, meta[TCA_EM_META_LVALUE]))
            return(1);
    } else {
        rec_log("error: %s: TCA_EM_META_LVALUE: no attribute", __func__);
        return(1);
    }

    mp = add_log(msg, mp, "%s ", conv_tcf_em_opnd(left->op, 0));

    if(meta[TCA_EM_META_RVALUE]) {
        if(parse_tca_em_meta_value(msg, &mp, right, meta[TCA_EM_META_RVALUE]))
            return(1);
    } else {
        rec_log("error: %s: TCA_EM_META_RVALUE: no attribute", __func__);
        return(1);
    }
    mp = add_log(msg, mp, ") ");

    rec_log("%s", msg);

    return(0);
}
开发者ID:t2mune,项目名称:nield,代码行数:49,代码来源:tcmsg_filter.c

示例7: get_netstat_nlmsg

static int get_netstat_nlmsg(struct sockaddr_nl *who, struct nlmsghdr *m, void *arg)
{
	struct ifinfomsg *ifi = NLMSG_DATA(m);
	struct rtattr * tb[IFLA_MAX+1];
	int len = m->nlmsg_len;
	struct ifstat_ent *n;
	uint64_t ival[MAXS];
	int i;

	if (m->nlmsg_type != RTM_NEWLINK)
		return 0;

	len -= NLMSG_LENGTH(sizeof(*ifi));
	if (len < 0)
		return -1;

	if (!(ifi->ifi_flags&IFF_UP))
		return 0;

	memset(tb, 0, sizeof(tb));
	parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
	if (tb[IFLA_IFNAME] == NULL || tb[IFLA_STATS64] == NULL)
		return 0;

	n = malloc(sizeof(*n));
	if (!n)
		abort();
	n->ifindex = ifi->ifi_index;
	n->name = strdup(RTA_DATA(tb[IFLA_IFNAME]));
	memcpy(&ival, RTA_DATA(tb[IFLA_STATS64]), sizeof(ival));
	for (i=0; i<MAXS; i++) {

#undef DO_L2_STATS
#ifdef DO_L2_STATS

		if(i == 2) n->ival[i] = n->ival[i]+4; /* RX CRC */
		if(i == 3) n->ival[i] = n->ival[i]+18; /* TX 14+4 E-hdr + CRC */
#endif
		n->val[i] = ival[i];
	}
	n->next = kern_db;
	kern_db = n;
	return 0;
}
开发者ID:jelaas,项目名称:ifstat2,代码行数:44,代码来源:ifstat2.c

示例8: NLMSG_LENGTH

int TunManager::getAddrRespParser(const struct sockaddr_nl *who,
                                  struct nlmsghdr *n,
                                  void *arg) {
  // only cares about RTM_NEWADDR
  if (n->nlmsg_type != RTM_NEWADDR) {
    return 0;
  }
  struct ifaddrmsg *ifa = static_cast<struct ifaddrmsg *>(NLMSG_DATA(n));
  struct rtattr *tb[IFA_MAX + 1];
  int len = n->nlmsg_len;
  len -= NLMSG_LENGTH(sizeof(*ifa));
  if (len < 0) {
    throw FbossError("Wrong length for RTM_GETADDR response ", len, " vs ",
                     NLMSG_LENGTH(sizeof(*ifa)));
  }
  // only care about v4 and v6 address
  if (ifa->ifa_family != AF_INET && ifa->ifa_family != AF_INET6) {
    VLOG(3) << "Skip address from device @ index "
            << static_cast<int>(ifa->ifa_index)
            << " because of its address family "
            << static_cast<int>(ifa->ifa_family);
    return 0;
  }

  parse_rtattr(tb, IFA_MAX, IFA_RTA(ifa), len);
  if (tb[IFA_ADDRESS] == nullptr) {
    VLOG(3) << "Device @ index " << static_cast<int>(ifa->ifa_index)
            << " does not have address at family "
            << static_cast<int>(ifa->ifa_family);
    return 0;
  }
  IPAddress addr;
  const void *data = RTA_DATA(tb[IFA_ADDRESS]);
  if (ifa->ifa_family == AF_INET) {
    addr = IPAddress(*static_cast<const in_addr *>(data));
  } else {
    addr = IPAddress(*static_cast<const in6_addr *>(data));
  }

  TunManager *mgr = static_cast<TunManager *>(arg);
  mgr->addProbedAddr(ifa->ifa_index, addr, ifa->ifa_prefixlen);
  return 0;
}
开发者ID:superchild,项目名称:fboss,代码行数:43,代码来源:TunManager.cpp

示例9: print_mpls

int print_mpls(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
{
	struct rtattr *tb[MPLS_ATTR_MAX + 1];
	struct genlmsghdr *ghdr = NLMSG_DATA(n);
	int len = n->nlmsg_len;
	struct rtattr *attrs;

	if (n->nlmsg_type !=  PF_MPLS) {
		fprintf(stderr, "Not a controller message, nlmsg_len=%d "
			"nlmsg_type=0x%x\n", n->nlmsg_len, n->nlmsg_type);
		return 0;
	}

        len -= NLMSG_LENGTH(GENL_HDRLEN);
        if (len < 0) {
                fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
                return -1;
        }

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

	switch (ghdr->cmd) {
		case MPLS_CMD_NEWILM:
			return print_ilm(n,arg,tb);
		case MPLS_CMD_NEWNHLFE:
			return print_nhlfe(n,arg,tb);
		case MPLS_CMD_NEWXC:
			return print_xc(n,arg,tb);
		case MPLS_CMD_SETLABELSPACE:
			return print_labelspace(n,arg,tb);
		default:
			return 0;
	}

#if 0
	if (n->nlmsg_type >= MPLS_RTM_ADDTUNNEL &&
		n->nlmsg_type <= MPLS_RTM_DELTUNNEL) {
		return print_tunnel(n,arg, tb);
	}
#endif
	return 0;
}
开发者ID:MichaelQQ,项目名称:Quagga-PE,代码行数:43,代码来源:mpls.c

示例10: xfrm_report_print

static int xfrm_report_print(const struct sockaddr_nl *who,
			     struct nlmsghdr *n, void *arg)
{
	FILE *fp = (FILE*)arg;
	struct xfrm_user_report *xrep = NLMSG_DATA(n);
	int len = n->nlmsg_len;
	struct rtattr * tb[XFRMA_MAX+1];
	__u16 family;

	if (n->nlmsg_type != XFRM_MSG_REPORT) {
		fprintf(stderr, "Not a report: %08x %08x %08x\n",
			n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags);
		return 0;
	}

	len -= NLMSG_LENGTH(sizeof(*xrep));
	if (len < 0) {
		fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
		return -1;
	}

	family = xrep->sel.family;
	if (family == AF_UNSPEC)
		family = preferred_family;

	fprintf(fp, "report ");

	fprintf(fp, "proto %s ", strxf_xfrmproto(xrep->proto));
	fprintf(fp, "%s", _SL_);

	xfrm_selector_print(&xrep->sel, family, fp, "  sel ");

	parse_rtattr(tb, XFRMA_MAX, XFRMREP_RTA(xrep), len);

	xfrm_xfrma_print(tb, family, fp, "  ");

	if (oneline)
		fprintf(fp, "\n");

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

示例11: netlink_receive_one

int netlink_receive_one(struct nlmsghdr *hdr, void *arg)
{
	struct rtattr *tb[NETLINK_DIAG_MAX+1];
	struct netlink_diag_msg *m;
	struct netlink_sk_desc *sd;
	unsigned long *groups;

	m = NLMSG_DATA(hdr);
	pr_info("Collect netlink sock 0x%x\n", m->ndiag_ino);

	sd = xmalloc(sizeof(*sd));
	if (!sd)
		return -1;

	sd->protocol = m->ndiag_protocol;
	sd->portid = m->ndiag_portid;
	sd->dst_portid = m->ndiag_dst_portid;
	sd->dst_group = m->ndiag_dst_group;
	sd->state = m->ndiag_state;

	parse_rtattr(tb, NETLINK_DIAG_MAX, (struct rtattr *)(m + 1),
		     hdr->nlmsg_len - NLMSG_LENGTH(sizeof(*m)));

	if (tb[NETLINK_DIAG_GROUPS]) {
		sd->gsize = RTA_PAYLOAD(tb[NETLINK_DIAG_GROUPS]);
		groups = RTA_DATA(tb[NETLINK_DIAG_GROUPS]);

		sd->groups = xmalloc(sd->gsize);
		if (!sd->groups) {
			xfree(sd);
			return -1;
		}
		memcpy(sd->groups, groups, sd->gsize);
	} else {
		sd->groups = NULL;
		sd->gsize = 0;
	}

	return sk_collect_one(m->ndiag_ino, PF_NETLINK, &sd->sd);
}
开发者ID:lesilva00,项目名称:criu,代码行数:40,代码来源:sk-netlink.c

示例12: debug_ematch_meta

/*
 * debug ematch meta
 */
void debug_ematch_meta(int lev, void *p, int len)
{
    struct rtattr *meta[__TCA_EM_META_MAX];
    struct tcf_meta_hdr *hdr = NULL;

    parse_rtattr(meta, TCA_EM_META_MAX, p, len);

    if(meta[TCA_EM_META_HDR])
        hdr = debug_tca_em_meta_hdr(lev, meta[TCA_EM_META_HDR],
            "TCA_EM_META_HDR");

    if(!hdr)
        return;

    if(meta[TCA_EM_META_LVALUE])
        debug_tca_em_meta_value(lev, meta[TCA_EM_META_LVALUE],
            "TCA_EM_META_LVALUE", &(hdr->left));

    if(meta[TCA_EM_META_RVALUE])
        debug_tca_em_meta_value(lev, meta[TCA_EM_META_RVALUE],
            "TCA_EM_META_RVALUE", &(hdr->right));
}
开发者ID:t2mune,项目名称:nield,代码行数:25,代码来源:tcmsg_filter.c

示例13: flush_rule

static int flush_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
{
	struct rtmsg *r = NLMSG_DATA(n);
	int len = n->nlmsg_len;
	struct rtattr * tb[RTA_MAX+1];

	len -= NLMSG_LENGTH(sizeof(*r));
	if (len < 0)
		return -1;

	parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len);

	if (tb[RTA_PRIORITY]) {
		n->nlmsg_type = RTM_DELRULE;
		n->nlmsg_flags = NLM_F_REQUEST;

		if (rtnl_talk(&rth, n, 0, 0, NULL, NULL, NULL) < 0)
			return -2;
	}

	return 0;
}
开发者ID:NieHao,项目名称:R7000,代码行数:22,代码来源:iprule.c

示例14: print_action

int print_action(const struct sockaddr_nl *who,
			   struct nlmsghdr *n,
			   void *arg)
{
	FILE *fp = (FILE*)arg;
	struct tcamsg *t = NLMSG_DATA(n);
	int len = n->nlmsg_len;
	struct rtattr * tb[TCAA_MAX+1];

	len -= NLMSG_LENGTH(sizeof(*t));

	if (len < 0) {
		fprintf(stderr, "Wrong len %d\n", len);
		return -1;
	}

	parse_rtattr(tb, TCAA_MAX, TA_RTA(t), len);

	if (NULL == tb[TCA_ACT_TAB]) {
		if (n->nlmsg_type != RTM_GETACTION)
			fprintf(stderr, "print_action: NULL kind\n");
		return -1;
	}

	if (n->nlmsg_type == RTM_DELACTION) {
		if (n->nlmsg_flags & NLM_F_ROOT) {
			fprintf(fp, "Flushed table ");
			tab_flush = 1;
		} else {
			fprintf(fp, "deleted action ");
		}
	}

	if (n->nlmsg_type == RTM_NEWACTION)
		fprintf(fp, "Added action ");
	tc_print_action(fp, tb[TCA_ACT_TAB]);

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

示例15: get_addrinfo

/****************************************************************
 NAME	: print_addr				00/06/02 18:24:09
 AIM	: 
 REMARK	:
****************************************************************/
static int get_addrinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
{
	struct ifaddrmsg *ifa 	= NLMSG_DATA(n);
	int		len	= n->nlmsg_len;
	iplist_ctx	*ctx	= (iplist_ctx *)arg;
	struct rtattr 	*rta_tb[IFA_MAX+1];
	/* sanity check */
	len -= NLMSG_LENGTH(sizeof(*ifa));
	if (len < 0) {
		fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
		return -1;
	}
	/* check the message type */
	if (n->nlmsg_type != RTM_NEWADDR )
		return 0;
	/* check it is ipv4 */
	if( ifa->ifa_family != AF_INET)
		return 0;
	/* check it is the good interface */
	if( ifa->ifa_index != ctx->ifindex )
		return 0;
		
	/* parse the attribute */
	memset(rta_tb, 0, sizeof(rta_tb));
	parse_rtattr(rta_tb, IFA_MAX, IFA_RTA(ifa), len);

	if (!rta_tb[IFA_LOCAL])
		rta_tb[IFA_LOCAL] = rta_tb[IFA_ADDRESS];

	if (rta_tb[IFA_LOCAL]) {
		u_char *src = RTA_DATA(rta_tb[IFA_LOCAL]);
		if( ctx->nb_elem >= ctx->max_elem )
			return 0;
		ctx->addr[ctx->nb_elem++] = 	(src[0]<<24) + (src[1]<<16) +
						(src[2]<<8) + src[3];
	}
	return 0;
}
开发者ID:HzyGit,项目名称:Vrrpd,代码行数:43,代码来源:ipaddr.c


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