OpenNSL API Guide and Reference Manual
Macros | Functions | Variables
example_mpls.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sal/driver.h>
#include <opennsl/types.h>
#include <opennsl/error.h>
#include <opennsl/vlan.h>
#include <opennsl/l2.h>
#include <opennsl/l3.h>
#include <opennsl/mpls.h>
#include <examples/util.h>

Go to the source code of this file.

Macros

#define CALL_IF_ERROR_RETURN(op)
 
#define DEFAULT_UNIT   0
 
#define EGRESS_LABEL1_ID   300
 
#define EGRESS_LABEL2_ID   400
 
#define IN_VLAN   10
 
#define INGRESS_LABEL1_ID   200
 
#define L3_OUT_INTF_ID   31
 
#define LABEL1_TTL   33
 
#define LABEL2_TTL   64
 
#define MAC_DA   {0x00, 0x11, 0x11, 0x11, 0x11, 0x0f}
 
#define MAC_SA   {0x00, 0x11, 0x11, 0x11, 0x11, 0x0e}
 
#define MAX_DIGITS_IN_CHOICE   5
 
#define MY_MAC   {0x00, 0x00, 0x00, 0x00, 0x11, 0x11}
 
#define OUT_VLAN   20
 
#define VPN_ID   (VRF_ID + VPN_ID_OFFSET)
 
#define VPN_ID_OFFSET   (1 << 12)
 
#define VRF_ID   0
 

Functions

int main (int argc, char *argv[])
 Main function for MPLS sample application.
 

Variables

char example_usage []
 
int verbose = 3
 

Macro Definition Documentation

#define CALL_IF_ERROR_RETURN (   op)
Value:
do { \
int __rv__; \
if ((__rv__ = (op)) < 0) { \
printf("%s:%s: line %d rv: %d failed: %s\n", \
__FILE__, __FUNCTION__, __LINE__, __rv__, \
opennsl_errmsg(__rv__)); \
} \
} while(0)

Definition at line 95 of file example_mpls.c.

#define DEFAULT_UNIT   0

Definition at line 71 of file example_mpls.c.

Referenced by main().

#define EGRESS_LABEL1_ID   300

Definition at line 89 of file example_mpls.c.

#define EGRESS_LABEL2_ID   400

Definition at line 91 of file example_mpls.c.

#define IN_VLAN   10

Definition at line 83 of file example_mpls.c.

#define INGRESS_LABEL1_ID   200

Definition at line 88 of file example_mpls.c.

#define L3_OUT_INTF_ID   31

Definition at line 86 of file example_mpls.c.

#define LABEL1_TTL   33

Definition at line 90 of file example_mpls.c.

#define LABEL2_TTL   64

Definition at line 92 of file example_mpls.c.

#define MAC_DA   {0x00, 0x11, 0x11, 0x11, 0x11, 0x0f}

Definition at line 76 of file example_mpls.c.

#define MAC_SA   {0x00, 0x11, 0x11, 0x11, 0x11, 0x0e}

Definition at line 74 of file example_mpls.c.

#define MAX_DIGITS_IN_CHOICE   5

Definition at line 93 of file example_mpls.c.

#define MY_MAC   {0x00, 0x00, 0x00, 0x00, 0x11, 0x11}

Definition at line 72 of file example_mpls.c.

#define OUT_VLAN   20

Definition at line 84 of file example_mpls.c.

#define VPN_ID   (VRF_ID + VPN_ID_OFFSET)

Definition at line 81 of file example_mpls.c.

#define VPN_ID_OFFSET   (1 << 12)

Definition at line 80 of file example_mpls.c.

#define VRF_ID   0

Definition at line 79 of file example_mpls.c.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Main function for MPLS sample application.

Parameters
argc,argvcommands line arguments
Returns
OPENNSL_E_XXX OpenNSL API return code

Definition at line 117 of file example_mpls.c.

References DEFAULT_UNIT, example_port_default_config(), example_read_user_choice(), example_switch_default_vlan_config(), example_usage, NULL, opennsl_driver_exit(), opennsl_driver_init(), OPENNSL_E_NONE, OPENNSL_E_PARAM, and opennsl_errmsg.

Variable Documentation

char example_usage[]
Initial value:
=
"Syntax: example_mpls \n\r"
" \n\r"
"Paramaters: None. \n\r"
" \n\r"
"Example: The following command is used to demonstrate MPLS by taking \n\r"
" ingress and egress port numbers as input. \n\r"
" example_mpls 5 6 \n\r"
" \n\r"
"Usage Guidelines: This program request the user to enter the \n\r"
" ingress and egress port numbers. \n\r"
" \n\r"
" in_sysport - Ingress port number on which test packet is \n\r"
" received. \n\r"
" out_sysport - Egress port number to which packet is forwarded. \n\r"
" \n\r"
" It looks for MPLS packets arrived on in_sysport with \n\r"
" VLAN = 10, destination MAC = 00:00:00:00:11:11 and take the \n\r"
" following actions before forwarding the packet to out_sysport. \n\r"
" \n\r"
" 1a) Swap incoming label 200 with 300 \n\r"
" 1b) Update TTL in this label to 33 \n\r"
" 2a) Push/Add label 400 with TTL 64 \n\r"
" \n\r"

Definition at line 41 of file example_mpls.c.

int verbose = 3

Definition at line 68 of file example_mpls.c.