]>
git.proxmox.com Git - mirror_iproute2.git/blob - rdma/rdma.c
a21ba440707b46f29a3d4a7f7d46bcb4cb6610af
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Leon Romanovsky <leonro@mellanox.com>
15 static void help(char *name
)
17 pr_out("Usage: %s [ OPTIONS ] OBJECT { COMMAND | help }\n"
18 "where OBJECT := { dev | link | help }\n"
19 " OPTIONS := { -V[ersion] | -d[etails] | -j[son] | -p[retty]}\n", name
);
22 static int cmd_help(struct rd
*rd
)
28 static int rd_cmd(struct rd
*rd
)
30 const struct rd_cmd cmds
[] = {
38 return rd_exec_cmd(rd
, cmds
, "object");
41 static int rd_init(struct rd
*rd
, int argc
, char **argv
, char *filename
)
46 rd
->filename
= filename
;
49 INIT_LIST_HEAD(&rd
->dev_map_list
);
50 INIT_LIST_HEAD(&rd
->filter_list
);
52 if (rd
->json_output
) {
53 rd
->jw
= jsonw_new(stdout
);
55 pr_err("Failed to create JSON writer\n");
58 jsonw_pretty(rd
->jw
, rd
->pretty_output
);
61 rd
->buff
= malloc(MNL_SOCKET_BUFFER_SIZE
);
65 rd_prepare_msg(rd
, RDMA_NLDEV_CMD_GET
,
66 &seq
, (NLM_F_REQUEST
| NLM_F_ACK
| NLM_F_DUMP
));
67 ret
= rd_send_msg(rd
);
71 return rd_recv_msg(rd
, rd_dev_init_cb
, rd
, seq
);
74 static void rd_cleanup(struct rd
*rd
)
77 jsonw_destroy(&rd
->jw
);
81 int main(int argc
, char **argv
)
83 static const struct option long_options
[] = {
84 { "version", no_argument
, NULL
, 'V' },
85 { "help", no_argument
, NULL
, 'h' },
86 { "json", no_argument
, NULL
, 'j' },
87 { "pretty", no_argument
, NULL
, 'p' },
88 { "details", no_argument
, NULL
, 'd' },
91 bool pretty_output
= false;
92 bool show_details
= false;
93 bool json_output
= false;
99 filename
= basename(argv
[0]);
101 while ((opt
= getopt_long(argc
, argv
, "Vhdpj",
102 long_options
, NULL
)) >= 0) {
105 printf("%s utility, iproute2-ss%s\n",
109 pretty_output
= true;
121 pr_err("Unknown option.\n");
130 rd
.show_details
= show_details
;
131 rd
.json_output
= json_output
;
132 rd
.pretty_output
= pretty_output
;
134 err
= rd_init(&rd
, argc
, argv
, filename
);
142 return err
? EXIT_FAILURE
: EXIT_SUCCESS
;