5 bool do_mirror_disable (int argc, const char **argv UNUSED, struct ngadmin *nga)
11 printf("this command takes no argument\n");
15 if (ngadmin_getCurrentSwitch(nga) == NULL) {
16 printf("must be logged\n");
20 i = ngadmin_setMirror(nga, NULL);
28 bool do_mirror_set (int argc, const char **argv, struct ngadmin *nga)
30 const struct swi_attr *sa;
37 printf("usage: mirror set <destination port> clone <port1> [<port2> ...]\n");
41 sa = ngadmin_getCurrentSwitch(nga);
43 printf("must be logged\n");
48 ports = malloc((sa->ports + 1) * sizeof(char));
49 memset(ports, 0, sa->ports + 1);
51 ports[0] = strtol(argv[k++], NULL, 0);
52 if (ports[0] < 1 || ports[0] > sa->ports || strcasecmp(argv[k++], "clone") != 0) {
53 printf("syntax error\n");
59 i = strtol(argv[k++], NULL, 0);
60 if (i < 1 || i > sa->ports) {
61 printf("port out of range\n");
64 } else if (i == ports[0]) {
65 printf("destination port cannot be in port list\n");
72 i = ngadmin_setMirror(nga, ports);
82 bool do_mirror_show (int argc, const char **argv UNUSED, struct ngadmin *nga)
84 const struct swi_attr *sa;
90 printf("this command takes no argument\n");
94 sa = ngadmin_getCurrentSwitch(nga);
96 printf("must be logged\n");
100 ports = malloc((sa->ports + 1) * sizeof(char));
101 i = ngadmin_getMirror(nga, ports);
108 printf("port mirroring is disabled\n");
112 printf("destination: %i\n", ports[0]);
114 for (i = 1; i <= sa->ports; i++) {