53 "Syntax: example_routing \n\r"
56 " in_sysport - Ingress port number on which test packet is \n\r"
58 " out_sysport - Egress port number to which packet is routed. \n\r"
60 "Example: The following command is used to demonstrate routing from \n\r"
61 " port 2 to port 6. \n\r"
62 " example_routing 2 6 \n\r"
64 "Usage Guidelines: This program request the user to enter the \n\r"
65 " ingress and egress port numbers. Using the host route, it routes\n\r"
66 " the packets arrived on ingress port with VLAN = 10, \n\r"
67 " destination MAC = 00:11:22:33:99:58 to host 20.1.1.2 attached \n\r"
68 " to egress port that is a member of VLAN 20. Using the default \n\r"
69 " route, it also routes packets with VLAN = 10, destination \n\r"
70 " MAC = 00:11:22:33:99:58 destinated to subnet 55.0.0.0 to egress \n\r"
71 " port that is a member of VLAN 20. \n\r"
72 " The routed packet should have destination MAC same as \n\r"
73 " 00:00:70:5B:C7:34 with TTL decremented by 1. \n\r";
76 #define INGRESS_VLAN 10
77 #define EGRESS_VLAN 20
78 #define HOST1 0x14010102
79 #define DEFAULT_SUBNET_IP 0x37000000
80 #define DEFAULT_SUBNET_MASK 0xff000000
81 #define MY_MAC {0x00, 0x11, 0x22, 0x33, 0x99, 0x58}
83 #define NEXTHOP_MAC {0x00, 0x00, 0x70, 0x5B, 0xC7, 0x34}
85 #define MAX_DIGITS_IN_CHOICE 5
140 printf(
"failed to create vlan(%d). Return code %s",
145 printf(
"Created VLAN: %d\n", vlan);
188 printf(
"Fail to add port %d to vlan %d. Return Code: %s\n", port, vid,
opennsl_errmsg(rc));
192 printf(
"Port %d is participating in VLAN: %d\n", port, vid);
201 printf(
"l3_setup: opennsl_l3_intf_create failed: %s\n",
opennsl_errmsg(rc));
208 printf(
"L3 interface is created with parameters: \n VLAN %d \n", vid);
211 printf(
" L3 Interface ID: %d\r\n", l3_intf.
l3a_intf_id);
246 l3eg.
intf = l3_eg_intf;
247 memcpy(l3eg.
mac_addr, next_hop_mac_addr, 6);
251 l3eg.
port = out_port;
263 printf(
"Created L3 egress ID %d for out_port: %d vlan: %d "
264 "L3 egress intf: %d\n",
265 *intf, out_port, vlan, l3_eg_intf);
293 printf (
"opennsl_l3_host_add failed. Return Code: %s \n",
300 printf(
" ---> egress-object = %d\n", intf);
338 printf (
"opennsl_l3_route_add failed. Return Code: %s \n",
346 printf(
" ---> egress-object = %d\n", intf);
359 int main(
int argc,
char *argv[])
365 int ing_intf_out = 0;
373 int host, subnet, mask;
376 unsigned int warm_boot;
379 if(strcmp(argv[0],
"gdb") == 0)
383 if((argc != (index + 3)) || ((argc > (index + 1))
384 && (strcmp(argv[index + 1],
"--help") == 0))) {
393 printf(
"\r\nFailed to initialize the system.\r\n");
398 in_sysport = atoi(argv[index + 1]);
399 out_sysport = atoi(argv[index + 2]);
408 printf(
"\r\nFailed to apply default config on ports, rc = %d (%s).\r\n",
418 printf(
"\nL3 Egress mode is set succesfully\n");
423 my_mac, &ing_intf_in);
425 printf(
"Error, create ingress interface-1, in_sysport=%d. "
432 my_mac, &ing_intf_out);
434 printf(
"Error, create egress interface-1, out_sysport=%d. "
442 printf(
"Failed to add L2 address. Return Code: %s\n",
opennsl_errmsg(rv));
448 printf(
"Failed to add L2 address. Return Code: %s\n",
opennsl_errmsg(rv));
455 next_hop_mac, &l3egid);
457 printf(
"Error, create egress object, out_sysport=%d. Return code %s \n",
466 printf(
"Error, host add. Return code %s\n",
478 printf(
"Error, default route add. Return code %s \n",
488 printf(
"Error, default route add. Return code %s\n",
495 printf(
"\r\nUser menu: Select one of the following options\r\n");
496 printf(
"1. Save the configuration to scache\n");
497 #ifdef INCLUDE_DIAG_SHELL
498 printf(
"9. Launch diagnostic shell\n");
500 printf(
"0. Quit the application.\r\n");
504 printf(
"Invalid option entered. Please re-enter.\n");
514 printf(
"Failed to synchronize the configuration to scache. "
518 printf(
"Warmboot configuration is saved successfully.\n");
522 #ifdef INCLUDE_DIAG_SHELL
525 opennsl_driver_shell();
532 printf(
"Exiting the application.\n");