38 "Syntax: example_link_monitor uplink_port downlink_ports \n\r"
41 " uplink_port - Uplink port number to be monitored. \n\r"
42 " downlink_ports - List of ports that follow the link state \n\r"
43 " of uplink port. \n\r"
44 " Maximum of 10 ports supported. \n\r"
46 "Example: The following command is used to configure ports 2 and 3 \n\r"
47 " to follow the link state of port 1. \n\r"
48 " example_link_monitor 1 2 3 \n\r"
50 "Usage Guidelines: This program assumes that software linkscan \n\r"
51 " is enabled on the system. \n\r";
53 #define DEFAULT_VLAN 1
54 #define LINKMON_MAX_DOWN_PORTS 10
55 #define DEFAULT_UNIT 0
59 #define LINK_MON_OFF 2
60 #define MAX_DIGITS_IN_CHOICE 5
73 static int example_link_monitor(
int unit,
int mode);
82 int main(
int argc,
char *argv[])
92 ((argc > 1) && (strcmp(argv[1],
"--help") == 0))) {
98 printf(
"Invalid number of arguments passed. Please see example help.\n\r");
103 uport = atoi(argv[1]);
104 for(i = 2,
dport_cnt = 0; i < argc; i++) {
109 printf(
"Uplink Port : %d\n\r",
uport);
110 printf(
"Downlink Ports : ");
112 printf(
"%2d ",
dport[i]);
120 printf(
"\r\nFailed to initialize the system. Error %s \n\r",
128 printf(
"\r\nFailed to apply default config on ports, rc = %d (%s).\r\n",
135 printf(
"\r\nFailed to set link monitor mode. Error: %s.\n\r",
139 printf(
"\r\nLink monitoring is enabled successfully.\n\r");
142 printf(
"\r\nUser menu: Select one of the following options\r\n");
143 printf(
"1. Enable the link monitoring mode.\r\n");
144 printf(
"2. Disable the link monitoring mode.\r\n");
145 #ifdef INCLUDE_DIAG_SHELL
146 printf(
"9. Launch diagnostic shell\n");
148 printf(
"0. Quit the application.\r\n");
152 printf(
"Invalid option entered. Please re-enter.\n");
161 printf(
"\r\nFailed to enable link monitor mode. Error: %s.\n\r",
170 printf(
"\r\nFailed to disable link monitor mode. Error: %s.\n\r",
176 #ifdef INCLUDE_DIAG_SHELL
179 opennsl_driver_shell();
186 printf(
"Exiting the application.\n");
209 int example_link_monitor(
int unit,
int mode) {
220 example_link_change_callback));
226 example_link_change_callback));
230 printf(
"Link Monitor mode is %s.\n", (mode ==
LINK_MON_ON) ?
"enabled" :
"disabled");
252 printf(
"Link on port %2d changed to %4s\n", port,
265 printf(
"Uplink port %2d link state transitioned to %4s.\n\r", port,
274 printf(
"Failed to %s port %2d.\n", (mode ==
TRUE)?
"enable" :
"disable",
278 printf(
"%s port %2d.\n", (mode ==
TRUE) ?
"Enabled" :
"Disabled",
dport[i]);