45 #define DEFAULT_UNIT 0
46 #define DEFAULT_VLAN 1
47 #define MAX_DIGITS_IN_CHOICE 5
48 #define MAX_TRUNK_MEMBER 8
51 "Syntax: example_trunk \n\r"
53 "Paramaters: None. \n\r"
55 "Example: The following command is used to demonstrate trunk API \n\r"
56 "calls. The interactive user interface allows the user to get \n\r"
57 "the trunk information, add, delete ports and destroy a trunk. \n\r"
60 "Usage Guidelines: None. \n\r";
126 int main(
int argc,
char *argv[])
137 unsigned int warm_boot;
142 if(strcmp(argv[0],
"gdb") == 0)
147 if((argc != (index + 1)) || ((argc > (index + 1)) && (strcmp(argv[index + 1],
"--help") == 0))) {
153 printf(
"Initializing the system.\r\n");
157 printf(
"\r\nFailed to initialize the system. Error %s\r\n",
170 printf(
"\r\nFailed to apply default config on ports, rc = %d (%s).\r\n",
175 printf(
"Adding ports to default vlan.\r\n");
179 printf(
"\r\nFailed to add default ports. rv: %s\r\n",
opennsl_errmsg(rv));
183 printf(
"Setting Hash controls for Trunk.\r\n");
187 printf(
"\r\nFailed to hash control for Trunk. Error %s\r\n",
193 printf(
"\r\nUser menu: Select one of the following options\r\n");
194 printf(
"1. Create trunk\n");
195 printf(
"2. Add port to trunk\n");
196 printf(
"3. Delete port from trunk\n");
197 printf(
"4. Get trunk info\n");
198 printf(
"5. Delete trunk\n");
199 printf(
"6. Save the configuration to scache\n");
200 printf(
"7. Set port selection criteria (PSC)\n");
201 #ifdef INCLUDE_DIAG_SHELL
202 printf(
"9. Launch diagnostic shell\n");
204 printf(
"0. Quit the application\n");
208 printf(
"Invalid option entered. Please re-enter.\n");
218 printf(
"Trunk %d created successfully\n", tid);
220 printf(
"Failed to create trunk. Error %s\n",
231 printf(
"\r\nEnter the port number.\r\n");
234 printf(
"Invalid option entered. Please re-enter.\n");
244 member.
gport = gport;
246 printf(
"\r\nEnter the trunk id.\r\n");
249 printf(
"Invalid option entered. Please re-enter.\n");
253 printf(
"member_add: Adding port %d to trunk-id %d\n", port, tid);
256 printf(
"Port %d added successfully to trunk %d\n", port, tid);
258 printf(
"Failed to add port. Error %s\n",
269 printf(
"\r\nEnter the port number.\r\n");
272 printf(
"Invalid option entered. Please re-enter.\n");
282 member.
gport = gport;
284 printf(
"\r\nEnter the trunk id.\r\n");
287 printf(
"Invalid option entered. Please re-enter.\n");
291 printf(
"member_delete: Deleting port %d from trunk-id %d\n", port, tid);
294 printf(
"Port %d deleted successfully from trunk %d\n", port, tid);
296 printf(
"Failed to delete port. Error %s\n",
307 printf(
"\r\nEnter the trunk id.\r\n");
310 printf(
"Invalid option entered. Please re-enter.\n");
314 for (i = 0; i < member_max; i++)
321 member_arr, &member_count);
323 printf(
"Failed to get trunk info. Error %s\n",
327 printf(
"trunk %d has %d members, psc %d\n", tid ,member_count, t_data.
psc);
328 for( i = 0; i < member_count; i++)
331 printf(
"port %d\n",port);
340 printf(
"\r\nEnter the trunk id.\r\n");
343 printf(
"Invalid option entered. Please re-enter.\n");
349 printf(
"trunk %d successfully deleted\n", tid);
351 printf(
"Failed to delete trunk. Error %s\n",
364 printf(
"Failed to synchronize the configuration to scache. "
368 printf(
"Warmboot configuration is saved successfully.\n");
374 printf(
"\r\nEnter the trunk id.\r\n");
377 printf(
"Invalid option entered. Please re-enter.\n");
381 printf(
"\r\nEnter the PSC.\r\n");
384 printf(
"Invalid option entered. Please re-enter.\n");
396 #ifdef INCLUDE_DIAG_SHELL
399 opennsl_driver_shell();
406 printf(
"Exiting the application.\n");