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


C++ rtnl_wilddump_request函数代码示例

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


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

示例1: load_info

static void load_info(void)
{
	struct ifstat_ent *db, *n;
	struct rtnl_handle rth;

	if (rtnl_open(&rth, 0) < 0)
		exit(1);

	if (rtnl_wilddump_request(&rth, AF_INET, RTM_GETLINK) < 0) {
		perror("Cannot send dump request");
		exit(1);
	}

	if (rtnl_dump_filter(&rth, get_netstat_nlmsg, NULL, NULL, NULL) < 0) {
		fprintf(stderr, "Dump terminated\n");
		exit(1);
	}

	rtnl_close(&rth);

	db = kern_db;
	kern_db = NULL;

	while (db) {
		n = db;
		db = db->next;
		n->next = kern_db;
		kern_db = n;
	}
}
开发者ID:jelaas,项目名称:ifstat2,代码行数:30,代码来源:ifstat2.c

示例2: iprule_flush

static int iprule_flush(int argc, char **argv)
{
	int af = preferred_family;

#ifdef HTC_IPRULE_DEBUG
	ALOGD("[IPROUTE2]iprule_flush +");
#endif

	if (af == AF_UNSPEC)
		af = AF_INET;

	if (argc > 0) {
		fprintf(stderr, "\"ip rule flush\" does not allow arguments\n");
		return -1;
	}

	if (rtnl_wilddump_request(&rth, af, RTM_GETRULE) < 0) {
		perror("Cannot send dump request");
		return 1;
	}

	if (rtnl_dump_filter(&rth, flush_rule, NULL) < 0) {
		fprintf(stderr, "Flush terminated\n");
		return 1;
	}

#ifdef HTC_IPRULE_DEBUG
	ALOGD("[IPROUTE2]iprule_flush -");
#endif

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

示例3: rt_fetch

struct rt_entry * rt_fetch(struct rt_entry *r)
{
	struct rtnl_handle rth;

	// open netlink socket of NETLINK_ROUTE
	if (rtnl_open(&rth, 0) < 0) {
		printf("Can not initialize netlink interface...\n");
		return NULL;
	}

	ll_init_map(&rth);

	if (rtnl_wilddump_request(&rth, AF_INET, RTM_GETROUTE) < 0) {
		printf("Cannot send dump request\n");
		close(rth.fd);
		return NULL;
	}

	if (rtnl_dump_filter(&rth, rt_filter, r, NULL, NULL) < 0) {
		printf("Dump terminated.\n");
		close(rth.fd);
		return NULL;
	}

	close(rth.fd);
	return r;
}
开发者ID:blex,项目名称:bxvrrpd,代码行数:27,代码来源:iproute.c

示例4: ipaddr_list

/****************************************************************
 NAME	: ipaddr_list				00/06/02 20:02:23
 AIM	: 
 REMARK	:
****************************************************************/
int ipaddr_list( int ifindex, uint32_t *array, int max_elem )
{
	struct rtnl_handle	rth;
	iplist_ctx	ctx;
	/* init the struct */
	ctx.ifindex	= ifindex;
	ctx.addr	= array;
	ctx.max_elem	= max_elem;
	ctx.nb_elem	= 0;
	/* open the rtnetlink socket */
	if( rtnl_open( &rth, 0) )
		return -1;
	/* send the request */
	if (rtnl_wilddump_request(&rth, AF_INET, RTM_GETADDR) < 0) {
		perror("Cannot send dump request");
		return -1;
	}
	/* parse the answer */
	if (rtnl_dump_filter(&rth, get_addrinfo, &ctx, NULL, NULL) < 0) {
		fprintf(stderr, "Flush terminated\n");
		exit(1);
	}
	
	/* to close the clocket */
 	rtnl_close( &rth );
	
	return ctx.nb_elem;
}
开发者ID:HzyGit,项目名称:Vrrpd,代码行数:33,代码来源:ipaddr.c

示例5: rule_flush_table_range

/*
 * rule_flush_table_range: deletes all the rules which lookup the table X.
 * The table X is any table in the range of `a' <= X <= `b'.
 */
int
rule_flush_table_range(int family, int a, int b)
{
	struct rtnl_handle rth;
	int arg[2];

	if (rtnl_open(&rth, 0) < 0)
		return 1;

	if (rtnl_wilddump_request(&rth, family, RTM_GETRULE) < 0) {
		error("Cannot dump the routing rule table");
		return -1;
	}

	arg[0] = a;
	arg[1] = b;
	if (rtnl_dump_filter
		(&rth, rule_flush_table_range_filter, arg, NULL, NULL) < 0) {
		error("Flush terminated");
		return -1;
	}

	rtnl_close(&rth);

	return 0;
}
开发者ID:Netsukuku,项目名称:netsukuku,代码行数:30,代码来源:krnl_rule.c

示例6: do_show

static int do_show(int argc, char **argv)
{
	struct {
		struct nlmsghdr		n;
		struct netconfmsg	ncm;
		char			buf[1024];
	} req;

	ipnetconf_reset_filter(0);
	filter.family = preferred_family;
	if (filter.family == AF_UNSPEC)
		filter.family = AF_INET;

	while (argc > 0) {
		if (strcmp(*argv, "dev") == 0) {
			NEXT_ARG();
			filter.ifindex = ll_name_to_index(*argv);
			if (filter.ifindex <= 0) {
				fprintf(stderr, "Device \"%s\" does not exist.\n",
					*argv);
				return -1;
			}
		}
		argv++; argc--;
	}

	ll_init_map(&rth);
	if (filter.ifindex) {
		memset(&req, 0, sizeof(req));
		req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct netconfmsg));
		req.n.nlmsg_flags = NLM_F_REQUEST|NLM_F_ACK;
		req.n.nlmsg_type = RTM_GETNETCONF;
		req.ncm.ncm_family = filter.family;
		if (filter.ifindex)
			addattr_l(&req.n, sizeof(req), NETCONFA_IFINDEX,
				  &filter.ifindex, sizeof(filter.ifindex));

		if (rtnl_send(&rth, &req.n, req.n.nlmsg_len) < 0) {
			perror("Can not send request");
			exit(1);
		}
		rtnl_listen(&rth, print_netconf, stdout);
	} else {
dump:
		if (rtnl_wilddump_request(&rth, filter.family, RTM_GETNETCONF) < 0) {
			perror("Cannot send dump request");
			exit(1);
		}
		if (rtnl_dump_filter(&rth, print_netconf2, stdout) < 0) {
			fprintf(stderr, "Dump terminated\n");
			exit(1);
		}
		if (preferred_family == AF_UNSPEC) {
			preferred_family = AF_INET6;
			filter.family = AF_INET6;
			goto dump;
		}
	}
	return 0;
}
开发者ID:Distrotech,项目名称:iproute2,代码行数:60,代码来源:ipnetconf.c

示例7: iprule_list_or_save

static int iprule_list_or_save(int argc, char **argv, int save)
{
	rtnl_filter_t filter = print_rule;
	int af = preferred_family;

	if (af == AF_UNSPEC)
		af = AF_INET;

	if (argc > 0) {
		fprintf(stderr, "\"ip rule %s\" does not take any arguments.\n",
				save ? "save" : "show");
		return -1;
	}

	if (save) {
		if (save_rule_prep())
			return -1;
		filter = save_rule;
	}

	if (rtnl_wilddump_request(&rth, af, RTM_GETRULE) < 0) {
		perror("Cannot send dump request");
		return 1;
	}

	if (rtnl_dump_filter(&rth, filter, stdout) < 0) {
		fprintf(stderr, "Dump terminated\n");
		return 1;
	}

	return 0;
}
开发者ID:hvoigt,项目名称:iproute2,代码行数:32,代码来源:iprule.c

示例8: fdb_show

static int fdb_show(int argc, char **argv)
{
	char *filter_dev = NULL;

	while (argc > 0) {
		if (strcmp(*argv, "dev") == 0) {
			NEXT_ARG();
			if (filter_dev)
				duparg("dev", *argv);
			filter_dev = *argv;
		}
		argc--; argv++;
	}

	if (filter_dev) {
		filter_index = if_nametoindex(filter_dev);
		if (filter_index == 0) {
			fprintf(stderr, "Cannot find device \"%s\"\n",
				filter_dev);
			return -1;
		}
	}

	if (rtnl_wilddump_request(&rth, PF_BRIDGE, RTM_GETNEIGH) < 0) {
		perror("Cannot send dump request");
		exit(1);
	}

	if (rtnl_dump_filter(&rth, print_fdb, stdout) < 0) {
		fprintf(stderr, "Dump terminated\n");
		exit(1);
	}

	return 0;
}
开发者ID:SamB,项目名称:iproute2,代码行数:35,代码来源:fdb.c

示例9: neigh_flush_table

void neigh_flush_table(char *iface)
{
	struct rtnl_handle rth;
	char flushb[4096-512];

   DEBUG_MSG("neigh_flush_table %s", iface);
   
	memset(&filter, 0, sizeof(filter));

   filter.state = ~0;
   filter.family = AF_INET;

   /* flush all but permanent and noarp */
    
	filter.state = ~(NUD_PERMANENT|NUD_NOARP);

   /* open the netlink socket */
   
	if (rtnl_open(&rth, 0) < 0)
		ERROR_MSG("rtnl_open()");

	ll_init_map(&rth);

   /* fill the device data */
   
   if ((filter.index = ll_name_to_index(iface)) == 0)
      ERROR_MSG("ll_name_to_index(%s)", iface);


	filter.flushb = flushb;
	filter.flushp = 0;
	filter.flushe = sizeof(flushb);
	filter.rth = &rth;
	filter.state &= ~NUD_FAILED;

	for (;;) {
		if (rtnl_wilddump_request(&rth, filter.family, RTM_GETNEIGH) < 0) 
         ERROR_MSG("rtnl_wilddump_request()");
      
		filter.flushed = 0;
		
      /* 
       * count how many neigh are to be flushed 
       * and prepare the data
       */
      
      if (rtnl_dump_filter(&rth, count_neigh, stdout, NULL, NULL) < 0) 
         ERROR_MSG("rtnl_dump_filter()");
      
		if (filter.flushed == 0)
         return;
		
		if (rtnl_send(filter.rth, filter.flushb, filter.flushp) < 0)
			ERROR_MSG("rtnl_send()");
      
      filter.flushp = 0;
 
      DEBUG_MSG("*** deleting %d entries ***", filter.flushed);
	}
}
开发者ID:daveti,项目名称:sarp,代码行数:60,代码来源:sad_neigh.c

示例10: iprule_list

int iprule_list(int argc, char **argv)
{
	struct rtnl_handle rth;
	int af = preferred_family;

	if (af == AF_UNSPEC)
		af = AF_INET;

	if (argc > 0) {
		fprintf(stderr, "\"ip rule show\" does not take any arguments.\n");
		return -1;
	}

	if (rtnl_open(&rth, 0) < 0)
		return 1;

	if (rtnl_wilddump_request(&rth, af, RTM_GETRULE) < 0) {
		perror("Cannot send dump request");
		return 1;
	}

	if (rtnl_dump_filter(&rth, print_rule, stdout, NULL, NULL) < 0) {
		fprintf(stderr, "Dump terminated\n");
		return 1;
	}

	return 0;
}
开发者ID:jameshilliard,项目名称:actiontec_opensrc_mi424wr-rev-e-f_fw-20-10-7-5,代码行数:28,代码来源:iprule.c

示例11: load_initial_table

static void load_initial_table(void)
{
	if (rtnl_wilddump_request(&rth, AF_INET, RTM_GETNEIGH) < 0) {
		perror("dump request failed");
		exit(1);
	}
		
}
开发者ID:gowthamramesh,项目名称:CSC573,代码行数:8,代码来源:arpd.c

示例12: lock

void TunManager::probe() {
  std::lock_guard<std::mutex> lock(mutex_);
  stop();                       // stop all interfaces
  intfs_.clear();               // clear all interface info
  auto ret = rtnl_wilddump_request(&rth_, AF_UNSPEC, RTM_GETLINK);
  sysCheckError(ret, "Cannot send RTM_GETLINK request");
  ret = rtnl_dump_filter(&rth_, getLinkRespParser, this);
  sysCheckError(ret, "Cannot process RTM_GETLINK response");
  ret = rtnl_wilddump_request(&rth_, AF_UNSPEC, RTM_GETADDR);
  sysCheckError(ret, "Cannot send RTM_GETADDR request");
  ret = rtnl_dump_filter(&rth_, getAddrRespParser, this);
  sysCheckError(ret, "Cannot process RTM_GETADDR response");
  // Bring up all interfaces. Interfaces could be already up.
  for (const auto& intf : intfs_) {
    bringupIntf(intf.second->getName(), intf.second->getIfIndex());
  }
  start();
}
开发者ID:superchild,项目名称:fboss,代码行数:18,代码来源:TunManager.cpp

示例13: ll_init_map

int ll_init_map(struct rtnl_handle *rth)
{
	if (rtnl_wilddump_request(rth, AF_UNSPEC, RTM_GETLINK) < 0) {
		bb_perror_msg_and_die("cannot send dump request");
	}

	if (rtnl_dump_filter(rth, ll_remember_index, &idxmap, NULL, NULL) < 0) {
		bb_error_msg_and_die("dump terminated");
	}
	return 0;
}
开发者ID:emuikernel,项目名称:WNR2000v4,代码行数:11,代码来源:ll_map.c

示例14: ll_init_map

int ll_init_map(struct rtnl_handle *rth)
{
	if (rtnl_wilddump_request(rth, AF_UNSPEC, RTM_GETLINK) < 0) {
//		perror("Cannot send dump request");
		exit(1);
	}

	if (rtnl_dump_filter(rth, ll_remember_index, &idxmap, NULL, NULL) < 0) {
//		fprintf(stderr, "Dump terminated\n");
		exit(1);
	}
	return 0;
}
开发者ID:ebichu,项目名称:dd-wrt,代码行数:13,代码来源:ll_map.c

示例15: dump

/* Based on iproute2/ip/iproute.c:iproute_list_flush_or_save. */
static int dump(int tbl_id)
{
	reset_filter();
	filter.tb = tbl_id;

	if (rtnl_wilddump_request(&rth, AF_XIA, RTM_GETROUTE) < 0) {
		perror("Cannot send dump request");
		exit(1);
	}
	if (rtnl_dump_filter(&rth, print_route, stdout, NULL, NULL) < 0) {
		fprintf(stderr, "Dump terminated\n");
		exit(1);
	}
	return 0;
}
开发者ID:AltraMayor,项目名称:xiaconf,代码行数:16,代码来源:xipad.c


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