42 "Syntax: example_mpls \n\r"
44 "Paramaters: None. \n\r"
46 "Example: The following command is used to demonstrate MPLS by taking \n\r"
47 " ingress and egress port numbers as input. \n\r"
48 " example_mpls 5 6 \n\r"
50 "Usage Guidelines: This program request the user to enter the \n\r"
51 " ingress and egress port numbers. \n\r"
53 " in_sysport - Ingress port number on which test packet is \n\r"
55 " out_sysport - Egress port number to which packet is forwarded. \n\r"
57 " It looks for MPLS packets arrived on in_sysport with \n\r"
58 " VLAN = 10, destination MAC = 00:00:00:00:11:11 and take the \n\r"
59 " following actions before forwarding the packet to out_sysport. \n\r"
61 " 1a) Swap incoming label 200 with 300 \n\r"
62 " 1b) Update TTL in this label to 33 \n\r"
63 " 2a) Push/Add label 400 with TTL 64 \n\r"
71 #define DEFAULT_UNIT 0
72 #define MY_MAC {0x00, 0x00, 0x00, 0x00, 0x11, 0x11}
74 #define MAC_SA {0x00, 0x11, 0x11, 0x11, 0x11, 0x0e}
76 #define MAC_DA {0x00, 0x11, 0x11, 0x11, 0x11, 0x0f}
80 #define VPN_ID_OFFSET (1 << 12)
81 #define VPN_ID (VRF_ID + VPN_ID_OFFSET)
86 #define L3_OUT_INTF_ID 31
88 #define INGRESS_LABEL1_ID 200
89 #define EGRESS_LABEL1_ID 300
91 #define EGRESS_LABEL2_ID 400
93 #define MAX_DIGITS_IN_CHOICE 5
95 #define CALL_IF_ERROR_RETURN(op) \
98 if ((__rv__ = (op)) < 0) { \
99 printf("%s:%s: line %d rv: %d failed: %s\n", \
100 __FILE__, __FUNCTION__, __LINE__, __rv__, \
101 opennsl_errmsg(__rv__)); \
108 static int mpls_lsr_term(
int unit,
int in_sysport,
int out_sysport);
117 int main(
int argc,
char *argv[])
126 if((argc != 3) || ((argc > 1) && (strcmp(argv[1],
"--help") == 0))) {
135 printf(
"\r\nFailed to initialize the system.\r\n");
142 printf(
"\r\nFailed to apply default config on ports, rc = %d (%s).\r\n",
147 printf(
"Adding ports to default vlan.\r\n");
150 printf(
"\r\nFailed to add default ports. Error: %s\r\n",
155 in_sysport = atoi(argv[1]);
156 out_sysport = atoi(argv[2]);
159 mpls_lsr_term(unit, in_sysport, out_sysport);
162 printf(
"\r\nUser menu: Select one of the following options\r\n");
164 printf(
"9. Launch diagnostic shell\n");
166 printf(
"0. Quit the application.\r\n");
170 printf(
"Invalid option entered. Please re-enter.\n");
178 opennsl_driver_shell();
185 printf(
"Exiting the application.\n");
206 static int mpls_lsr_term(
int unit,
int in_port,
int out_port)
237 vpn_type_id = vpn_info.
vpn;
240 printf(
"VPN is created with ID: %d\n", vpn_type_id);
251 printf(
"Port %d is added to Ingress VLAN %d\n", in_port,
IN_VLAN);
262 printf(
"Port %d is added to Egress VLAN %d\n", out_port,
OUT_VLAN);
275 printf(
"\r\nOutgoing L3 interface %d is created with the following "
277 printf(
" Egress VLAN %d\n",
OUT_VLAN);
288 l3_egress.
port = gport;
293 printf(
"Outgoing Egress object %d is created with the "
294 "following parameters\n", egr_obj_1);
295 printf(
" Port %d Egress VLAN %d L3 interface %d\n",
OUT_VLAN,
306 tunnel_switch.
vpn = vpn_type_id;
318 printf(
"Added entry for incoming label matching and Swap with the "
319 "following parameters\n");
322 printf(
" Action SWAP\n");
333 printf(
"Installed L2 tunnel for Ingress VLAN %d ",
IN_VLAN);
346 printf(
"Updated tunnel to add MPLS label %d with TTL %d to the packet\n",