本文整理汇总了C++中rtnl_dump_filter函数的典型用法代码示例。如果您正苦于以下问题:C++ rtnl_dump_filter函数的具体用法?C++ rtnl_dump_filter怎么用?C++ rtnl_dump_filter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rtnl_dump_filter函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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
示例2: 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
示例3: pyrtnl_dump_filter
static PyObject* pyrtnl_dump_filter(PyObject* obj, PyObject* args)
{
PyRtnlObject* self = (PyRtnlObject*)obj;
PyObject *filter;
if (!PyArg_ParseTuple(args, "O:dump_filter", &filter))
return NULL;
if (!PyCallable_Check(filter)) {
PyErr_SetString(PyExc_TypeError, "parameter must be callable");
return NULL;
}
Py_INCREF(filter);
if (rtnl_dump_filter(&self->rth, dump_filter_helper, filter, NULL,
NULL) < 0)
{
Py_DECREF(filter);
return NULL;
}
Py_DECREF(filter);
Py_INCREF(Py_None);
return Py_None;
}
开发者ID:Angel666,项目名称:android_hardware_intel,代码行数:25,代码来源:netlink.c
示例4: 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
示例5: ipoe_nl_get_sessions
void ipoe_nl_get_sessions(struct list_head *list)
{
struct nlmsghdr *nlh;
struct genlmsghdr *ghdr;
struct {
struct nlmsghdr n;
char buf[1024];
} req;
if (rth.fd == -1)
return;
nlh = &req.n;
nlh->nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
nlh->nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
nlh->nlmsg_type = ipoe_genl_id;
nlh->nlmsg_seq = rth.dump = ++rth.seq;
ghdr = NLMSG_DATA(&req.n);
ghdr->cmd = IPOE_CMD_GET;
if (rtnl_send(&rth, (char *)nlh, nlh->nlmsg_len) < 0) {
log_emerg("ipoe: failed to send dump request: %s\n", strerror(errno));
return;
}
rtnl_dump_filter(&rth, dump_session, list, NULL, NULL);
}
开发者ID:jorgeluiztaioque,项目名称:accel-ppp-fork,代码行数:28,代码来源:ipoe_netlink.c
示例6: 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
示例7: 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
示例8: 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
示例9: 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
示例10: 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
示例11: tc_qdisc_list
int tc_qdisc_list(int argc, char **argv)
{
struct tcmsg t;
struct rtnl_handle rth;
char d[16];
memset(&t, 0, sizeof(t));
t.tcm_family = AF_UNSPEC;
memset(&d, 0, sizeof(d));
while (argc > 0) {
if (strcmp(*argv, "dev") == 0) {
NEXT_ARG();
strncpy(d, *argv, sizeof(d)-1);
#ifdef TC_H_INGRESS
} else if (strcmp(*argv, "ingress") == 0) {
if (t.tcm_parent) {
fprintf(stderr, "Duplicate parent ID\n");
usage();
}
t.tcm_parent = TC_H_INGRESS;
#endif
} else if (matches(*argv, "help") == 0) {
usage();
} else {
fprintf(stderr, "What is \"%s\"? Try \"tc qdisc help\".\n", *argv);
return -1;
}
argc--; argv++;
}
if (rtnl_open(&rth, 0) < 0) {
fprintf(stderr, "Cannot open rtnetlink\n");
exit(1);
}
ll_init_map(&rth);
if (d[0]) {
if ((t.tcm_ifindex = ll_name_to_index(d)) == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n", d);
exit(1);
}
filter_ifindex = t.tcm_ifindex;
}
if (rtnl_dump_request(&rth, RTM_GETQDISC, &t, sizeof(t)) < 0) {
perror("Cannot send dump request");
exit(1);
}
if (rtnl_dump_filter(&rth, print_qdisc, stdout, NULL, NULL) < 0) {
fprintf(stderr, "Dump terminated\n");
exit(1);
}
rtnl_close(&rth);
return 0;
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:60,代码来源:tc_qdisc.c
示例12: 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
示例13: 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
示例14: vlan_show
static int vlan_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;
} else if (strcmp(*argv, "vid") == 0) {
NEXT_ARG();
if (filter_vlan)
duparg("vid", *argv);
filter_vlan = atoi(*argv);
}
argc--; argv++;
}
if (filter_dev) {
if ((filter_index = if_nametoindex(filter_dev)) == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n",
filter_dev);
return -1;
}
}
if (rtnl_wilddump_req_filter(&rth, PF_BRIDGE, RTM_GETLINK,
(compress_vlans ?
RTEXT_FILTER_BRVLAN_COMPRESSED :
RTEXT_FILTER_BRVLAN)) < 0) {
perror("Cannont send dump request");
exit(1);
}
if (json_output) {
jw_global = jsonw_new(stdout);
if (!jw_global) {
fprintf(stderr, "Error allocation json object\n");
exit(1);
}
jsonw_start_object(jw_global);
} else {
printf("port\tvlan ids\n");
}
if (rtnl_dump_filter(&rth, print_vlan, stdout) < 0) {
fprintf(stderr, "Dump ternminated\n");
exit(1);
}
if (jw_global) {
jsonw_end_object(jw_global);
jsonw_destroy(&jw_global);
}
return 0;
}
开发者ID:idosch,项目名称:iproute2,代码行数:58,代码来源:vlan.c
示例15: xrtnl_dump_filter
int FAST_FUNC xrtnl_dump_filter(struct rtnl_handle *rth,
int (*filter)(const struct sockaddr_nl *, struct nlmsghdr *, void *),
void *arg1)
{
int ret = rtnl_dump_filter(rth, filter, arg1/*, NULL, NULL*/);
if (ret < 0)
bb_error_msg_and_die("dump terminated");
return ret;
}
开发者ID:kpykc,项目名称:ARDrone2.0,代码行数:9,代码来源:libnetlink.c
示例16: 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
示例17: iplink_ifla_xstats
int iplink_ifla_xstats(int argc, char **argv)
{
struct link_util *lu = NULL;
__u32 filt_mask;
if (!argc) {
fprintf(stderr, "xstats: missing argument\n");
return -1;
}
if (matches(*argv, "type") == 0) {
NEXT_ARG();
lu = get_link_kind(*argv);
if (!lu)
invarg("invalid type", *argv);
} else if (matches(*argv, "help") == 0) {
print_explain(stdout);
return 0;
} else {
invarg("unknown argument", *argv);
}
if (!lu) {
print_explain(stderr);
return -1;
}
if (!lu->print_ifla_xstats) {
fprintf(stderr, "xstats: link type %s doesn't support xstats\n",
lu->id);
return -1;
}
if (lu->parse_ifla_xstats &&
lu->parse_ifla_xstats(lu, argc-1, argv+1))
return -1;
if (strstr(lu->id, "_slave"))
filt_mask = IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS_SLAVE);
else
filt_mask = IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS);
if (rtnl_wilddump_stats_req_filter(&rth, AF_UNSPEC,
RTM_GETSTATS,
filt_mask) < 0) {
perror("Cannont send dump request");
return -1;
}
if (rtnl_dump_filter(&rth, lu->print_ifla_xstats, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
return -1;
}
return 0;
}
开发者ID:6WIND,项目名称:iproute2,代码行数:56,代码来源:iplink_xstats.c
示例18: 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
示例19: 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
示例20: 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_dump_filter函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论