X-Git-Url: https://git.sur5r.net/?p=gsconf;a=blobdiff_plain;f=shell_port.c;fp=shell_port.c;h=d9400290b6afde6a028f8610eba95dc25b45054b;hp=4e69179b58095fbc1e48779acfdb7a8c69d3b55e;hb=11ae7c1958d87f75fb840c6556fa99abf85e6607;hpb=bdf95351d3563e4039ee2cc229452d78b3b6a612 diff --git a/shell_port.c b/shell_port.c index 4e69179..d940029 100644 --- a/shell_port.c +++ b/shell_port.c @@ -2,7 +2,7 @@ void shell_port(char ** argv, int elem) { - int n, i; + int n, i, m, o; if (elem == 1) { @@ -48,5 +48,47 @@ void shell_port(char ** argv, int elem) { else printf("\033[92mCable is fine!\033[0m\n", settings.portStatistics[n].errorDist); } + } else if (strncmp(argv[1], "mirror", 6) == 0) { + + if (elem == 3) { + if (strncmp(argv[2], "off", 3) == 0) { + password(); + printError(gs105e_mirrorPorts(0, 0)); + return; + + } + } + + if (elem < 4) { + printf("port mirror output input [input.....]\n"); + return; + } + + n = atoi(argv[2]); + + if (n < 1 | n > 5) { + printf("Invalid Port %i\n", n); + return; + } + + o = 0; + + for (m = 3; m < elem; m++) { + i = atoi(argv[m]); + if (i < 1 | i > 5) { + printf("Invalid Port %i\n", i); + return; + } + + if (i == n) { + printf("Output can't be input port!\n"); + return; + } + + o |= (0x80 >> (i - 1)); + } + password(); + printError(gs105e_mirrorPorts(n, o)); + } }