45 "Syntax: example_routing \n\r"
48 " in_sysport - Ingress port number on which test packet is \n\r"
50 " out_sysport - Egress port number to which packet is routed. \n\r"
52 "Example: The following command is used to demonstrate routing from \n\r"
53 " port 2 to port 6. \n\r"
54 " example_routing 2 6 \n\r"
56 "Usage Guidelines: This program request the user to enter the \n\r"
57 " ingress and egress port numbers. Using the host route, it routes\n\r"
58 " the packets arrived on ingress port with VLAN = 10, \n\r"
59 " destination MAC = 00:11:22:33:99:58 to host 20.1.1.2 attached \n\r"
60 " to egress port that is a member of VLAN 20. Using the default \n\r"
61 " route, it also routes packets with VLAN = 10, destination \n\r"
62 " MAC = 00:11:22:33:99:58 destinated to subnet 55.0.0.0 to egress \n\r"
63 " port that is a member of VLAN 20. \n\r"
64 " The routed packet should have destination MAC same as \n\r"
65 " 00:00:70:5B:C7:34 with TTL decremented by 1. \n\r";
68 #define DEFAULT_UNIT 0
69 #define INGRESS_VLAN 10
70 #define EGRESS_VLAN 20
71 #define HOST1 0x14010102
72 #define MY_MAC {0x00, 0x11, 0x22, 0x33, 0x99, 0x58}
74 #define NEXTHOP_MAC {0x00, 0x00, 0x70, 0x5B, 0xC7, 0x34}
76 #define DEFAULT_SUBNET_IP 0x37000000
77 #define DEFAULT_SUBNET_MASK 0xff000000
90 printf(
"%s vrf : %d ", type, vrf);
107 printf(
"%s vrf : %d ", type, vrf);
140 printf (
"opennsl_l3_host_add failed: %x \n", rc);
175 printf (
"opennsl_l3_route_add failed: %x \n", rc);
179 printf(
"---> egress-object=0x%08x, \n", intf);
218 memcpy(station.
dst_mac, mac_addr, 6);
234 printf(
"vlan (%d) already exists", vlan);
237 printf(
"fail open vlan (%d)", vlan);
238 printf(
" continue..\n");
243 printf(
"fail add port(0x%08x) to vlan(%d)\n", port, vlan);
293 int l3_eg_intf,
opennsl_mac_t nhop_mac_addr,
int *intf,
int *encap_id)
302 l3eg.
intf = l3_eg_intf;
303 memcpy(l3eg.
mac_addr, nhop_mac_addr, 6);
306 l3eg.
port = out_port;
313 printf(
"Error, create egress object, out_port = %d, \n", out_port);
350 printf(
"Error, create ingress interface, in_port = %d, \n", in_port);
352 printf(
"---> Ingress router intf = 0x%08x created on port %d\n", ing_intf_in, in_port);
357 printf(
"Error, create ingress enterface, out_port = %d, \n", out_port);
359 printf(
"---> Ingress router intf = 0x%08x created on port %d\n", ing_intf_out, out_port);
366 next_hop_mac, &fec[0], &encap_id[0]);
368 printf(
"Error, create egress object, out_port = %d, \n", out_port);
370 printf(
"---> Egress interface = 0x%08x, \n", ing_intf_out);
371 printf(
" created FEC-id = 0x%08x, \n", fec[0]);
372 printf(
" next hop mac at encap-id %08x, \n", encap_id[0]);
377 printf(
"Error, example_host_add\n");
381 printf(
"---> egress-intf = 0x%08x, port = %d, \n", ing_intf_out, out_port);
389 printf(
"Error, failed to add route\n");
404 int main(
int argc,
char *argv[])
413 if(strcmp(argv[0],
"gdb") == 0)
417 if((argc != (index + 3)) || ((argc > (index + 1))
418 && (strcmp(argv[index + 1],
"--help") == 0))) {
427 printf(
"\r\nFailed to initialize the system.\r\n");
432 in_sysport = atoi(argv[index + 1]);
433 out_sysport = atoi(argv[index + 2]);
437 printf(
"\r\nFailed to apply default config on ports, rc = %d (%s).\r\n",
443 printf(
"\r\nFailed to configure routing, rc = %d (%s).\r\n",
448 printf(
"\r\nUser menu: Select one of the following options\r\n");
449 #ifdef INCLUDE_DIAG_SHELL
450 printf(
"9. Launch diagnostic shell\n");
452 printf(
"0. Quit the application.\r\n");
456 printf(
"Invalid option entered. Please re-enter.\n");
461 #ifdef INCLUDE_DIAG_SHELL
464 opennsl_driver_shell();
471 printf(
"Exiting the application.\n");