12 #include <netlink-private/netlink.h>
13 #include <netlink/cli/utils.h>
15 static void print_usage(
void)
17 fprintf(stderr,
"Usage: nl-list-caches\n");
21 static char *id_attr_list(
struct nl_object_ops *ops,
char *buf,
size_t len)
23 if (ops->oo_attrs2str != NULL)
24 return ops->oo_attrs2str(ops->oo_id_attrs, buf, len);
31 static void print(
struct nl_cache_ops *ops,
void *arg)
36 " hdrsize: %d bytes\n" \
38 " request-update: %s\n" \
40 ops->co_name, ops->co_hdrsize,
41 nl_nlfamily2str(ops->co_protocol, buf,
sizeof(buf)),
42 ops->co_request_update ?
"yes" :
"no",
43 ops->co_msg_parser ?
"yes" :
"no");
45 if (ops->co_obj_ops) {
46 struct nl_object_ops *obj_ops = ops->co_obj_ops;
47 const char *dump_names[NL_DUMP_MAX+1] = {
54 printf(
" cacheable object:\n" \
56 " size: %zu bytes\n" \
57 " constructor: %s\n" \
61 " id attributes: %s\n" \
63 obj_ops->oo_name, obj_ops->oo_size,
64 obj_ops->oo_constructor ?
"yes" :
"no",
65 obj_ops->oo_free_data ?
"yes" :
"no",
66 obj_ops->oo_clone ?
"yes" :
"no",
67 obj_ops->oo_compare ?
"yes" :
"no",
68 id_attr_list(obj_ops, buf,
sizeof(buf)));
70 for (i = 0; i <= NL_DUMP_MAX; i++)
71 if (obj_ops->oo_dump[i])
93 for (i = 0; i < genl_ops->
o_ncmds; i++) {
100 " attr-policy: %s\n",
109 int main(
int argc,
char *argv[])
111 if (argc > 1 && !strcasecmp(argv[1],
"-h"))