5 bool do_mirror_disable (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga)
10 if (ngadmin_getCurrentSwitch(nga) == NULL) {
11 printf("must be logged\n");
16 i = ngadmin_setMirror(nga, NULL);
24 bool do_mirror_set (int nb, const char **com, struct ngadmin *nga)
26 const struct swi_attr *sa;
33 printf("Usage: mirror set <destination port> clone <port1> [<port2> ...]\n");
37 sa = ngadmin_getCurrentSwitch(nga);
39 printf("must be logged\n");
44 ports = malloc((sa->ports + 1) * sizeof(char));
45 memset(ports, 0, sa->ports + 1);
47 ports[0] = strtol(com[k++], NULL, 0);
48 if (ports[0] < 1 || ports[0] > sa->ports || strcasecmp(com[k++], "clone") != 0) {
49 printf("syntax error\n");
55 i = strtol(com[k++], NULL, 0);
56 if (i < 1 || i > sa->ports) {
57 printf("port out of range\n");
60 } else if (i == ports[0]) {
61 printf("destination port cannot be in port list\n");
68 i = ngadmin_setMirror(nga, ports);
78 bool do_mirror_show (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga)
80 const struct swi_attr *sa;
85 sa = ngadmin_getCurrentSwitch(nga);
87 printf("must be logged\n");
92 ports = malloc((sa->ports + 1) * sizeof(char));
93 i = ngadmin_getMirror(nga, ports);
100 printf("port mirroring is disabled\n");
104 printf("destination: %i\n", ports[0]);
106 for (i = 1; i <= sa->ports; i++) {