7 bool do_mirror_disable (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
12 if ( ngadmin_getCurrentSwitch(nga)==NULL ) {
13 printf("must be logged\n");
18 i=ngadmin_setMirror(nga, NULL);
28 bool do_mirror_set (int nb, const char **com, struct ngadmin *nga) {
30 const struct swi_attr *sa;
37 printf("Usage: mirror set <destination port> clone <port1> [<port2> ...]\n");
41 if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
42 printf("must be logged\n");
48 ports=malloc((sa->ports+1)*sizeof(char));
49 memset(ports, 0, sa->ports+1);
51 ports[0]=strtol(com[k++], NULL, 0);
52 if ( ports[0]<1 || ports[0]>sa->ports || strcasecmp(com[k++], "clone")!=0 ) {
53 printf("syntax error\n");
60 i=strtol(com[k++], NULL, 0);
61 if ( i<1 || i>sa->ports ) {
62 printf("port out of range\n");
65 } else if ( i==ports[0] ) {
66 printf("destination port cannot be in port list\n");
74 i=ngadmin_setMirror(nga, ports);
87 bool do_mirror_show (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
89 const struct swi_attr *sa;
94 if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
95 printf("must be logged\n");
100 ports=malloc((sa->ports+1)*sizeof(char));
102 i=ngadmin_getMirror(nga, ports);
109 printf("port mirroring is disabled\n");
113 printf("destination: %i\n", ports[0]);
115 for (i=1; i<=sa->ports; ++i) {