2 * nl-list-caches.c List registered cache types
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation version 2.1
9 * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
14 static void print_usage(void)
16 fprintf(stderr, "Usage: nl-list-caches\n");
20 static char *id_attr_list(struct nl_object_ops *ops, char *buf, size_t len)
22 if (ops->oo_attrs2str != NULL)
23 return ops->oo_attrs2str(ops->oo_id_attrs, buf, len);
30 static void print(struct nl_cache_ops *ops, void *arg)
35 " hdrsize: %d bytes\n" \
37 " request-update: %s\n" \
39 ops->co_name, ops->co_hdrsize,
40 nl_nlfamily2str(ops->co_protocol, buf, sizeof(buf)),
41 ops->co_request_update ? "yes" : "no",
42 ops->co_msg_parser ? "yes" : "no");
44 if (ops->co_obj_ops) {
45 struct nl_object_ops *obj_ops = ops->co_obj_ops;
46 const char *dump_names[NL_DUMP_MAX+1] = {
56 printf(" cacheable object:\n" \
58 " size: %zu bytes\n" \
59 " constructor: %s\n" \
63 " id attributes: %s\n" \
65 obj_ops->oo_name, obj_ops->oo_size,
66 obj_ops->oo_constructor ? "yes" : "no",
67 obj_ops->oo_free_data ? "yes" : "no",
68 obj_ops->oo_clone ? "yes" : "no",
69 obj_ops->oo_compare ? "yes" : "no",
70 id_attr_list(obj_ops, buf, sizeof(buf)));
72 for (i = 0; i <= NL_DUMP_MAX; i++)
73 if (obj_ops->oo_dump[i])
82 struct genl_ops *genl_ops = ops->co_genl;
88 genl_ops->o_name, genl_ops->o_family, genl_ops->o_id);
90 if (genl_ops->o_ncmds) {
95 for (i = 0; i < genl_ops->o_ncmds; i++) {
96 struct genl_cmd *cmd = &genl_ops->o_cmds[i];
101 " msg-parser: %s\n" \
102 " attr-policy: %s\n",
103 cmd->c_name, cmd->c_id, cmd->c_maxattr,
104 cmd->c_msg_parser ? "yes" : "no",
105 cmd->c_attr_policy ? "yes" : "no");
111 int main(int argc, char *argv[])
113 if (argc > 1 && !strcasecmp(argv[1], "-h"))
116 nl_cache_ops_foreach(print, NULL);