5 int 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 int do_mirror_set (int argc, const char **argv, struct ngadmin *nga)
30 const struct swi_attr *sa;
32 int i, k = 0, ret = 0;
36 printf("usage: mirror set <destination port> clone <port1> [<port2> ...]\n");
40 sa = ngadmin_getCurrentSwitch(nga);
42 printf("must be logged\n");
47 ports = malloc((sa->ports + 1) * sizeof(char));
48 memset(ports, 0, sa->ports + 1);
50 ports[0] = strtol(argv[k++], NULL, 0);
51 if (ports[0] < 1 || ports[0] > sa->ports || strcasecmp(argv[k++], "clone") != 0) {
52 printf("syntax error\n");
58 i = strtol(argv[k++], NULL, 0);
59 if (i < 1 || i > sa->ports) {
60 printf("port out of range\n");
63 } else if (i == ports[0]) {
64 printf("destination port cannot be in port list\n");
71 i = ngadmin_setMirror(nga, ports);
81 int do_mirror_show (int argc, const char **argv UNUSED, struct ngadmin *nga)
83 const struct swi_attr *sa;
89 printf("this command takes no argument\n");
93 sa = ngadmin_getCurrentSwitch(nga);
95 printf("must be logged\n");
99 ports = malloc((sa->ports + 1) * sizeof(char));
100 i = ngadmin_getMirror(nga, ports);
107 printf("port mirroring is disabled\n");
111 printf("destination: %i\n", ports[0]);
113 for (i = 1; i <= sa->ports; i++) {