]>
git.proxmox.com Git - mirror_iproute2.git/blob - rdma/rdma.c
0e8fd688674ce8e3622af6546d8b1286ec878346
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
);
51 if (rd
->json_output
) {
52 rd
->jw
= jsonw_new(stdout
);
54 pr_err("Failed to create JSON writer\n");
57 jsonw_pretty(rd
->jw
, rd
->pretty_output
);
60 rd
->buff
= malloc(MNL_SOCKET_BUFFER_SIZE
);
64 rd_prepare_msg(rd
, RDMA_NLDEV_CMD_GET
,
65 &seq
, (NLM_F_REQUEST
| NLM_F_ACK
| NLM_F_DUMP
));
66 ret
= rd_send_msg(rd
);
70 return rd_recv_msg(rd
, rd_dev_init_cb
, rd
, seq
);
73 static void rd_cleanup(struct rd
*rd
)
76 jsonw_destroy(&rd
->jw
);
80 int main(int argc
, char **argv
)
82 static const struct option long_options
[] = {
83 { "version", no_argument
, NULL
, 'V' },
84 { "help", no_argument
, NULL
, 'h' },
85 { "json", no_argument
, NULL
, 'j' },
86 { "pretty", no_argument
, NULL
, 'p' },
87 { "details", no_argument
, NULL
, 'd' },
90 bool pretty_output
= false;
91 bool show_details
= false;
92 bool json_output
= false;
98 filename
= basename(argv
[0]);
100 while ((opt
= getopt_long(argc
, argv
, "Vhdpj",
101 long_options
, NULL
)) >= 0) {
104 printf("%s utility, iproute2-ss%s\n",
108 pretty_output
= true;
120 pr_err("Unknown option.\n");
129 rd
.show_details
= show_details
;
130 rd
.json_output
= json_output
;
131 rd
.pretty_output
= pretty_output
;
133 err
= rd_init(&rd
, argc
, argv
, filename
);
141 return err
? EXIT_FAILURE
: EXIT_SUCCESS
;