3 void shell_port(char ** argv, int elem) {
8 printf(" port [show|diag|mirror] \n");
11 if (strncmp(argv[1], "show", 4) == 0) {
12 printf("Port\tSpeed\t\tBytes In\t\tBytes Out\n");
13 for (n = 0; n< 5; n++) {
14 printf("%i\t%s\t%8lu\t\t%8lu\n", n,
15 (settings.portStatistics[n].state == 0x05 ? "1000 Mbit/s" : (settings.portStatistics[n].state == 0x04 ? "100 Mbit/s" : (settings.portStatistics[n].state == 0x03 ? "10 Mbit/s": (settings.portStatistics[n].state == 0x00 ? "No Cable": "???")))),
16 settings.portStatistics[n].bytesIn,
17 settings.portStatistics[n].bytesOut
20 } else if (strncmp(argv[1], "diag", 4) == 0) {
22 printf("Port needed\n");
28 if ((n < 1) | (n > 5)) {
29 printf("Invalid Port\n");
34 i = gs105e_cableDiagnostics((char) n);
39 if (settings.portStatistics[n].cableError) {
40 printf("\033[91mError detected: %s in %i m\033[0m\n",
41 (settings.portStatistics[n].cableError == 0x03 ? "short circuit" : (settings.portStatistics[n].cableError == 0x02 ? "Only one pair Connected!": "damaged")),
42 settings.portStatistics[n].errorDist
46 if (settings.portStatistics[n].errorDist == 0 )
47 printf("\033[92mSeems no Cable is connected!?\033[0m\n");
49 printf("\033[92mCable is fine!\033[0m\n", settings.portStatistics[n].errorDist);
51 } else if (strncmp(argv[1], "mirror", 6) == 0) {
54 if (strncmp(argv[2], "off", 3) == 0) {
56 printError(gs105e_mirrorPorts(0, 0));
63 printf("port mirror output input [input.....]\n");
69 if ((n < 1) | (n > 5)) {
70 printf("Invalid Port %i\n", n);
76 for (m = 3; m < elem; m++) {
78 if ((i < 1) | (i > 5)) {
79 printf("Invalid Port %i\n", i);
84 printf("Output can't be input port!\n");
88 o |= (0x80 >> (i - 1));
91 printError(gs105e_mirrorPorts(n, o));